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.
master
Benno Schulenberg 2020-01-23 12:32:28 +01:00
parent a65f0ec80c
commit fa686457c2
4 changed files with 13 additions and 1 deletions

View File

@ -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. */

View File

@ -2570,6 +2570,10 @@ int main(int argc, char **argv)
while (TRUE) {
#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);

View File

@ -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;

View File

@ -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) {