From 96f88fa5e5e22eac65147eb950b5dae770a5783c Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 28 Oct 2018 10:18:24 +0000 Subject: [PATCH] use names colours (PR #370) --- contrib/completions.fish | 2 +- src/info/filetype.rs | 15 ++++++++------- src/output/render/size.rs | 6 +++--- src/style/colours.rs | 26 ++++++++++++++++---------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/contrib/completions.fish b/contrib/completions.fish index b8bf2e46..b5a8667b 100644 --- a/contrib/completions.fish +++ b/contrib/completions.fish @@ -18,7 +18,7 @@ complete -c exa -l 'colour-scale' -d "Highlight levels of file sizes dist # Filtering and sorting options complete -c exa -l 'group-directories-first' -d "Sort directories before other files" complete -c exa -l 'git-ignore' -d "Ignore files mentioned in '.gitignore'" -complete -c exa -s 'a' -l 'all' -d "Show and 'dot' files" +complete -c exa -s 'a' -l 'all' -d "Show hidden and 'dot' files" complete -c exa -s 'd' -l 'list-dirs' -d "List directories like regular files" complete -c exa -s 'L' -l 'level' -d "Limit the depth of recursion" -a "1 2 3 4 5 6 7 8 9" complete -c exa -s 'r' -l 'reverse' -d "Reverse the sort order" diff --git a/src/info/filetype.rs b/src/info/filetype.rs index 14ba6e9d..776ee919 100644 --- a/src/info/filetype.rs +++ b/src/info/filetype.rs @@ -103,14 +103,15 @@ impl FileColours for FileExtensions { Some(match file { f if self.is_temp(f) => Fixed(244).normal(), f if self.is_immediate(f) => Yellow.bold().underline(), - f if self.is_image(f) => Fixed(133).normal(), - f if self.is_video(f) => Fixed(135).normal(), - f if self.is_music(f) => Fixed(92).normal(), - f if self.is_lossless(f) => Fixed(93).normal(), - f if self.is_crypto(f) => Fixed(109).normal(), - f if self.is_document(f) => Fixed(105).normal(), + f if self.is_image(f) => Purple.normal(), + f if self.is_video(f) => Purple.bold(), + f if self.is_music(f) => Cyan.normal(), + f if self.is_lossless(f) => Cyan.bold(), + f if self.is_crypto(f) => Green.bold(), + f if self.is_document(f) => Green.normal(), f if self.is_compressed(f) => Red.normal(), - f if self.is_compiled(f) => Fixed(137).normal(), + f if self.is_temp(f) => White.normal(), + f if self.is_compiled(f) => Yellow.normal(), _ => return None, }) } diff --git a/src/output/render/size.rs b/src/output/render/size.rs index 25b2007d..91c2aca0 100644 --- a/src/output/render/size.rs +++ b/src/output/render/size.rs @@ -44,7 +44,7 @@ impl f::Size { width, contents: vec![ colours.size(size).paint(number), - colours.unit().paint(symbol), + colours.unit(size).paint(symbol), ].into(), } } @@ -70,7 +70,7 @@ impl f::DeviceIDs { pub trait Colours { fn size(&self, size: u64) -> Style; - fn unit(&self) -> Style; + fn unit(&self, size: u64) -> Style; fn no_size(&self) -> Style; fn major(&self) -> Style; @@ -95,7 +95,7 @@ pub mod test { impl Colours for TestColours { fn size(&self, _size: u64) -> Style { Fixed(66).normal() } - fn unit(&self) -> Style { Fixed(77).bold() } + fn unit(&self, _size: u64) -> Style { Fixed(77).bold() } fn no_size(&self) -> Style { Black.italic() } fn major(&self) -> Style { Blue.on(Red) } diff --git a/src/style/colours.rs b/src/style/colours.rs index d2186358..3d5947a8 100644 --- a/src/style/colours.rs +++ b/src/style/colours.rs @@ -1,5 +1,5 @@ use ansi_term::Style; -use ansi_term::Colour::{Red, Green, Yellow, Blue, Cyan, Purple, Fixed}; +use ansi_term::Colour::{Black, Red, Green, Yellow, Blue, Cyan, Purple}; use output::render; use output::file_name::Colours as FileNameColours; @@ -152,11 +152,11 @@ impl Colours { major: Green.bold(), minor: Green.normal(), - scale_byte: Fixed(118).normal(), - scale_kilo: Fixed(190).normal(), - scale_mega: Fixed(226).normal(), - scale_giga: Fixed(220).normal(), - scale_huge: Fixed(214).normal(), + scale_byte: Green.normal(), + scale_kilo: Green.bold(), + scale_mega: Yellow.normal(), + scale_giga: Red.normal(), + scale_huge: Purple.normal(), }, users: Users { @@ -179,7 +179,7 @@ impl Colours { typechange: Purple.normal(), }, - punctuation: Fixed(244).normal(), + punctuation: Black.bold(), date: Blue.normal(), inode: Purple.normal(), blocks: Cyan.normal(), @@ -356,7 +356,7 @@ impl render::PermissionsColours for Colours { } impl render::SizeColours for Colours { - fn size(&self, size: u64) -> Style { + fn size(&self, size: u64) -> Style { if self.scale { if size < 1024 { self.size.scale_byte @@ -379,7 +379,14 @@ impl render::SizeColours for Colours { } } - fn unit(&self) -> Style { self.size.unit } + fn unit(&self, size: u64) -> Style { + if self.scale { + self.size(size) + } + else { + self.size.unit + } + } fn no_size(&self) -> Style { self.punctuation } fn major(&self) -> Style { self.size.major } fn comma(&self) -> Style { self.punctuation } @@ -400,4 +407,3 @@ impl FileNameColours for Colours { fn symlink_path(&self) -> Style { self.symlink_path } fn executable_file(&self) -> Style { self.filekinds.executable } } -