vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit eff51d379c52b3fca7a5ad0aa4c6b47fe1d6d6d0
parent dd8e316f829133cba5c413db5686842e5bc40363
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 12 Sep 2014 16:45:03 +0200

Use the new global keypress hook to hide user messages

Diffstat:
Mconfig.def.h | 23++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -61,7 +61,7 @@ static Command cmds[] = { }; /* draw a statubar, do whatever you want with win->statuswin curses window */ -static void statusbar(EditorWin *win) { +static void vis_statusbar(EditorWin *win) { size_t line, col; bool focused = vis->win == win || vis->prompt->editor == win; window_cursor_getxy(win->win, &line, &col); @@ -77,6 +77,13 @@ static void statusbar(EditorWin *win) { } } +/* called before any other keybindings are checked, if the function returns false + * the key is completely ignored. used to clear a user visible message. */ +static bool vis_keypress(Key *key) { + editor_info_hide(vis); + return true; +} + static KeyBinding basic_movement[] = { { { KEY(LEFT) }, movement, { .i = MOVE_CHAR_PREV } }, { { KEY(SLEFT) }, movement, { .i = MOVE_WORD_START_PREV } }, @@ -701,8 +708,18 @@ static Mode nano[] = { * argv[0] i.e. program name upon execution */ static Config editors[] = { - { .name = "vis", .mode = &vis_modes[VIS_MODE_NORMAL], .statusbar = statusbar }, - { .name = "nano", .mode = &nano[1], .statusbar = statusbar }, + { + .name = "vis", + .mode = &vis_modes[VIS_MODE_NORMAL], + .statusbar = vis_statusbar, + .keypress = vis_keypress, + }, + { + .name = "nano", + .mode = &nano[1], + .statusbar = vis_statusbar, + .keypress = vis_keypress, + }, }; /* Color definitions, by default the i-th color is used for the i-th syntax