From 24f8bcc162ad68cd24f49b9bf80f3396aa97255f Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 5 Apr 2016 15:30:19 -0700 Subject: Unset ICRNL on tty I get a few reports of enter not working with fzy occasionally. This usually occurrs after running a badly behaved program which doesn't clean up the tty properly (looking at you, pry) after cleaning the ICRNL flag. This commit now always unsets ICRNL. This also could have been fixed by ensuring ICRNL was set, but I believe this will give more control over keybindings. --- fzy.c | 2 +- tty.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fzy.c b/fzy.c index 9521739..273e9c8 100644 --- a/fzy.c +++ b/fzy.c @@ -157,7 +157,7 @@ static void run(tty_t *tty, choices_t *choices) { clear(tty); tty_close(tty); exit(EXIT_FAILURE); - } else if (ch == 10) { /* Enter */ + } else if (ch == 13) { /* CR */ clear(tty); /* ttyout should be flushed before outputting on stdout */ diff --git a/tty.c b/tty.c index 5293627..11c6de4 100644 --- a/tty.c +++ b/tty.c @@ -30,11 +30,13 @@ void tty_init(tty_t *tty, const char *tty_filename) { struct termios new_termios = tty->original_termios; /* - * Disable both of + * Disable all of * ICANON Canonical input (erase and kill processing). - * ECHO Enable echo. - * ISIG Enable signals from control characters + * ECHO Echo. + * ISIG Signals from control characters + * ICRNL Conversion of CR characters into NL */ + new_termios.c_iflag &= ~(ICRNL); new_termios.c_lflag &= ~(ICANON | ECHO | ISIG); if (tcsetattr(tty->fdin, TCSANOW, &new_termios)) -- cgit v1.2.3