Restore the terminal after exit (fix #14)
This commit is contained in:
parent
77780bb6fb
commit
91bb40ebed
1 changed files with 6 additions and 0 deletions
|
@ -18,9 +18,15 @@ void die(const char *s) {
|
||||||
void disableRawMode() {
|
void disableRawMode() {
|
||||||
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1)
|
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1)
|
||||||
die("tcsetattr");
|
die("tcsetattr");
|
||||||
|
|
||||||
|
// Remove the alternate screen and restore the origin one
|
||||||
|
write(STDOUT_FILENO, "\x1b[?1049l", 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableRawMode() {
|
void enableRawMode() {
|
||||||
|
// Use the alternate screen
|
||||||
|
write(STDOUT_FILENO, "\x1b[?1049h", 8);
|
||||||
|
|
||||||
if (tcgetattr(STDIN_FILENO, &E.orig_termios) == -1)
|
if (tcgetattr(STDIN_FILENO, &E.orig_termios) == -1)
|
||||||
die("tcgetattr");
|
die("tcgetattr");
|
||||||
atexit(disableRawMode);
|
atexit(disableRawMode);
|
||||||
|
|
Loading…
Reference in a new issue