summaryrefslogtreecommitdiffstats
path: root/src/canvas/widgets/process_table.rs
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-08-07 01:29:20 -0700
committerGitHub <noreply@github.com>2020-08-07 04:29:20 -0400
commit30bdaa6073ad28eb1083997e874654727460fcbb (patch)
tree07a373b3f2493c9c6e2872ceec617127ee5dc8d8 /src/canvas/widgets/process_table.rs
parentd2129056e3f04c961a28099510d3bd577925af47 (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/widgets/process_table.rs')
-rw-r--r--src/canvas/widgets/process_table.rs32
1 files changed, 23 insertions, 9 deletions
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]
};