diff --git a/Cargo.toml b/Cargo.toml index 6d3ac010..38ef6168 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ tokio = "0.2.0-alpha.4" winapi = "0.3.8" [dependencies.tui-temp-fork] -#git = "https://github.com/ClementTsang/tui-rs" +git = "https://github.com/ClementTsang/tui-rs" #path = "../tui-rs" version = "0.6.4" default-features = false diff --git a/TODO.md b/TODO.md index 993170f6..207d9db4 100644 --- a/TODO.md +++ b/TODO.md @@ -4,8 +4,6 @@ Note this will probably migrate to GitHub's native Issues; this was mostly for p - Rebalance cpu usage in process by using current value (it's currently just summing to 100%) -- Scrolling support for temp/disk - - Travis - Refactoring! Please. @@ -18,8 +16,6 @@ Note this will probably migrate to GitHub's native Issues; this was mostly for p - Mouse + key events conflict? Make it so that some events don't clog up the loop if they are not valid keys! -- Header should be clear on current sorting direction! - - It would be maybe a good idea to see if we can run the process calculation across ALL cpus...? Might be more accurate. - ~~Add custom error because it's really messy~~ Done, but need to implement across rest of app! diff --git a/src/canvas.rs b/src/canvas.rs index 3d76535d..c15782ae 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -358,19 +358,41 @@ pub fn draw_data(terminal : &mut Terminal, app_state : ) }); - Table::new(["PID", "Name", "CPU%", "Mem%"].iter(), process_rows) - .block( - Block::default() - .title("Processes") - .borders(Borders::ALL) - .border_style(match app_state.current_application_position { - app::ApplicationPosition::PROCESS => highlighted_border_style, - _ => border_style, - }), - ) - .header_style(Style::default().fg(Color::LightBlue)) - .widths(&[(width * 0.2) as u16, (width * 0.35) as u16, (width * 0.2) as u16, (width * 0.2) as u16]) - .render(&mut f, bottom_chunks[1]); + { + use app::data_collection::processes::ProcessSorting; + let mut pid = "PID".to_string(); + let mut name = "Name".to_string(); + let mut cpu = "CPU%".to_string(); + let mut mem = "Mem%".to_string(); + + let direction_val = if app_state.process_sorting_reverse { + " ⯆".to_string() + } + else { + " ⯅".to_string() + }; + + match app_state.process_sorting_type { + ProcessSorting::CPU => cpu += &direction_val, + ProcessSorting::MEM => mem += &direction_val, + ProcessSorting::PID => pid += &direction_val, + ProcessSorting::NAME => name += &direction_val, + }; + + Table::new([pid, name, cpu, mem].iter(), process_rows) + .block( + Block::default() + .title("Processes") + .borders(Borders::ALL) + .border_style(match app_state.current_application_position { + app::ApplicationPosition::PROCESS => highlighted_border_style, + _ => border_style, + }), + ) + .header_style(Style::default().fg(Color::LightBlue)) + .widths(&[(width * 0.2) as u16, (width * 0.35) as u16, (width * 0.2) as u16, (width * 0.2) as u16]) + .render(&mut f, bottom_chunks[1]); + } } })?;