aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar keis <keijser@gmail.com>2009-10-14 04:07:45 +0200
committerGravatar keis <keijser@gmail.com>2009-10-15 04:03:05 +0200
commitc7a4e5d5d26f59d7d0f0b40f4d69fa8560bf5454 (patch)
tree3093a9a87119300f34047f2e7b0ac87a1a355076 /examples
parent0b993cff1b50de7e40ca8d4ea8f87052e8e99ea5 (diff)
add methods to KeyLet to extract mod and key -cmd parts.
Diffstat (limited to 'examples')
-rw-r--r--examples/data/uzbl/scripts/plugins/bind.py12
-rw-r--r--examples/data/uzbl/scripts/plugins/keycmd.py20
2 files changed, 15 insertions, 17 deletions
diff --git a/examples/data/uzbl/scripts/plugins/bind.py b/examples/data/uzbl/scripts/plugins/bind.py
index bcfaa9f..6b1c727 100644
--- a/examples/data/uzbl/scripts/plugins/bind.py
+++ b/examples/data/uzbl/scripts/plugins/bind.py
@@ -274,7 +274,7 @@ def filter_bind(uzbl, bind_dict, bind):
def match_and_exec(uzbl, bind, depth, keycmd):
bind_dict = get_bind_dict(uzbl)
- mode_cmd, on_exec, has_args, glob = bind.stack[depth]
+ mod_cmd, on_exec, has_args, glob = bind.stack[depth]
if has_args:
if not keycmd.startswith(glob):
@@ -293,7 +293,7 @@ def match_and_exec(uzbl, bind, depth, keycmd):
execindex = len(bind.stack)-1
if execindex == depth == 0:
uzbl.exec_handler(bind, *args)
- if not has_args:
+ if not has_args and not mod_cmd:
uzbl.clear_keycmd()
return True
@@ -321,7 +321,7 @@ def match_and_exec(uzbl, bind, depth, keycmd):
def keycmd_update(uzbl, keylet):
depth = get_stack_depth(uzbl)
- keycmd = keylet.to_string()
+ keycmd = keylet.key_cmd()
for bind in get_filtered_binds(uzbl):
t = bind.stack[depth]
if t[MOD_CMD] or t[ON_EXEC]:
@@ -332,7 +332,7 @@ def keycmd_update(uzbl, keylet):
def keycmd_exec(uzbl, keylet):
depth = get_stack_depth(uzbl)
- keycmd = keylet.to_string()
+ keycmd = keylet.key_cmd()
for bind in get_filtered_binds(uzbl):
t = bind.stack[depth]
if t[MOD_CMD] or not t[ON_EXEC]:
@@ -343,7 +343,7 @@ def keycmd_exec(uzbl, keylet):
def modcmd_update(uzbl, keylet):
depth = get_stack_depth(uzbl)
- keycmd = keylet.to_string()
+ keycmd = keylet.mod_cmd()
for bind in get_filtered_binds(uzbl):
t = bind.stack[depth]
if not t[MOD_CMD] or t[ON_EXEC]:
@@ -354,7 +354,7 @@ def modcmd_update(uzbl, keylet):
def modcmd_exec(uzbl, keylet):
depth = get_stack_depth(uzbl)
- keycmd = keylet.to_string()
+ keycmd = keylet.mod_cmd()
for bind in get_filtered_binds(uzbl):
t = bind.stack[depth]
if not t[MOD_CMD] or not t[ON_EXEC]:
diff --git a/examples/data/uzbl/scripts/plugins/keycmd.py b/examples/data/uzbl/scripts/plugins/keycmd.py
index 18d2e32..c423ab2 100644
--- a/examples/data/uzbl/scripts/plugins/keycmd.py
+++ b/examples/data/uzbl/scripts/plugins/keycmd.py
@@ -60,11 +60,16 @@ class Keylet(object):
def mod_held(self):
return any([len(x) != 1 for x in self.held])
-
+
+ def key_cmd(self):
+ return self.cmd
+
+ def mod_cmd(self):
+ return ''.join(['<%s>' % key for key in self.held])
+
def __repr__(self):
return '<Keycmd(%r)>' % self.to_string()
-
def to_string(self):
'''Return a string representation of the keys held and pressed that
have been recorded.'''
@@ -72,15 +77,8 @@ class Keylet(object):
if self._to_string is not None:
# Return cached keycmd string.
return self._to_string
-
- if not self.held:
- self._to_string = self.cmd
-
- else:
- self._to_string = ''.join(['<%s>' % key for key in self.held])
- if self.cmd:
- self._to_string += self.cmd
-
+
+ self._to_string = self.mod_cmd() + self.key_cmd()
return self._to_string