init
This commit is contained in:
27
c-src/terminal_linux.c
Normal file
27
c-src/terminal_linux.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user