Browse code

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.

John Hawthorn authored on 05/04/2016 22:30:19
Showing 2 changed files

  • fzy.c index 9521739..273e9c8 100644
  • tty.c index 5293627..11c6de4 100644
... ...
@@ -157,7 +157,7 @@ static void run(tty_t *tty, choices_t *choices) {
157 157
 			clear(tty);
158 158
 			tty_close(tty);
159 159
 			exit(EXIT_FAILURE);
160
-		} else if (ch == 10) { /* Enter */
160
+		} else if (ch == 13) { /* CR */
161 161
 			clear(tty);
162 162
 
163 163
 			/* ttyout should be flushed before outputting on stdout */
... ...
@@ -30,11 +30,13 @@ void tty_init(tty_t *tty, const char *tty_filename) {
30 30
 	struct termios new_termios = tty->original_termios;
31 31
 
32 32
 	/*
33
-	 * Disable both of
33
+	 * Disable all of
34 34
 	 * ICANON  Canonical input (erase and kill processing).
35
-	 * ECHO    Enable echo.
36
-	 * ISIG    Enable signals from control characters
35
+	 * ECHO    Echo.
36
+	 * ISIG    Signals from control characters
37
+	 * ICRNL   Conversion of CR characters into NL
37 38
 	 */
39
+	new_termios.c_iflag &= ~(ICRNL);
38 40
 	new_termios.c_lflag &= ~(ICANON | ECHO | ISIG);
39 41
 
40 42
 	if (tcsetattr(tty->fdin, TCSANOW, &new_termios))