From 35c1e804e1dc1204f6e9ffe5942123b0f11eb59a Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Wed, 4 Nov 2009 21:31:03 +0800 Subject: Fixed binding. --- examples/config/uzbl/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 57d1ea5..7547dbe 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -211,7 +211,7 @@ set formfiller = spawn @scripts_dir/formfiller # you'll want this at the very least @bind = event KEYCMD_EXEC_CURRENT -@bind = event @set_mode +@bind = @set_mode # basic searching @bind = event SET_CURSOR_POS 0 -- cgit v1.2.3 From 32c2a87c3206565f0d0d14a6b707d82b0b693116 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Wed, 4 Nov 2009 23:01:06 +0800 Subject: Added INJECT_KEYCMD and APPEND_KEYCMD events in keycmd.py --- examples/config/uzbl/config | 7 +++++++ examples/data/uzbl/plugins/keycmd.py | 35 ++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 7547dbe..8a2ad87 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -206,6 +206,13 @@ set formfiller = spawn @scripts_dir/formfiller @bind a<:>q = exit @bind a<:>h = uri http://uzbl.org/ +# Inject handy values into the keycmd. +@bind su = event INJECT_KEYCMD \@uri +@bind st = event INJECT_KEYCMD \@TITLE +# Or append. +@bind du = event APPEND_KEYCMD \@uri +@bind dt = event APPEND_KEYCMD \@TITLE + # === command editing configuration ========================================== diff --git a/examples/data/uzbl/plugins/keycmd.py b/examples/data/uzbl/plugins/keycmd.py index d01d2ac..8961f74 100644 --- a/examples/data/uzbl/plugins/keycmd.py +++ b/examples/data/uzbl/plugins/keycmd.py @@ -227,11 +227,10 @@ def update_event(uzbl, k, execute=True): uzbl.set('keycmd', KEYCMD_FORMAT % tuple(map(uzbl_escape, chunks))) -def inject_char(str, index, char): - '''Inject character into string at at given index.''' +def inject_str(str, index, inj): + '''Inject a string into string at at given index.''' - assert len(char) == 1 - return "%s%s%s" % (str[:index], char, str[index:]) + return "%s%s%s" % (str[:index], inj, str[index:]) def key_press(uzbl, key): @@ -253,13 +252,13 @@ def key_press(uzbl, key): return if key == 'Space' and not k.held and k.keycmd: - k.keycmd = inject_char(k.keycmd, k.cursor, ' ') + k.keycmd = inject_str(k.keycmd, k.cursor, ' ') k.cursor += 1 elif not k.held and len(key) == 1: config = uzbl.get_config() if 'keycmd_events' not in config or config['keycmd_events'] == '1': - k.keycmd = inject_char(k.keycmd, k.cursor, key) + k.keycmd = inject_str(k.keycmd, k.cursor, key) k.cursor += 1 elif k.keycmd: @@ -317,6 +316,26 @@ def set_keycmd(uzbl, keycmd): update_event(uzbl, k, False) +def inject_keycmd(uzbl, keycmd): + '''Allow injecting of a string into the keycmd at the cursor position.''' + + k = get_keylet(uzbl) + k.keycmd = inject_str(k.keycmd, k.cursor, keycmd) + k._repr_cache = None + k.cursor += len(keycmd) + update_event(uzbl, k, False) + + +def append_keycmd(uzbl, keycmd): + '''Allow appening of a string to the keycmd.''' + + k = get_keylet(uzbl) + k.keycmd += keycmd + k._repr_cache = None + k.cursor = len(k.keycmd) + update_event(uzbl, k, False) + + def keycmd_strip_word(uzbl, sep): ''' Removes the last word from the keycmd, similar to readline ^W ''' @@ -406,6 +425,8 @@ def init(uzbl): 'SET_CURSOR_POS': set_cursor_pos, 'FOCUS_LOST': focus_changed, 'FOCUS_GAINED': focus_changed, - 'MODMAP': modmap_parse} + 'MODMAP': modmap_parse, + 'APPEND_KEYCMD': append_keycmd, + 'INJECT_KEYCMD': inject_keycmd} uzbl.connect_dict(connects) -- cgit v1.2.3