aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Mason Larobina <mason.larobina@gmail.com>2009-12-26 20:53:24 +0800
committerGravatar Mason Larobina <mason.larobina@gmail.com>2009-12-26 20:53:24 +0800
commit3733d86d0d28e072697a17a43eff360dcdac8038 (patch)
treee0fea382ab9faa1c310581078ae37d44a1735996 /examples
parent92ccf67e010bcff1a153dd67093c23300c2ce47f (diff)
Keycmd plugin now sets raw_{key,mod}cmd vars and updated title format.
Diffstat (limited to 'examples')
-rw-r--r--examples/config/uzbl/config2
-rw-r--r--examples/data/uzbl/plugins/keycmd.py25
2 files changed, 17 insertions, 10 deletions
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index a6be6d6..072c045 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -96,6 +96,8 @@ set selected_section = <span foreground="#606060">\@[\@SELECTED_URI]\@</span>
set status_format = <span font_family="monospace">@mode_section @keycmd_section @progress_section @uri_section @name_section @status_section @scroll_section @selected_section</span>
+set title_format_long = \@keycmd_prompt \@raw_modcmd \@raw_keycmd \@TITLE - Uzbl browser <\@NAME> \@SELECTED_URI
+
# Progress bar config
@progress width = 8
# %d = done, %p = pending %c = percent done, %i = int done, %s = spinner,
diff --git a/examples/data/uzbl/plugins/keycmd.py b/examples/data/uzbl/plugins/keycmd.py
index af6beff..8475c1d 100644
--- a/examples/data/uzbl/plugins/keycmd.py
+++ b/examples/data/uzbl/plugins/keycmd.py
@@ -10,20 +10,18 @@ UZBLS = {}
# Keycmd format which includes the markup for the cursor.
KEYCMD_FORMAT = "%s<span @cursor_style>%s</span>%s"
+MODCMD_FORMAT = "<span> %s </span>"
-def uzbl_escape(str):
- '''Prevent outgoing keycmd values from expanding inside the
- status_format.'''
+def escape(str):
+ for char in ['\\', '@']:
+ str = str.replace(char, '\\'+char)
- if not str:
- return ''
+ return str
- for char in ['\\', '@']:
- if char in str:
- str = str.replace(char, '\\'+char)
- return "@[%s]@" % str
+def uzbl_escape(str):
+ return "@[%s]@" % escape(str) if str else ''
class Keylet(object):
@@ -261,6 +259,7 @@ def clear_keycmd(uzbl):
k.cursor = 0
k._repr_cache = False
uzbl.set('keycmd')
+ uzbl.set('raw_keycmd')
uzbl.event('KEYCMD_CLEARED')
@@ -276,6 +275,7 @@ def clear_modcmd(uzbl, clear_held=False):
k.held = set()
uzbl.set('modcmd')
+ uzbl.set('raw_modcmd')
uzbl.event('MODCMD_CLEARED')
@@ -314,9 +314,11 @@ def update_event(uzbl, k, execute=True):
new_modcmd = k.get_modcmd()
if not new_modcmd:
uzbl.set('modcmd', config=config)
+ uzbl.set('raw_modcmd', config=config)
elif new_modcmd == modcmd:
- uzbl.set('modcmd', '<span> %s </span>' % uzbl_escape(new_modcmd),
+ uzbl.set('raw_modcmd', escape(modcmd), config=config)
+ uzbl.set('modcmd', MODCMD_FORMAT % uzbl_escape(modcmd),
config=config)
if 'keycmd_events' in config and config['keycmd_events'] != '1':
@@ -325,6 +327,7 @@ def update_event(uzbl, k, execute=True):
new_keycmd = k.get_keycmd()
if not new_keycmd:
uzbl.set('keycmd', config=config)
+ uzbl.set('raw_keycmd', config=config)
elif new_keycmd == keycmd:
# Generate the pango markup for the cursor in the keycmd.
@@ -332,6 +335,7 @@ def update_event(uzbl, k, execute=True):
chunks = [keycmd[:k.cursor], curchar, keycmd[k.cursor+1:]]
value = KEYCMD_FORMAT % tuple(map(uzbl_escape, chunks))
uzbl.set('keycmd', value, config=config)
+ uzbl.set('raw_keycmd', escape(keycmd), config=config)
def inject_str(str, index, inj):
@@ -391,6 +395,7 @@ def key_press(uzbl, key):
k.keycmd = ''
k.cursor = 0
uzbl.set('keycmd', config=config)
+ uzbl.set('raw_keycmd', config=config)
return
k.keycmd = inject_str(k.keycmd, k.cursor, key)