feat: Global config struct.
This commit is contained in:
@@ -13,7 +13,11 @@
|
|||||||
|
|
||||||
/*** data ***/
|
/*** data ***/
|
||||||
|
|
||||||
|
struct editorConfig {
|
||||||
struct termios orig_termios;
|
struct termios orig_termios;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct editorConfig E;
|
||||||
|
|
||||||
/*** terminal ***/
|
/*** terminal ***/
|
||||||
|
|
||||||
@@ -28,16 +32,16 @@ void die(const char* s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void disableRawMode() {
|
void disableRawMode() {
|
||||||
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios) == -1)
|
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1)
|
||||||
die("tcsetattr");
|
die("tcsetattr");
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableRawMode() {
|
void enableRawMode() {
|
||||||
if (tcgetattr(STDIN_FILENO, &orig_termios) == -1)
|
if (tcgetattr(STDIN_FILENO, &E.orig_termios) == -1)
|
||||||
die("tcgetattr");
|
die("tcgetattr");
|
||||||
atexit(disableRawMode);
|
atexit(disableRawMode);
|
||||||
|
|
||||||
struct termios raw = orig_termios;
|
struct termios raw = E.orig_termios;
|
||||||
|
|
||||||
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
|
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
|
||||||
raw.c_oflag &= ~(OPOST);
|
raw.c_oflag &= ~(OPOST);
|
||||||
|
|||||||
Reference in New Issue
Block a user