This commit is contained in:
2026-03-02 08:09:02 +13:00
commit cdd88973dc
11 changed files with 1434 additions and 0 deletions

27
c-src/terminal_linux.c Normal file
View 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);
}