diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-05-12 00:40:44 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:48 +0300 |
commit | 6e7ab0421b2ac2ef58d03c7633a9ddc660b83fbe (patch) | |
tree | eb2bc022df5fc346f45a415acc6defe2eb79378d | |
parent | 5d6c4ee2c8d33e5f36634bc44b26552444156a23 (diff) |
ui: fix pager scrolling getting stuck
-rw-r--r-- | ui/src/components/utilities.rs | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index e4ce67ef..0521dca1 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 { |