From 6e7ab0421b2ac2ef58d03c7633a9ddc660b83fbe Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 12 May 2019 00:40:44 +0300 Subject: [PATCH] ui: fix pager scrolling getting stuck --- ui/src/components/utilities.rs | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index e4ce67ef1..0521dca1a 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -446,13 +446,8 @@ impl Component for Pager { self.cursor_pos = self.cursor_pos.saturating_sub(height); } PageMovement::PageDown => { - /* This might "overflow" beyond the max_cursor_pos boundary if it's not yet - * set. TODO: Rework the page up/down stuff - */ - if self.cursor_pos + 2 * height + 1 < self.height { + if self.cursor_pos + height < self.height { self.cursor_pos += height; - } else { - self.cursor_pos = self.height.saturating_sub(height).saturating_sub(1); } } } @@ -462,18 +457,6 @@ impl Component for Pager { return; } - match self.max_cursor_pos { - Some(max) if max <= self.cursor_pos => { - self.cursor_pos -= 1; - return; - } - Some(max) if max >= height => { - self.cursor_pos = 0; - return; - } - _ => {} - } - clear_area(grid, area); //let pager_context: usize = context.settings.pager.pager_context; //let pager_stop: bool = context.settings.pager.pager_stop; @@ -489,16 +472,15 @@ impl Component for Pager { self.content = CellBuffer::new(width, height, Cell::with_char(' ')); Pager::print_string(&mut self.content, lines); } - + if self.cursor_pos + height >= self.height { + self.cursor_pos = self.height.saturating_sub(height); + }; let pos = copy_area_with_break( grid, &self.content, area, ((0, self.cursor_pos), (self.width - 1, self.height - 1)), ); - if pos.1 < get_y(bottom_right!(area)) { - self.max_cursor_pos = Some(self.height + 1); - } context.dirty_areas.push_back(area); } fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {