diff options
author | 2009-11-04 19:46:36 +0100 | |
---|---|---|
committer | 2009-11-04 19:46:36 +0100 | |
commit | d9b8be00c5a7799e6d3f7be90679a1f12b1cc24b (patch) | |
tree | 0a740f30ea73bb427d3b6deef80b2022bb5a2c5e | |
parent | c1fe4e485816cd4207af48dd1e4e3e667a1b4825 (diff) | |
parent | 32c2a87c3206565f0d0d14a6b707d82b0b693116 (diff) |
Merge branch 'experimental' of git://github.com/mason-larobina/uzbl into experimental
-rw-r--r-- | examples/config/uzbl/config | 9 | ||||
-rw-r--r-- | examples/data/uzbl/plugins/keycmd.py | 35 |
2 files changed, 36 insertions, 8 deletions
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 57d1ea5..8a2ad87 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -206,12 +206,19 @@ set formfiller = spawn @scripts_dir/formfiller @bind <Ctrl>a<:><Ctrl>q = exit @bind <Ctrl>a<:><Ctrl>h = uri http://uzbl.org/ +# Inject handy values into the keycmd. +@bind <Ctrl>su = event INJECT_KEYCMD \@uri +@bind <Ctrl>st = event INJECT_KEYCMD \@TITLE +# Or append. +@bind <Ctrl>du = event APPEND_KEYCMD \@uri +@bind <Ctrl>dt = event APPEND_KEYCMD \@TITLE + # === command editing configuration ========================================== # you'll want this at the very least @bind <Return> = event KEYCMD_EXEC_CURRENT -@bind <Escape> = event @set_mode +@bind <Escape> = @set_mode # basic searching @bind <Home> = event SET_CURSOR_POS 0 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) |