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):
le='Blame the previous revision' href='/acidbong/suckless/dwm/blame/dwm.1?h=6.2&id=8cc7f3bace087dfb024a23115c211d82b35614ae'>^
f17e898 ^
e6cbe9c ^
cdbc84b ^
84432e6 ^
39af3c2 ^
338c083 ^
84432e6 ^

1a25414 ^

b439892 ^
caf5a16 ^
901b3ed ^
1076f2b

901b3ed ^
0c3544d ^
2b35fae ^

a3e3f0b ^

2b35fae ^
3e06ede ^
cdbc84b ^
338c083 ^
292ccc4 ^
d4b7a9a ^
10885d3 ^
1836b67 ^
ee8fb0c ^
7ab8c87 ^
1836b67 ^
ee8fb0c ^
7ab8c87 ^
2b35fae ^
72655f0 ^
ee8fb0c ^
df74b26 ^
0ea0343 ^
72655f0 ^
ee8fb0c ^
5871008 ^
cb9607c ^
0b5c14c ^


2e95837 ^

39af3c2 ^
2e95837 ^

fef6c5c ^
2e95837 ^

aa53e39 ^
ee8fb0c ^
7ab8c87 ^
72655f0 ^
ee8fb0c ^
7ab8c87 ^
3af6434 ^
d66ad14 ^


ee8fb0c ^
1549faf ^
7ab8c87 ^

1549faf ^
ee8fb0c ^
42fd392 ^

ee8fb0c ^
df74b26 ^
7ab8c87 ^

df74b26 ^
ee8fb0c ^
7ab8c87 ^
45aea23 ^
ee8fb0c ^
a92cf49 ^
8dc8605 ^
ee8fb0c ^
df74b26 ^
7ab8c87 ^

1549faf ^
ee8fb0c ^
7ab8c87 ^
daae3bb ^
ee8fb0c ^
3e06ede ^
7ab8c87 ^

4bb89e2 ^
ee8fb0c ^
7ab8c87 ^
2b35fae ^
0c3544d ^
ee8fb0c ^
d1ce3ea ^
0e5c819 ^
ee8fb0c ^
b2f276b ^
4bd0d33 ^
ee8fb0c ^
d1ce3ea ^
0c3544d ^
7ab8c87 ^
dc5c070 ^
7e98db2 ^

bced907 ^
60b3dce ^
21bd90d ^
c8f96b5 ^
4bb89e2 ^
c8f96b5 ^



c7da124 ^


c8f96b5 ^

124866e ^







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