From ec85525a5510b3b861be99b9830b2876d18158d5 Mon Sep 17 00:00:00 2001 From: jmug Date: Fri, 9 Oct 2026 20:24:43 -0700 Subject: [PATCH] feat: Global config struct. --- kilo.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kilo.c b/kilo.c index bb2dd3f..14d18af 100644 --- a/kilo.c +++ b/kilo.c @@ -13,7 +13,11 @@ /*** data ***/ -struct termios orig_termios; +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);