mirror of git://git.sv.gnu.org/nano.git
verbatim: do not report "Invalid code" when the terminal is resized
During verbatim input at most four integers are produced (the longest
possible unicode sequence), so use the value 999 to indicate a special
condition (a screen resize) that should not enter anything into the
buffer AND should not produce any error message or beep.
This fixes https://savannah.gnu.org/bugs/?58923.
Bug existed since version 5.0, commit 5899181a
.
This commit is contained in:
parent
be20383240
commit
8e226a9f28
|
@ -200,9 +200,9 @@ void do_statusbar_verbatim_input(void)
|
|||
|
||||
bytes = get_verbatim_kbinput(bottomwin, &count);
|
||||
|
||||
if (count > 0)
|
||||
if (0 < count && count < 999)
|
||||
inject_into_answer(bytes, count);
|
||||
else
|
||||
else if (count == 0)
|
||||
beep();
|
||||
|
||||
free(bytes);
|
||||
|
|
|
@ -3016,15 +3016,17 @@ void do_verbatim_input(void)
|
|||
|
||||
/* When something valid was obtained, unsuppress cursor-position display,
|
||||
* insert the bytes into the edit buffer, and blank the status bar. */
|
||||
if (count > 0) {
|
||||
if (0 < count && count < 999) {
|
||||
if (ISSET(CONSTANT_SHOW))
|
||||
lastmessage = VACUUM;
|
||||
|
||||
inject(bytes, count);
|
||||
wipe_statusbar();
|
||||
} else
|
||||
} else if (count == 0)
|
||||
/* TRANSLATORS: An invalid verbatim Unicode code was typed. */
|
||||
statusline(ALERT, _("Invalid code"));
|
||||
else
|
||||
wipe_statusbar();
|
||||
|
||||
free(bytes);
|
||||
}
|
||||
|
|
16
src/winio.c
16
src/winio.c
|
@ -1375,7 +1375,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
|
|||
#ifndef NANO_TINY
|
||||
/* When the window was resized, abort and return nothing. */
|
||||
if (keycode == KEY_WINCH) {
|
||||
*count = 0;
|
||||
*count = 999;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -1397,6 +1397,12 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
|
|||
unicode = assemble_unicode(keycode);
|
||||
}
|
||||
|
||||
if (keycode == KEY_WINCH) {
|
||||
*count = 999;
|
||||
free(yield);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* For an invalid digit, discard its possible continuation bytes. */
|
||||
if (unicode == INVALID_DIGIT)
|
||||
while (key_buffer_len > 0 && 0x7F < *key_buffer && *key_buffer < 0xC0)
|
||||
|
@ -1480,9 +1486,11 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
|
|||
keypad(bottomwin, TRUE);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < *count; i++)
|
||||
bytes[i] = (char)input[i];
|
||||
bytes[*count] = '\0';
|
||||
if (*count < 999) {
|
||||
for (size_t i = 0; i < *count; i++)
|
||||
bytes[i] = (char)input[i];
|
||||
bytes[*count] = '\0';
|
||||
}
|
||||
|
||||
free(input);
|
||||
|
||||
|
|
Loading…
Reference in New Issue