summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2016-04-05 15:30:19 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2016-04-05 15:52:17 -0700
commit24f8bcc162ad68cd24f49b9bf80f3396aa97255f (patch)
tree1335c796814178b40c68c730cda05cdd68cdc7bd
parent8d94b43ef7d04225b9104ea286d88cc09d873919 (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.c2
-rw-r--r--tty.c8
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))