Skip to content

Commit

Permalink
Map CR to NL
Browse files Browse the repository at this point in the history
Instead of explicitly list all key bindings that could be either CR or
NL, make use of the ICRNL input mode.
  • Loading branch information
mptre committed Jun 18, 2017
1 parent f37e5e8 commit 42467e5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pick.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ tty_init(void)

tcgetattr(fileno(tty_in), &original_attributes);
new_attributes = original_attributes;
new_attributes.c_iflag |= ICRNL; /* map CR to NL */
new_attributes.c_lflag &= ~(ICANON | ECHO);
tcsetattr(fileno(tty_in), TCSANOW, &new_attributes);

Expand Down Expand Up @@ -794,7 +795,6 @@ get_key(char *buf, size_t size, size_t *nread)
size_t length;
} keys[] = {
KEY(ALT_ENTER, "\033\n"),
KEY(ALT_ENTER, "\033\r"),
KEY(BACKSPACE, "\177"),
KEY(CTRL_A, "\001"),
KEY(CTRL_E, "\005"),
Expand All @@ -808,7 +808,6 @@ get_key(char *buf, size_t size, size_t *nread)
KEY(DOWN, "\033OB"),
KEY(DOWN, "\033[B"),
KEY(ENTER, "\n"),
KEY(ENTER, "\r"),
KEY(LEFT, "\002"),
KEY(LEFT, "\033OD"),
KEY(LEFT, "\033[D"),
Expand Down

0 comments on commit 42467e5

Please sign in to comment.