Skip to content

Commit

Permalink
use names colours (PR ogham#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott committed Oct 28, 2018
1 parent 57e4c08 commit 96f88fa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion contrib/completions.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 8 additions & 7 deletions src/info/filetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/output/render/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand All @@ -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;
Expand All @@ -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) }
Expand Down
26 changes: 16 additions & 10 deletions src/style/colours.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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(),
Expand Down Expand Up @@ -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
Expand All @@ -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 }
Expand All @@ -400,4 +407,3 @@ impl FileNameColours for Colours {
fn symlink_path(&self) -> Style { self.symlink_path }
fn executable_file(&self) -> Style { self.filekinds.executable }
}

0 comments on commit 96f88fa

Please sign in to comment.