aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar keis <keijser@gmail.com>2009-10-15 03:53:48 +0200
committerGravatar keis <keijser@gmail.com>2009-10-15 04:04:38 +0200
commit8f881188ce26d9bfbaed86b0dd76391b7fc77ef4 (patch)
tree8dbd4f22953e3163192b2fb0687513b486d9c309 /examples
parent7ed6303f3d5dd02ec900fc5dcad4c977c465b0c6 (diff)
Make prompts work again.
For now treats all single-depth modcmds as commands that should be executed regardless of context, global commands. globalness should perhaps by expressed in the bind event instead.
Diffstat (limited to 'examples')
-rw-r--r--examples/data/uzbl/scripts/plugins/bind.py35
1 files changed, 22 insertions, 13 deletions
diff --git a/examples/data/uzbl/scripts/plugins/bind.py b/examples/data/uzbl/scripts/plugins/bind.py
index 6b1c727..16834a7 100644
--- a/examples/data/uzbl/scripts/plugins/bind.py
+++ b/examples/data/uzbl/scripts/plugins/bind.py
@@ -172,7 +172,7 @@ class Bind(object):
msg = 'found null segment after first prompt: %r' % split
raise BindParseError(msg)
- self.stack = []
+ self._stack = []
for glob in split[::2]:
# Is the binding a MODCMD or KEYCMD:
@@ -185,8 +185,15 @@ class Bind(object):
has_args = True if glob[-1] in ['*', '_'] else False
glob = glob[:-1] if has_args else glob
- self.stack.append((mod_cmd, on_exec, has_args, glob))
+ self._stack.append((mod_cmd, on_exec, has_args, glob))
+ def is_global(self):
+ return len(self._stack) == 1 and self._stack[0][MOD_CMD]
+
+ def __getitem__(self, depth):
+ if self.is_global():
+ return self._stack[0], False
+ return self._stack[depth], depth - len(self._stack) + 1
def __repr__(self):
args = ['glob=%r' % self.glob, 'bid=%d' % self.bid]
@@ -274,33 +281,35 @@ def filter_bind(uzbl, bind_dict, bind):
def match_and_exec(uzbl, bind, depth, keycmd):
bind_dict = get_bind_dict(uzbl)
- mod_cmd, on_exec, has_args, glob = bind.stack[depth]
+ (mod_cmd, on_exec, has_args, glob), more = bind[depth]
if has_args:
if not keycmd.startswith(glob):
- filter_bind(uzbl, bind_dict, bind)
+ if not mod_cmd:
+ filter_bind(uzbl, bind_dict, bind)
return False
args = [keycmd[len(glob):],]
elif keycmd != glob:
- filter_bind(uzbl, bind_dict, bind)
+ if not mod_cmd:
+ filter_bind(uzbl, bind_dict, bind)
return False
else:
args = []
- execindex = len(bind.stack)-1
- if execindex == depth == 0:
+ if bind.is_global() or (not more and depth == 0):
uzbl.exec_handler(bind, *args)
if not has_args and not mod_cmd:
uzbl.clear_keycmd()
return True
- elif depth != execindex:
+ elif more:
if bind_dict['depth'] == depth:
- bind_dict['filter'] = [bind,]
+ globalcmds = [cmd for cmd in bind_dict['binds'] if cmd.is_global()]
+ bind_dict['filter'] = [bind,] + globalcmds
bind_dict['args'] += args
bind_dict['depth'] = depth + 1
@@ -323,7 +332,7 @@ def keycmd_update(uzbl, keylet):
depth = get_stack_depth(uzbl)
keycmd = keylet.key_cmd()
for bind in get_filtered_binds(uzbl):
- t = bind.stack[depth]
+ (t,more) = bind[depth]
if t[MOD_CMD] or t[ON_EXEC]:
continue
@@ -334,7 +343,7 @@ def keycmd_exec(uzbl, keylet):
depth = get_stack_depth(uzbl)
keycmd = keylet.key_cmd()
for bind in get_filtered_binds(uzbl):
- t = bind.stack[depth]
+ (t,more) = bind[depth]
if t[MOD_CMD] or not t[ON_EXEC]:
continue
@@ -345,7 +354,7 @@ def modcmd_update(uzbl, keylet):
depth = get_stack_depth(uzbl)
keycmd = keylet.mod_cmd()
for bind in get_filtered_binds(uzbl):
- t = bind.stack[depth]
+ (t,more) = bind[depth]
if not t[MOD_CMD] or t[ON_EXEC]:
continue
@@ -356,7 +365,7 @@ def modcmd_exec(uzbl, keylet):
depth = get_stack_depth(uzbl)
keycmd = keylet.mod_cmd()
for bind in get_filtered_binds(uzbl):
- t = bind.stack[depth]
+ (t,more) = bind[depth]
if not t[MOD_CMD] or not t[ON_EXEC]:
continue