aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-08 21:58:50 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-08 21:58:50 +0200
commitee3ded959f5486e921e45ac6753b21c2fcd63f0f (patch)
tree69bbccd4f7babce44dad355ac0dcc1573e9fa895 /main.c
parente7b6ac1574ba4dad280e6a45beb52dac4e3ea2e9 (diff)
downloadvis-ee3ded959f5486e921e45ac6753b21c2fcd63f0f.tar.gz
vis-ee3ded959f5486e921e45ac6753b21c2fcd63f0f.tar.xz
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.
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 6 insertions, 2 deletions
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;
}