Skip to content

Commit 190056b

Browse files
authored
Merge pull request #1471 from Darazaki/repl-ctrl-arrow
Add ctrl + left/right arrow support to the REPL
2 parents 3078686 + ae6b359 commit 190056b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/mainclient/shell.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ static int line() {
867867
if (write_console((char *) gbl_prompt, gbl_plen) == -1) return -1;
868868
for (;;) {
869869
char c;
870-
char seq[3];
870+
char seq[5];
871871

872872
int rc;
873873
do {
@@ -991,6 +991,20 @@ static int line() {
991991
default:
992992
break;
993993
}
994+
} else if (seq[2] == ';') {
995+
if (read_console(seq + 3, 2) == -1) break;
996+
if (seq[3] == '5') {
997+
switch (seq[4]) {
998+
case 'C': /* ctrl-right */
999+
krightw();
1000+
break;
1001+
case 'D': /* ctrl-left */
1002+
kleftw();
1003+
break;
1004+
default:
1005+
break;
1006+
}
1007+
}
9941008
}
9951009
} else if (seq[0] == 'O') {
9961010
if (read_console(seq + 1, 1) == -1) break;

0 commit comments

Comments
 (0)