Skip to content

Commit

Permalink
--colo[u]r-scale: use same color for size and unit and use named co…
Browse files Browse the repository at this point in the history
…lors
  • Loading branch information
ariasuni committed Dec 20, 2019
1 parent 7eeb860 commit 5fa2e05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/output/render/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl f::Size {
width,
contents: vec![
colours.size(size).paint(number),
colours.unit().paint(symbol),
colours.unit(size).paint(symbol),
].into(),
}
}
Expand All @@ -69,7 +69,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 @@ -94,7 +94,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
11 changes: 9 additions & 2 deletions src/style/colours.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,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 @@ -383,7 +383,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 Down

0 comments on commit 5fa2e05

Please sign in to comment.