Fix scroll problem with resizing/maximizing.

This commit is contained in:
ClementTsang 2020-02-18 21:34:20 -05:00
parent 47b78d22f8
commit 5131859ab8
4 changed files with 13 additions and 7 deletions

View File

@ -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),

View File

@ -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<B: backend::Backend>(
&mut self, terminal: &mut Terminal<B>, app_state: &mut app::App,

View File

@ -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

View File

@ -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 {