diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2013-03-26 14:14:08 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2013-03-26 14:14:08 +0000 |
commit | dfac36b6c3d72ac3732ec2c638b8bae16d1a01ae (patch) | |
tree | e5b32e543d20dde34d3854ca48f08c608044fc95 /tty-keys.c | |
parent | 771d7db3a6e19cd773b2f1a2547ec3db5f75b07f (diff) | |
download | rtmux-dfac36b6c3d72ac3732ec2c638b8bae16d1a01ae.tar.gz rtmux-dfac36b6c3d72ac3732ec2c638b8bae16d1a01ae.tar.bz2 rtmux-dfac36b6c3d72ac3732ec2c638b8bae16d1a01ae.zip |
Only accept partial keys if the timer has not expired, fixes infinite
loop when Escape is pressed the wrong number of times.
Diffstat (limited to 'tty-keys.c')
-rw-r--r-- | tty-keys.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -448,7 +448,7 @@ tty_keys_next(struct tty *tty) const char *buf; size_t len, size; cc_t bspace; - int key, delay; + int key, delay, expired = 0; /* Get key buffer. */ buf = EVBUFFER_DATA(tty->event->input); @@ -508,7 +508,7 @@ first_key: } tk = tty_keys_find(tty, buf + 1, len - 1, &size); - if (tk != NULL) { + if (tk != NULL && (!expired || tk->next == NULL)) { size++; /* include escape */ if (tk->next != NULL) goto partial_key; @@ -540,8 +540,10 @@ partial_key: /* If timer is going, check for expiration. */ if (tty->flags & TTY_TIMER) { if (evtimer_initialized(&tty->key_timer) && - !evtimer_pending(&tty->key_timer, NULL)) + !evtimer_pending(&tty->key_timer, NULL)) { + expired = 1; goto first_key; + } return (0); } |