mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
Update how cpu disabling field looks.
This commit is contained in:
parent
9b13ac1158
commit
6dc78a0c0c
@ -23,7 +23,7 @@ use drawing_utils::*;
|
|||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
const CPU_LEGEND_HEADER: [&str; 2] = ["CPU", "Use%"];
|
const CPU_LEGEND_HEADER: [&str; 2] = ["CPU", "Use%"];
|
||||||
const CPU_SELECT_LEGEND_HEADER: [&str; 3] = ["Show (Space)", "CPU", "Use%"];
|
const CPU_SELECT_LEGEND_HEADER: [&str; 2] = ["CPU", "Show (Space)"];
|
||||||
const DISK_HEADERS: [&str; 7] = ["Disk", "Mount", "Used", "Free", "Total", "R/s", "W/s"];
|
const DISK_HEADERS: [&str; 7] = ["Disk", "Mount", "Used", "Free", "Total", "R/s", "W/s"];
|
||||||
const TEMP_HEADERS: [&str; 2] = ["Sensor", "Temp"];
|
const TEMP_HEADERS: [&str; 2] = ["Sensor", "Temp"];
|
||||||
const MEM_HEADERS: [&str; 3] = ["Mem", "Usage", "Use%"];
|
const MEM_HEADERS: [&str; 3] = ["Mem", "Usage", "Use%"];
|
||||||
@ -608,28 +608,25 @@ impl Painter {
|
|||||||
let sliced_cpu_data = &cpu_data[start_position as usize..];
|
let sliced_cpu_data = &cpu_data[start_position as usize..];
|
||||||
let mut stringified_cpu_data: Vec<Vec<String>> = Vec::new();
|
let mut stringified_cpu_data: Vec<Vec<String>> = Vec::new();
|
||||||
|
|
||||||
|
// TODO: [OPT] Reduce this instead...
|
||||||
if app_state.cpu_state.is_showing_tray {
|
if app_state.cpu_state.is_showing_tray {
|
||||||
for (itx, cpu) in sliced_cpu_data.iter().enumerate() {
|
for (itx, cpu) in sliced_cpu_data.iter().enumerate() {
|
||||||
if let Some(cpu_data) = cpu.cpu_data.last() {
|
stringified_cpu_data.push(vec![
|
||||||
let entry = vec![
|
cpu.cpu_name.clone(),
|
||||||
if app_state.cpu_state.core_show_vec[itx + start_position as usize] {
|
if app_state.cpu_state.core_show_vec[itx + start_position as usize] {
|
||||||
"[*]".to_string()
|
"[*]".to_string()
|
||||||
} else {
|
} else {
|
||||||
"[ ]".to_string()
|
"[ ]".to_string()
|
||||||
},
|
},
|
||||||
cpu.cpu_name.clone(),
|
]);
|
||||||
format!("{:.0}%", cpu_data.1.round()),
|
|
||||||
];
|
|
||||||
|
|
||||||
stringified_cpu_data.push(entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for cpu in sliced_cpu_data.iter() {
|
for cpu in sliced_cpu_data.iter() {
|
||||||
if let Some(cpu_data) = cpu.cpu_data.last() {
|
if let Some(cpu_data) = cpu.cpu_data.last() {
|
||||||
let entry = vec![cpu.cpu_name.clone(), format!("{:.0}%", cpu_data.1.round())];
|
stringified_cpu_data.push(vec![
|
||||||
|
cpu.cpu_name.clone(),
|
||||||
stringified_cpu_data.push(entry);
|
format!("{:.0}%", cpu_data.1.round()),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,11 +671,8 @@ impl Painter {
|
|||||||
|
|
||||||
// Calculate widths
|
// Calculate widths
|
||||||
let width = f64::from(draw_loc.width);
|
let width = f64::from(draw_loc.width);
|
||||||
let width_ratios = if app_state.cpu_state.is_showing_tray {
|
let width_ratios = vec![0.5, 0.5];
|
||||||
vec![0.4, 0.3, 0.3]
|
|
||||||
} else {
|
|
||||||
vec![0.5, 0.5]
|
|
||||||
};
|
|
||||||
let variable_intrinsic_results = get_variable_intrinsic_widths(
|
let variable_intrinsic_results = get_variable_intrinsic_widths(
|
||||||
width as u16,
|
width as u16,
|
||||||
&width_ratios,
|
&width_ratios,
|
||||||
@ -691,7 +685,7 @@ impl Painter {
|
|||||||
let intrinsic_widths = &(variable_intrinsic_results.0)[0..variable_intrinsic_results.1];
|
let intrinsic_widths = &(variable_intrinsic_results.0)[0..variable_intrinsic_results.1];
|
||||||
|
|
||||||
let title = if app_state.cpu_state.is_showing_tray {
|
let title = if app_state.cpu_state.is_showing_tray {
|
||||||
const TITLE_BASE: &str = " Esc to close";
|
const TITLE_BASE: &str = " Esc to close ";
|
||||||
let repeat_num = max(
|
let repeat_num = max(
|
||||||
0,
|
0,
|
||||||
draw_loc.width as i32 - TITLE_BASE.chars().count() as i32 - 2,
|
draw_loc.width as i32 - TITLE_BASE.chars().count() as i32 - 2,
|
||||||
@ -706,9 +700,9 @@ impl Painter {
|
|||||||
// Draw
|
// Draw
|
||||||
Table::new(
|
Table::new(
|
||||||
if app_state.cpu_state.is_showing_tray {
|
if app_state.cpu_state.is_showing_tray {
|
||||||
CPU_SELECT_LEGEND_HEADER.to_vec()
|
CPU_SELECT_LEGEND_HEADER
|
||||||
} else {
|
} else {
|
||||||
CPU_LEGEND_HEADER.to_vec()
|
CPU_LEGEND_HEADER
|
||||||
}
|
}
|
||||||
.iter(),
|
.iter(),
|
||||||
cpu_rows,
|
cpu_rows,
|
||||||
|
@ -76,6 +76,7 @@ struct ConfigFlags {
|
|||||||
regex: Option<bool>,
|
regex: Option<bool>,
|
||||||
default_widget: Option<String>,
|
default_widget: Option<String>,
|
||||||
show_disabled_data: Option<bool>,
|
show_disabled_data: Option<bool>,
|
||||||
|
//disabled_cpu_cores: Option<Vec<u64>>, // TODO: [FEATURE] Enable disabling cores in config/flags
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Deserialize)]
|
#[derive(Default, Deserialize)]
|
||||||
@ -112,7 +113,7 @@ fn get_matches() -> clap::ArgMatches<'static> {
|
|||||||
(@arg LEFT_LEGEND: -l --left_legend "Puts external chart legends on the left side rather than the default right side.")
|
(@arg LEFT_LEGEND: -l --left_legend "Puts external chart legends on the left side rather than the default right side.")
|
||||||
(@arg USE_CURR_USAGE: -u --current_usage "Within Linux, sets a process' CPU usage to be based on the total current CPU usage, rather than assuming 100% usage.")
|
(@arg USE_CURR_USAGE: -u --current_usage "Within Linux, sets a process' CPU usage to be based on the total current CPU usage, rather than assuming 100% usage.")
|
||||||
(@arg CONFIG_LOCATION: -C --config +takes_value "Sets the location of the config file. Expects a config file in the TOML format.")
|
(@arg CONFIG_LOCATION: -C --config +takes_value "Sets the location of the config file. Expects a config file in the TOML format.")
|
||||||
//(@arg BASIC_MODE: -b --basic "Sets bottom to basic mode, not showing graphs and only showing basic tables.")
|
//(@arg BASIC_MODE: -b --basic "Sets bottom to basic mode, not showing graphs and only showing basic tables.") // TODO: [FEATURE] Min mode
|
||||||
(@arg GROUP_PROCESSES: -g --group "Groups processes with the same name together on launch.")
|
(@arg GROUP_PROCESSES: -g --group "Groups processes with the same name together on launch.")
|
||||||
(@arg CASE_SENSITIVE: -S --case_sensitive "Match case when searching by default.")
|
(@arg CASE_SENSITIVE: -S --case_sensitive "Match case when searching by default.")
|
||||||
(@arg WHOLE_WORD: -W --whole_word "Match whole word when searching by default.")
|
(@arg WHOLE_WORD: -W --whole_word "Match whole word when searching by default.")
|
||||||
@ -126,6 +127,7 @@ fn get_matches() -> clap::ArgMatches<'static> {
|
|||||||
(@arg NET_WIDGET: --network_default "Selects the network widget to be selected by default.")
|
(@arg NET_WIDGET: --network_default "Selects the network widget to be selected by default.")
|
||||||
(@arg PROC_WIDGET: --process_default "Selects the process widget to be selected by default. This is the default if nothing is set.")
|
(@arg PROC_WIDGET: --process_default "Selects the process widget to be selected by default. This is the default if nothing is set.")
|
||||||
)
|
)
|
||||||
|
//(@arg TURNED_OFF_CPUS: -t ... +takes_value "Hides CPU data points by default") // TODO: [FEATURE] Enable disabling cores in config/flags
|
||||||
)
|
)
|
||||||
.get_matches()
|
.get_matches()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user