[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH] input: ignore any <Escape>s before a valid command
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH] input: ignore any <Escape>s before a valid command keystroke |
Date: |
Sun, 8 Jul 2018 18:09:09 +0200 |
Just like an <Esc> before a Ctrl+letter keystroke is ignored, an <Esc>
before an Alt+letter keystroke should be ignored too -- it should not
be interpreted as if the user had typed <Esc> <Esc> letter.
[The trigger for this patch was that during my vacation I played with some
other editors, and in all of them a valid Ctrl+X or Alt+X keystroke would
fail to work if I had pressed <Esc> beforehand -- and one had to press
<Esc> sometimes, to discard a menu for example, so this happened quite
a lot. It was majorly frustrating.]
---
src/winio.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/winio.c b/src/winio.c
index 281488a8..613beb3c 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -385,7 +385,7 @@ int parse_kbinput(WINDOW *win)
if (escapes > 3)
escapes = 1;
/* Take note when an Esc arrived by itself. */
- solitary = (escapes == 1 && key_buffer_len == 0);
+ solitary = (key_buffer_len == 0);
return ERR;
}
@@ -476,12 +476,13 @@ int parse_kbinput(WINDOW *win)
}
} else {
if (digit_count == 0)
- /* Two escapes followed by a
non-decimal
- * digit (or a decimal digit
that would
- * create a byte sequence
greater than 2XX)
- * and there aren't any other
codes waiting:
- * control character sequence
mode. */
- retval =
get_control_kbinput(keycode);
+ /* Two escapes followed by a
non-digit: meta key
+ * or control character
sequence mode. */
+ if (!solitary) {
+ meta_key = TRUE;
+ retval = keycode;
+ } else
+ retval =
get_control_kbinput(keycode);
else {
/* An invalid digit in the
middle of a byte
* sequence: reset the byte
sequence counter
@@ -505,11 +506,13 @@ int parse_kbinput(WINDOW *win)
}
break;
case 3:
- if (key_buffer_len == 0)
+ if (key_buffer_len == 0) {
+ if (!solitary)
+ meta_key = TRUE;
/* Three escapes followed by a non-escape, and
no
* other codes are waiting: normal input mode.
*/
retval = keycode;
- else
+ } else
/* Three escapes followed by a non-escape, and
more
* codes are waiting: combined control
character and
* escape sequence mode. First interpret the
escape
--
2.17.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nano-devel] [PATCH] input: ignore any <Escape>s before a valid command keystroke,
Benno Schulenberg <=