diff --git a/src/global.c b/src/global.c index d6005be3..4289c8cb 100644 --- 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 index dcbbc1fc..44fa2d93 100644 --- a/src/nano.c +++ b/src/nano.c @@ -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); diff --git a/src/proto.h b/src/proto.h index f3c21b50..db9a7d09 100644 --- 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 index 516091ad..22dbb0ac 100644 --- 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) {