mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 13:45:12 +02:00
bug: Fixes incorrect colours being used the CPU widget in basic mode (#373)
Fixes the colour order being off in basic mode, and not using the average CPU colour.
This commit is contained in:
parent
9d1f3c9ac2
commit
23ad597d18
@ -49,6 +49,7 @@ impl CpuBasicWidget for Painter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let num_cpus = cpu_data.len();
|
let num_cpus = cpu_data.len();
|
||||||
|
let show_avg_cpu = app_state.app_config_fields.show_average_cpu;
|
||||||
|
|
||||||
if draw_loc.height > 0 {
|
if draw_loc.height > 0 {
|
||||||
let remaining_height = usize::from(draw_loc.height);
|
let remaining_height = usize::from(draw_loc.height);
|
||||||
@ -158,11 +159,20 @@ impl CpuBasicWidget for Painter {
|
|||||||
let end_index = min(start_index + how_many_cpus, num_cpus);
|
let end_index = min(start_index + how_many_cpus, num_cpus);
|
||||||
|
|
||||||
let cpu_column = (start_index..end_index)
|
let cpu_column = (start_index..end_index)
|
||||||
.map(|cpu_index| {
|
.map(|itx| {
|
||||||
Spans::from(Span {
|
Spans::from(Span {
|
||||||
content: (&cpu_bars[cpu_index]).into(),
|
content: (&cpu_bars[itx]).into(),
|
||||||
style: self.colours.cpu_colour_styles
|
style: if show_avg_cpu {
|
||||||
[cpu_index % self.colours.cpu_colour_styles.len()],
|
if itx == 0 {
|
||||||
|
self.colours.avg_colour_style
|
||||||
|
} else {
|
||||||
|
self.colours.cpu_colour_styles
|
||||||
|
[(itx - 1) % self.colours.cpu_colour_styles.len()]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.colours.cpu_colour_styles
|
||||||
|
[(itx - 1) % self.colours.cpu_colour_styles.len()]
|
||||||
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user