diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-08-07 01:29:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-07 04:29:20 -0400 |
commit | 30bdaa6073ad28eb1083997e874654727460fcbb (patch) | |
tree | 07a373b3f2493c9c6e2872ceec617127ee5dc8d8 /src/canvas | |
parent | d2129056e3f04c961a28099510d3bd577925af47 (diff) |
feature: add full command to process widget
This PR adds the ability to toggle between the process name and process path. Currently, this uses `P` as the modifier key.
Currently, the longer command names are dealt with by forcefully changing the width of the columns, but this can be handled in a more graceful manner IMO.
Diffstat (limited to 'src/canvas')
-rw-r--r-- | src/canvas/dialogs/dd_dialog.rs | 7 | ||||
-rw-r--r-- | src/canvas/dialogs/help_dialog.rs | 2 | ||||
-rw-r--r-- | src/canvas/widgets/process_table.rs | 32 |
3 files changed, 27 insertions, 14 deletions
diff --git a/src/canvas/dialogs/dd_dialog.rs b/src/canvas/dialogs/dd_dialog.rs index d4b605d6..cb123df2 100644 --- a/src/canvas/dialogs/dd_dialog.rs +++ b/src/canvas/dialogs/dd_dialog.rs @@ -28,20 +28,19 @@ impl KillDialog for Painter { if app_state.is_grouped(app_state.current_widget.widget_id) { if to_kill_processes.1.len() != 1 { Text::raw(format!( - "\nKill {} processes with the name {}?", + "\nKill {} processes with the name \"{}\"?", to_kill_processes.1.len(), to_kill_processes.0 )) } else { Text::raw(format!( - "\nKill {} process with the name {}?", - to_kill_processes.1.len(), + "\nKill 1 process with the name \"{}\"?", to_kill_processes.0 )) } } else { Text::raw(format!( - "\nKill process {} with PID {}?", + "\nKill process \"{}\" with PID {}?", to_kill_processes.0, first_pid )) }, diff --git a/src/canvas/dialogs/help_dialog.rs b/src/canvas/dialogs/help_dialog.rs index a11e19e1..d0156d1a 100644 --- a/src/canvas/dialogs/help_dialog.rs +++ b/src/canvas/dialogs/help_dialog.rs @@ -31,7 +31,7 @@ impl HelpDialog for Painter { // small terminal sizes... oh joy. let mut overflow_buffer = 0; - let paragraph_width = draw_loc.width - 2; + let paragraph_width = std::cmp::max(draw_loc.width.saturating_sub(2), 1); let mut prev_section_len = 0; constants::HELP_TEXT diff --git a/src/canvas/widgets/process_table.rs b/src/canvas/widgets/process_table.rs index 721d34b0..5ceb8b28 100644 --- a/src/canvas/widgets/process_table.rs +++ b/src/canvas/widgets/process_table.rs @@ -133,13 +133,17 @@ impl ProcessTableWidget for Painter { }); use app::data_harvester::processes::ProcessSorting; - let mut pid_or_name = if proc_widget_state.is_grouped { + let mut pid_or_count = if proc_widget_state.is_grouped { "Count" } else { "PID(p)" } .to_string(); - let mut name = "Name(n)".to_string(); + let mut identifier = if proc_widget_state.is_using_full_path { + "Command(n)".to_string() + } else { + "Name(n)".to_string() + }; let mut cpu = "CPU%(c)".to_string(); let mut mem = "Mem%(m)".to_string(); let rps = "R/s".to_string(); @@ -157,14 +161,15 @@ impl ProcessTableWidget for Painter { match proc_widget_state.process_sorting_type { ProcessSorting::CPU => cpu += &direction_val, ProcessSorting::MEM => mem += &direction_val, - ProcessSorting::PID => pid_or_name += &direction_val, - ProcessSorting::NAME => name += &direction_val, + ProcessSorting::PID => pid_or_count += &direction_val, + ProcessSorting::IDENTIFIER => identifier += &direction_val, }; + // TODO: Gonna have to figure out how to do left/right GUI notation. let process_headers = if proc_widget_state.is_grouped { vec![ - pid_or_name, - name, + pid_or_count, + identifier, cpu, mem, rps, @@ -174,8 +179,8 @@ impl ProcessTableWidget for Painter { ] } else { vec![ - pid_or_name, - name, + pid_or_count, + identifier, cpu, mem, rps, @@ -185,6 +190,7 @@ impl ProcessTableWidget for Painter { process_state, ] }; + proc_widget_state.num_columns = process_headers.len(); let process_headers_lens: Vec<usize> = process_headers .iter() .map(|entry| entry.len()) @@ -192,8 +198,16 @@ impl ProcessTableWidget for Painter { // Calculate widths let width = f64::from(draw_loc.width); + + // TODO: This is a ugly work-around for now. let width_ratios = if proc_widget_state.is_grouped { - vec![0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.15, 0.15] + if proc_widget_state.is_using_full_path { + vec![0.1, 0.7, 0.05, 0.05, 0.025, 0.025, 0.025, 0.025] + } else { + vec![0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.15, 0.15] + } + } else if proc_widget_state.is_using_full_path { + vec![0.1, 0.7, 0.05, 0.05, 0.02, 0.02, 0.02, 0.02, 0.02] } else { vec![0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] }; |