summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-01 22:33:03 +0100
committerhut <hut@lavabit.com>2009-12-01 22:33:03 +0100
commitd494f0195e5eccc97fd9a135046ff028dec14ae7 (patch)
tree6e5c8f6445595ff22d984b942ffa0004f3cb3862
parentc2b99d5235cadcd541ed00909f7df5e0ace7ac42 (diff)
downloadranger-d494f0195e5eccc97fd9a135046ff028dec14ae7.tar.gz
scrolling
-rw-r--r--ranger/fm.py6
-rw-r--r--ranger/gui/defaultui.py4
-rw-r--r--ranger/gui/ui.py9
-rw-r--r--ranger/gui/wdisplay.py16
4 files changed, 34 insertions, 1 deletions
diff --git a/ranger/fm.py b/ranger/fm.py
index e88ff964..55fd64f3 100644
--- a/ranger/fm.py
+++ b/ranger/fm.py
@@ -64,10 +64,14 @@ class FM():
 	def move_pointer(self, relative = 0, absolute = None):
 		self.env.cf = self.env.pwd.move_pointer(relative, absolute)
 
-	def move_pointer_by_pages(self, relative = 0):
+	def move_pointer_by_pages(self, relative):
 		self.env.cf = self.env.pwd.move_pointer(
 				relative = int(relative * self.env.termsize[0]))
 
+	def scroll(self, relative):
+		self.ui.scroll(relative)
+		self.env.cf = self.env.pwd.pointed_file
+
 	def redraw(self):
 		self.ui.redraw()
 
diff --git a/ranger/gui/defaultui.py b/ranger/gui/defaultui.py
index 419d8a4f..d4d89047 100644
--- a/ranger/gui/defaultui.py
+++ b/ranger/gui/defaultui.py
@@ -14,11 +14,15 @@ class DefaultUI(SuperClass):
 				WDisplay(self.win, self.colorscheme, -1),
 				WDisplay(self.win, self.colorscheme, 0),
 				WDisplay(self.win, self.colorscheme, 1) ]
+		self.main_display = self.displays[2]
 		self.displays[2].display_infostring = True
 		self.displays[2].main_display = True
 		for disp in self.displays:
 			self.add_widget(disp)
 	
+	def scroll(self, relative):
+		self.main_display.scroll(relative)
+
 	def resize(self):
 		SuperClass.resize(self)
 		y, x = self.win.getmaxyx()
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 78adde28..fb6e9193 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -41,9 +41,18 @@ class UI():
 					widg.click(event, fm)
 					break
 
+		if event.pressed(4) or event.pressed(2) or event.bstate & 134217728:
+			if event.pressed(4):
+				fm.scroll(relative = -3)
+			else:
+				fm.scroll(relative = 3)
+
 	def setup(self):
 		pass
 
+	def scroll(self, relative):
+		pass
+
 	def resize(self):
 		self.env.termsize = self.win.getmaxyx()
 
diff --git a/ranger/gui/wdisplay.py b/ranger/gui/wdisplay.py
index 2aba3a61..1379c24e 100644
--- a/ranger/gui/wdisplay.py
+++ b/ranger/gui/wdisplay.py
@@ -151,6 +151,9 @@ class WDisplay(SuperClass):
 		upper_limit = winsize - 1 - offset
 		lower_limit = offset
 
+		if original < 0:
+			return 0
+
 		if dirsize < winsize:
 			return 0
 
@@ -178,3 +181,16 @@ class WDisplay(SuperClass):
 		self.scroll_begin = self.get_scroll_begin()
 		self.target.scroll_begin = self.scroll_begin
 
+	# TODO: does not work if options.scroll_offset is high,
+	# relative > 1 and you scroll from scroll_begin = 1 to 0
+	def scroll(self, relative):
+		self.set_scroll_begin()
+		old_value = self.target.scroll_begin
+		self.target.scroll_begin += relative
+		self.set_scroll_begin()
+
+		if self.target.scroll_begin == old_value:
+			self.target.move_pointer(relative = relative)
+			self.target.scroll_begin += relative
+
+
m> 2010-02-16 02:03:46 +0100 incremented version number and updated pydoc html files' href='/akspecs/ranger/commit/doc/pydoc/ranger.gui.widgets.html?h=v1.4.1&id=34a60763e79546e0f84e30fbcc430632f3dbb39e'>34a60763 ^
f07bb12f ^


62cd83ba ^

f07bb12f ^






4c13e1f2 ^

f07bb12f ^


4c13e1f2 ^

f07bb12f ^



4c13e1f2 ^


f07bb12f ^











f07bb12f ^















4c13e1f2 ^




34a60763 ^
4c13e1f2 ^
34a60763 ^
4c13e1f2 ^



f07bb12f ^
62cd83ba ^
f07bb12f ^


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