dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 7da673b181625d295df8453c5d9ecaac72d77e06
parent 96aff05ac2072adb4c333970053d7faeca4f8636
Author: Mark Edgar <medgar123@gmail.com>
Date:   Tue, 24 Dec 2013 16:45:42 +0100

Do not write unsuppored KEY_* values as characters.

Diffstat:
vt.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/vt.c b/vt.c @@ -21,6 +21,7 @@ #include <errno.h> #include <fcntl.h> #include <langinfo.h> +#include <limits.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -222,6 +223,7 @@ static const char *keytable[KEY_MAX+1] = { [KEY_F(21)] = "\e[33~", [KEY_F(22)] = "\e[34~", [KEY_RESIZE] = "", + [KEY_EVENT] = "", }; static void puttab(Vt *t, int count); @@ -1636,11 +1638,9 @@ static void send_curs(Vt *t) void vt_keypress(Vt *t, int keycode) { - char c = (char)keycode; - vt_noscroll(t); - if (keycode >= 0 && keycode < KEY_MAX && keytable[keycode]) { + if (keycode >= 0 && keycode <= KEY_MAX && keytable[keycode]) { switch (keycode) { case KEY_UP: case KEY_DOWN: @@ -1653,8 +1653,13 @@ void vt_keypress(Vt *t, int keycode) default: vt_write(t, keytable[keycode], strlen(keytable[keycode])); } - } else { + } else if (keycode <= UCHAR_MAX) { + char c = keycode; vt_write(t, &c, 1); + } else { +#ifndef NDEBUG + fprintf(stderr, "unhandled key %#o\n", keycode); +#endif } }