Restore the terminal after exit (fix #14)

This commit is contained in:
Aaron Fischer 2018-10-25 14:03:31 +02:00
parent 77780bb6fb
commit 91bb40ebed

View file

@ -18,9 +18,15 @@ void die(const char *s) {
void disableRawMode() {
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1)
die("tcsetattr");
// Remove the alternate screen and restore the origin one
write(STDOUT_FILENO, "\x1b[?1049l", 8);
}
void enableRawMode() {
// Use the alternate screen
write(STDOUT_FILENO, "\x1b[?1049h", 8);
if (tcgetattr(STDIN_FILENO, &E.orig_termios) == -1)
die("tcgetattr");
atexit(disableRawMode);