mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-05-03 13:30:44 +00:00
bug: skip avg cpu in basic mode with dedicated row (#1811)
update sample config
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
# Whether to hide the average cpu entry.
|
||||
#hide_avg_cpu = false
|
||||
|
||||
# Whether to use a dedicated row for the average cpu entry
|
||||
#average_cpu_row = false
|
||||
|
||||
# Whether to use dot markers rather than braille.
|
||||
#dot_marker = false
|
||||
|
||||
|
||||
+2
-1
@@ -351,7 +351,8 @@ impl Painter {
|
||||
let c = (actual_cpu_data_len / 4) as u16
|
||||
+ u16::from(actual_cpu_data_len % 4 != 0)
|
||||
+ u16::from(
|
||||
app_state.app_config_fields.dedicated_average_row
|
||||
app_state.app_config_fields.show_average_cpu
|
||||
&& app_state.app_config_fields.dedicated_average_row
|
||||
&& actual_cpu_data_len.saturating_sub(1) % 4 != 0,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::cmp::min;
|
||||
|
||||
use itertools::{Either, Itertools};
|
||||
use itertools::Itertools;
|
||||
use tui::{
|
||||
Frame,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
@@ -42,8 +42,11 @@ impl Painter {
|
||||
}
|
||||
|
||||
// TODO: This is pretty ugly. Is there a better way of doing it?
|
||||
let mut cpu_iter = Either::Right(cpu_data.iter());
|
||||
if app_state.app_config_fields.dedicated_average_row {
|
||||
let mut avg_index = cpu_data.len() + 1;
|
||||
let mut avg_row_count = 0;
|
||||
if app_state.app_config_fields.dedicated_average_row
|
||||
&& app_state.app_config_fields.show_average_cpu
|
||||
{
|
||||
if let Some((index, avg)) = cpu_data
|
||||
.iter()
|
||||
.find_position(|&datum| matches!(datum.data_type, CpuDataType::Avg))
|
||||
@@ -66,9 +69,9 @@ impl Painter {
|
||||
.ratio(ratio.into()),
|
||||
avg_loc,
|
||||
);
|
||||
|
||||
avg_row_count += 1;
|
||||
avg_index = index;
|
||||
draw_loc = cores_loc;
|
||||
cpu_iter = Either::Left(cpu_data.iter().skip(index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +86,13 @@ impl Painter {
|
||||
.direction(Direction::Horizontal)
|
||||
.split(draw_loc);
|
||||
|
||||
let mut gauge_info = cpu_iter.map(|cpu| self.cpu_info(cpu));
|
||||
let mut gauge_info = cpu_data.iter().enumerate().filter_map(|(index, cpu)| {
|
||||
if index == avg_index {
|
||||
None
|
||||
} else {
|
||||
Some(self.cpu_info(cpu))
|
||||
}
|
||||
});
|
||||
|
||||
// Very ugly way to sync the gauge limit across all gauges.
|
||||
let hide_parts = columns
|
||||
@@ -99,7 +108,7 @@ impl Painter {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let num_entries = cpu_data.len();
|
||||
let num_entries = cpu_data.len() - avg_row_count;
|
||||
let mut row_counter = num_entries;
|
||||
for (itx, column) in columns.iter().enumerate() {
|
||||
if REQUIRED_COLUMNS > itx {
|
||||
|
||||
@@ -259,6 +259,9 @@ pub(crate) const CONFIG_TEXT: &str = r#"# This is a default config file for bott
|
||||
# Whether to hide the average cpu entry.
|
||||
#hide_avg_cpu = false
|
||||
|
||||
# Whether to use a dedicated row for the average cpu entry
|
||||
#average_cpu_row = false
|
||||
|
||||
# Whether to use dot markers rather than braille.
|
||||
#dot_marker = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user