~martanne/dvtm

7e8027149aa462a48401da31d04c347fd4a970a6 — Marc AndrĂ© Tanner 7 years ago fa9d946
Improve handling of Alt + Special key

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
1 files changed, 9 insertions(+), 1 deletions(-)

M dvtm.c
M dvtm.c => dvtm.c +9 -1
@@ 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);
	}



@@ 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;