Added freezing of updates.

This commit is contained in:
ClementTsang 2019-10-09 22:34:09 -04:00
parent 2900ae2acf
commit 0697e44802
6 changed files with 37 additions and 30 deletions

View File

@ -30,7 +30,7 @@ tokio = "0.2.0-alpha.4"
winapi = "0.3.8" winapi = "0.3.8"
[dependencies.tui-temp-fork] [dependencies.tui-temp-fork]
git = "https://github.com/ClementTsang/tui-rs" #git = "https://github.com/ClementTsang/tui-rs"
#path = "../tui-rs" #path = "../tui-rs"
version = "0.6.4" version = "0.6.4"
default-features = false default-features = false

View File

@ -47,6 +47,8 @@ Currently, I'm unable to really dev or test on MacOS, so I'm not sure how well t
- `q`, `Ctrl-C` to quit. - `q`, `Ctrl-C` to quit.
- `f` to freeze updating. Press `f` again to unfreeze. Note updating will still continue in the background.
- `Up/k`, `Down/j`, `Left/h`, `Right/l` to navigate between panels. - `Up/k`, `Down/j`, `Left/h`, `Right/l` to navigate between panels.
- `Shift+Up` and `Shift+Down` scrolls through the list if the panel is a table (Temperature, Disks, Processes). - `Shift+Up` and `Shift+Down` scrolls through the list if the panel is a table (Temperature, Disks, Processes).

View File

@ -8,7 +8,7 @@ Note this will probably migrate to GitHub's native Issues; this was mostly for p
- Scaling in and out (zoom), may need to show zoom levels - Scaling in and out (zoom), may need to show zoom levels
- More keybinds (jumping, scaling, help) - More keybinds (jumping, scaling)
- ~~Add custom error because it's really messy~~ Done, but need to implement across rest of app! - ~~Add custom error because it's really messy~~ Done, but need to implement across rest of app!
@ -16,8 +16,6 @@ Note this will probably migrate to GitHub's native Issues; this was mostly for p
- Filtering in processes (that is, allow searching) - Filtering in processes (that is, allow searching)
- Help screen
- Probably good to add a "are you sure" to dd-ing... - Probably good to add a "are you sure" to dd-ing...
## Less important ## Less important

View File

@ -40,6 +40,7 @@ pub struct App {
awaiting_second_d : bool, awaiting_second_d : bool,
pub use_dot : bool, pub use_dot : bool,
pub show_help : bool, pub show_help : bool,
pub is_frozen : bool,
} }
impl App { impl App {
@ -64,6 +65,7 @@ impl App {
awaiting_second_d : false, awaiting_second_d : false,
use_dot, use_dot,
show_help : false, show_help : false,
is_frozen : false,
} }
} }
@ -83,14 +85,16 @@ impl App {
'd' => { 'd' => {
if self.awaiting_second_d { if self.awaiting_second_d {
self.awaiting_second_d = false; self.awaiting_second_d = false;
self.kill_highlighted_process().unwrap_or(()); // TODO: Should this be handled? self.kill_highlighted_process().unwrap_or(());
} }
else { else {
self.awaiting_second_d = true; self.awaiting_second_d = true;
} }
} }
'f' => {
self.is_frozen = !self.is_frozen;
}
'c' => { 'c' => {
// TODO: This should depend on what tile you're on!
match self.process_sorting_type { match self.process_sorting_type {
processes::ProcessSorting::CPU => self.process_sorting_reverse = !self.process_sorting_reverse, processes::ProcessSorting::CPU => self.process_sorting_reverse = !self.process_sorting_reverse,
_ => { _ => {

View File

@ -61,6 +61,7 @@ pub fn draw_data<B : backend::Backend>(terminal : &mut Terminal<B>, app_state :
let text = [ let text = [
Text::raw("\nGeneral Keybinds\n"), Text::raw("\nGeneral Keybinds\n"),
Text::raw("q, Ctrl-C to quit.\n"), Text::raw("q, Ctrl-C to quit.\n"),
Text::raw("f to toggle freezing and unfreezing the display.\n"),
Text::raw("Up/k, Down/j, Left/h, Right/l to navigate between panels.\n"), Text::raw("Up/k, Down/j, Left/h, Right/l to navigate between panels.\n"),
Text::raw("Shift+Up and Shift+Down scrolls through the list.\n"), Text::raw("Shift+Up and Shift+Down scrolls through the list.\n"),
Text::raw("Esc to close a dialog window (help or dd confirmation).\n"), Text::raw("Esc to close a dialog window (help or dd confirmation).\n"),
@ -400,10 +401,10 @@ pub fn draw_data<B : backend::Backend>(terminal : &mut Terminal<B>, app_state :
{ {
use app::data_collection::processes::ProcessSorting; use app::data_collection::processes::ProcessSorting;
let mut pid = "PID".to_string(); let mut pid = "PID (p)".to_string();
let mut name = "Name".to_string(); let mut name = "Name (n)".to_string();
let mut cpu = "CPU%".to_string(); let mut cpu = "CPU% (c)".to_string();
let mut mem = "Mem%".to_string(); let mut mem = "Mem% (m)".to_string();
let direction_val = if app_state.process_sorting_reverse { let direction_val = if app_state.process_sorting_reverse {
"".to_string() "".to_string()

View File

@ -226,6 +226,7 @@ fn main() -> error::Result<()> {
} }
Event::Update(data) => { Event::Update(data) => {
// debug!("Update event fired!"); // debug!("Update event fired!");
if !app.is_frozen {
app.data = *data; app.data = *data;
data_collection::processes::sort_processes( data_collection::processes::sort_processes(
&mut app.data.list_of_processes, &mut app.data.list_of_processes,
@ -251,6 +252,7 @@ fn main() -> error::Result<()> {
} }
} }
} }
}
// Draw! // Draw!
if let Err(err) = canvas::draw_data(&mut terminal, &mut app, &canvas_data) { if let Err(err) = canvas::draw_data(&mut terminal, &mut app, &canvas_data) {
input().disable_mouse_mode().unwrap(); input().disable_mouse_mode().unwrap();