diff options
author | hut <hut@lavabit.com> | 2010-04-05 23:48:31 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-05 23:48:31 +0200 |
commit | b312584976a07c622d70022fb78102285acc5624 (patch) | |
tree | d4b2ed4b5900fb0f1c3c0c567c942a1415129f8e | |
parent | f4ad6457049af41d5e818b8dd6682abf08a6b8d1 (diff) | |
download | ranger-b312584976a07c622d70022fb78102285acc5624.tar.gz |
gui.mouse_event: added mouse_wheel_direction()
-rw-r--r-- | ranger/gui/mouse_event.py | 9 | ||||
-rw-r--r-- | ranger/gui/widgets/browserview.py | 7 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 7 |
3 files changed, 15 insertions, 8 deletions
diff --git a/ranger/gui/mouse_event.py b/ranger/gui/mouse_event.py index d588fd8e..f3955825 100644 --- a/ranger/gui/mouse_event.py +++ b/ranger/gui/mouse_event.py @@ -41,6 +41,15 @@ class MouseEvent(object): except: return False + def mouse_wheel_direction(self): + if self.bstate & curses.BUTTON4_PRESSED: + return -1 + elif self.bstate & curses.BUTTON2_PRESSED \ + or self.bstate > curses.ALL_MOUSE_EVENTS: + return 1 + else: + return 0 + def ctrl(self): return self.bstate & curses.BUTTON_CTRL diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py index 1a7ab4e6..163fd503 100644 --- a/ranger/gui/widgets/browserview.py +++ b/ranger/gui/widgets/browserview.py @@ -233,10 +233,9 @@ class BrowserView(Widget, DisplayableContainer): def click(self, event): n = event.ctrl() and 5 or 1 - if event.pressed(4): - self.main_column.scroll(relative = -n) - elif event.pressed(2) or event.key_invalid(): - self.main_column.scroll(relative = n) + direction = event.mouse_wheel_direction() + if direction: + self.main_column.scroll(direction) else: DisplayableContainer.click(self, event) diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index 08702f3f..2fc8ecda 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -205,10 +205,9 @@ class Pager(Widget): def click(self, event): n = event.ctrl() and 1 or 3 - if event.pressed(4): - self.move(relative = -n) - elif event.pressed(2) or event.key_invalid(): - self.move(relative = n) + direction = event.mouse_wheel_direction() + if direction: + self.move(relative=direction) return True def _get_line(self, n, attempt_to_read=True): |