diff options
author | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2018-10-08 01:09:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-08 01:09:56 +0200 |
commit | 48ac4fa4c0ad69f1f4e54d56d26add6567fc7de1 (patch) | |
tree | 2ca913e3a8058dce22c659f713e498ace0419024 | |
parent | 3d8df486a82aca3945429df93f16fce75a498e02 (diff) | |
parent | 87855973952ea2d044826325dd96d869d4692a02 (diff) | |
download | ranger-48ac4fa4c0ad69f1f4e54d56d26add6567fc7de1.tar.gz |
Merge pull request #1329 from pvl1/master
initial mouse wheel scroll support in preview Closes #147.
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 7 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index bc6f7b1b..3845dc41 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -60,7 +60,7 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes def request_redraw(self): self.need_redraw = True - def click(self, event): + def click(self, event): # pylint: disable=too-many-branches """Handle a MouseEvent""" direction = event.mouse_wheel_direction() if not (event.pressed(1) or event.pressed(3) or direction): @@ -95,7 +95,9 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes elif self.level == 0: 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) + self.need_redraw = True else: if self.level > 0 and not direction: self.fm.move(right=0) @@ -155,6 +157,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 if target: target.use() diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index d64d4ac1..c88f5ff0 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -29,6 +29,7 @@ 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) @@ -39,6 +40,7 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes self.lines = [] self.image = None self.image_drawn = False + self.scrollbit = 0 def _close_source(self): if self.source and self.source_is_stream: @@ -95,7 +97,7 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes if not self.image: line_gen = self._generate_lines( - starty=self.scroll_begin, startx=self.startx) + starty=self.scrollbit, startx=self.startx) for line, i in zip(line_gen, range(self.hei)): self._draw_line(i, line) |