diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-01-06 22:10:37 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-01-06 22:10:37 +0100 |
| commit | 6d2d23ac62fe41dcac97b21985051cfc87e0362f (patch) | |
| tree | 6225c105737f029c9293dc87d54b0b1cd13379fd /vis-modes.c | |
| parent | 604c866bd0c034340efaea54ebbb86b6dc6e66f4 (diff) | |
| download | vis-6d2d23ac62fe41dcac97b21985051cfc87e0362f.tar.gz vis-6d2d23ac62fe41dcac97b21985051cfc87e0362f.tar.xz | |
vis: simplify mode lookup for :map and :unmap
Diffstat (limited to 'vis-modes.c')
| -rw-r--r-- | vis-modes.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/vis-modes.c b/vis-modes.c index 1fe460d..c4f0027 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -1,4 +1,5 @@ #include <string.h> +#include <strings.h> #include "vis-core.h" #include "util.h" @@ -86,6 +87,15 @@ void vis_mode_switch(Vis *vis, enum VisMode mode) { mode_set(vis, &vis_modes[mode]); } +enum VisMode vis_mode_from(Vis *vis, const char *name) { + for (size_t i = 0; i < LENGTH(vis_modes); i++) { + Mode *mode = &vis_modes[i]; + if (!strcasecmp(mode->name, name)) + return mode->id; + } + return VIS_MODE_INVALID; +} + enum VisMode vis_mode_get(Vis *vis) { return vis->mode->id; } @@ -241,7 +251,7 @@ Mode vis_modes[] = { }, [VIS_MODE_VISUAL_LINE] = { .id = VIS_MODE_VISUAL_LINE, - .name = "VISUAL LINE", + .name = "VISUAL-LINE", .parent = &vis_modes[VIS_MODE_VISUAL], .status = "VISUAL-LINE", .help = "", |
