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"
[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

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.
- `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.
- `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
- 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!
@ -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)
- Help screen
- Probably good to add a "are you sure" to dd-ing...
## Less important

View file

@ -40,6 +40,7 @@ pub struct App {
awaiting_second_d : bool,
pub use_dot : bool,
pub show_help : bool,
pub is_frozen : bool,
}
impl App {
@ -64,6 +65,7 @@ impl App {
awaiting_second_d : false,
use_dot,
show_help : false,
is_frozen : false,
}
}
@ -83,14 +85,16 @@ impl App {
'd' => {
if self.awaiting_second_d {
self.awaiting_second_d = false;
self.kill_highlighted_process().unwrap_or(()); // TODO: Should this be handled?
self.kill_highlighted_process().unwrap_or(());
}
else {
self.awaiting_second_d = true;
}
}
'f' => {
self.is_frozen = !self.is_frozen;
}
'c' => {
// TODO: This should depend on what tile you're on!
match self.process_sorting_type {
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 = [
Text::raw("\nGeneral Keybinds\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("Shift+Up and Shift+Down scrolls through the list.\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;
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 mut pid = "PID (p)".to_string();
let mut name = "Name (n)".to_string();
let mut cpu = "CPU% (c)".to_string();
let mut mem = "Mem% (m)".to_string();
let direction_val = if app_state.process_sorting_reverse {
"".to_string()

View file

@ -226,28 +226,30 @@ fn main() -> error::Result<()> {
}
Event::Update(data) => {
// debug!("Update event fired!");
app.data = *data;
data_collection::processes::sort_processes(
&mut app.data.list_of_processes,
&app.process_sorting_type,
app.process_sorting_reverse,
);
if !app.is_frozen {
app.data = *data;
data_collection::processes::sort_processes(
&mut app.data.list_of_processes,
&app.process_sorting_type,
app.process_sorting_reverse,
);
// Convert all data into tui components
let network_data = update_network_data_points(&app.data);
canvas_data.network_data_rx = network_data.rx;
canvas_data.network_data_tx = network_data.tx;
canvas_data.rx_display = network_data.rx_display;
canvas_data.tx_display = network_data.tx_display;
canvas_data.disk_data = update_disk_row(&app.data);
canvas_data.temp_sensor_data = update_temp_row(&app.data, &app.temperature_type);
canvas_data.process_data = update_process_row(&app.data);
canvas_data.mem_data = update_mem_data_points(&app.data);
canvas_data.mem_values = update_mem_data_values(&app.data);
canvas_data.swap_data = update_swap_data_points(&app.data);
canvas_data.cpu_data = update_cpu_data_points(app.show_average_cpu, &app.data);
// Convert all data into tui components
let network_data = update_network_data_points(&app.data);
canvas_data.network_data_rx = network_data.rx;
canvas_data.network_data_tx = network_data.tx;
canvas_data.rx_display = network_data.rx_display;
canvas_data.tx_display = network_data.tx_display;
canvas_data.disk_data = update_disk_row(&app.data);
canvas_data.temp_sensor_data = update_temp_row(&app.data, &app.temperature_type);
canvas_data.process_data = update_process_row(&app.data);
canvas_data.mem_data = update_mem_data_points(&app.data);
canvas_data.mem_values = update_mem_data_values(&app.data);
canvas_data.swap_data = update_swap_data_points(&app.data);
canvas_data.cpu_data = update_cpu_data_points(app.show_average_cpu, &app.data);
debug!("Update event complete.");
debug!("Update event complete.");
}
}
}
}