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]) {
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;

View file

@ -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");
}