From db65ac01a21d097183ae811e0847155f99bae25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 22 Oct 2015 19:17:54 +0200 Subject: vis: improve :help text, add separate status mode names --- vis.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 26b9fb4..9b9ba42 100644 --- a/vis.c +++ b/vis.c @@ -1598,10 +1598,9 @@ static void switchmode_to(Mode *new_mode) { if (vis->mode->isuser) vis->mode_prev = vis->mode; vis->mode = new_mode; - if (new_mode == config->mode || (new_mode->name && new_mode->name[0] == '-')) - vis->win->ui->draw_status(vis->win->ui); if (new_mode->enter) new_mode->enter(vis->mode_prev); + vis->win->ui->draw_status(vis->win->ui); } /** ':'-command implementations */ @@ -2336,7 +2335,7 @@ bool print_keybinding(const char *key, void *value, void *data) { const char *desc = binding->alias; if (!desc && binding->action) desc = binding->action->help; - return text_printf(txt, text_size(txt), " %-15s\t%s\n", key, desc ? desc : ""); + return text_appendf(txt, " %-15s\t%s\n", key, desc ? desc : ""); } static void print_mode(Mode *mode, Text *txt, bool recursive) { @@ -2350,15 +2349,31 @@ static bool cmd_help(Filerange *range, enum CmdOpt opt, const char *argv[]) { return false; Text *txt = vis->win->file->text; + + text_appendf(txt, "vis %s, compiled " __DATE__ " " __TIME__ "\n\n", VERSION); + + text_appendf(txt, " Modes\n\n"); + for (int i = 0; i < LENGTH(vis_modes); i++) { + Mode *mode = &vis_modes[i]; + if (mode->help) + 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 || i == VIS_MODE_TEXTOBJ) { - text_printf(txt, text_size(txt), "\n%s\n\n", mode->name); + 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); + text_save(txt, NULL); return true; } -- cgit v1.2.3