aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Mason Larobina <mason.larobina@gmail.com>2009-12-01 17:52:27 +0800
committerGravatar Mason Larobina <mason.larobina@gmail.com>2009-12-01 17:52:27 +0800
commit1a109cb03c761cbeaa3bd81cb9f5f45953c7148e (patch)
tree7819ce5c5a29480ca15b0d824a0f874c9a5d845c /examples
parentdbdd7053b19275fff29787f50855eca82921bccf (diff)
Keycmd and mode plugin config setting optimisations.
Diffstat (limited to 'examples')
-rw-r--r--examples/data/uzbl/plugins/keycmd.py35
-rw-r--r--examples/data/uzbl/plugins/mode.py6
2 files changed, 16 insertions, 25 deletions
diff --git a/examples/data/uzbl/plugins/keycmd.py b/examples/data/uzbl/plugins/keycmd.py
index 4c88fd8..fd17363 100644
--- a/examples/data/uzbl/plugins/keycmd.py
+++ b/examples/data/uzbl/plugins/keycmd.py
@@ -256,10 +256,7 @@ def clear_keycmd(uzbl):
k.keycmd = ''
k.cursor = 0
k._repr_cache = False
- config = uzbl.get_config()
- if 'keycmd' not in config or config['keycmd']:
- uzbl.set('keycmd')
-
+ uzbl.set('keycmd')
uzbl.event('KEYCMD_CLEAR')
@@ -273,10 +270,7 @@ def clear_modcmd(uzbl, clear_held=False):
if clear_held:
k.held = set()
- config = uzbl.get_config()
- if 'modcmd' not in config or config['modcmd']:
- uzbl.set('modcmd')
-
+ uzbl.set('modcmd')
uzbl.event('MODCMD_CLEAR')
@@ -314,22 +308,25 @@ def update_event(uzbl, k, execute=True):
if 'modcmd_updates' not in config or config['modcmd_updates'] == '1':
new_modcmd = k.get_modcmd()
if not new_modcmd:
- uzbl.set('modcmd')
+ uzbl.set('modcmd', config=config)
elif new_modcmd == modcmd:
- uzbl.set('modcmd', "<span> %s </span>" % uzbl_escape(new_modcmd))
+ uzbl.set('modcmd', '<span> %s </span>' % uzbl_escape(new_modcmd),
+ config=config)
if 'keycmd_events' in config and config['keycmd_events'] != '1':
return
- keycmd = k.get_keycmd()
- if not keycmd:
- return uzbl.set('keycmd')
+ new_keycmd = k.get_keycmd()
+ if not new_keycmd:
+ uzbl.set('keycmd', config=config)
- # Generate the pango markup for the cursor in the keycmd.
- curchar = keycmd[k.cursor] if k.cursor < len(keycmd) else ' '
- chunks = [keycmd[:k.cursor], curchar, keycmd[k.cursor+1:]]
- uzbl.set('keycmd', KEYCMD_FORMAT % tuple(map(uzbl_escape, chunks)))
+ elif new_keycmd == keycmd:
+ # Generate the pango markup for the cursor in the keycmd.
+ curchar = keycmd[k.cursor] if k.cursor < len(keycmd) else ' '
+ chunks = [keycmd[:k.cursor], curchar, keycmd[k.cursor+1:]]
+ value = KEYCMD_FORMAT % tuple(map(uzbl_escape, chunks))
+ uzbl.set('keycmd', value, config=config)
def inject_str(str, index, inj):
@@ -380,9 +377,7 @@ def key_press(uzbl, key):
if 'keycmd_events' in config and config['keycmd_events'] != '1':
k.keycmd = ''
k.cursor = 0
- if config['keycmd']:
- uzbl.set('keycmd')
-
+ uzbl.set('keycmd', config=config)
return
k.keycmd = inject_str(k.keycmd, k.cursor, key)
diff --git a/examples/data/uzbl/plugins/mode.py b/examples/data/uzbl/plugins/mode.py
index 52b104a..2b2579a 100644
--- a/examples/data/uzbl/plugins/mode.py
+++ b/examples/data/uzbl/plugins/mode.py
@@ -63,11 +63,7 @@ def mode_changed(uzbl, mode):
config = uzbl.get_config()
mode_config = get_mode_config(uzbl, mode)
for (key, value) in mode_config.items():
- if key not in config:
- config[key] = value
-
- elif config[key] != value:
- config[key] = value
+ uzbl.set(key, value, config=config)
if 'mode_indicator' not in mode_config:
config['mode_indicator'] = mode