From e52c367a421c7109e23a4d69b8c5ba7882c1b20b Mon Sep 17 00:00:00 2001 From: Benoit de Chezelles Date: Tue, 7 May 2024 22:52:46 +0200 Subject: [PATCH] fix(color-scale): file size unit custom color when not using color scale --- man/eza.1.md | 2 +- src/output/color_scale.rs | 2 ++ src/output/render/size.rs | 2 +- src/theme/default_theme.rs | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/man/eza.1.md b/man/eza.1.md index a6d43fd86..933027195 100644 --- a/man/eza.1.md +++ b/man/eza.1.md @@ -97,7 +97,7 @@ Use comma(,) separated list of all, age, size `--color-scale-mode`, `--colour-scale-mode` : Use gradient or fixed colors in `--color-scale`. -Valid options are `fixed` or `gradient`. +Valid options are `fixed` to use a fixed color (disabling color scale), or `gradient` to use an automatic darker (old/small file) to lighter (recent/big file) gradient of colors. The default value is `gradient`. `--icons=WHEN` diff --git a/src/output/color_scale.rs b/src/output/color_scale.rs index 94a513ab1..0fb3e3f94 100644 --- a/src/output/color_scale.rs +++ b/src/output/color_scale.rs @@ -18,7 +18,9 @@ pub struct ColorScaleOptions { #[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum ColorScaleMode { + // Color scale is disabled, use a static color for the range Fixed, + // Color scale uses an automatic gradient of colors for the range Gradient, } diff --git a/src/output/render/size.rs b/src/output/render/size.rs index e4222f550..bbf4b86f3 100644 --- a/src/output/render/size.rs +++ b/src/output/render/size.rs @@ -83,7 +83,7 @@ impl f::Size { vec![ csi.adjust_style(colours.size(Some(prefix)), size as f32, csi.size) .paint(number), - csi.adjust_style(colours.size(Some(prefix)), size as f32, csi.size) + csi.adjust_style(colours.unit(Some(prefix)), size as f32, csi.size) .paint(symbol), ] } else { diff --git a/src/theme/default_theme.rs b/src/theme/default_theme.rs index daf0c820d..763c2dfb3 100644 --- a/src/theme/default_theme.rs +++ b/src/theme/default_theme.rs @@ -126,7 +126,7 @@ impl UiStyles { impl Size { pub fn colourful(scale: ColorScaleOptions) -> Self { - if scale.size && scale.mode == ColorScaleMode::Fixed { + if scale.mode == ColorScaleMode::Fixed { Self::colourful_fixed() } else { Self::colourful_gradient()