diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-11-03 22:04:19 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-11-03 22:04:19 +0200 |
commit | 47102feef6f62b38deadf084fa5c7f0628e59e84 (patch) | |
tree | aa106170fcef2604482c25d5080efe33a6a919ec /src | |
parent | 6fb9fa863b13164f0d2215579abed982052c1818 (diff) |
Add bold attribute to CPU stats
Concerns #19
Diffstat (limited to 'src')
-rw-r--r-- | src/components/kernel.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/components/kernel.rs b/src/components/kernel.rs index e62d98b..d072518 100644 --- a/src/components/kernel.rs +++ b/src/components/kernel.rs @@ -439,9 +439,10 @@ impl Component for KernelMetrics { None, ); - for (i, (tag, s, fg_color, bg_color)) in get_cpu_times(&old_cpu_stat, &self.cpu_stat[0]) - .into_iter() - .enumerate() + for (i, (tag, s, fg_color, bg_color, attr)) in + get_cpu_times(&old_cpu_stat, &self.cpu_stat[0]) + .into_iter() + .enumerate() { let (x, y) = write_string_to_grid( tag, @@ -461,7 +462,7 @@ impl Component for KernelMetrics { grid, fg_color, bg_color, - Attr::Default, + attr, ((x + 2 + padding, y), bottom_right), None, ); @@ -564,7 +565,7 @@ fn get_loadavg() -> [String; 3] { fn get_cpu_times( old_cpu_stat: &Stat, cpu_stat: &Stat, -) -> Vec<(&'static str, String, Color, Color)> { +) -> Vec<(&'static str, String, Color, Color, Attr)> { let mut ret = Vec::new(); macro_rules! val { @@ -593,6 +594,15 @@ fn get_cpu_times( } else { Color::Default }, + if percent < 0.15 { + Attr::Default + } else if percent < 0.50 { + Attr::Bold + } else if $tag != "idle " { + Attr::Bold + } else { + Attr::Default + }, )); }; }; |