From bdbf0fe2ad9249ae6672d4ee8caf0ce73ddca409 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 1 Feb 2014 13:47:36 +1000 Subject: Check for lone escapes a little differently. --- handlekeys.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/handlekeys.c b/handlekeys.c index 030c933..2d30d53 100644 --- a/handlekeys.c +++ b/handlekeys.c @@ -185,7 +185,7 @@ void handle_keys(long extra, struct sigaction sigAction, oldSigAction; sigset_t signalMask; char buffer[20], sequence[20]; - int buffIndex = 0; + int buffIndex = 0, pendingEsc = 0; buffer[0] = 0; sequence[0] = 0; @@ -241,7 +241,7 @@ void handle_keys(long extra, } else if (0 == p) // A timeout, trigger a time event. { - if ((0 == buffer[1]) && ('\x1B' == buffer[0])) + if (pendingEsc) { // After a short delay to check, this is a real Escape key, // not part of an escape sequence, so deal with it. @@ -287,6 +287,10 @@ void handle_keys(long extra, } } + // Check for lone Esc first, wait a bit longer if it is + pendingEsc = ((0 == buffer[1]) && ('\x1B' == buffer[0])); + if (pendingEsc) continue; + // Check if it's a CSI before we check for the known key sequences. if ('\x9B' == buffer[0]) csi = 1; -- cgit v1.1