#include "termio.h" /* c_iflag bit masks */ #define ifl_RAW (~(IMAXBEL)) /* NOTE: the line below won't work, bad bitwise ops */ #define ifl_NOPARITY ((IGNPAR) & ~(PARMRK | INPCK | ISTRIP)) /* c_cflag bit masks */ #define cfl_NOPARITY (~(PARENB)) /* c_lflag bit masks */ #define lfl_RAW (~(ISIG | ICANON)) #define lfl_ECHO ((ECHO | ECHOE | ECHOK | ECHONL | ECHO)) // & ~(ECHOCTL | ECHOPRT | ECHOKE)) int termmode_raw(struct ct_term *restrict const term) { term->termios.c_lflag &= lfl_RAW & ~(lfl_ECHO); ct_applyterm(term); return OK; } int termmode_canon(struct ct_term *restrict const term) { term->termios.c_lflag &= (ISIG); return OK; } /* Set ncurses terminal mode (buffering, character processing, * Key->SIG handling, and other termios(3) functionality). */ static inline int termmode(struct ct_term *restrict const term, const enum crs_termmode mode) { switch (mode) { case TMODE_RAW: return termmode_raw(term); case TMODE_CANON: return termmode_canon(term); /* ITS A CANON EVENT OHMAHGOH */ default: /* defaulting is not possible. */ return 1; } }