summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2021-01-21 21:00:22 -0700
committermo khan <mo.khan@gmail.com>2021-01-21 21:00:22 -0700
commitb554effdabf7d2529738bd93855df884e3e19c65 (patch)
treeeeedb844140eb936b18736090e1a17d85d9282c2
parentf7aa3bab725e09ad0e3337fe2f8320f5aa5057ea (diff)
create global struct
-rw-r--r--kilo.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/kilo.c b/kilo.c
index dd0ea1c..0ea1b77 100644
--- a/kilo.c
+++ b/kilo.c
@@ -13,7 +13,11 @@
/*** data ***/
-struct termios orig_termios;
+struct editor_config {
+ struct termios orig_termios;
+};
+
+struct editor_config E;
/*** terminal ***/
@@ -26,15 +30,15 @@ void die(const char *s) {
}
void disable_raw_mode() {
- if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios) == -1)
+ if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1)
die("tcsetattr");
}
void enable_raw_mode() {
- if (tcgetattr(STDIN_FILENO, &orig_termios) == -1) die("tcgetattr");
+ if (tcgetattr(STDIN_FILENO, &E.orig_termios) == -1) die("tcgetattr");
atexit(disable_raw_mode);
- struct termios raw = orig_termios;
+ struct termios raw = E.orig_termios;
raw.c_lflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_lflag &= ~(OPOST);
raw.c_lflag &= ~(CS8);