diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-01-12 15:48:17 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-01-13 21:38:19 +0100 |
| commit | 11ede8254974aba6e1ef318ab90374fb85e6bf5c (patch) | |
| tree | 248276ff41ce2efe9bc0280e54905dc977a45c6d /vis-cmds.c | |
| parent | 24bf7a500ecad7091f92cf9063d0b6cbbf678db1 (diff) | |
| download | vis-11ede8254974aba6e1ef318ab90374fb85e6bf5c.tar.gz vis-11ede8254974aba6e1ef318ab90374fb85e6bf5c.tar.xz | |
vis: cleanup key binding definitions
This removes the tree based mode structures and instead merges
all keybindings in flat modes which uses some more memory but
will allow (per mode) run-time configurable key bindings.
Make sure to update/remove config.h.
Diffstat (limited to 'vis-cmds.c')
| -rw-r--r-- | vis-cmds.c | 24 |
1 files changed, 7 insertions, 17 deletions
@@ -864,9 +864,9 @@ bool print_keybinding(const char *key, void *value, void *data) { return text_appendf(txt, " %-15s\t%s\n", key, desc ? desc : ""); } -static void print_mode(Mode *mode, Text *txt, bool recursive) { - if (recursive && mode->parent) - print_mode(mode->parent, txt, recursive); +static void print_mode(Mode *mode, Text *txt) { + if (!map_empty(mode->bindings)) + text_appendf(txt, "\n %s\n\n", mode->name); map_iterate(mode->bindings, print_keybinding, txt); } @@ -885,20 +885,10 @@ static bool cmd_help(Vis *vis, Filerange *range, enum CmdOpt opt, const char *ar text_appendf(txt, " %-15s\t%s\n", mode->name, mode->help); } - for (int i = 0; i < LENGTH(vis_modes); i++) { - Mode *mode = &vis_modes[i]; - if (mode->isuser && !map_empty(mode->bindings)) { - text_appendf(txt, "\n %s\n\n", mode->name); - print_mode(mode, txt, i == VIS_MODE_NORMAL || - i == VIS_MODE_INSERT); - } - } - - text_appendf(txt, "\n Text objects\n\n"); - print_mode(&vis_modes[VIS_MODE_TEXTOBJ], txt, false); - - text_appendf(txt, "\n Motions\n\n"); - print_mode(&vis_modes[VIS_MODE_MOVE], txt, false); + print_mode(&vis_modes[VIS_MODE_NORMAL], txt); + print_mode(&vis_modes[VIS_MODE_OPERATOR_PENDING], txt); + print_mode(&vis_modes[VIS_MODE_VISUAL], txt); + print_mode(&vis_modes[VIS_MODE_INSERT], txt); text_appendf(txt, "\n :-Commands\n\n"); for (Command *cmd = cmds; cmd && cmd->name[0]; cmd++) |
