summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-05-02 01:55:17 +0200
committerhut <hut@lavabit.com>2010-05-02 01:55:17 +0200
commit4b5162c71db1da63b32f5ab3f5d8175aae6369af (patch)
tree272d5541fb7076044b3dda0a66b033f5f178fef7
parent7e0c69f3a4c3e204b4da2fbbd10ee7c0d40da4b8 (diff)
downloadranger-4b5162c71db1da63b32f5ab3f5d8175aae6369af.tar.gz
widgets.browsercolumn: call move_parent when scrolling in second column
-rw-r--r--ranger/gui/mouse_event.py9
-rw-r--r--ranger/gui/widgets/browsercolumn.py10
-rw-r--r--ranger/gui/widgets/browserview.py8
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
nger/commit/setup.py?h=v1.8.1&id=8a5944e1bd52dd749c34a5b4eda401902531175a'>8a5944e1 ^
3cd8a402 ^


d1a1173d ^








d1a1173d ^
e6b847b3 ^
225aa78f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50