From 81581b190578795f9fc4c053f74f48c6ea4d9ad7 Mon Sep 17 00:00:00 2001 From: night0721 Date: Sun, 27 Oct 2024 01:28:30 +0000 Subject: [PATCH] Weirdly alternate buffer works --- src/io.c | 5 +---- src/term.c | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/io.c b/src/io.c index 3f46205..c9b337d 100644 --- a/src/io.c +++ b/src/io.c @@ -171,8 +171,6 @@ void process_key() switch (cmd[0]) { case 'q': if (cmd[1] == '!') { - write(STDOUT_FILENO, "\x1b[2J", 4); - write(STDOUT_FILENO, "\x1b[H", 3); exit(0); break; } else { @@ -181,8 +179,7 @@ void process_key() vip.mode = NORMAL; return; } - write(STDOUT_FILENO, "\x1b[2J", 4); - write(STDOUT_FILENO, "\x1b[H", 3); + exit(0); break; diff --git a/src/term.c b/src/term.c index 2146b6b..94f7869 100644 --- a/src/term.c +++ b/src/term.c @@ -10,8 +10,7 @@ extern editor vip; void die(const char *s) { - write(STDOUT_FILENO, "\x1b[2J", 4); - write(STDOUT_FILENO, "\x1b[H", 3); + write(STDOUT_FILENO, "\x1b[2J\x1b[H", 7); perror(s); exit(1); } @@ -21,6 +20,7 @@ void reset_term() if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &vip.termios) == -1) { die("tcsetattr"); } + write(STDOUT_FILENO, "\x1b[2J\x1b[?1049l", 12); } /* @@ -28,6 +28,7 @@ void reset_term() */ void setup_term() { + write(STDOUT_FILENO, "\x1b[?1049h\x1b[2J", 12); if (tcgetattr(STDIN_FILENO, &vip.termios) == -1) { die("tcgetattr"); }