diff options
author | hut <hut@lavabit.com> | 2010-05-02 01:55:17 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-05-02 01:55:17 +0200 |
commit | 4b5162c71db1da63b32f5ab3f5d8175aae6369af (patch) | |
tree | 272d5541fb7076044b3dda0a66b033f5f178fef7 | |
parent | 7e0c69f3a4c3e204b4da2fbbd10ee7c0d40da4b8 (diff) | |
download | ranger-4b5162c71db1da63b32f5ab3f5d8175aae6369af.tar.gz |
widgets.browsercolumn: call move_parent when scrolling in second column
-rw-r--r-- | ranger/gui/mouse_event.py | 9 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 10 | ||||
-rw-r--r-- | ranger/gui/widgets/browserview.py | 8 |
3 files changed, 19 insertions, 8 deletions
diff --git a/ranger/gui/mouse_event.py b/ranger/gui/mouse_event.py index f3955825..4a2860b8 100644 --- a/ranger/gui/mouse_event.py +++ b/ranger/gui/mouse_event.py @@ -21,6 +21,7 @@ class MouseEvent(object): curses.BUTTON2_PRESSED, curses.BUTTON3_PRESSED, curses.BUTTON4_PRESSED ] + CTRL_SCROLLWHEEL_MULTIPLIER = 5 def __init__(self, getmouse): """Creates a MouseEvent object from the result of win.getmouse()""" @@ -42,11 +43,15 @@ class MouseEvent(object): return False def mouse_wheel_direction(self): + """Returns the direction of the scroll action, 0 if there was none""" + # If the bstate > ALL_MOUSE_EVENTS, it's an invalid mouse button. + # I interpret invalid buttons as "scroll down" because all tested + # systems have a broken curses implementation and this is a workaround. if self.bstate & curses.BUTTON4_PRESSED: - return -1 + return self.ctrl() and -self.CTRL_SCROLLWHEEL_MULTIPLIER or -1 elif self.bstate & curses.BUTTON2_PRESSED \ or self.bstate > curses.ALL_MOUSE_EVENTS: - return 1 + return self.ctrl() and self.CTRL_SCROLLWHEEL_MULTIPLIER or 1 else: return 0 diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index e4ba4b64..6e020e5f 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -87,7 +87,8 @@ class BrowserColumn(Pager): def click(self, event): """Handle a MouseEvent""" - if not (event.pressed(1) or event.pressed(3)): + direction = event.mouse_wheel_direction() + if not (event.pressed(1) or event.pressed(3) or direction): return False if self.target is None: @@ -97,7 +98,12 @@ class BrowserColumn(Pager): if self.target.accessible and self.target.content_loaded: index = self.scroll_begin + event.y - self.y - if event.pressed(1): + if direction: + if self.level == -1: + self.fm.move_parent(direction) + else: + return False + elif event.pressed(1): if not self.main_column: self.fm.enter_dir(self.target.path) diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py index b301d7ca..105c3ae6 100644 --- a/ranger/gui/widgets/browserview.py +++ b/ranger/gui/widgets/browserview.py @@ -232,12 +232,12 @@ class BrowserView(Widget, DisplayableContainer): left += wid def click(self, event): - n = event.ctrl() and 5 or 1 - direction = event.mouse_wheel_direction() * n + if DisplayableContainer.click(self, event): + return True + direction = event.mouse_wheel_direction() if direction: self.main_column.scroll(direction) - else: - DisplayableContainer.click(self, event) + return False def open_pager(self): self.pager.visible = True |