diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-15 17:14:01 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-15 17:14:01 +0200 |
| commit | aaaaaa5ad6a93101d38800467fe3750b35fed6ea (patch) | |
| tree | 8cd7b7561f3e923a382e5f97b4bd0fbe5fd68c39 /miscutils | |
| parent | e58b44755dbac7c55bf602f7f76dfb37b47323f5 (diff) | |
| download | busybox-w32-aaaaaa5ad6a93101d38800467fe3750b35fed6ea.tar.gz busybox-w32-aaaaaa5ad6a93101d38800467fe3750b35fed6ea.tar.bz2 busybox-w32-aaaaaa5ad6a93101d38800467fe3750b35fed6ea.zip | |
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>
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/less.c | 12 | ||||
| -rw-r--r-- | miscutils/microcom.c | 14 |
2 files changed, 8 insertions, 18 deletions
diff --git a/miscutils/less.c b/miscutils/less.c index d524b6c87..c6c158a51 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
| @@ -1824,15 +1824,9 @@ int less_main(int argc, char **argv) | |||
| 1824 | G.kbd_fd_orig_flags = ndelay_on(tty_fd); | 1824 | G.kbd_fd_orig_flags = ndelay_on(tty_fd); |
| 1825 | kbd_fd = tty_fd; /* save in a global */ | 1825 | kbd_fd = tty_fd; /* save in a global */ |
| 1826 | 1826 | ||
| 1827 | tcgetattr(kbd_fd, &term_orig); | 1827 | get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL); |
| 1828 | term_less = term_orig; | 1828 | |
| 1829 | term_less.c_lflag &= ~(ICANON | ECHO); | 1829 | IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line); |
| 1830 | term_less.c_iflag &= ~(IXON | ICRNL); | ||
| 1831 | /*term_less.c_oflag &= ~ONLCR;*/ | ||
| 1832 | term_less.c_cc[VMIN] = 1; | ||
| 1833 | term_less.c_cc[VTIME] = 0; | ||
| 1834 | |||
| 1835 | IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(kbd_fd, &width, &max_displayed_line); | ||
| 1836 | /* 20: two tabstops + 4 */ | 1830 | /* 20: two tabstops + 4 */ |
| 1837 | if (width < 20 || max_displayed_line < 3) | 1831 | if (width < 20 || max_displayed_line < 3) |
| 1838 | return bb_cat(argv); | 1832 | return bb_cat(argv); |
diff --git a/miscutils/microcom.c b/miscutils/microcom.c index b87f3273f..fa090057e 100644 --- a/miscutils/microcom.c +++ b/miscutils/microcom.c | |||
| @@ -33,15 +33,11 @@ | |||
| 33 | // set raw tty mode | 33 | // set raw tty mode |
| 34 | static void xget1(int fd, struct termios *t, struct termios *oldt) | 34 | static void xget1(int fd, struct termios *t, struct termios *oldt) |
| 35 | { | 35 | { |
| 36 | //TODO: use set_termios_to_raw() | 36 | get_termios_and_make_raw(fd, t, oldt, 0 |
| 37 | tcgetattr(fd, oldt); | 37 | | TERMIOS_CLEAR_ISIG /* ^C is ASCII char 3, not "interrupt me!" */ |
| 38 | *t = *oldt; | 38 | | TERMIOS_RAW_INPUT /* pass all chars verbatim, no special handling or translating CR->NL */ |
| 39 | cfmakeraw(t); | 39 | | TERMIOS_RAW_CRNL /* dont convert NL<->CR on output too */ |
| 40 | // t->c_lflag &= ~(ISIG|ICANON|ECHO|IEXTEN); | 40 | ); |
| 41 | // t->c_iflag &= ~(BRKINT|IXON|ICRNL); | ||
| 42 | // t->c_oflag &= ~(ONLCR); | ||
| 43 | // t->c_cc[VMIN] = 1; | ||
| 44 | // t->c_cc[VTIME] = 0; | ||
| 45 | } | 41 | } |
| 46 | 42 | ||
| 47 | static int xset1(int fd, struct termios *tio, const char *device) | 43 | static int xset1(int fd, struct termios *tio, const char *device) |
