summary refs log tree commit diff stats
path: root/ranger
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 /ranger
parent7e0c69f3a4c3e204b4da2fbbd10ee7c0d40da4b8 (diff)
downloadranger-4b5162c71db1da63b32f5ab3f5d8175aae6369af.tar.gz
widgets.browsercolumn: call move_parent when scrolling in second column
Diffstat (limited to 'ranger')
-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
pre>4d33242 ^
4d33242 ^






9275c95 ^






689d6d8 ^


015d065 ^
7df7fe4 ^
f7ab5dd ^

7df7fe4 ^
16de708 ^

7df7fe4 ^
16de708 ^
e43cdbe ^

7df7fe4 ^
7d96a88 ^

c0c6785 ^
fe9708f ^
16de708 ^



9275c95 ^
c0c6785 ^

e43cdbe ^
7df7fe4 ^
16de708 ^

9275c95 ^
e43cdbe ^















8d5d27a ^
e43cdbe ^

8d5d27a ^
e43cdbe ^
440f6e9 ^
8d5d27a ^
e43cdbe ^

440f6e9 ^


8d5d27a ^
516ac2f ^





31af4bd ^








516ac2f ^
9275c95 ^


156f978 ^
50008ed ^
















e43cdbe ^
156f978 ^
4dffcac ^
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173