diff --git a/src/colours.rs b/src/colours.rs index 46397a0..b4dc1ac 100644 --- a/src/colours.rs +++ b/src/colours.rs @@ -8,6 +8,11 @@ use std::default::Default; #[derive(Clone, Copy, Debug, Default, PartialEq)] pub struct Colours { + pub filetypes: FileTypes, +} + +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub struct FileTypes { pub normal: Style, pub directory: Style, pub symlink: Style, @@ -32,21 +37,23 @@ impl Colours { pub fn colourful() -> Colours { Colours { - normal: Plain, - directory: Blue.bold(), - symlink: Cyan.normal(), - special: Yellow.normal(), - executable: Green.bold(), - image: Fixed(133).normal(), - video: Fixed(135).normal(), - music: Fixed(92).normal(), - lossless: Fixed(93).normal(), - crypto: Fixed(109).normal(), - document: Fixed(105).normal(), - compressed: Red.normal(), - temp: GREY.normal(), - immediate: Yellow.bold().underline(), - compiled: Fixed(137).normal(), + filetypes: FileTypes { + normal: Plain, + directory: Blue.bold(), + symlink: Cyan.normal(), + special: Yellow.normal(), + executable: Green.bold(), + image: Fixed(133).normal(), + video: Fixed(135).normal(), + music: Fixed(92).normal(), + lossless: Fixed(93).normal(), + crypto: Fixed(109).normal(), + document: Fixed(105).normal(), + compressed: Red.normal(), + temp: GREY.normal(), + immediate: Yellow.bold().underline(), + compiled: Fixed(137).normal(), + } } } } diff --git a/src/filetype.rs b/src/filetype.rs index dadc415..a75f842 100644 --- a/src/filetype.rs +++ b/src/filetype.rs @@ -5,21 +5,21 @@ use colours::Colours; pub fn file_colour(colours: &Colours, file: &File) -> Style { match file { - f if f.is_directory() => colours.directory, - f if f.is_executable_file() => colours.executable, - f if f.is_link() => colours.symlink, - f if !f.is_file() => colours.special, - f if f.is_immediate() => colours.immediate, - f if f.is_image() => colours.image, - f if f.is_video() => colours.video, - f if f.is_music() => colours.music, - f if f.is_lossless() => colours.lossless, - f if f.is_crypto() => colours.crypto, - f if f.is_document() => colours.document, - f if f.is_compressed() => colours.compressed, - f if f.is_temp() => colours.temp, - f if f.is_compiled() => colours.compiled, - _ => colours.normal, + f if f.is_directory() => colours.filetypes.directory, + f if f.is_executable_file() => colours.filetypes.executable, + f if f.is_link() => colours.filetypes.symlink, + f if !f.is_file() => colours.filetypes.special, + f if f.is_immediate() => colours.filetypes.immediate, + f if f.is_image() => colours.filetypes.image, + f if f.is_video() => colours.filetypes.video, + f if f.is_music() => colours.filetypes.music, + f if f.is_lossless() => colours.filetypes.lossless, + f if f.is_crypto() => colours.filetypes.crypto, + f if f.is_document() => colours.filetypes.document, + f if f.is_compressed() => colours.filetypes.compressed, + f if f.is_temp() => colours.filetypes.temp, + f if f.is_compiled() => colours.filetypes.compiled, + _ => colours.filetypes.normal, } }