28 lines
634 B
C
28 lines
634 B
C
#include "../include/terminal.h"
|
|
|
|
#include <termios.h>
|
|
#include <unistd.h>
|
|
|
|
static struct termios orig_termios;
|
|
|
|
void exit_raw_mode() {
|
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
|
|
}
|
|
|
|
void enter_raw_mode() {
|
|
tcgetattr(STDIN_FILENO, &orig_termios);
|
|
// atexit(exit_raw_mode); // zig is handling this step
|
|
struct termios raw = orig_termios;
|
|
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
|
|
raw.c_oflag &= ~(OPOST);
|
|
raw.c_cflag |= (CS8);
|
|
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
|
|
|
|
raw.c_cc[VMIN] = 0;
|
|
// raw.c_cc[VTIME] = 1;
|
|
|
|
|
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
|
|
}
|
|
|