Weirdly alternate buffer works

This commit is contained in:
Night Kaly 2024-10-27 01:28:30 +00:00
parent f6eaf81d8c
commit 81581b1905
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
2 changed files with 4 additions and 6 deletions

View file

@ -171,8 +171,6 @@ void process_key()
switch (cmd[0]) { switch (cmd[0]) {
case 'q': case 'q':
if (cmd[1] == '!') { if (cmd[1] == '!') {
write(STDOUT_FILENO, "\x1b[2J", 4);
write(STDOUT_FILENO, "\x1b[H", 3);
exit(0); exit(0);
break; break;
} else { } else {
@ -181,8 +179,7 @@ void process_key()
vip.mode = NORMAL; vip.mode = NORMAL;
return; return;
} }
write(STDOUT_FILENO, "\x1b[2J", 4);
write(STDOUT_FILENO, "\x1b[H", 3);
exit(0); exit(0);
break; break;

View file

@ -10,8 +10,7 @@ extern editor vip;
void die(const char *s) void die(const char *s)
{ {
write(STDOUT_FILENO, "\x1b[2J", 4); write(STDOUT_FILENO, "\x1b[2J\x1b[H", 7);
write(STDOUT_FILENO, "\x1b[H", 3);
perror(s); perror(s);
exit(1); exit(1);
} }
@ -21,6 +20,7 @@ void reset_term()
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &vip.termios) == -1) { if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &vip.termios) == -1) {
die("tcsetattr"); die("tcsetattr");
} }
write(STDOUT_FILENO, "\x1b[2J\x1b[?1049l", 12);
} }
/* /*
@ -28,6 +28,7 @@ void reset_term()
*/ */
void setup_term() void setup_term()
{ {
write(STDOUT_FILENO, "\x1b[?1049h\x1b[2J", 12);
if (tcgetattr(STDIN_FILENO, &vip.termios) == -1) { if (tcgetattr(STDIN_FILENO, &vip.termios) == -1) {
die("tcgetattr"); die("tcgetattr");
} }