diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-10-14 23:00:47 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-10-14 23:17:15 +0200 |
| commit | 632b5909af96861c881865afae8638a2fd072668 (patch) | |
| tree | 22c745db9a95d6a8c999f0026a3d2e2301d95100 /editor.c | |
| parent | fc8b564ab2a58cf5dd19dcaabd460b65bd5d444c (diff) | |
| download | vis-632b5909af96861c881865afae8638a2fd072668.tar.gz vis-632b5909af96861c881865afae8638a2fd072668.tar.xz | |
vis: introduce special keys which allow mappings to editor actions
Key bindings in vis are always recursive, hence mapping ~
to ~l will cause an infinite loop.
Instead vis supports special editor "keys" which map to
internal editor functions.
As an example one can thus map ~ to <vis-operator-case-swap>l
or even <vis-operator-case-swap><cursor-char-next>
Furthermore this makes it possible to completely unmap core
editor features such as operators, the corresponding funtionality
is still available via its corresponding special key.
Diffstat (limited to 'editor.c')
| -rw-r--r-- | editor.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -252,6 +252,14 @@ bool editor_mode_unmap(Mode *mode, const char *name) { return map_delete(mode->bindings, name); } +bool editor_action_register(Editor *ed, KeyAction *action) { + if (!ed->actions) + ed->actions = map_new(); + if (!ed->actions) + return false; + return map_put(ed->actions, action->name, action); +} + static void window_free(Win *win) { if (!win) return; @@ -430,6 +438,7 @@ void editor_free(Editor *ed) { ed->ui->free(ed->ui); map_free(ed->cmds); map_free(ed->options); + map_free(ed->actions); buffer_release(&ed->buffer_repeat); free(ed); } |
