diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-02-10 22:23:24 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-02-10 22:31:52 +0100 |
| commit | 197ab824206335eab7ceed774ddeccac18fafc09 (patch) | |
| tree | 3f31dcbb2b0c2031675c97fb5e6084f115649556 | |
| parent | 66a56c827efcac36e07d6ac34bd05681ab8364e9 (diff) | |
| download | vis-197ab824206335eab7ceed774ddeccac18fafc09.tar.gz vis-197ab824206335eab7ceed774ddeccac18fafc09.tar.xz | |
vis: simplify modes implementation
Make replace mode a child of insert mode and visual line a
child of visual mode. This means any key binding for the
former is automatically available in the latter. Also keys
can not be unmapped solely from the child modes.
| -rw-r--r-- | config.def.h | 8 | ||||
| -rw-r--r-- | vis-modes.c | 2 | ||||
| -rw-r--r-- | vis-prompt.c | 2 | ||||
| -rw-r--r-- | vis.c | 2 |
4 files changed, 4 insertions, 10 deletions
diff --git a/config.def.h b/config.def.h index 774871b..5d53e41 100644 --- a/config.def.h +++ b/config.def.h @@ -330,11 +330,6 @@ static const KeyBinding **default_bindings[] = { }, [VIS_MODE_VISUAL_LINE] = (const KeyBinding*[]){ bindings_visual_line, - bindings_visual, - bindings_textobjects, - bindings_operators, - bindings_motions, - bindings_basic, NULL, }, [VIS_MODE_INSERT] = (const KeyBinding*[]){ @@ -345,9 +340,6 @@ static const KeyBinding **default_bindings[] = { }, [VIS_MODE_REPLACE] = (const KeyBinding*[]){ bindings_replace, - bindings_insert, - bindings_readline, - bindings_basic, NULL, }, }; diff --git a/vis-modes.c b/vis-modes.c index d7784e2..858e427 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -159,6 +159,7 @@ Mode vis_modes[] = { }, [VIS_MODE_VISUAL_LINE] = { .name = "VISUAL LINE", + .parent = &vis_modes[VIS_MODE_VISUAL], .status = "--VISUAL LINE--", .help = "", .enter = vis_mode_visual_line_enter, @@ -177,6 +178,7 @@ Mode vis_modes[] = { }, [VIS_MODE_REPLACE] = { .name = "REPLACE", + .parent = &vis_modes[VIS_MODE_INSERT], .status = "--REPLACE--", .help = "", .enter = vis_mode_replace_enter, diff --git a/vis-prompt.c b/vis-prompt.c index 2441fa4..ecb07b3 100644 --- a/vis-prompt.c +++ b/vis-prompt.c @@ -166,9 +166,7 @@ void vis_prompt_show(Vis *vis, const char *title) { prompt->parent_mode = vis->mode; vis_window_mode_map(prompt, VIS_MODE_NORMAL, "<Enter>", &prompt_enter_binding); vis_window_mode_map(prompt, VIS_MODE_INSERT, "<Enter>", &prompt_enter_binding); - vis_window_mode_map(prompt, VIS_MODE_REPLACE, "<Enter>", &prompt_enter_binding); vis_window_mode_map(prompt, VIS_MODE_VISUAL, "<Enter>", &prompt_enter_binding); - vis_window_mode_map(prompt, VIS_MODE_VISUAL_LINE, "<Enter>", &prompt_enter_binding); vis_window_mode_map(prompt, VIS_MODE_NORMAL, "<Escape>", &prompt_esc_binding); vis_window_mode_map(prompt, VIS_MODE_INSERT, "<Up>", &prompt_up_binding); vis_window_mode_map(prompt, VIS_MODE_INSERT, "<Backspace>", &prompt_backspace_binding); @@ -662,6 +662,8 @@ static const char *vis_keys_raw(Vis *vis, Buffer *buf, const char *input) { } for (; mode && !binding && !prefix; mode = mode->parent) { + if (!mode->bindings) + continue; binding = map_get(mode->bindings, start); /* "<" is never treated as a prefix because it is used to denote * special key symbols */ |
