1
0
mirror of https://github.com/danog/ytop.git synced 2024-11-30 04:29:10 +01:00

[cpu] fix CPUs overflowing widget (fix #26)

This commit is contained in:
Caleb Bassi 2020-02-05 23:42:32 -08:00
parent 2619795032
commit 42473723df
2 changed files with 6 additions and 1 deletions

View File

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- fix several 'overflow when subtracting durations' panics
- [cpu] fix CPUs overflowing widget
## [0.4.1] - 2020-02-04

View File

@ -165,9 +165,13 @@ impl Widget for CpuWidget<'_> {
if self.show_percpu {
let offset = if self.show_average { 1 } else { 0 };
for i in 0..self.cpu_count {
let y = area.y + 2 + offset + i as u16;
if y >= area.bottom() - 1 {
break;
}
buf.set_string(
area.x + 3,
area.y + 2 + offset + i as u16,
y,
format!("CPU{} {:3.0}%", i, self.percpu_data[i].last().unwrap().1),
self.colorscheme.cpu_lines
[(i + offset as usize) % self.colorscheme.cpu_lines.len()],