diff options
author | Mason Larobina <mason.larobina@gmail.com> | 2009-11-29 18:41:56 +0800 |
---|---|---|
committer | Mason Larobina <mason.larobina@gmail.com> | 2009-11-29 18:41:56 +0800 |
commit | 50d4c84aa7e28167cedbe14cd064d98a605ca1ea (patch) | |
tree | 4772b6decabef5449c636b385e5e613b437bf85d /examples/data | |
parent | 5cecb5d6570df33c2ce9c700c563fad8b787f13e (diff) |
Correctly implemented stack mode usage in the bind plugin.
Using the stack mode in the bind plugin is required when using a stack
bind in a mode with "set keycmd_events = 0" and "set forward_keys = 1"
otherwise no keycmd input would work.
Diffstat (limited to 'examples/data')
-rw-r--r-- | examples/data/uzbl/plugins/bind.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py index 4976a80..3169b15 100644 --- a/examples/data/uzbl/plugins/bind.py +++ b/examples/data/uzbl/plugins/bind.py @@ -17,7 +17,7 @@ __export__ = ['bind', 'del_bind', 'del_bind_by_glob', 'get_binds'] # Hold the bind dicts for each uzbl instance. UZBLS = {} -DEFAULTS = {'binds': [], 'depth': 0, 'stack': [], 'args': []} +DEFAULTS = {'binds': [], 'depth': 0, 'stack': [], 'args': [], 'last_mode': ''} # Commonly used regular expressions. starts_with_mod = re.compile('^<([A-Z][A-Za-z0-9-_]*)>') @@ -276,15 +276,25 @@ def parse_bind_event(uzbl, args): bind(uzbl, glob, command) -def clear_stack(uzbl, mode): +def mode_changed(uzbl, mode): + '''Clear the stack on all non-stack mode changes.''' + + if mode != 'stack': + clear_stack(uzbl) + + +def clear_stack(uzbl): '''Clear everything related to stacked binds.''' bind_dict = get_bind_dict(uzbl) bind_dict['stack'] = [] bind_dict['depth'] = 0 bind_dict['args'] = [] + if bind_dict['last_mode']: + uzbl.set_mode(bind_dict['last_mode']) + bind_dict['last_mode'] = '' - uzbl.set('keycmd_prompt', '') + uzbl.set('keycmd_prompt', force=False) def stack_bind(uzbl, bind, args, depth): @@ -298,6 +308,10 @@ def stack_bind(uzbl, bind, args, depth): return + if uzbl.get_mode() != 'stack': + bind_dict['last_mode'] = uzbl.get_mode() + uzbl.set_mode('stack') + globalcmds = [cmd for cmd in bind_dict['binds'] if cmd.is_global] bind_dict['stack'] = [bind,] + globalcmds bind_dict['args'] += args @@ -356,6 +370,7 @@ def match_and_exec(uzbl, bind, depth, keylet): exec_bind(uzbl, bind, *args) uzbl.set_mode() if not has_args: + clear_stack(uzbl) uzbl.clear_current() return True @@ -411,6 +426,6 @@ def init(uzbl): 'MODCMD_UPDATE': modcmd_update, 'KEYCMD_EXEC': keycmd_exec, 'MODCMD_EXEC': modcmd_exec, - 'MODE_CHANGED': clear_stack} + 'MODE_CHANGED': mode_changed} uzbl.connect_dict(connects) |