aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Mason Larobina <mason.larobina@gmail.com>2010-01-19 21:00:44 +0800
committerGravatar Mason Larobina <mason.larobina@gmail.com>2010-01-19 21:00:44 +0800
commit8b40bdc060f29d9c7d2092fce2bd33f1c3115b7f (patch)
treebffccd6193144b036b46e0fa7673a6069a0fec18 /examples
parentc31bec6355e70a3867505a7ab3eb4c4e974e1631 (diff)
Fixed problem with * binds in stack mode.
Diffstat (limited to 'examples')
-rw-r--r--examples/data/uzbl/plugins/bind.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py
index 427c8d3..1dd2ee8 100644
--- a/examples/data/uzbl/plugins/bind.py
+++ b/examples/data/uzbl/plugins/bind.py
@@ -404,7 +404,6 @@ def mode_changed(uzbl, mode):
def match_and_exec(uzbl, bind, depth, keylet, bindlet):
-
(on_exec, has_args, mod_cmd, glob, more) = bind[depth]
cmd = keylet.modcmd if mod_cmd else keylet.keycmd
@@ -436,20 +435,20 @@ def match_and_exec(uzbl, bind, depth, keylet, bindlet):
args = bindlet.args + args
exec_bind(uzbl, bind, *args)
- uzbl.set_mode()
- if not has_args:
+ if not has_args or on_exec:
+ uzbl.set_mode()
bindlet.reset()
uzbl.clear_current()
return True
-def key_event(uzbl, keylet, modcmd=False, onexec=False):
+def key_event(uzbl, keylet, mod_cmd=False, on_exec=False):
bindlet = get_bindlet(uzbl)
depth = bindlet.depth
for bind in bindlet.get_binds():
t = bind[depth]
- if (bool(t[MOD_CMD]) != modcmd) or (t[ON_EXEC] != onexec):
+ if (bool(t[MOD_CMD]) != mod_cmd) or (t[ON_EXEC] != on_exec):
continue
if match_and_exec(uzbl, bind, depth, keylet, bindlet):
@@ -457,6 +456,11 @@ def key_event(uzbl, keylet, modcmd=False, onexec=False):
bindlet.after()
+ # Return to the previous mode if the KEYCMD_EXEC keycmd doesn't match any
+ # binds in the stack mode.
+ if on_exec and not mod_cmd and depth and depth == bindlet.depth:
+ uzbl.set_mode()
+
def init(uzbl):
# Event handling hooks.
@@ -470,10 +474,10 @@ def init(uzbl):
events = [['KEYCMD_UPDATE', 'KEYCMD_EXEC'],
['MODCMD_UPDATE', 'MODCMD_EXEC']]
- for modcmd in range(2):
- for onexec in range(2):
- event = events[modcmd][onexec]
- uzbl.connect(event, key_event, bool(modcmd), bool(onexec))
+ for mod_cmd in range(2):
+ for on_exec in range(2):
+ event = events[mod_cmd][on_exec]
+ uzbl.connect(event, key_event, bool(mod_cmd), bool(on_exec))
# Function exports to the uzbl object, `function(uzbl, *args, ..)`
# becomes `uzbl.function(*args, ..)`.