build: do not let Slang translate escape sequences to key codes

Slang fails to translate the longer sequences, and then truncates
these sequences to just four bytes, effectively destroying them.

Therefore, when built with --with-slang, always activate --raw-sequences.

This avoids https://savannah.gnu.org/bugs/?49771.

Bug was visible since version 2.5.0, since bindings
for Ctrl+Left/Ctrl+Right were added.
master
Benno Schulenberg 2020-09-17 16:40:07 +02:00
parent 3a22028042
commit e12f397140
2 changed files with 18 additions and 1 deletions

View File

@ -430,11 +430,13 @@ void window_init(void)
/* In case the terminal shrunk, make sure the status line is clear. */
wipe_statusbar();
#ifndef USE_SLANG
/* When not disabled, turn escape-sequence translation on. */
if (!ISSET(RAW_SEQUENCES)) {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
}
#endif
#ifdef ENABLED_WRAPORJUSTIFY
/* Set up the wrapping point, accounting for screen width when negative. */
@ -534,8 +536,10 @@ void usage(void)
print_opt(_("-J <number>"), _("--guidestripe=<number>"),
N_("Show a guiding bar at this column"));
#endif
#ifndef USE_SLANG
print_opt("-K", "--rawsequences",
N_("Fix numeric keypad key confusion problem"));
#endif
#ifndef NANO_TINY
print_opt("-L", "--nonewlines",
N_("Don't add an automatic newline"));
@ -1690,7 +1694,9 @@ int main(int argc, char **argv)
#ifdef ENABLE_NANORC
{"ignorercfiles", 0, NULL, 'I'},
#endif
#ifndef USE_SLANG
{"rawsequences", 0, NULL, 'K'},
#endif
#ifdef ENABLED_WRAPORJUSTIFY
{"trimblanks", 0, NULL, 'M'},
#endif
@ -1871,9 +1877,11 @@ int main(int argc, char **argv)
}
break;
#endif
#ifndef USE_SLANG
case 'K':
SET(RAW_SEQUENCES);
break;
#endif
#ifndef NANO_TINY
case 'L':
SET(NO_NEWLINES);
@ -2192,9 +2200,15 @@ int main(int argc, char **argv)
#endif
}
#ifdef USE_SLANG
/* When using Slang, do not let Slang translate escape sequences to
* key codes, because it does it wrong for the longer sequences. */
SET(RAW_SEQUENCES);
#else
/* When getting untranslated escape sequences, the mouse cannot be used. */
if (ISSET(RAW_SEQUENCES))
UNSET(USE_MOUSE);
#endif
#ifdef ENABLE_HISTORIES
/* Initialize the pointers for the Search/Replace/Execute histories. */

View File

@ -1447,9 +1447,10 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
* don't get extended keypad values. */
if (ISSET(PRESERVE))
disable_flow_control();
#ifndef USE_SLANG
if (!ISSET(RAW_SEQUENCES))
keypad(win, FALSE);
#endif
#ifndef NANO_TINY
/* Turn bracketed-paste mode off. */
printf("\x1B[?2004l");
@ -1483,12 +1484,14 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
* keypad back on if necessary now that we're done. */
if (ISSET(PRESERVE))
enable_flow_control();
#ifndef USE_SLANG
/* Use the global window pointers, because a resize may have freed
* the data that the win parameter points to. */
if (!ISSET(RAW_SEQUENCES)) {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
}
#endif
if (*count < 999) {
for (size_t i = 0; i < *count; i++)