summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-05 23:48:31 +0200
committerhut <hut@lavabit.com>2010-04-05 23:48:31 +0200
commitb312584976a07c622d70022fb78102285acc5624 (patch)
treed4b2ed4b5900fb0f1c3c0c567c942a1415129f8e
parentf4ad6457049af41d5e818b8dd6682abf08a6b8d1 (diff)
downloadranger-b312584976a07c622d70022fb78102285acc5624.tar.gz
gui.mouse_event: added mouse_wheel_direction()
-rw-r--r--ranger/gui/mouse_event.py9
-rw-r--r--ranger/gui/widgets/browserview.py7
-rw-r--r--ranger/gui/widgets/pager.py7
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):
i/profani-tty/commit/src/command/cmd_autocomplete.h?id=eaf2901b0138c5ac9beb3c3619246eef577b2b31'>eaf2901b ^
a2726b6a ^

a45f05a4 ^
a2726b6a ^

eaf2901b ^
a2726b6a ^


eaf2901b ^
a2726b6a ^

eaf2901b ^
a2726b6a ^
dcc2123e ^
dfe61341 ^
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