From b5174b158278895d0fea24f3d8392e5ac8846399 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Sun, 10 Sep 2023 20:35:14 -0700 Subject: [PATCH 1/5] feat(ui): Make file types themeable --- src/info/filetype.rs | 28 +-------------- src/theme/default_theme.rs | 13 +++++++ src/theme/mod.rs | 74 ++++++++++++++++++++++++++------------ src/theme/ui_styles.rs | 26 ++++++++++++++ 4 files changed, 91 insertions(+), 50 deletions(-) diff --git a/src/info/filetype.rs b/src/info/filetype.rs index 005c28bcb..9ac33257a 100644 --- a/src/info/filetype.rs +++ b/src/info/filetype.rs @@ -7,11 +7,9 @@ //! # Contributors //! Please keep these lists sorted. If you're using vim, :sort i -use ansiterm::Style; use phf::{phf_map, Map}; use crate::fs::File; -use crate::theme::FileColours; #[derive(Debug, Clone)] pub enum FileType { @@ -269,7 +267,7 @@ impl FileType { /// Lookup the file type based on the file's name, by the file name /// lowercase extension, or if the file could be compiled from related /// source code. - fn get_file_type(file: &File<'_>) -> Option { + pub(crate) fn get_file_type(file: &File<'_>) -> Option { // Case-insensitive readme is checked first for backwards compatibility. if file.name.to_lowercase().starts_with("readme") { return Some(Self::Immediate) @@ -291,27 +289,3 @@ impl FileType { None } } - -#[derive(Debug)] -pub struct FileTypeColor; - -impl FileColours for FileTypeColor { - /// Map from the file type to the display style/color for the file. - fn colour_file(&self, file: &File<'_>) -> Option