feat: Global config struct.

This commit is contained in:
jmug
2026-10-09 20:24:43 -07:00
parent 07882d8ba5
commit ec85525a55
+7 -3
View File
@@ -13,7 +13,11 @@
/*** data ***/
struct editorConfig {
struct termios orig_termios;
};
struct editorConfig E;
/*** terminal ***/
@@ -28,16 +32,16 @@ void die(const char* s) {
}
void disableRawMode() {
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios) == -1)
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1)
die("tcsetattr");
}
void enableRawMode() {
if (tcgetattr(STDIN_FILENO, &orig_termios) == -1)
if (tcgetattr(STDIN_FILENO, &E.orig_termios) == -1)
die("tcgetattr");
atexit(disableRawMode);
struct termios raw = orig_termios;
struct termios raw = E.orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag &= ~(OPOST);