From 00b627921c0a493e064501f444fa69e147bbb59d Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 9 Apr 2010 04:31:45 +0200 Subject: defaults.keys: improved --- ranger/defaults/keys.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 061e9091..81ebfea0 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -25,15 +25,23 @@ The CommandArgs object has these attributes: arg.fm: the file manager instance arg.wdg: the widget or ui instance arg.n: the number typed before the key combination (if allowed) +arg.direction: the direction object (if applicable) arg.keys: the string representation of the used key combination arg.keybuffer: the keybuffer instance Direction keys are special. They must be mapped with: map.dir(*keys, **args) -where args is a dict of values such as up, left, down, right, absolute, -relative, pages, etc... +where args is a dict of values such as up, down, to, absolute, relative... Example: map.dir('gg', to=0) Direction keys can be accessed in a mapping that contians "". +Additionally, there are shortcuts for accessing methods of the current +file manager and widget instance: +map('xyz', fm.method(foo=bar)) +will be translated to: +map('xyz', lamdba arg: arg.fm.method(foo=bar)) +If possible, arg.n and arg.direction are automatically inserted. + + Example scenario ---------------- If this keys are defined: @@ -105,7 +113,10 @@ map = keymanager['general'] map.merge(global_keys) map.merge(vim_aliases) +# -------------------------------------------------------- movement map('gg', fm.move(to=0)) +map('', 'J', fm.move(down=0.5, pages=True)) +map('', 'K', fm.move(up=0.5, pages=True)) # --------------------------------------------------------- history map('H', fm.history_go(-1)) -- cgit 1.4.1-2-gfad0