summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-08-26 17:25:50 +0200
committerhut <hut@lavabit.com>2010-08-26 17:25:50 +0200
commit0a8001b2a141b141e6e34b1ebcce316288ef7ab7 (patch)
tree79becf7190e9173e738c9ac39c216fafec9c30a2 /ranger
parent0fb328f92a939dd342b070a386bb717bd9c645b0 (diff)
downloadranger-0a8001b2a141b141e6e34b1ebcce316288ef7ab7.tar.gz
Fixed history
Diffstat (limited to 'ranger')
-rw-r--r--ranger/container/history.py21
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/defaults/commands.py2
-rw-r--r--ranger/defaults/options.py2
-rw-r--r--ranger/gui/widgets/console.py13
-rw-r--r--ranger/help/console.py24
6 files changed, 37 insertions, 27 deletions
diff --git a/ranger/container/history.py b/ranger/container/history.py
index ba13775d..5d4da07a 100644
--- a/ranger/container/history.py
+++ b/ranger/container/history.py
@@ -63,7 +63,7 @@ class History(object):
 			self.history_forward.appendleft( self.history.pop() )
 		return self.current()
 
-	def move(self, n):
+	def move(self, n, pattern=None):
 		if n > 0:
 			return self.forward()
 		if n < 0:
@@ -84,3 +84,22 @@ class History(object):
 		if self.history_forward:
 			self.history.extend(self.history_forward)
 			self.history_forward.clear()
+
+	def unique(self):
+		found = []
+		i = len(self.history)
+		while i:
+			i -= 1
+			item = self.history[i]
+			if item in found:
+				del self.history[i]
+			else:
+				found.append(item)
+		i = len(self.history_forward)
+		while i:
+			i -= 1
+			item = self.history_forward[i]
+			if item in found:
+				del self.history_forward[i]
+			else:
+				found.append(item)
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 6b8fc13c..d12d9c6c 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -86,7 +86,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		self.ui.console.line = string
 		self.ui.console.execute()
 
-	def substitute_metachars(self, string):
+	def substitute_macros(self, string):
 		return _MacroTemplate(string).safe_substitute(self._get_macros())
 
 	def _get_macros(self):
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index 8005100c..b6e77697 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -117,7 +117,7 @@ class shell(Command):
 		if not command and 'p' in flags: command = 'cat %f'
 		if command:
 			if '%' in command:
-				command = self.fm.substitute_metachars(command)
+				command = self.fm.substitute_macros(command)
 			self.fm.execute_command(command, flags=flags)
 
 	def tab(self):
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index 23752d97..d3c420af 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -85,7 +85,7 @@ tilde_in_titlebar = True
 
 # How many directory-changes or console-commands should be kept in history?
 max_history_size = 20
-max_console_history_size = 20
+max_console_history_size = 50
 
 # Try to keep so much space between the top/bottom border when scrolling:
 scroll_offset = 8
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 636073fc..2efb059d 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -34,6 +34,7 @@ import ranger
 class Console(Widget):
 	visible = False
 	last_cursor_mode = None
+	history_search_pattern = None
 	prompt = ':'
 	copy = ''
 	tab_deque = None
@@ -51,16 +52,16 @@ class Console(Widget):
 		if not ranger.arg.clean:
 			self.historypath = relpath_conf('history')
 			try:
-				f = open(path, 'r')
+				f = open(self.historypath, 'r')
 			except:
 				pass
 			else:
 				for line in f:
-					hist.add(line[:-1])
+					self.history.add(line[:-1])
 				f.close()
 
 	def destroy(self):
-		# save histories from files
+		# save history to files
 		if ranger.arg.clean or not self.settings.save_console_history:
 			return
 		if self.historypath:
@@ -69,7 +70,7 @@ class Console(Widget):
 			except:
 				pass
 			else:
-				for entry in self.histories[i]:
+				for entry in self.history:
 					f.write(entry + '\n')
 				f.close()
 
@@ -173,6 +174,7 @@ class Console(Widget):
 
 		self.pos += len(key)
 		self.on_line_change()
+		self.history_search_pattern = self.line
 
 	def history_move(self, n):
 		try:
@@ -182,7 +184,7 @@ class Console(Widget):
 		else:
 			if self.line != current and self.line != self.history.top():
 				self.history.modify(self.line)
-			self.history.move(n)
+			self.history.move(n, self.history_search_pattern)
 			current = self.history.current()
 			if self.line != current:
 				self.line = self.history.current()
@@ -191,6 +193,7 @@ class Console(Widget):
 	def add_to_history(self):
 		self.history.fast_forward()
 		self.history.modify(self.line)
+		self.history.unique()
 
 	def move(self, **keywords):
 		direction = Direction(keywords)
diff --git a/ranger/help/console.py b/ranger/help/console.py
index bc69f7fb..f03491db 100644
--- a/ranger/help/console.py
+++ b/ranger/help/console.py
@@ -139,29 +139,17 @@ done typing and executes the command right away.
 The key "f" opens the console with ":find "
 
 3.3.2. "shell"
-The shell command accepts flags |25?| as the first argument if it starts
-with a "-". Example: ":shell -p cat somefile.txt" will use the "p"-flag,
-which pipes the output to the pager.
-There are some keys which open the console with the shell command:
+The shell command accepts flags |25?| as the first argument. This example
+will use the "p"-flag, which pipes the output to the pager:
+	:shell -p cat somefile.txt
+
+There are some shortcuts which open the console with the shell command:
 	"!" opens ":shell "
 	"@" opens ":shell  %s"
 	"#" opens ":shell -p "
 
 3.3.3. "open_with"
-The open_with command opens the current file with the specified program,
-mode |24?| and flags |25?|. 
-The programs and the meaning of modes can be defined in the apps.py,
-giving you a high level interface for running files.
-Pressing "r" will open the console with ":open_with "
-
-Examples:
-
-:open_with mplayer D     open the selection in mplayer, but not detached
-:open_with 1             open it with the default handler in mode 1
-:open_with d             open it detached with the default handler
-:open_with p             open it as usual, but pipe the output to "less"
-:open_with totem 1 Ds    open in totem in mode 1, will not detach the
-                         process (flag D) but discard the output (flag s)
+The open_with command is explained in detail in chapter 2.2. |22?|
 
 ==============================================================================
 """
957b3'>^
89807038 ^
50bff0c5 ^
89807038 ^

89807038 ^
6c96a437 ^
6abdff27 ^
89807038 ^
89807038 ^






ac0e9db5 ^
b24eb476 ^
05d17773 ^
89807038 ^
05d17773 ^
89807038 ^

6ca059ef ^


31401373 ^
77017b6d ^



31401373 ^
77017b6d ^
6c96a437 ^
31401373 ^
795f5244 ^
31401373 ^



cea49fde ^


ae5f0b6f ^
8f0a9149 ^




6c96a437 ^
8f0a9149 ^
364b8f88 ^
78c50205 ^
7e8d0ba8 ^
8f0a9149 ^
cea49fde ^
8f0a9149 ^
cea49fde ^

5152d4ea ^
6d17ef49 ^
5152d4ea ^
5497090a ^
6d17ef49 ^
b24eb476 ^
6d17ef49 ^
b24eb476 ^
ec99eb7a ^
6d17ef49 ^


7fd01071 ^
6d17ef49 ^
45ca3bb7 ^


b24eb476 ^
45ca3bb7 ^


6ca059ef ^
5eddbc16 ^
6ca059ef ^
795f5244 ^
166e3c0d ^
5eddbc16 ^
166e3c0d ^
1b76245c ^
5db2faeb ^

7afe09fb ^
9dcbec39 ^
5db2faeb ^

166e3c0d ^



7f73795c ^
45ca3bb7 ^
5e14ce10 ^
3e3383e7 ^
cdf28227 ^
3473c63a ^
016599f1 ^
78a12c9d ^
1fa53058 ^
6d17ef49 ^
0487a30e ^
827898fc ^
6ca059ef ^

afbe301d ^
4a943d4e ^





























































5e14ce10 ^
a542b5a9 ^

4a943d4e ^












a542b5a9 ^




ccc5eb73 ^
78a12c9d ^
4a943d4e ^



























































82ceda30 ^
75a00270 ^

4a943d4e ^




















75a00270 ^
1a33d221 ^
5f98a10c ^
75a00270 ^


45ca3bb7 ^
00b808d9 ^
4a943d4e ^













00b808d9 ^
45ca3bb7 ^
6c96a437 ^
45ca3bb7 ^

19695cc7 ^
00b808d9 ^
00b808d9 ^

45ca3bb7 ^


b24eb476 ^
6c96a437 ^
45ca3bb7 ^





82ceda30 ^

4a943d4e ^



















82ceda30 ^



795f5244 ^
166e3c0d ^
82ceda30 ^
166e3c0d ^
2b250717 ^
e4630643 ^

7afe09fb ^
9dcbec39 ^
e4630643 ^

166e3c0d ^



b24eb476 ^

6c96a437 ^
05d17773 ^

82ceda30 ^


cfb142b9 ^
827898fc ^
82ceda30 ^

9d670bb5 ^
45ca3bb7 ^

9d670bb5 ^
134dad7c ^

795f5244 ^
166e3c0d ^
134dad7c ^
166e3c0d ^
2b250717 ^
e4630643 ^

7afe09fb ^
9dcbec39 ^
e4630643 ^

166e3c0d ^



b24eb476 ^
6c96a437 ^
134dad7c ^








a6cdf15c ^

795f5244 ^
166e3c0d ^



a6cdf15c ^

6c96a437 ^
00b808d9 ^
a6cdf15c ^


88e99894 ^


4a943d4e ^





















88e99894 ^





c442a5ad ^
88e99894 ^







6abdff27 ^
2ada05dc ^
6abdff27 ^
6abdff27 ^
2ada05dc ^
6abdff27 ^
6abdff27 ^


6c96a437 ^
6abdff27 ^





88e99894 ^
b24eb476 ^
88e99894 ^





795f5244 ^
166e3c0d ^
88e99894 ^
166e3c0d ^
2b250717 ^
88e99894 ^

7afe09fb ^
9dcbec39 ^
88e99894 ^

7afe09fb ^
9dcbec39 ^
88e99894 ^

166e3c0d ^



b24eb476 ^
6c96a437 ^
88e99894 ^






94fed202 ^
d8c6265d ^
ccba6718 ^
d8c6265d ^
ccba6718 ^


d8c6265d ^






2b250717 ^
d8c6265d ^











6c96a437 ^
d8c6265d ^
ccba6718 ^
d8c6265d ^






27d90d80 ^
4a943d4e ^














































9c184f02 ^


4a943d4e ^





















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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709