From 5131859ab896ad0eb323245fad1ddbc869d2ed93 Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Tue, 18 Feb 2020 21:34:20 -0500 Subject: Fix scroll problem with resizing/maximizing. --- src/app/data_farmer.rs | 6 +++--- src/canvas.rs | 1 + src/canvas/drawing_utils.rs | 10 +++++++--- src/main.rs | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/app/data_farmer.rs b/src/app/data_farmer.rs index 151a710d..9741c563 100644 --- a/src/app/data_farmer.rs +++ b/src/app/data_farmer.rs @@ -278,13 +278,13 @@ pub fn generate_joining_points( // Let's generate... about this many points! let num_points = std::cmp::min( std::cmp::max( - (value_difference.abs() / time_difference * 1000.0) as u64, + (value_difference.abs() / time_difference * 2000.0) as u64, 50, ), - 1000, + 2000, ); - for itx in (0..num_points).step_by(4) { + for itx in (0..num_points).step_by(2) { points.push(( time_difference - (itx as f64 / num_points as f64 * time_difference), start_y + (itx as f64 / num_points as f64 * value_difference), diff --git a/src/canvas.rs b/src/canvas.rs index af8f08ed..85293c89 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -141,6 +141,7 @@ impl Painter { } // TODO: [REFACTOR] We should clean this up tbh + // TODO: [FEATURE] Auto-resizing dialog sizes. #[allow(clippy::cognitive_complexity)] pub fn draw_data( &mut self, terminal: &mut Terminal, app_state: &mut app::App, diff --git a/src/canvas/drawing_utils.rs b/src/canvas/drawing_utils.rs index 2d53d064..0670af33 100644 --- a/src/canvas/drawing_utils.rs +++ b/src/canvas/drawing_utils.rs @@ -76,7 +76,10 @@ pub fn get_start_position( ) -> u64 { match scroll_direction { app::ScrollDirection::DOWN => { - if currently_selected_position < *previously_scrolled_position + num_rows { + if currently_selected_position < num_rows { + // Can we see it outright? + 0 + } else if currently_selected_position < *previously_scrolled_position + num_rows { // If, using previous_scrolled_position, we can see the element // (so within that and + num_rows) just reuse the current previously scrolled position *previously_scrolled_position @@ -90,11 +93,12 @@ pub fn get_start_position( 0 } } + // TODO: [FIX] This is bugged. Scrolling up then resizing is a no go! app::ScrollDirection::UP => { - if currently_selected_position <= *previously_scrolled_position { + if currently_selected_position < *previously_scrolled_position { // If it's past the first element, then show from that element downwards *previously_scrolled_position = currently_selected_position; - currently_selected_position + *previously_scrolled_position } else { // Else, don't change what our start position is from whatever it is set to! *previously_scrolled_position diff --git a/src/main.rs b/src/main.rs index da2f8292..4bc692d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -354,7 +354,8 @@ fn handle_key_event_or_break( KeyCode::Char('u') => app.clear_search(), KeyCode::Char('a') => app.skip_cursor_beginning(), KeyCode::Char('e') => app.skip_cursor_end(), - // TODO: [FEATURE] Ctrl-backspace KeyCode::Backspace => app.on_skip_backspace(), + // TODO: [FEATURE] Ctrl-backspace + // KeyCode::Backspace => app.on_skip_backspace(), _ => {} } } else if let KeyModifiers::SHIFT = event.modifiers { -- cgit v1.2.3