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):
'#n270'>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