aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-01-14 14:19:32 -0800
committerRob Landley <rob@landley.net>2020-01-14 20:53:24 -0600
commitdf3238e86581007f266f0639c2a2ac30ee526dfd (patch)
tree05082ae18e6d206e7379efec9617be038613cca6
parent24ae8229485aaa67b2e93643750676351f228242 (diff)
downloadtoybox-df3238e86581007f266f0639c2a2ac30ee526dfd.tar.gz
vi: don't exit on ^C or ^D.
^D is the opposite of ^U in vi (the ^D/^U pair is the half-screen version of ^F/^B). ^C is unbound in vi. It's pretty surprising for these to cause toybox vi to exit, and it's annoying as long as toybox vi unconditionally exits rather than checks whether there are unsaved modifications! (I'm tempted to implement ^D/^U and ^F/^B, but I don't want to make Jarno's rebase of his in-progress changes any harder.)
-rw-r--r--toys/pending/vi.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/toys/pending/vi.c b/toys/pending/vi.c
index 9906ca93..2fb6d442 100644
--- a/toys/pending/vi.c
+++ b/toys/pending/vi.c
@@ -909,9 +909,11 @@ void vi_main(void)
draw_page();
- while(1) {
+ for (;;) {
int key = scan_key(keybuf, -1);
+ if (key == -1) goto cleanup_vi;
+
terminal_size(&TT.screen_width, &TT.screen_height);
TT.screen_height -= 2; //TODO this is hack fix visual alignment
@@ -926,12 +928,6 @@ void vi_main(void)
continue;
}
- switch (key) {
- case -1:
- case 3:
- case 4:
- goto cleanup_vi;
- }
if (TT.vi_mode == 1) { //NORMAL
switch (key) {
case '/':