verbatim: pause a little after an ESC, to not miss a succeeding code
When we get an ESC from the keyboard, it might be the start of an escape sequence, but the keyboard routines will need a little time (tens of microseconds, probably) to get these codes to ncurses. So, when doing verbatim input, pause a moment after an ESC. This completes the fix for https://savannah.gnu.org/bugs/?58909.master
parent
b0e3767af5
commit
5fab1e6754
10
src/winio.c
10
src/winio.c
|
@ -49,6 +49,8 @@ static bool waiting_mode = TRUE;
|
||||||
/* Whether getting a character will wait for a key to be pressed. */
|
/* Whether getting a character will wait for a key to be pressed. */
|
||||||
static bool reveal_cursor = FALSE;
|
static bool reveal_cursor = FALSE;
|
||||||
/* Whether the cursor should be shown when waiting for input. */
|
/* Whether the cursor should be shown when waiting for input. */
|
||||||
|
static bool linger_after_escape = FALSE;
|
||||||
|
/* Whether to give ncurses some time to get the next code. */
|
||||||
static int statusblank = 0;
|
static int statusblank = 0;
|
||||||
/* The number of keystrokes left before we blank the status bar. */
|
/* The number of keystrokes left before we blank the status bar. */
|
||||||
#ifdef USING_OLD_NCURSES
|
#ifdef USING_OLD_NCURSES
|
||||||
|
@ -222,6 +224,11 @@ void read_keys_from(WINDOW *win)
|
||||||
/* Read in the remaining characters using non-blocking input. */
|
/* Read in the remaining characters using non-blocking input. */
|
||||||
nodelay(win, TRUE);
|
nodelay(win, TRUE);
|
||||||
|
|
||||||
|
/* When taking verbatim input, pause a moment after receiving an ESC,
|
||||||
|
* to give the keyboard some time to bring the next code to ncurses. */
|
||||||
|
if (linger_after_escape && input == ESC_CODE)
|
||||||
|
napms(20);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (recording)
|
if (recording)
|
||||||
|
@ -1371,10 +1378,13 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||||
int *kbinput;
|
int *kbinput;
|
||||||
|
|
||||||
reveal_cursor = TRUE;
|
reveal_cursor = TRUE;
|
||||||
|
linger_after_escape = TRUE;
|
||||||
|
|
||||||
/* Read in the first code. */
|
/* Read in the first code. */
|
||||||
kbinput = get_input(win, 1);
|
kbinput = get_input(win, 1);
|
||||||
|
|
||||||
|
linger_after_escape = FALSE;
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* When the window was resized, abort and return nothing. */
|
/* When the window was resized, abort and return nothing. */
|
||||||
if (*kbinput == KEY_WINCH) {
|
if (*kbinput == KEY_WINCH) {
|
||||||
|
|
Loading…
Reference in New Issue