From 6dc78a0c0c13bc5eaf2c80d3240c823a8679a6d2 Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Mon, 17 Feb 2020 19:25:59 -0500 Subject: Update how cpu disabling field looks. --- src/canvas.rs | 44 +++++++++++++++++++------------------------- src/main.rs | 4 +++- 2 files changed, 22 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/canvas.rs b/src/canvas.rs index 398bbe34..7c3f1920 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -23,7 +23,7 @@ use drawing_utils::*; // Headers 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 TEMP_HEADERS: [&str; 2] = ["Sensor", "Temp"]; 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 mut stringified_cpu_data: Vec> = Vec::new(); + // TODO: [OPT] Reduce this instead... if app_state.cpu_state.is_showing_tray { for (itx, cpu) in sliced_cpu_data.iter().enumerate() { - if let Some(cpu_data) = cpu.cpu_data.last() { - let entry = vec![ - if app_state.cpu_state.core_show_vec[itx + start_position as usize] { - "[*]".to_string() - } else { - "[ ]".to_string() - }, - cpu.cpu_name.clone(), - format!("{:.0}%", cpu_data.1.round()), - ]; - - stringified_cpu_data.push(entry); - } + stringified_cpu_data.push(vec![ + cpu.cpu_name.clone(), + if app_state.cpu_state.core_show_vec[itx + start_position as usize] { + "[*]".to_string() + } else { + "[ ]".to_string() + }, + ]); } } else { for cpu in sliced_cpu_data.iter() { 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(entry); + stringified_cpu_data.push(vec![ + cpu.cpu_name.clone(), + format!("{:.0}%", cpu_data.1.round()), + ]); } } } @@ -674,11 +671,8 @@ impl Painter { // Calculate widths let width = f64::from(draw_loc.width); - let width_ratios = if app_state.cpu_state.is_showing_tray { - vec![0.4, 0.3, 0.3] - } else { - vec![0.5, 0.5] - }; + let width_ratios = vec![0.5, 0.5]; + let variable_intrinsic_results = get_variable_intrinsic_widths( width as u16, &width_ratios, @@ -691,7 +685,7 @@ impl Painter { let intrinsic_widths = &(variable_intrinsic_results.0)[0..variable_intrinsic_results.1]; 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( 0, draw_loc.width as i32 - TITLE_BASE.chars().count() as i32 - 2, @@ -706,9 +700,9 @@ impl Painter { // Draw Table::new( if app_state.cpu_state.is_showing_tray { - CPU_SELECT_LEGEND_HEADER.to_vec() + CPU_SELECT_LEGEND_HEADER } else { - CPU_LEGEND_HEADER.to_vec() + CPU_LEGEND_HEADER } .iter(), cpu_rows, diff --git a/src/main.rs b/src/main.rs index aefa5626..cc87cfc9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,6 +76,7 @@ struct ConfigFlags { regex: Option, default_widget: Option, show_disabled_data: Option, + //disabled_cpu_cores: Option>, // TODO: [FEATURE] Enable disabling cores in config/flags } #[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 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 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 CASE_SENSITIVE: -S --case_sensitive "Match case 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 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() } -- cgit v1.2.3