int get_terminal_width(int fd) FAST_FUNC;
int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC;
-#define TERMIOS_CLEAR_ISIG (1 << 0)
-#define TERMIOS_RAW_CRNL (1 << 1)
-#define TERMIOS_RAW_INPUT (1 << 2)
+#define TERMIOS_CLEAR_ISIG (1 << 0)
+#define TERMIOS_RAW_CRNL_INPUT (1 << 1)
+#define TERMIOS_RAW_CRNL_OUTPUT (1 << 2)
+#define TERMIOS_RAW_CRNL (TERMIOS_RAW_CRNL_INPUT|TERMIOS_RAW_CRNL_OUTPUT)
+#define TERMIOS_RAW_INPUT (1 << 3)
int get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) FAST_FUNC;
int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC;
newterm->c_cc[VMIN] = 1;
/* no timeout (reads block forever) */
newterm->c_cc[VTIME] = 0;
- if (flags & TERMIOS_RAW_CRNL) {
/* IXON, IXOFF, and IXANY:
* IXOFF=1: sw flow control is enabled on input queue:
* tty transmits a STOP char when input queue is close to full
* and resume sending if START is received, or if any char
* is received and IXANY=1.
*/
+ if (flags & TERMIOS_RAW_CRNL_INPUT) {
/* IXON=0: XON/XOFF chars are treated as normal chars (why we do this?) */
/* dont convert CR to NL on input */
newterm->c_iflag &= ~(IXON | ICRNL);
+ }
+ if (flags & TERMIOS_RAW_CRNL_OUTPUT) {
/* dont convert NL to CR+NL on output */
newterm->c_oflag &= ~(ONLCR);
/* Maybe clear more c_oflag bits? Usually, only OPOST and ONLCR are set.
#ifndef IXANY
# define IXANY 0
#endif
- /* IXOFF=0: disable sending XON/XOFF if input buf is full */
- /* IXON=0: input XON/XOFF chars are not special */
- /* dont convert anything on input */
+ /* IXOFF=0: disable sending XON/XOFF if input buf is full
+ * IXON=0: input XON/XOFF chars are not special
+ * BRKINT=0: dont send SIGINT on break
+ * IMAXBEL=0: dont echo BEL on input line too long
+ * INLCR,ICRNL,IUCLC: dont convert anything on input
+ */
newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL);
}
return r;
G.kbd_fd_orig_flags = ndelay_on(tty_fd);
kbd_fd = tty_fd; /* save in a global */
- get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL);
+ get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL_INPUT);
IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line);
/* 20: two tabstops + 4 */