summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-14 00:39:48 +0200
committerhut <hut@lavabit.com>2010-04-14 00:39:48 +0200
commit656c2bf6deb5dfbbd971880154f109ceb2be87c3 (patch)
tree651ab4e007f70111ee747896685fd5981265c6c4
parent7fe782e7acc4ecf05c38bffde6591a791a539f50 (diff)
downloadranger-656c2bf6deb5dfbbd971880154f109ceb2be87c3.tar.gz
dirarg: fully functioning now
-rw-r--r--ranger/core/actions.py31
-rw-r--r--ranger/ext/direction.py4
2 files changed, 21 insertions, 14 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 929dec31..e8634099 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -545,20 +545,25 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	def copy(self, narg=None, dirarg=None):
 		"""Copy the selected items"""
 		cwd = self.env.cwd
-		direction = Direction(dirarg or {})
-		if direction.vertical():
-			pos, selected = direction.select(
-					override=narg, lst=cwd.files, current=currentpos,
-					pagesize=self.env.termsize[0])
-		else:
-			pos = currentpos + (narg or 0)
+		if not narg and not dirarg:
 			selected = (f for f in self.env.get_selection() if f in cwd.files)
-		self.env.copy = set(selected)
-		self.env.copy.add(self.env.cwd.pointed_obj)
-		self.env.cut = False
-		self.env.cwd.pointer = pos
-		self.env.cwd.correct_pointer()
-		self.env.copy.add(self.env.cwd.pointed_obj)
+			self.env.copy = set(selected)
+			self.env.cut = False
+		else:
+			direction = Direction(dirarg or {})
+			offset = 0
+			if not direction.vertical():
+				direction = Direction(down=1)
+				offset = -1
+			pos, selected = direction.select(
+					override=narg, lst=cwd.files, current=cwd.pointer,
+					pagesize=self.env.termsize[0], offset=offset)
+			self.env.copy = set(selected)
+			self.env.copy.add(self.env.cwd.pointed_obj)
+			self.env.cut = False
+			self.env.cwd.pointer = pos
+			self.env.cwd.correct_pointer()
+			self.env.copy.add(self.env.cwd.pointed_obj)
 		self.ui.browser.main_column.request_redraw()
 
 	def cut(self, narg=None, dirarg=None):
diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py
index f96ee90f..5a22d553 100644
--- a/ranger/ext/direction.py
+++ b/ranger/ext/direction.py
@@ -134,9 +134,11 @@ class Direction(dict):
 			pos += current
 		return int(max(min(pos, maximum + offset - 1), minimum))
 
-	def select(self, lst, override, current, pagesize):
+	def select(self, lst, override, current, pagesize, offset=0):
 		destination = self.move(direction=self.down(), override=override,
 			current=current, pagesize=pagesize, minimum=0, maximum=len(lst))
 		if destination > current:
+			destination += offset
 			return destination, lst[current:destination]
+		destination -= offset
 		return destination, lst[destination:current]
t.com> 2010-04-13 12:38:28 +0200 Fixed suggested cd-after-exit-script for zsh' href='/akspecs/ranger/commit/doc/ranger.1?h=v1.9.0b5&id=fab4dc542e9f2b0ee55a97046915894c9e5ae37b'>fab4dc54 ^
dd91e084 ^








































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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216