From 17d763c597ff9dd740a0c96acb7a83a56b228329 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sun, 28 Sep 2025 00:06:02 +1000 Subject: [PATCH] init ct_termio --- src/termio.c | 21 +++++++++++++++++++++ src/termio.h | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/termio.c create mode 100644 src/termio.h diff --git a/src/termio.c b/src/termio.c new file mode 100644 index 0000000..09c37ca --- /dev/null +++ b/src/termio.c @@ -0,0 +1,21 @@ +#include "termio.h" + +int termmode_raw(struct ct_term *restrict t) { + t->termios.c_lflag &= ~(ISIG); +} + +/* Set ncurses terminal mode (buffering, character processing, + * Key->SIG handling, and other termios(3) functionality). + */ +int termmode(struct ct_term *restrict t, const enum crs_termmode mode) { + switch (mode) { + case TMODE_RAW: + return raw(); + case TMODE_CANON: + return canon(); /* ITS A CANON EVENT OHMAHGOH */ + default: + /* defaulting is not possible. */ + return 1; + } +} + diff --git a/src/termio.h b/src/termio.h new file mode 100644 index 0000000..5a9bb1f --- /dev/null +++ b/src/termio.h @@ -0,0 +1,19 @@ +#ifndef CURSETREE_TERMIO_H +#define CURSETREE_TERMIO_H + +#include "term.h" + +enum crs_termmode { + /* tty cbreak mode */ + TMODE_CBREAK, + /* tty canonical mode */ + TMODE_CANON, + /* tty raw mode */ + TMODE_RAW, + /* tty cooked mode (ISIG & IXON not modified)*/ + TMODE_NOCBREAK, + /* tty cooked mode (ISIG & IXON set) */ + TMODE_NORAW, +}; + +#endif /* CURSETREE_TERMIO_H */