commit fa686457c2dc0fddd4607de3468663721c2fb923
parent a65f0ec80ca2d00ff6b45ba9b27c731fd4778246
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 23 Jan 2020 12:32:28 +0100
input: ignore modifiers on a VT while executing a macro or a string bind
Any modifier keys that are needed to start the execution of a macro
(or of a string bind) should not affect the interpretation of the
keystrokes that are contained within the macro or the string.
This fixes https://savannah.gnu.org/bugs/?57660.
Bug existed since macros were introduced, in version 2.9.0.
Diffstat:
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/global.c b/src/global.c
@@ -40,8 +40,11 @@ bool meta_key;
/* Whether the current keystroke is a Meta key. */
bool shift_held;
/* Whether Shift was being held together with a movement key. */
+bool mute_modifiers = FALSE;
+ /* Whether to ignore modifier keys while running a macro or string bind. */
bool bracketed_paste = FALSE;
/* Whether text is being pasted into nano from outside. */
+
bool focusing = TRUE;
/* Whether an update of the edit window should center the cursor. */
diff --git a/src/nano.c b/src/nano.c
@@ -2571,6 +2571,10 @@ int main(int argc, char **argv)
#ifdef ENABLE_LINENUMBERS
confirm_margin();
#endif
+#ifdef __linux__
+ if (on_a_vt && get_key_buffer_len() == 0)
+ mute_modifiers = FALSE;
+#endif
if (currmenu != MMAIN)
bottombars(MMAIN);
diff --git a/src/proto.h b/src/proto.h
@@ -31,6 +31,7 @@ extern bool shifted_metas;
extern bool meta_key;
extern bool shift_held;
+extern bool mute_modifiers;
extern bool bracketed_paste;
extern bool focusing;
diff --git a/src/winio.c b/src/winio.c
@@ -115,6 +115,8 @@ void run_macro(void)
for (i = 0; i < macro_length; i++)
key_buffer[i] = macro_buffer[i];
+
+ mute_modifiers = TRUE;
}
#endif /* !NANO_TINY */
@@ -284,6 +286,8 @@ void implant(const char *string)
{
for (int i = strlen(string); i > 0; i--)
put_back((unsigned char)string[i - 1]);
+
+ mute_modifiers = TRUE;
}
#endif
@@ -586,7 +590,7 @@ int parse_kbinput(WINDOW *win)
unsigned char modifiers = 6;
/* Modifiers are: Alt (8), Ctrl (4), Shift (1). */
- if (on_a_vt && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
+ if (on_a_vt && !mute_modifiers && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
#ifndef NANO_TINY
/* Is Delete pressed together with Shift or Shift+Ctrl? */
if (retval == KEY_DC) {