Skip to content

Commit

Permalink
Improve handling of Alt + Special key
Browse files Browse the repository at this point in the history
Trying to treat curses symbolic key (KEY_*) constants normal chars is obviously
nonsense. In general the input handling code is a bit of a mess and needs to be
overhauled at some point.

This should fix Alt+Backspace handling.

Close #36
  • Loading branch information
martanne committed Jan 5, 2017
1 parent fa9d946 commit 7e80271
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dvtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,14 +866,20 @@ viewprevtag(const char *args[]) {

static void
keypress(int code) {
int key = -1;
unsigned int len = 1;
char buf[8] = { '\e' };

if (code == '\e') {
/* pass characters following escape to the underlying app */
nodelay(stdscr, TRUE);
for (int t; len < sizeof(buf) && (t = getch()) != ERR; len++)
for (int t; len < sizeof(buf) && (t = getch()) != ERR; len++) {
if (t > 255) {
key = t;
break;
}
buf[len] = t;
}
nodelay(stdscr, FALSE);
}

Expand All @@ -884,6 +890,8 @@ keypress(int code) {
vt_write(c->term, buf, len);
else
vt_keypress(c->term, code);
if (key != -1)
vt_keypress(c->term, key);
}
if (!runinall)
break;
Expand Down

0 comments on commit 7e80271

Please sign in to comment.