From 8dc1b974650325704f4086a9ff3eaff5f6e6368f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 24 Jul 2020 13:38:44 +0200 Subject: [PATCH] tweaks: three escapes is the same as either zero escapes or one escape --- src/winio.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/winio.c b/src/winio.c index 9046eb9e..5540e10a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -925,14 +925,15 @@ int parse_kbinput(WINDOW *win) if (keycode == ERR) return ERR; - /* If it is an ESC, increment the counter, but trim an overabundance. */ + /* Remember whether an Esc arrived by itself, and increment + * its counter, rolling around on three escapes. */ if (keycode == ESC_CODE) { - if (++escapes > 3 || digit_count > 0) { + solitary = (key_buffer_len == 0); + if (digit_count > 0) { digit_count = 0; escapes = 1; - } - /* Take note when an Esc arrived by itself. */ - solitary = (key_buffer_len == 0); + } else if (++escapes > 2) + escapes = (solitary ? 0 : 1); return ERR; } @@ -1028,21 +1029,6 @@ int parse_kbinput(WINDOW *win) } escapes = 0; break; - case 3: - if (key_buffer_len == 0) { - if (!solitary) { - meta_key = TRUE; - retval = (shifted_metas) ? keycode : tolower(keycode); - } else - /* Three escapes followed by a non-escape, and no - * other codes are waiting: normal input mode. */ - retval = keycode; - } else - /* Three escapes followed by a non-escape, and more - * codes are waiting: escape sequence mode. */ - retval = parse_escape_sequence(keycode); - escapes = 0; - break; } if (retval == controlleft)