diff options
author | ClementTsang <clementjhtsang@gmail.com> | 2019-12-15 00:17:15 -0500 |
---|---|---|
committer | ClementTsang <clementjhtsang@gmail.com> | 2019-12-15 00:17:15 -0500 |
commit | f8209c9162435383cc8a0f3e89d81d9edaae7e75 (patch) | |
tree | 568b5fc35a943c1a5a54448c223663d62490a4a4 /src | |
parent | 7592fec1d109cc5d6f6acc2bfc1ec1cbe969d34b (diff) |
Update controls.
Diffstat (limited to 'src')
-rw-r--r-- | src/canvas.rs | 12 | ||||
-rw-r--r-- | src/data_conversion.rs | 26 | ||||
-rw-r--r-- | src/main.rs | 39 |
3 files changed, 39 insertions, 38 deletions
diff --git a/src/canvas.rs b/src/canvas.rs index 00e70d41..baffb2d2 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -55,13 +55,13 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu .constraints([Constraint::Percentage(30), Constraint::Percentage(40), Constraint::Percentage(30)].as_ref()) .split(vertical_dialog_chunk[1]); - let text = [ + let help_text = [ Text::raw("\nGeneral Keybinds\n"), Text::raw("q, Ctrl-c to quit.\n"), Text::raw("Ctrl-r to reset all data.\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("Ctrl+Up/k, Ctrl+Down/j, Ctrl+Left/h, Ctrl+Right/l to navigate between panels.\n"), + Text::raw("Up and Down scrolls through a list.\n"), Text::raw("Esc to close a dialog window (help or dd confirmation).\n"), Text::raw("? to get this help screen.\n"), Text::raw("\n Process Panel Keybinds\n"), @@ -72,7 +72,7 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu Text::raw("n to sort by process name.\n"), ]; - Paragraph::new(text.iter()) + Paragraph::new(help_text.iter()) .block(Block::default().title("Help (Press Esc to close)").borders(Borders::ALL)) .style(Style::default().fg(Color::Gray)) .alignment(Alignment::Left) @@ -193,7 +193,7 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu .labels(&["0%", "100%"]); let mem_name = "RAM:".to_string() - + &format!("{:3}%", (canvas_data.mem_data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)) + + &format!("{:3}%", (canvas_data.mem_data.last().unwrap_or(&(0_f64, 0_f64)).1.floor() as u64)) + &format!( " {:.1}GB/{:.1}GB", canvas_data.mem_values.first().unwrap_or(&(0, 0)).0 as f64 / 1024.0, @@ -211,7 +211,7 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu if let Some(last_canvas_result) = (&canvas_data.swap_data).last() { if last_canvas_result.1 >= 0.0 { swap_name = "SWP:".to_string() - + &format!("{:3}%", (canvas_data.swap_data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)) + + &format!("{:3}%", (canvas_data.swap_data.last().unwrap_or(&(0_f64, 0_f64)).1.floor() as u64)) + &format!( " {:.1}GB/{:.1}GB", canvas_data.mem_values[1].0 as f64 / 1024.0, diff --git a/src/data_conversion.rs b/src/data_conversion.rs index 3417e04b..b94af4c4 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -41,19 +41,19 @@ pub fn update_disk_row(app_data: &data_collection::Data) -> Vec<Vec<String>> { let read_bytes_per_sec = ((ele.read_bytes - prev.read_bytes) as f64 / time_difference) as u64; let write_bytes_per_sec = ((ele.write_bytes - prev.write_bytes) as f64 / time_difference) as u64; ( - if read_bytes_per_sec < 1024 { + if read_bytes_per_sec < 1000 { format!("{}B", read_bytes_per_sec) - } else if read_bytes_per_sec < 1024 * 1024 { - format!("{}KB", read_bytes_per_sec / 1024) + } else if read_bytes_per_sec < 1000 * 1000 { + format!("{}KB", read_bytes_per_sec / 1000) } else { - format!("{}MB", read_bytes_per_sec / 1024 / 1024) + format!("{}MB", read_bytes_per_sec / 1000 / 1000) }, - if write_bytes_per_sec < 1024 { + if write_bytes_per_sec < 1000 { format!("{}B", write_bytes_per_sec) - } else if write_bytes_per_sec < 1024 * 1024 { - format!("{}KB", write_bytes_per_sec / 1024) + } else if write_bytes_per_sec < 1000 * 1000 { + format!("{}KB", write_bytes_per_sec / 1000) } else { - format!("{}MB", write_bytes_per_sec / 1024 / 1024) + format!("{}MB", write_bytes_per_sec / 1000 / 1000) }, ) } else { @@ -72,15 +72,15 @@ pub fn update_disk_row(app_data: &data_collection::Data) -> Vec<Vec<String>> { disk.name.to_string(), disk.mount_point.to_string(), format!("{:.0}%", disk.used_space as f64 / disk.total_space as f64 * 100_f64), - if disk.free_space < 1024 { + if disk.free_space < 1000 { disk.free_space.to_string() + "MB" } else { - (disk.free_space / 1024).to_string() + "GB" + (disk.free_space / 1000).to_string() + "GB" }, - if disk.total_space < 1024 { + if disk.total_space < 1000 { disk.total_space.to_string() + "MB" } else { - (disk.total_space / 1024).to_string() + "GB" + (disk.total_space / 1000).to_string() + "GB" }, io_activity.0, io_activity.1, @@ -104,7 +104,7 @@ pub fn update_process_row(app_data: &data_collection::Data) -> Vec<Vec<String>> mem_usage } else if let Some(mem_usage_kb) = process.mem_usage_kb { if let Some(mem_data) = app_data.memory.last() { - (mem_usage_kb / 1024) as f64 / mem_data.mem_total_in_mb as f64 * 100_f64 + (mem_usage_kb / 1000) as f64 / mem_data.mem_total_in_mb as f64 * 100_f64 } else { 0_f64 } diff --git a/src/main.rs b/src/main.rs index 8a6ff033..ada8b05d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,19 +46,20 @@ enum ResetEvent { fn main() -> error::Result<()> { // Parse command line options let matches = clap_app!(app => - (name: crate_name!()) - (version: crate_version!()) - (author: crate_authors!()) - (about: crate_description!()) - (@arg AVG_CPU: -a --avgcpu "Enables showing the average CPU usage.") - (@arg DOT_MARKER: -m --dot_marker "Use a dot marker instead of the default braille marker. May be needed in things like Powershell.") - (@arg DEBUG: -d --debug "Enables debug mode.") - (@group TEMPERATURE_TYPE => - (@arg CELSIUS : -c --celsius "Sets the temperature type to Celsius. This is the default option.") - (@arg FAHRENHEIT : -f --fahrenheit "Sets the temperature type to Fahrenheit.") - (@arg KELVIN : -k --kelvin "Sets the temperature type to Kelvin.") - ) - (@arg RATE_MILLIS: -r --rate +takes_value "Sets a refresh rate in milliseconds; the minimum is 250ms, defaults to 1000ms. Smaller values may take more resources.") + (name: crate_name!()) + (version: crate_version!()) + (author: crate_authors!()) + (about: crate_description!()) + (@arg AVG_CPU: -a --avgcpu "Enables showing the average CPU usage.") + (@arg DOT_MARKER: -m --dot_marker "Use a dot marker instead of the default braille marker.") + (@arg DEBUG: -d --debug "Enables debug mode, which will output a log file.") + (@group TEMPERATURE_TYPE => + (@arg CELSIUS : -c --celsius "Sets the temperature type to Celsius. This is the default option.") + (@arg FAHRENHEIT : -f --fahrenheit "Sets the temperature type to Fahrenheit.") + (@arg KELVIN : -k --kelvin "Sets the temperature type to Kelvin.") + ) + (@arg RATE_MILLIS: -r --rate +takes_value "Sets a refresh rate in milliseconds; the minimum is 250ms, defaults to 1000ms. Smaller values may take more resources.") + //(@arg CONFIG_LOCATION: -co --config +takes_value "Sets the location of the config file. Expects a config file in the JSON format.") ) .get_matches(); @@ -213,18 +214,18 @@ fn main() -> error::Result<()> { Event::KeyInput(event) => { match event { KeyEvent::Ctrl('c') | KeyEvent::Char('q') => break, - KeyEvent::Char('h') | KeyEvent::Left => app.on_left(), - KeyEvent::Char('l') | KeyEvent::Right => app.on_right(), - KeyEvent::Char('k') | KeyEvent::Up => app.on_up(), - KeyEvent::Char('j') | KeyEvent::Down => app.on_down(), + KeyEvent::Char('h') | KeyEvent::CtrlLeft => app.on_left(), + KeyEvent::Char('l') | KeyEvent::CtrlRight => app.on_right(), + KeyEvent::Char('k') | KeyEvent::CtrlUp => app.on_up(), + KeyEvent::Char('j') | KeyEvent::CtrlDown => app.on_down(), KeyEvent::Ctrl('r') => { while rtx.send(ResetEvent::Reset).is_err() { debug!("Sent reset message."); } debug!("Resetting begins..."); } - KeyEvent::ShiftUp => app.decrement_position_count(), - KeyEvent::ShiftDown => app.increment_position_count(), + KeyEvent::Up => app.decrement_position_count(), + KeyEvent::Down => app.increment_position_count(), KeyEvent::Char(c) => app.on_key(c), //KeyEvent::Enter => app.on_enter(), KeyEvent::Esc => app.on_esc(), |