diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2016-04-05 15:30:19 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2016-04-05 15:52:17 -0700 |
commit | 24f8bcc162ad68cd24f49b9bf80f3396aa97255f (patch) | |
tree | 1335c796814178b40c68c730cda05cdd68cdc7bd | |
parent | 8d94b43ef7d04225b9104ea286d88cc09d873919 (diff) |
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.
-rw-r--r-- | fzy.c | 2 | ||||
-rw-r--r-- | tty.c | 8 |
2 files changed, 6 insertions, 4 deletions
@@ -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 */ @@ -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)) |