vis

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

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

commit 325665e27c33f45b6bacee5829715325d016b49a
parent 0c4fdf9298b44ba76f684a7d34085488850126e4
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon, 22 Sep 2014 05:46:46 +0200

Make idle timeout configurable per mode

Diffstat:
Mconfig.def.h | 2++
Mvis.c | 3++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/config.def.h b/config.def.h @@ -642,6 +642,7 @@ static Mode vis_modes[] = { .leave = vis_mode_insert_leave, .input = vis_mode_insert_input, .idle = vis_mode_insert_idle, + .idle_timeout = 3, }, [VIS_MODE_REPLACE] = { .name = "--REPLACE--", @@ -650,6 +651,7 @@ static Mode vis_modes[] = { .leave = vis_mode_replace_leave, .input = vis_mode_replace_input, .idle = vis_mode_insert_idle, + .idle_timeout = 3, }, }; diff --git a/vis.c b/vis.c @@ -74,6 +74,7 @@ struct Mode { the return value determines whether parent modes will be searched */ void (*input)(const char*, size_t); /* called whenever a key is not found in this mode and all its parent modes */ void (*idle)(void); /* called whenever a certain idle time i.e. without any user input elapsed */ + time_t idle_timeout; /* idle time in seconds after which the registered function will be called */ }; typedef struct { @@ -1354,7 +1355,7 @@ int main(int argc, char *argv[]) { editor_update(vis); doupdate(); - idle.tv_sec = 3; + idle.tv_sec = mode->idle_timeout; int r = select(1, &fds, NULL, NULL, timeout); if (r == -1 && errno == EINTR) continue;