less,microcom,lineedit: use common routine to set raw termios

function                                             old     new   delta
get_termios_and_make_raw                               -     139    +139
xget1                                                 39       8     -31
read_line_input                                     3912    3867     -45
less_main                                           2525    2471     -54
set_termios_to_raw                                   116      36     -80
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/4 up/down: 139/-210)          Total: -71 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2017-09-15 17:14:01 +02:00
parent e58b44755d
commit aaaaaa5ad6
5 changed files with 53 additions and 48 deletions

View File

@ -33,15 +33,11 @@
// set raw tty mode
static void xget1(int fd, struct termios *t, struct termios *oldt)
{
//TODO: use set_termios_to_raw()
tcgetattr(fd, oldt);
*t = *oldt;
cfmakeraw(t);
// t->c_lflag &= ~(ISIG|ICANON|ECHO|IEXTEN);
// t->c_iflag &= ~(BRKINT|IXON|ICRNL);
// t->c_oflag &= ~(ONLCR);
// t->c_cc[VMIN] = 1;
// t->c_cc[VTIME] = 0;
get_termios_and_make_raw(fd, t, oldt, 0
| TERMIOS_CLEAR_ISIG /* ^C is ASCII char 3, not "interrupt me!" */
| TERMIOS_RAW_INPUT /* pass all chars verbatim, no special handling or translating CR->NL */
| TERMIOS_RAW_CRNL /* dont convert NL<->CR on output too */
);
}
static int xset1(int fd, struct termios *tio, const char *device)