improve term RAW mode (REF: glibc)
This commit is contained in:
parent
059606b5ef
commit
7ff74c0d67
1 changed files with 15 additions and 5 deletions
20
src/termio.c
20
src/termio.c
|
|
@ -13,15 +13,25 @@
|
|||
#define lfl_ECHO ((ECHO | ECHOE | ECHOK | ECHONL | ECHO))
|
||||
// & ~(ECHOCTL | ECHOPRT | ECHOKE))
|
||||
|
||||
/*
|
||||
* NOTE: This function is taken from the GNU C Library (glibc),
|
||||
* NOTE: specifically `glibc/termios/cfmakeraw.c`.
|
||||
*/
|
||||
int termmode_raw(struct ct_term *restrict const term) {
|
||||
term->termios.c_lflag &= lfl_RAW & ~(lfl_ECHO);
|
||||
ct_applyterm(term);
|
||||
return OK;
|
||||
term->termios.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
|
||||
term->termios.c_oflag &= ~OPOST;
|
||||
term->termios.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
|
||||
term->termios.c_cflag &= ~(CSIZE|PARENB);
|
||||
term->termios.c_cflag |= CS8;
|
||||
term->termios.c_cc[VMIN] = 1; /* read returns when one char is available. */
|
||||
term->termios.c_cc[VTIME] = 0;
|
||||
return ct_applyterm(term);
|
||||
}
|
||||
|
||||
int termmode_canon(struct ct_term *restrict const term) {
|
||||
term->termios.c_lflag &= (ISIG);
|
||||
return OK;
|
||||
/* TODO: inverse of termmode_raw */
|
||||
term->termios.c_lflag &= ~lfl_RAW & lfl_ECHO;
|
||||
return ct_applyterm(term);
|
||||
}
|
||||
|
||||
/* Set ncurses terminal mode (buffering, character processing,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue