summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-09-29 00:05:06 +0200
committerhut <hut@lavabit.com>2011-09-29 00:14:35 +0200
commitaffbad6ce1e2c8783b0002b617fe0a229546a069 (patch)
tree38bb46d7b90a04cdc81891bdfd8d51730727c1f1
parentbdc872b0178be74059f49d8878b5c05f2d7ed8ce (diff)
downloadranger-affbad6ce1e2c8783b0002b617fe0a229546a069.tar.gz
core.main: added --list-unused-keys option
-rw-r--r--doc/ranger.17
-rw-r--r--doc/ranger.pod6
-rw-r--r--ranger/container/keymap.py4
-rw-r--r--ranger/core/helper.py2
-rw-r--r--ranger/core/main.py14
5 files changed, 30 insertions, 3 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 897a2969..2192047c 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -124,7 +124,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.4.3" "09/28/2011" "ranger manual"
+.TH RANGER 1 "ranger-1.4.3" "09/29/2011" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -174,6 +174,11 @@ write the last visited directory into \fItargetfile\fR.
 Create copies of the default configuration files in your local configuration
 directory.  Existing ones will not be overwritten.  Possible values: \fIall\fR,
 \&\fIapps\fR, \fIcommands\fR, \fIkeys\fR, \fIoptions\fR, \fIscope\fR.
+.IP "\fB\-\-list\-unused\-keys\fR" 14
+.IX Item "--list-unused-keys"
+List common keys which are not bound to any action in the \*(L"browser\*(R" context.
+This list is not complete, you can bind any key that is supported by curses:
+use the key code returned by \f(CW\*(C`getch()\*(C'\fR.
 .IP "\fB\-\-fail\-unless\-c\fRd" 14
 .IX Item "--fail-unless-cd"
 Return the exit code 1 if ranger is used to run a file instead of used for file
diff --git a/doc/ranger.pod b/doc/ranger.pod
index e5cd8987..be1d14fd 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -65,6 +65,12 @@ Create copies of the default configuration files in your local configuration
 directory.  Existing ones will not be overwritten.  Possible values: I<all>,
 I<apps>, I<commands>, I<keys>, I<options>, I<scope>.
 
+=item B<--list-unused-keys>
+
+List common keys which are not bound to any action in the "browser" context.
+This list is not complete, you can bind any key that is supported by curses:
+use the key code returned by C<getch()>.
+
 =item B<--fail-unless-c>d
 
 Return the exit code 1 if ranger is used to run a file instead of used for file
diff --git a/ranger/container/keymap.py b/ranger/container/keymap.py
index d52a5215..8739d22a 100644
--- a/ranger/container/keymap.py
+++ b/ranger/container/keymap.py
@@ -95,9 +95,9 @@ class KeyMapWithDirections(KeyMap):
 		self.directions = KeyMap()
 
 	def merge(self, other):
-		assert hasattr(other, 'directions'), 'Merging with wrong type?'
 		Tree.merge(self, other)
-		Tree.merge(self.directions, other.directions)
+		if hasattr(other, 'directions'):
+			Tree.merge(self.directions, other.directions)
 
 	def dir(self, *args, **keywords):
 		if ALIASARG in keywords:
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index d1ef3ed0..910c0241 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -73,6 +73,8 @@ def parse_arguments():
 	parser.add_option('--choosedir', type='string', metavar='TARGET',
 			help="Makes ranger act like a directory chooser. When ranger quits"
 			", it will write the name of the last visited directory to TARGET")
+	parser.add_option('--list-unused-keys', action='store_true',
+			help="List common keys which are not bound to any action.")
 
 	options, positional = parser.parse_args()
 	arg = OpenStruct(options.__dict__, targets=positional)
diff --git a/ranger/core/main.py b/ranger/core/main.py
index e6392387..5a7b32af 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -77,6 +77,20 @@ def main():
 		fm.tabs = dict((n+1, os.path.abspath(path)) for n, path \
 				in enumerate(targets[:9]))
 		load_settings(fm, arg.clean)
+
+		if arg.list_unused_keys:
+			from ranger.ext.keybinding_parser import special_keys
+			tree = EnvironmentAware.env.keymanager.get_context('browser')
+			tree.merge(tree.directions)
+			reversed_special_keys = dict((v,k) for k,v in special_keys.items())
+			for key in sorted(special_keys.values()):
+				if key not in tree._tree:
+					print("<%s>" % reversed_special_keys[key])
+			for key in range(33, 128):
+				if key not in tree._tree:
+					print(chr(key))
+			return 1 if arg.fail_unless_cd else 0
+
 		if fm.env.username == 'root':
 			fm.settings.preview_files = False
 			fm.settings.use_preview_script = False
a title='Blame the previous revision' href='/akkartik/mu/blame/091socket.cc?h=main&id=5e320aa049bc1d5ad78eec23be0127f4a8d6ec3d'>^
68578a78 ^


a7c59e3e ^
68578a78 ^




a7c59e3e ^
68578a78 ^
c87a0b7d ^
2821a0a3 ^
51ae6e61 ^
2821a0a3 ^

68578a78 ^

51ae6e61 ^
51ae6e61 ^
68578a78 ^

54e7f47c ^
aa229fbe ^
54e7f47c ^

e5360e06 ^

8140ff13 ^
e5360e06 ^
54e7f47c ^


aac885fd ^
aa229fbe ^
f03d2f15 ^
347510c0 ^


54e7f47c ^

aa229fbe ^
54e7f47c ^
54e7f47c ^

68578a78 ^
68578a78 ^






2b250717 ^
68578a78 ^






2b250717 ^
68578a78 ^









51ae6e61 ^
d3d30176 ^



f5863594 ^
d3d30176 ^





68578a78 ^

19f47cc0 ^
f5863594 ^
d3d30176 ^


f03d2f15 ^
d3d30176 ^
19f47cc0 ^
68578a78 ^






b07576d2 ^
2b250717 ^
68578a78 ^


b07576d2 ^
68578a78 ^

28191d31 ^

2b250717 ^
51ae6e61 ^

b07576d2 ^

c83f3bca ^

28191d31 ^









c83f3bca ^

68578a78 ^



28191d31 ^
51ae6e61 ^

f24eeaab ^





b07576d2 ^




f24eeaab ^
f24eeaab ^



5e19c6ce ^

28191d31 ^





5e19c6ce ^
28191d31 ^
f24eeaab ^
28191d31 ^



f24eeaab ^

28191d31 ^
f24eeaab ^
b07576d2 ^
5eb5a8de ^
b07576d2 ^
5eb5a8de ^
5eb5a8de ^




b07576d2 ^
28191d31 ^

5eb5a8de ^
51ae6e61 ^









2b250717 ^
51ae6e61 ^






20d6e2f1 ^
20d6e2f1 ^
51ae6e61 ^

20d6e2f1 ^
4896fd81 ^


51ae6e61 ^
16cf7896 ^
51ae6e61 ^
68578a78 ^







25cd8e98 ^
2b250717 ^
68578a78 ^

25cd8e98 ^
f205e7f0 ^
68578a78 ^

87eb3aca ^
2b250717 ^
87eb3aca ^





68578a78 ^



25cd8e98 ^


5eb5a8de ^
87eb3aca ^

68578a78 ^

c00d3b94 ^

c00d3b94 ^
f24eeaab ^

493fd4e9 ^

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