nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 4f7593b704972a26bf243605fd53b22543cb0b69
parent 2157738a184b3dda9a8228ece6b630a28a4aca13
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat,  5 Dec 2020 11:57:08 +0100

general: remove support for Slang

Slang has too many bugs to be useful.

This addresses https://savannah.gnu.org/bugs/?59210.

Diffstat:
Msrc/definitions.h | 13+------------
Msrc/nano.c | 60++----------------------------------------------------------
Msrc/winio.c | 36++----------------------------------
3 files changed, 5 insertions(+), 104 deletions(-)

diff --git a/src/definitions.h b/src/definitions.h @@ -68,15 +68,8 @@ #define PATH_MAX 4096 #endif -#ifdef USE_SLANG -/* Slang support. */ -#include <slcurses.h> -/* Slang curses emulation brain damage, part 3: Slang doesn't define the - * curses equivalents of the Insert or Delete keys. */ -#define KEY_DC SL_KEY_DELETE -#define KEY_IC SL_KEY_IC /* Ncurses support. */ -#elif defined(HAVE_NCURSESW_NCURSES_H) +#if defined(HAVE_NCURSESW_NCURSES_H) #include <ncursesw/ncurses.h> #elif defined(HAVE_NCURSES_H) #include <ncurses.h> @@ -615,11 +608,7 @@ enum /* A special keycode for when a key produces an unknown escape sequence. */ #define FOREIGN_SEQUENCE 0x4FC -#ifdef USE_SLANG -#define KEY_FLUSH 0xFF /* Clipped error code. */ -#else #define KEY_FLUSH KEY_F0 /* Nonexistent function key. */ -#endif #ifndef NANO_TINY /* An imaginary key for when we get a SIGWINCH (window resize). */ diff --git a/src/nano.c b/src/nano.c @@ -62,10 +62,6 @@ static struct termios original_state; static struct sigaction oldaction, newaction; /* Containers for the original and the temporary handler for SIGINT. */ -#ifdef USE_SLANG -static bool selfinduced = FALSE; - /* Whether a suspension was caused from inside nano or from outside. */ -#endif /* Create a new linestruct node. Note that we do not set prevnode->next. */ linestruct *make_new_node(linestruct *prevnode) @@ -422,13 +418,11 @@ 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. */ @@ -526,10 +520,8 @@ 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")); @@ -776,9 +768,6 @@ void version(void) #else printf(" --disable-utf8"); #endif -#ifdef USE_SLANG - printf(" --with-slang"); -#endif printf("\n"); } @@ -957,13 +946,7 @@ void do_suspend(int signal) void do_suspend_void(void) { if (ISSET(SUSPENDABLE)) { -#ifdef USE_SLANG - selfinduced = TRUE; - do_suspend(0); - selfinduced = FALSE; -#else do_suspend(0); -#endif } else { statusbar(_("Suspension is not enabled")); beep(); @@ -987,13 +970,9 @@ void do_continue(int signal) /* Put the terminal in the desired state again. */ terminal_init(); #endif -#ifdef USE_SLANG - if (!selfinduced) - full_refresh(); -#else + /* Insert a fake keystroke, to neutralize a key-eating issue. */ ungetch(KEY_FLUSH); -#endif } #if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR) @@ -1202,36 +1181,14 @@ void enable_flow_control(void) * control characters. */ void terminal_init(void) { -#ifdef USE_SLANG - /* Slang curses emulation brain damage, part 2: Slang doesn't - * implement raw(), nonl(), or noecho() properly, so there's no way - * to properly reinitialize the terminal using them. We have to - * disable the special control keys and interpretation of the flow - * control characters using termios, save the terminal state after - * the first call, and restore it on subsequent calls. */ - static struct termios desired_state; - static bool have_new_state = FALSE; - - if (!have_new_state) { -#endif raw(); nonl(); noecho(); disable_extended_io(); -#ifdef USE_SLANG - tcgetattr(0, &desired_state); - have_new_state = TRUE; - } else - tcsetattr(0, TCSANOW, &desired_state); - SLang_init_tty(-1, 0, 0); -#endif if (ISSET(PRESERVE)) enable_flow_control(); -#ifdef USE_SLANG - else - disable_flow_control(); -#endif + disable_kb_interrupt(); #ifndef NANO_TINY @@ -1711,9 +1668,7 @@ 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 @@ -1816,9 +1771,6 @@ int main(int argc, char **argv) * to use the multibyte functions for text processing. */ if (setlocale(LC_ALL, "") != NULL && strcmp(nl_langinfo(CODESET), "UTF-8") == 0) { -#ifdef USE_SLANG - SLutf8_enable(1); -#endif utf8_init(); } #else @@ -1898,11 +1850,9 @@ 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); @@ -2233,15 +2183,9 @@ 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. */ diff --git a/src/winio.c b/src/winio.c @@ -180,9 +180,6 @@ void read_keys_from(WINDOW *win) if (reveal_cursor) { curs_set(1); -#ifdef USE_SLANG - doupdate(); -#endif } /* Read in the first keycode, waiting for it to arrive. */ @@ -570,11 +567,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed) } else if (length > 4 && seq[2] == ';' && seq[4] == '~') /* Esc [ 1 n ; 2 ~ == F17...F20 on some terminals. */ *consumed = 5; -#ifdef USE_SLANG - else if (length == 3 && seq[2] == ';') - /* Discard broken sequences that Slang produces. */ - *consumed = 3; -#endif break; case '2': if (length > 2 && seq[2] == '~') { @@ -605,11 +597,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed) else if (length > 4 && seq[2] == ';' && seq[4] == '~') /* Esc [ 2 n ; 2 ~ == F21...F24 on some terminals. */ *consumed = 5; -#ifdef USE_SLANG - else if (length == 3 && seq[2] == ';') - /* Discard broken sequences that Slang produces. */ - *consumed = 3; -#endif #ifndef NANO_TINY else if (length > 3 && seq[1] == '0' && seq[3] == '~') { /* Esc [ 2 0 0 ~ == start of a bracketed paste, @@ -1447,10 +1434,9 @@ 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"); @@ -1484,14 +1470,13 @@ 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++) @@ -2152,11 +2137,6 @@ void statusline(message_type importance, const char *msg, ...) statusblank = 1; else statusblank = 26; - -#ifdef USE_SLANG - /* Work around a shy cursor -- https://sv.gnu.org/bugs/?59091. */ - bottombars(MGOTODIR); -#endif } /* Display a normal message on the status bar, quietly. */ @@ -3284,14 +3264,7 @@ void adjust_viewport(update_type manner) /* Tell curses to unconditionally redraw whatever was on the screen. */ void full_refresh(void) { -#ifdef USE_SLANG - /* Slang curses emulation brain damage, part 4: Slang doesn't define - * curscr. */ - SLsmg_touch_screen(); - SLsmg_refresh(); -#else wrefresh(curscr); -#endif } /* Draw all elements of the screen. That is: the title bar plus the content @@ -3337,11 +3310,6 @@ void report_cursor_position(void) _("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"), openfile->current->lineno, openfile->filebot->lineno, linepct, column, fullwidth, colpct, sum, openfile->totsize, charpct); - -#ifdef USE_SLANG - /* Restore the help lines after the above call overwrote them. */ - bottombars(MMAIN); -#endif } /* Highlight the text between the given two columns on the current line. */