Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new CAP() macro for arrow keys #206

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions pick.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ tty_init(void)
if (use_alternate_screen)
tty_putp(enter_ca_mode, 0);

tty_putp(keypad_xmit, 0);

signal(SIGINT, handle_sigint);
}

Expand All @@ -677,6 +679,7 @@ tty_restore(void)
tcsetattr(fileno(tty_in), TCSANOW, &original_attributes);
fclose(tty_in);

tty_putp(keypad_local, 0);
tty_putp(carriage_return, 1); /* move cursor to first column */
tty_putp(clr_eos, 1);

Expand Down Expand Up @@ -824,30 +827,25 @@ get_key(char *buf, size_t size, size_t *nread)
KEY(CTRL_K, "\013"),
KEY(CTRL_U, "\025"),
KEY(CTRL_W, "\027"),
CAP(DEL, "kdch1"),
KEY(DEL, "\004"),
KEY(DEL, "\033O3~"),
KEY(DEL, "\033[3~"),
CAP(DOWN, "kcud1"),
KEY(DOWN, "\016"),
KEY(DOWN, "\033OB"),
KEY(DOWN, "\033[B"),
CAP(END, "kend"),
KEY(END, "\033>"),
KEY(ENTER, "\n"),
CAP(HOME, "khome"),
KEY(HOME, "\033<"),
CAP(LEFT, "kcub1"),
KEY(LEFT, "\002"),
KEY(LEFT, "\033OD"),
KEY(LEFT, "\033[D"),
CAP(PAGE_DOWN, "knp"),
KEY(PAGE_DOWN, "\026"),
KEY(PAGE_DOWN, "\033[6~"),
CAP(PAGE_UP, "kpp"),
KEY(PAGE_UP, "\033v"),
KEY(PAGE_UP, "\033[5~"),
CAP(RIGHT, "kcuf1"),
KEY(RIGHT, "\006"),
KEY(RIGHT, "\033OC"),
KEY(RIGHT, "\033[C"),
CAP(UP, "kcuu1"),
KEY(UP, "\020"),
KEY(UP, "\033OA"),
KEY(UP, "\033[A"),
KEY(UNKNOWN, NULL),
};
int c, i;
Expand Down
2 changes: 1 addition & 1 deletion tests/03.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: backspace
keys: abb \177 \b c \\n ## BACKSPACE BACKSPACE ENTER
keys: ab \b c \\n ## BACKSPACE BACKSPACE ENTER
stdin:
ab
ac
Expand Down
2 changes: 1 addition & 1 deletion tests/05.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: down arrow
keys: \033[B \\n # DOWN ENTER
keys: \033OB \\n # DOWN ENTER
stdin:
1
2
Expand Down
2 changes: 1 addition & 1 deletion tests/10.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: UTF-8 backspace
keys: ö \177 \\n # BACKSPACE ENTER
keys: ö \b \\n # BACKSPACE ENTER
stdin:
å
ä
Expand Down