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))
|
#define lfl_ECHO ((ECHO | ECHOE | ECHOK | ECHONL | ECHO))
|
||||||
// & ~(ECHOCTL | ECHOPRT | ECHOKE))
|
// & ~(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) {
|
int termmode_raw(struct ct_term *restrict const term) {
|
||||||
term->termios.c_lflag &= lfl_RAW & ~(lfl_ECHO);
|
term->termios.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
|
||||||
ct_applyterm(term);
|
term->termios.c_oflag &= ~OPOST;
|
||||||
return OK;
|
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) {
|
int termmode_canon(struct ct_term *restrict const term) {
|
||||||
term->termios.c_lflag &= (ISIG);
|
/* TODO: inverse of termmode_raw */
|
||||||
return OK;
|
term->termios.c_lflag &= ~lfl_RAW & lfl_ECHO;
|
||||||
|
return ct_applyterm(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set ncurses terminal mode (buffering, character processing,
|
/* Set ncurses terminal mode (buffering, character processing,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue