summary refs log tree commit diff stats
path: root/ranger/keys.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/keys.py')
-rw-r--r--ranger/keys.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/ranger/keys.py b/ranger/keys.py
index b710a2aa..fe885278 100644
--- a/ranger/keys.py
+++ b/ranger/keys.py
@@ -1,15 +1,32 @@
 def initialize_commands(command_list):
 	from ranger.fm import FM
+	from curses.ascii import ctrl
 
 	cl = command_list
 	
-	# note: the bound function will be called with one parameter, which
-	# is the FM instance. To use functions with multiple parameters, use:
-	# lambda fm: myfunction(fm, param1, param2, ...) as the function
+	# syntax for binding keys: cl.bind(fnc, *keys)
+	# fnc is a function which is called with the FM instance,
+	# keys are one or more key-combinations which are either:
+	# * a string
+	# * an integer which represents an ascii value
+	# * a tuple of integers
 
-	cl.bind(FM.move_left, 'h', 'back')
+	def move(relative = 0, absolute = None):
+		return lambda fm: fm.move_pointer(relative = relative, absolute = absolute)
+
+	def move_screens(n):
+		return lambda fm: fm.move_pointer_by_screensize(n)
+
+	cl.bind(FM.move_left, 'h', 195, 'back')
 	cl.bind(FM.move_right, 'l', 'forward')
-	cl.bind(FM.exit, 'q')
+	cl.bind(move( relative = 1 ), 'j')
+	cl.bind(move_screens( 0.5 ), 'J')
+	cl.bind(move( relative = -1 ), 'k')
+	cl.bind(move_screens( -0.5 ), 'K')
+	cl.bind(move( absolute = 0 ), 'gg')
+	cl.bind(move( absolute = -1 ), 'G')
+	cl.bind(FM.exit, 'q', ctrl('D'), 'ZZ')
+	cl.bind(FM.redraw, ctrl('L'))
 
 	cl.rebuild_paths()