summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--ranger/actions.py56
-rw-r--r--ranger/defaults/keys.py18
-rw-r--r--ranger/fsobject/directory.py32
-rw-r--r--ranger/gui/widgets/console.py2
5 files changed, 85 insertions, 25 deletions
diff --git a/TODO b/TODO
index 206f0445..bfd80a4d 100644
--- a/TODO
+++ b/TODO
@@ -17,4 +17,4 @@ General
    (X) #9   09/12/24  add a widget for managing running operations
    (X) #10  09/12/24  sorting
    (X) #11  09/12/27  filter
-   ( ) #12  09/12/27  jump through the list in a specific order
+   (X) #12  09/12/27  jump through the list in a specific order
diff --git a/ranger/actions.py b/ranger/actions.py
index e1005201..968aae4f 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -5,15 +5,53 @@ from ranger.shared import EnvironmentAware, SettingsAware
 from ranger import fsobject
 
 class Actions(EnvironmentAware, SettingsAware):
-	def search_forward(self):
-		"""Search forward for the regexp in self.env.last_search"""
-		if self.env.pwd:
-			self.env.pwd.search(self.env.last_search)
-
-	def search_backward(self):
-		"""Search backward for the regexp in self.env.last_search"""
-		if self.env.pwd:
-			self.env.pwd.search(self.env.last_search, -1)
+	search_method = 'ctime'
+	search_forward = False
+
+	def search(self, order=None, forward=True):
+		if self.search_forward:
+			direction = bool(forward)
+		else:
+			direction = not bool(forward)
+
+		if order is None:
+			order = self.search_method
+		else:
+			self.set_search_method(order=order)
+
+		if order in ('search', 'tag'):
+			if order == 'search':
+				arg = self.env.last_search
+				if arg is None:
+					return False
+				if hasattr(arg, 'search'):
+					fnc = lambda x: arg.search(x.basename)
+				else:
+					fnc = lambda x: arg in x.basename
+			elif order == 'tag':
+				fnc = lambda x: x.realpath in self.tags
+
+			return self.env.pwd.search_fnc(fnc=fnc, forward=forward)
+
+		elif order in ('size', 'mimetype', 'ctime'):
+			pwd = self.env.pwd
+			if not pwd.cycle_list:
+				lst = list(pwd.files)
+				if order == 'size':
+					fnc = lambda item: item.size
+				elif order == 'mimetype':
+					fnc = lambda item: item.mimetype
+				elif order == 'ctime':
+					fnc = lambda item: -int(item.stat and item.stat.st_ctime)
+				lst.sort(key=fnc)
+				pwd.set_cycle_list(lst)
+
+			return pwd.cycle(forward=forward)
+
+	def set_search_method(self, order, forward=True):
+		if order in ('search', 'tag', 'size', 'mimetype', 'ctime'):
+			self.search_method = order
+			self.search_forward = forward
 
 	def interrupt(self):
 		"""
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 75956b7a..c3490c4a 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -39,12 +39,14 @@ def initialize_commands(command_list):
 	bind('v', do('mark', all=True, toggle=True))
 	bind('V', do('mark', all=True, val=False))
 
-	bind('yy', 'cp', do('copy'))
-	bind('cut', do('cut'))
+	bind('yy', do('copy'))
+	bind('dd', do('cut'))
 	bind('p', do('paste'))
 
 	bind('s', do('spawn', 'bash'))
 
+	bind(TAB, do('search', order='tag'))
+
 	t_hint = "show_//h//idden //p//review_files //d//irectories_first //a//uto_load_preview //c//ollapse_preview"
 	command_list.hint(t_hint, 't')
 	bind('th', do('toggle_boolean_option', 'show_hidden'))
@@ -83,6 +85,8 @@ def initialize_commands(command_list):
 	bind('term', do('spawn', 'x-terminal-emulator'))
 	bind('du', do('runcmd', 'du --max-depth=1 -h | less'))
 	bind('tf', do('open_console', cmode.COMMAND, 'filter '))
+	d_hint = 'd//u// (disk usage) d//d// (cut)'
+	command_list.hint(d_hint, 'd')
 
 	# key combinations which change the current directory
 	def cd(path):
@@ -98,8 +102,14 @@ def initialize_commands(command_list):
 	bind('gs', do('cd', '/srv'))
 	bind('gR', do('cd', RANGERDIR))
 
-	bind('n', do('search_forward'))
-	bind('N', do('search_backward'))
+	bind('n', do('search', forward=True))
+	bind('N', do('search', forward=False))
+
+	bind('cc', do('search', forward=True, order='ctime'))
+	bind('cm', do('search', forward=True, order='mimetype'))
+	bind('cs', do('search', forward=True, order='size'))
+	c_hint = '//c//time //m//imetype //s//ize'
+	command_list.hint(c_hint, 'c')
 
 	# bookmarks
 	for key in ALLOWED_BOOKMARK_KEYS:
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index f263aa74..6c9ab7b1 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -1,6 +1,7 @@
 from ranger.fsobject import BAD_INFO, File, FileSystemObject
 from ranger.shared import SettingsAware
 from ranger.ext.accumulator import Accumulator
+from collections import deque
 from ranger import log
 import ranger.fsobject
 
@@ -18,6 +19,7 @@ class NoDirectoryGiven(Exception):
 class Directory(FileSystemObject, Accumulator, SettingsAware):
 	enterable = False
 	load_generator = None
+	cycle_list = None
 	loading = False
 
 	filenames = None
@@ -171,6 +173,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 			self.files = None
 			self.infostring = BAD_INFO
 
+		self.cycle_list = None
 		self.content_loaded = True
 		self.loading = False
 
@@ -251,21 +254,18 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 
 		Accumulator.move_to_obj(self, arg, attr='path')
 
-	def search(self, arg, direction = 1):
-		"""Search for a regular expression"""
-		if self.empty() or arg is None:
+	def search_fnc(self, fnc, forward=True):
+		if not hasattr(fnc, '__call__'):
 			return False
-		elif hasattr(arg, 'search'):
-			fnc = lambda x: arg.search(x.basename)
-		else:
-			fnc = lambda x: arg in x.basename
 
 		length = len(self)
 
-		if direction > 0:
-			generator = ((self.pointer + (x + 1)) % length for x in range(length-1))
+		if forward:
+			generator = ((self.pointer + (x + 1)) % length \
+					for x in range(length-1))
 		else:
-			generator = ((self.pointer - (x + 1)) % length for x in range(length-1))
+			generator = ((self.pointer - (x + 1)) % length \
+					for x in range(length-1))
 
 		for i in generator:
 			_file = self.files[i]
@@ -276,6 +276,18 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 				return True
 		return False
 
+	def set_cycle_list(self, lst):
+		self.cycle_list = deque(lst)
+
+	def cycle(self, forward=True):
+		if self.cycle_list:
+			if forward:
+				self.cycle_list.rotate(-1)
+			else:
+				self.cycle_list.rotate(1)
+
+			self.move_to_obj(self.cycle_list[0])
+
 	def correct_pointer(self):
 		"""Make sure the pointer is in the valid range"""
 		Accumulator.correct_pointer(self)
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 2d6df2a7..92c57a46 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -296,7 +296,7 @@ class SearchConsole(Console):
 		if self.fm.env.pwd:
 			regexp = re.compile(self.line, re.L | re.U | re.I)
 			self.fm.env.last_search = regexp
-			if self.fm.env.pwd.search(regexp):
+			if self.fm.search(order='search'):
 				self.fm.env.cf = self.fm.env.pwd.pointed_obj
 		Console.execute(self)
 
356c966d ^
4c879fa1 ^

decaddb4 ^
4c879fa1 ^
95f2fe96 ^





c442a5ad ^
4c879fa1 ^
c062697c ^
e85cb85b ^
95f2fe96 ^
e85cb85b ^
e62aa7e3 ^
e85cb85b ^


4c879fa1 ^
95f2fe96 ^

e6692482 ^
436b2b2e ^

95f2fe96 ^
e6692482 ^
436b2b2e ^


e6692482 ^
436b2b2e ^

4c879fa1 ^
95f2fe96 ^
4c879fa1 ^
ab6ed192 ^
c442a5ad ^
4c879fa1 ^
32f6079f ^

decaddb4 ^
4c879fa1 ^

c442a5ad ^
4c879fa1 ^

decaddb4 ^
4c879fa1 ^
090cad5c ^
4c879fa1 ^

e62aa7e3 ^
95f2fe96 ^
4c879fa1 ^

4ce90b39 ^
4c879fa1 ^

e6692482 ^
c442a5ad ^
e6692482 ^
c442a5ad ^
decaddb4 ^


6f8f9fb5 ^

85173b62 ^
1fba5d5d ^
85173b62 ^
7ac221e4 ^
decaddb4 ^
7ac221e4 ^
decaddb4 ^
1b76245c ^
795f5244 ^
decaddb4 ^

4a943d4e ^


















3d45bf38 ^
4a943d4e ^














3d45bf38 ^
4a943d4e ^


















3d45bf38 ^
4a943d4e ^






















c062697c ^
4a943d4e ^






















c062697c ^
4a943d4e ^

















c062697c ^
4a943d4e ^
















c062697c ^
4a943d4e ^















c062697c ^
4a943d4e ^













32f6079f ^
4a943d4e ^


















32f6079f ^
4a943d4e ^


















15ab959d ^
4a943d4e ^


















15ab959d ^
4a943d4e ^













15ab959d ^

4a943d4e ^


















4c879fa1 ^
4a943d4e ^










e85cb85b ^
4a943d4e ^












436b2b2e ^
5109e78f ^
e765f9e7 ^
4a943d4e ^













e765f9e7 ^
4a943d4e ^













e765f9e7 ^

7d07cd1d ^
e765f9e7 ^


5109e78f ^
e765f9e7 ^

5109e78f ^
e765f9e7 ^
c8f2ff13 ^
e765f9e7 ^





7d07cd1d ^
e765f9e7 ^


5109e78f ^
e765f9e7 ^

5109e78f ^
e765f9e7 ^
c8f2ff13 ^
e765f9e7 ^







c8f2ff13 ^

3473c63a ^
5109e78f ^

e765f9e7 ^







95f2fe96 ^
e765f9e7 ^


5109e78f ^




c8f2ff13 ^
5109e78f ^
e765f9e7 ^





436b2b2e ^











795f5244 ^





436b2b2e ^






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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566