From 28315daa6ba4096a6a4965ea9f0a706ee521e360 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 22 Sep 2009 17:16:49 +0800 Subject: Made modcmd updating optional. Used when in insert mode. --- examples/data/uzbl/scripts/plugins/keycmd.py | 18 +++++++++++++++--- examples/data/uzbl/scripts/plugins/mode.py | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'examples/data/uzbl/scripts') diff --git a/examples/data/uzbl/scripts/plugins/keycmd.py b/examples/data/uzbl/scripts/plugins/keycmd.py index 7abb042..4e67a50 100644 --- a/examples/data/uzbl/scripts/plugins/keycmd.py +++ b/examples/data/uzbl/scripts/plugins/keycmd.py @@ -17,6 +17,17 @@ _SIMPLEKEYS = { } +def keycmd_escape(keycmd): + '''Prevent outgoing keycmd values from expanding inside the + status_format.''' + + for char in ['\\', '@']: + if char in keycmd: + keycmd = keycmd.replace(char, '\\'+char) + + return keycmd + + def get_regex(regex): '''Compiling regular expressions is a very time consuming so return a pre-compiled regex match object if possible.''' @@ -139,14 +150,15 @@ def update_event(uzbl, keylet): if keylet.modcmd: keycmd = keylet.to_string() uzbl.event('MODCMD_UPDATE', keylet) - if keycmd == keylet.to_string(): - config['keycmd'] = keylet.to_string() + if 'modcmd_updates' not in config or config['modcmd_updates'] == '1': + if keycmd == keylet.to_string(): + config['keycmd'] = keycmd_escape(keycmd) elif 'keycmd_events' not in config or config['keycmd_events'] == '1': keycmd = keylet.cmd uzbl.event('KEYCMD_UPDATE', keylet) if keycmd == keylet.cmd: - config['keycmd'] = keylet.cmd + config['keycmd'] = keycmd_escape(keycmd) def key_press(uzbl, key): diff --git a/examples/data/uzbl/scripts/plugins/mode.py b/examples/data/uzbl/scripts/plugins/mode.py index debaba6..f8464e7 100644 --- a/examples/data/uzbl/scripts/plugins/mode.py +++ b/examples/data/uzbl/scripts/plugins/mode.py @@ -12,10 +12,12 @@ DEFAULTS = { 'insert': { 'forward_keys': True, 'keycmd_events': False, + 'modcmd_updates': False, 'indicator': 'I'}, 'command': { 'forward_keys': False, 'keycmd_events': True, + 'modcmd_updates': True, 'indicator': 'C'}}} _RE_FINDSPACES = re.compile("\s+") -- cgit v1.2.3