diff options
-rw-r--r-- | ranger/core/actions.py | 4 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 6 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 6 |
3 files changed, 9 insertions, 7 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 4e76df65..1b5d0028 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1004,9 +1004,9 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if preview_column.target and preview_column.target.is_file: if narg is not None: lines = narg - target_scroll = preview_column.scrollbit + lines + target_scroll = preview_column.scroll_extra + lines max_scroll = len(preview_column.lines) - preview_column.hei - preview_column.scrollbit = max(0, min(target_scroll, max_scroll)) + preview_column.scroll_extra = max(0, min(target_scroll, max_scroll)) preview_column.request_redraw() # -------------------------- diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 3845dc41..8d2e63eb 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -96,7 +96,9 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes self.fm.thisdir.move_to_obj(clicked_file) self.fm.execute_file(clicked_file) elif self.target.is_file: - self.scrollbit = max(0, self.scrollbit + direction) + target_scroll = self.scroll_extra + direction + max_scroll = len(self.lines) - self.hei + self.scroll_extra = max(0, min(target_scroll, max_scroll)) self.need_redraw = True else: if self.level > 0 and not direction: @@ -157,7 +159,7 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes if target != self.old_dir: self.need_redraw = True self.old_dir = target - self.scrollbit = 0 # reset scroll start + self.scroll_extra = 0 # reset scroll start if target: target.use() diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index c88f5ff0..3bb52e3f 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -29,18 +29,17 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes need_clear_image = False need_redraw_image = False max_width = None - scrollbit = 0 def __init__(self, win, embedded=False): Widget.__init__(self, win) self.embedded = embedded self.scroll_begin = 0 + self.scroll_extra = 0 self.startx = 0 self.markup = None self.lines = [] self.image = None self.image_drawn = False - self.scrollbit = 0 def _close_source(self): if self.source and self.source_is_stream: @@ -96,8 +95,9 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes self.clear_image() if not self.image: + scroll_pos = self.scroll_begin + self.scroll_extra line_gen = self._generate_lines( - starty=self.scrollbit, startx=self.startx) + starty=scroll_pos, startx=self.startx) for line, i in zip(line_gen, range(self.hei)): self._draw_line(i, line) |