vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 233fdad930ed3292d846b36fbe1af1d177d1bf85 parent fb54681aa2383e4f40210c5e10bded6b399bea8f Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 30 Sep 2014 16:26:55 +0200 Allow to supend the editor via CTRL-Z Diffstat:
| M | config.def.h | | | 1 | + |
| M | vis.c | | | 8 | ++++++++ |
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/config.def.h b/config.def.h @@ -93,6 +93,7 @@ static bool vis_keypress(Key *key) { } static KeyBinding basic_movement[] = { + { { CONTROL('Z') }, suspend, { NULL } }, { { KEY(LEFT) }, movement, { .i = MOVE_CHAR_PREV } }, { { KEY(SLEFT) }, movement, { .i = MOVE_LONGWORD_START_PREV } }, { { KEY(RIGHT) }, movement, { .i = MOVE_CHAR_NEXT } }, diff --git a/vis.c b/vis.c @@ -372,6 +372,8 @@ static TextObject *moves_linewise[] = { }; /** functions to be called from keybindings */ +/* temporarily suspend the editor and return to the shell, type 'fg' to get back */ +static void suspend(const Arg *arg); /* switch to mode indicated by arg->i */ static void switchmode(const Arg *arg); /* set mark indicated by arg->i to current cursor position */ @@ -768,6 +770,11 @@ static size_t window_lines_bottom(const Arg *arg) { /** key bindings functions of type: void (*func)(const Arg*) */ +static void suspend(const Arg *arg) { + endwin(); + raise(SIGSTOP); +} + static void repeat(const Arg *arg) { action = action_prev; action_do(&action); @@ -1512,6 +1519,7 @@ static void setup() { sigemptyset(&sa.sa_mask); sa.sa_handler = sigwinch_handler; sigaction(SIGWINCH, &sa, NULL); + sigaction(SIGCONT, &sa, NULL); } static bool keymatch(Key *key0, Key *key1) {