mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05: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:
parent
fbd84630ac
commit
62c0bff87e
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user