1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-28 03:06:20 -04:00

terminal: In the ESC timeout, don't assume merely ESC was pressed.

If there is e.g. ESC [ in the input buffer, combine that to Alt-[.
Check the first character too; don't blindly assume it is ESC, as
it can be NUL as well.  Note this means you can no longer activate
the main menu by pressing Ctrl-@ (or Ctrl-Space on some terminals).
This commit is contained in:
Kalle Olavi Niemitalo 2006-07-28 15:55:28 +03:00 committed by Miciah Dashiel Butler Masters
parent fbd84630ac
commit 62c0bff87e

View File

@ -800,6 +800,10 @@ set_kbd_event(struct term_event *ev, int key, int modifier)
key = KBD_ENTER;
break;
case ASCII_ESC:
key = KBD_ESC;
break;
default:
if (key < ' ') {
key += 'A' - 1;
@ -814,6 +818,7 @@ static void
kbd_timeout(struct itrm *itrm)
{
struct term_event ev;
int el;
itrm->timer = TIMER_ID_UNDEF;
@ -826,11 +831,19 @@ kbd_timeout(struct itrm *itrm)
return;
}
set_kbd_term_event(&ev, KBD_ESC, KBD_MOD_NONE);
if (itrm->in.queue.len >= 2 && itrm->in.queue.data[0] == ASCII_ESC) {
/* This is used for ESC [ and ESC O. */
set_kbd_event(&ev, itrm->in.queue.data[1], KBD_MOD_ALT);
el = 2;
} else {
set_kbd_event(&ev, itrm->in.queue.data[0], KBD_MOD_NONE);
el = 1;
}
itrm_queue_event(itrm, (char *) &ev, sizeof(ev));
if (--itrm->in.queue.len)
memmove(itrm->in.queue.data, itrm->in.queue.data + 1, itrm->in.queue.len);
itrm->in.queue.len -= el;
if (itrm->in.queue.len)
memmove(itrm->in.queue.data, itrm->in.queue.data + el, itrm->in.queue.len);
while (process_queue(itrm));
}