Removes use of the alternate screen, leaves terminal in better state
This commit is contained in:
parent
f3f18eb712
commit
db3cce1d28
3
config.h
3
config.h
|
@ -9,9 +9,6 @@
|
|||
// Set global tab width for the editor here
|
||||
static const int tabwidth = 4;
|
||||
|
||||
// Enable use of the "alternate screen" in the terminal
|
||||
static const int use_alternate_screen = 1; // use as bool (0 or 1)
|
||||
|
||||
/*
|
||||
* Values from 1 to 256 representing 256 color/8-bit pallate
|
||||
* see: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
||||
|
|
7
hermes.c
7
hermes.c
|
@ -116,8 +116,8 @@ char *editorPrompt(char *prompt);
|
|||
// terminal
|
||||
// --------
|
||||
void die(const char *s) {
|
||||
write(STDOUT_FILENO, "\033[m", 3);
|
||||
write(STDOUT_FILENO, "\033[2J", 4);
|
||||
write(STDOUT_FILENO, "\033[H", 3);
|
||||
perror(s);
|
||||
write(STDOUT_FILENO, "\r", 1);
|
||||
exit(1);
|
||||
|
@ -126,14 +126,12 @@ void die(const char *s) {
|
|||
void quit() {
|
||||
write(STDOUT_FILENO, "\033[m", 3);
|
||||
write(STDOUT_FILENO, "\033[2J", 4);
|
||||
write(STDOUT_FILENO, "\033[H", 3);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void disableRawMode() {
|
||||
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1)
|
||||
die("tcsetattr");
|
||||
if (use_alternate_screen) write(STDOUT_FILENO, "\033[?47h", 6); // disable alt screen
|
||||
}
|
||||
|
||||
void enableRawMode() {
|
||||
|
@ -1533,9 +1531,6 @@ void handleSigWinCh(int unused __attribute__((unused))) {
|
|||
// init
|
||||
// ----
|
||||
void initEditor() {
|
||||
if (use_alternate_screen) {
|
||||
write(STDOUT_FILENO, "\033[?47h", 6);
|
||||
}
|
||||
E.mode = CommandMode;
|
||||
E.rowoff = 0;
|
||||
E.coloff = 0;
|
||||
|
|
Loading…
Reference in New Issue