summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-23 20:21:52 +0100
committerhut <hut@lavabit.com>2009-12-23 20:21:52 +0100
commit0f337fce2f5f8ae8890b280fd83bd549bdce7d6b (patch)
treec13213f5165121b30929644d6b47420ceb0d117b
parent857c260357cf2e89f2db1baa174468633571b507 (diff)
downloadranger-0f337fce2f5f8ae8890b280fd83bd549bdce7d6b.tar.gz
improved keys.py
-rw-r--r--ranger/defaults/keys.py43
1 files changed, 23 insertions, 20 deletions
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 2fa02285..f40d97d9 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -1,4 +1,7 @@
 import curses
+from curses import KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_HOME, \
+		KEY_END, KEY_DC, KEY_BACKSPACE, KEY_BTAB, KEY_RESIZE, KEY_ENTER, \
+		KEY_MOUSE
 from curses.ascii import *
 from ranger import RANGERDIR
 from ranger import log
@@ -24,9 +27,9 @@ def initialize_commands(command_list):
 	def bind(*args):
 		command_list.bind(args[-1], *args[:-1])
 
-	bind('h', curses.KEY_BACKSPACE, DEL, do('move_left'))
-	bind('l', do('move_right'))
-	bind(curses.KEY_ENTER, ctrl('j'), do('move_right', mode=1))
+	bind('h', KEY_LEFT, KEY_BACKSPACE, DEL, do('move_left'))
+	bind('l', KEY_RIGHT, do('move_right'))
+	bind(KEY_ENTER, ctrl('j'), do('move_right', mode=1))
 	bind('H', do('history_go', -1))
 	bind('L', do('history_go',  1))
 	bind('J', do('move_pointer_by_pages', 0.5))
@@ -77,8 +80,8 @@ def initialize_commands(command_list):
 	bind(ctrl('R'), do('reset'))
 	bind(ctrl('L'), do('redraw_window'))
 	bind(ctrl('C'), do('interrupt'))
-	bind(curses.KEY_RESIZE, do('resize'))
-	bind(curses.KEY_MOUSE, do('handle_mouse'))
+	bind(KEY_RESIZE, do('resize'))
+	bind(KEY_MOUSE, do('handle_mouse'))
 	bind(':', do('open_console', ':'))
 	bind('>', do('open_console', '>'))
 	bind('/', do('open_console', '/'))
@@ -97,9 +100,9 @@ def initialize_commands(command_list):
 		# moves to an absolute point, or to a predefined default
 		# if no number is specified.
 		return lambda fm, n: \
-				fm.move_pointer(absolute=(n or default))
+				fm.move_pointer(absolute=(n or default)-1)
 
-	bind('gg', ggG(0))
+	bind('gg', ggG(1))
 	bind('G', ggG(-1))
 
 	bind('%', lambda fm, n: fm.move_pointer_by_percentage(absolute=n or 0))
@@ -110,8 +113,8 @@ def initialize_commands(command_list):
 		return lambda fm, n: \
 				fm.move_pointer(relative=(n or 1) * direction)
 
-	bind('j', jk(1))
-	bind('k', jk(-1))
+	bind('j', KEY_DOWN, jk(1))
+	bind('k', KEY_UP, jk(-1))
 
 	command_list.rebuild_paths()
 
@@ -129,14 +132,14 @@ def initialize_console_commands(command_list):
 		return lambda con: getattr(con.fm, method)(*args, **kw)
 
 	# movement
-	bind(curses.KEY_UP, do('history_move', -1))
-	bind(curses.KEY_DOWN, do('history_move', 1))
-	bind(ctrl('b'), curses.KEY_LEFT, do('move', relative = -1))
-	bind(ctrl('f'), curses.KEY_RIGHT, do('move', relative = 1))
-	bind(ctrl('a'), curses.KEY_HOME, do('move', absolute = 0))
-	bind(ctrl('e'), curses.KEY_END, do('move', absolute = -1))
-	bind(ctrl('d'), curses.KEY_DC, do('delete', 0))
-	bind(ctrl('h'), curses.KEY_BACKSPACE, DEL, do('delete', -1))
+	bind(KEY_UP, do('history_move', -1))
+	bind(KEY_DOWN, do('history_move', 1))
+	bind(ctrl('b'), KEY_LEFT, do('move', relative = -1))
+	bind(ctrl('f'), KEY_RIGHT, do('move', relative = 1))
+	bind(ctrl('a'), KEY_HOME, do('move', absolute = 0))
+	bind(ctrl('e'), KEY_END, do('move', absolute = -1))
+	bind(ctrl('d'), KEY_DC, do('delete', 0))
+	bind(ctrl('h'), KEY_BACKSPACE, DEL, do('delete', -1))
 	bind(ctrl('w'), do('delete_word'))
 	bind(ctrl('k'), do('delete_rest', 1))
 	bind(ctrl('u'), do('delete_rest', -1))
@@ -144,11 +147,11 @@ def initialize_console_commands(command_list):
 
 	# system functions
 	bind(ctrl('c'), ESC, do('close'))
-	bind(ctrl('j'), curses.KEY_ENTER, do('execute'))
+	bind(ctrl('j'), KEY_ENTER, do('execute'))
 	bind(ctrl('l'), do_fm('redraw'))
 	bind(TAB, do('tab'))
-	bind(curses.KEY_BTAB, do('tab', -1))
-	bind(curses.KEY_RESIZE, do_fm('resize'))
+	bind(KEY_BTAB, do('tab', -1))
+	bind(KEY_RESIZE, do_fm('resize'))
 
 	# type keys
 	def type_key(key):
16-09-11 17:54:47 -0700 3326' href='/akkartik/mu/commit/018type_abbreviations.cc?h=hlt&id=f7f40d32b023751bb34c3a5508b48edfb4eae18a'>f7f40d32 ^
36d74808 ^


621c64b5 ^





cdf0f349 ^



36d74808 ^
cdf0f349 ^















621c64b5 ^




4c0c5eb5 ^
621c64b5 ^
2224e41f ^









6c96a437 ^
2224e41f ^






6c96a437 ^
2224e41f ^



cdf0f349 ^


17ec4016 ^




cdf0f349 ^
f7f40d32 ^




4c0c5eb5 ^
f7f40d32 ^
cdf0f349 ^



cdf0f349 ^

b8f11f75 ^




cdf0f349 ^










cdf0f349 ^
ea19d0dc ^
cdf0f349 ^



59085fca ^



cdf0f349 ^
6c96a437 ^
cdf0f349 ^

6c96a437 ^
cdf0f349 ^


6c96a437 ^
cdf0f349 ^



59e47aca ^
cdf0f349 ^











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