From ee3ded959f5486e921e45ac6753b21c2fcd63f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 8 Sep 2014 21:58:50 +0200 Subject: Improve undo/redo Currently a snapshot is taken whenever an operator is completed or a certain idle time in either insert or replace mode is detected. --- main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 7078f44..28b72c5 100644 --- a/main.c +++ b/main.c @@ -47,6 +47,7 @@ struct Mode { void (*leave)(Mode *new); bool (*unknown)(Key *key0, Key *key1); /* unknown key for this mode, return value determines whether parent modes will be checked */ bool (*input)(const char *str, size_t len); /* unknown key for this an all parent modes */ + void (*idle)(void); }; typedef struct { @@ -263,7 +264,8 @@ int main(int argc, char *argv[]) { } if (!FD_ISSET(STDIN_FILENO, &fds)) { - vis_snapshot(vis); + if (mode->idle) + mode->idle(); timeout = NULL; continue; } @@ -291,7 +293,9 @@ int main(int argc, char *argv[]) { if (key.code) continue; - if (mode->input && mode->input(key.str, strlen(key.str))) + if (mode->input) + mode->input(key.str, strlen(key.str)); + if (mode->idle) timeout = &idle; } -- cgit v1.2.3