From c9b049f668148dab6ae90f32de6a4981f673bfa1 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 11 Aug 2007 09:52:30 +0200 Subject: [PATCH] Remove support for antiquated ncurses libraries. Assume we have at least ncurses 5.x. Signed-off-by: Pierre Habouzit --- CMakeLists.txt | 21 ---------------- config.h.cmake | 20 --------------- lib-sys/mutt_signal.c | 11 -------- lib-ui/CMakeLists.txt | 1 - lib-ui/color.c | 6 ----- lib-ui/curs_lib.c | 40 +++++++++++++++++++++++++++-- lib-ui/curs_main.c | 3 --- lib-ui/curses.h | 14 +---------- lib-ui/menu.c | 2 -- lib-ui/resize.c | 58 ------------------------------------------- main.c | 4 --- pager.c | 6 ----- 12 files changed, 39 insertions(+), 147 deletions(-) delete mode 100644 lib-ui/resize.c diff --git a/CMakeLists.txt b/CMakeLists.txt index d234c5e..0845d34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,22 +115,7 @@ INCLUDE (CheckFunctionExists) CHECK_FUNCTION_EXISTS(strlimit HAVE_SETRLIMIT) CHECK_FUNCTION_EXISTS(getsid HAVE_GETSID) CHECK_FUNCTION_EXISTS(setegid HAVE_SETEGID) -CHECK_FUNCTION_EXISTS(isctype HAVE_ISCTYPE) CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT) -CHECK_FUNCTION_EXISTS(regcomp HAVE_REGCOMP) -CHECK_FUNCTION_EXISTS(iswalnum HAVE_ISWALNUM) -CHECK_FUNCTION_EXISTS(iswalpha HAVE_ISWALPHA) -CHECK_FUNCTION_EXISTS(iswcntrl HAVE_ISWCNTRL) -CHECK_FUNCTION_EXISTS(iswdigit HAVE_ISWDIGIT) -CHECK_FUNCTION_EXISTS(iswgraph HAVE_ISWGRAPH) -CHECK_FUNCTION_EXISTS(iswlower HAVE_ISWLOWER) -CHECK_FUNCTION_EXISTS(iswprint HAVE_ISWPRINT) -CHECK_FUNCTION_EXISTS(iswpunct HAVE_ISWPUNCT) -CHECK_FUNCTION_EXISTS(iswspace HAVE_ISWSPACE) -CHECK_FUNCTION_EXISTS(iswupper HAVE_ISWUPPER) -CHECK_FUNCTION_EXISTS(iswxdigit HAVE_ISWXDIGIT) -CHECK_FUNCTION_EXISTS(towupper HAVE_TOWUPPER) -CHECK_FUNCTION_EXISTS(towlower HAVE_TOWLOWER) CHECK_FUNCTION_EXISTS(nl_langinfo HAVE_LANGINFO_CODESET) # }}} @@ -151,12 +136,6 @@ ELSE(HAVE_NCURSESW_NCURSES_H) MESSAGE(FATAL_ERROR "could not find ncurses.h") ENDIF(HAVE_NCURSESW_NCURSES_H) SET(CMAKE_REQUIRED_LIBRARIES ${MUTTLIBS}) -CHECK_FUNCTION_EXISTS(start_color HAVE_START_COLOR) -CHECK_FUNCTION_EXISTS(typeahead HAVE_TYPEAHEAD) -CHECK_FUNCTION_EXISTS(bkgdset HAVE_BKGDSET) -CHECK_FUNCTION_EXISTS(curs_set HAVE_CURS_SET) -CHECK_FUNCTION_EXISTS(meta HAVE_META) -CHECK_FUNCTION_EXISTS(use_default_colors HAVE_USE_DEFAULT_COLORS) CHECK_FUNCTION_EXISTS(resizeterm HAVE_RESIZETERM) SET(CMAKE_REQUIRED_LIBRARIES) SET(CMAKE_REQUIRED_INCLUDES) diff --git a/config.h.cmake b/config.h.cmake index 23dc287..54a3be7 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -46,27 +46,7 @@ /* functions */ #cmakedefine HAVE_GETSID 1 #cmakedefine HAVE_SETEGID 1 -#cmakedefine HAVE_ISCTYPE 1 #cmakedefine HAVE_GETOPT 1 -#cmakedefine HAVE_REGCOMP 1 -#cmakedefine HAVE_ISWALNUM 1 -#cmakedefine HAVE_ISWALPHA 1 -#cmakedefine HAVE_ISWCNTRL 1 -#cmakedefine HAVE_ISWDIGIT 1 -#cmakedefine HAVE_ISWGRAPH 1 -#cmakedefine HAVE_ISWLOWER 1 -#cmakedefine HAVE_ISWPRINT 1 -#cmakedefine HAVE_ISWPUNCT 1 -#cmakedefine HAVE_ISWSPACE 1 -#cmakedefine HAVE_ISWUPPER 1 -#cmakedefine HAVE_ISWXDIGIT 1 -#cmakedefine HAVE_TOWUPPER 1 -#cmakedefine HAVE_TOWLOWER 1 -#cmakedefine HAVE_TYPEAHEAD 1 -#cmakedefine HAVE_BKGDSET 1 -#cmakedefine HAVE_CURS_SET 1 -#cmakedefine HAVE_META 1 -#cmakedefine HAVE_USE_DEFAULT_COLORS 1 #cmakedefine HAVE_RESIZETERM 1 /* libraries */ diff --git a/lib-sys/mutt_signal.c b/lib-sys/mutt_signal.c index 8609671..f8e0dba 100644 --- a/lib-sys/mutt_signal.c +++ b/lib-sys/mutt_signal.c @@ -51,18 +51,11 @@ static void sighandler (int sig) if (!IsEndwin) refresh (); mutt_curs_set (-1); -#if defined (HAVE_RESIZETERM) /* We don't receive SIGWINCH when suspended; however, no harm is done by * just assuming we received one, and triggering the 'resize' anyway. */ - SigWinch = 1; -#endif - break; - -#if defined (HAVE_RESIZETERM) case SIGWINCH: SigWinch = 1; break; -#endif case SIGINT: SigInt = 1; @@ -105,9 +98,7 @@ void mutt_signal_initialize (void) sigaction (SIGCONT, &act, NULL); sigaction (SIGTSTP, &act, NULL); sigaction (SIGINT, &act, NULL); -#if defined (HAVE_RESIZETERM) sigaction (SIGWINCH, &act, NULL); -#endif /* POSIX doesn't allow us to ignore SIGCHLD, * so we just install a dummy handler for it @@ -129,9 +120,7 @@ void mutt_block_signals (void) sigaddset (&Sigset, SIGHUP); sigaddset (&Sigset, SIGTSTP); sigaddset (&Sigset, SIGINT); -#if defined (HAVE_RESIZETERM) sigaddset (&Sigset, SIGWINCH); -#endif sigprocmask (SIG_BLOCK, &Sigset, 0); set_option (OPTSIGNALSBLOCKED); } diff --git a/lib-ui/CMakeLists.txt b/lib-ui/CMakeLists.txt index f2b3156..25f259d 100644 --- a/lib-ui/CMakeLists.txt +++ b/lib-ui/CMakeLists.txt @@ -8,7 +8,6 @@ ADD_LIBRARY(ui history.c menu.c query.c - resize.c sidebar.c status.c ) diff --git a/lib-ui/color.c b/lib-ui/color.c index c503724..584c113 100644 --- a/lib-ui/color.c +++ b/lib-ui/color.c @@ -47,9 +47,7 @@ static struct mapping_t Colors[] = { {"red", COLOR_RED}, {"white", COLOR_WHITE}, {"yellow", COLOR_YELLOW}, -#if defined (HAVE_USE_DEFAULT_COLORS) {"default", COLOR_DEFAULT}, -#endif {0, 0} }; @@ -170,12 +168,10 @@ int mutt_alloc_color (int fg, int bg) p->bg = bg; p->fg = fg; -#if defined (HAVE_USE_DEFAULT_COLORS) if (fg == COLOR_DEFAULT) fg = -1; if (bg == COLOR_DEFAULT) bg = -1; -#endif init_pair (i, fg, bg); @@ -567,7 +563,6 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, return 0; -#ifdef HAVE_USE_DEFAULT_COLORS if (!option (OPTNOCURSES) && has_colors () /* delay use_default_colors() until needed, since it initializes things */ && (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT) @@ -575,7 +570,6 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, m_strcpy(err->data, err->dsize, _("default colors not supported")); return (-1); } -#endif /* HAVE_USE_DEFAULT_COLORS */ if (object == MT_COLOR_HEADER) r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err, 0); diff --git a/lib-ui/curs_lib.c b/lib-ui/curs_lib.c index 7880f51..c50c18d 100644 --- a/lib-ui/curs_lib.c +++ b/lib-ui/curs_lib.c @@ -14,6 +14,11 @@ #include #include +#ifdef HAVE_SYS_IOCTL_H +# include +#elif defined(HAVE_IOCTL_H) +# include +#endif #include #include @@ -438,7 +443,6 @@ void mutt_flushinp (void) flushinp (); } -#if defined(HAVE_CURS_SET) /* The argument can take 3 values: * -1: restore the value of the last call * 0: make the cursor invisible @@ -458,7 +462,6 @@ void mutt_curs_set (int cursor) curs_set (2); /* cvvis */ } } -#endif int mutt_multi_choice (const char *prompt, const char *letters) { @@ -668,3 +671,36 @@ void mutt_paddstr (int n, const char *s) addch (' '); } +/* this routine should be called after receiving SIGWINCH */ +void mutt_resize_screen (void) +{ + char *cp; + int fd; + struct winsize w; + + int rows, cols; + + rows = -1; + cols = -1; + if ((fd = open ("/dev/tty", O_RDONLY)) != -1) { + if (ioctl (fd, TIOCGWINSZ, &w) != -1) { + rows = w.ws_row; + cols = w.ws_col; + } + close (fd); + } + if (rows <= 0) { + if ((cp = getenv ("LINES")) != NULL) { + rows = atoi (cp); + } + else + rows = 24; + } + if (cols <= 0) { + if ((cp = getenv ("COLUMNS")) != NULL) + cols = atoi (cp); + else + cols = 80; + } + resizeterm (rows, cols); +} diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index 5af770b..3fbe0e9 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -563,7 +563,6 @@ int mutt_index_menu (void) move (menu->current - menu->top + menu->offset, COLS - 1); mutt_refresh (); -#if defined (HAVE_RESIZETERM) if (SigWinch) { mutt_flushinp (); mutt_resize_screen (); @@ -578,10 +577,8 @@ int mutt_index_menu (void) clearok (stdscr, TRUE); continue; } -#endif op = km_dokey (MENU_MAIN); - if (op == -1) continue; /* either user abort or timeout */ diff --git a/lib-ui/curses.h b/lib-ui/curses.h index 39bfad0..c639c86 100644 --- a/lib-ui/curses.h +++ b/lib-ui/curses.h @@ -35,21 +35,9 @@ #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) #define BEEP() do { if (mod_core.beep) beep(); } while (0) -#if !defined(HAVE_CURS_SET) -#define curs_set(x) -#endif - -#if defined(HAVE_BKGDSET) -#define BKGDSET(x) bkgdset (ColorDefs[x] | ' ') -#else -#define BKGDSET(x) -#endif +#define BKGDSET(x) bkgdset(ColorDefs[x] | ' ') -#if defined(HAVE_CURS_SET) void mutt_curs_set (int); -#else -#define mutt_curs_set(x) -#endif #define PAGELEN (LINES-3) #define ctrl(c) ((c)-'@') diff --git a/lib-ui/menu.c b/lib-ui/menu.c index b023ece..2be0518 100644 --- a/lib-ui/menu.c +++ b/lib-ui/menu.c @@ -782,14 +782,12 @@ int mutt_menuLoop (MUTTMENU * menu) mutt_curs_set (1); -#if defined (HAVE_RESIZETERM) if (SigWinch) { mutt_resize_screen (); menu->redraw = REDRAW_FULL; SigWinch = 0; clearok (stdscr, TRUE); /*force complete redraw */ } -#endif if (i == -1) continue; diff --git a/lib-ui/resize.c b/lib-ui/resize.c deleted file mode 100644 index fe0e965..0000000 --- a/lib-ui/resize.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright notice from original mutt: - * Copyright (C) 1996-2000 Michael R. Elkins - * - * This file is part of mutt-ng, see http://www.muttng.org/. - * It's licensed under the GNU General Public License, - * please see the file GPL in the top level source directory. - */ - -#include - -#if defined(HAVE_RESIZETERM) - -#include -#ifdef HAVE_SYS_IOCTL_H -# include -#elif defined(HAVE_IOCTL_H) -# include -#endif - -#include -#include "mutt.h" - -/* this routine should be called after receiving SIGWINCH */ -void mutt_resize_screen (void) -{ - char *cp; - int fd; - struct winsize w; - - int rows, cols; - - rows = -1; - cols = -1; - if ((fd = open ("/dev/tty", O_RDONLY)) != -1) { - if (ioctl (fd, TIOCGWINSZ, &w) != -1) { - rows = w.ws_row; - cols = w.ws_col; - } - close (fd); - } - if (rows <= 0) { - if ((cp = getenv ("LINES")) != NULL) { - rows = atoi (cp); - } - else - rows = 24; - } - if (cols <= 0) { - if ((cp = getenv ("COLUMNS")) != NULL) - cols = atoi (cp); - else - cols = 80; - } - resizeterm (rows, cols); -} - -#endif /* defined(HAVE_RESIZETERM) */ diff --git a/main.c b/main.c index a47a827..8a1b70a 100644 --- a/main.c +++ b/main.c @@ -233,12 +233,8 @@ static void start_curses (void) keypad (stdscr, TRUE); cbreak (); noecho (); -#ifdef HAVE_TYPEAHEAD typeahead (-1); /* simulate smooth scrolling */ -#endif -#ifdef HAVE_META meta (stdscr, TRUE); -#endif } #define M_IGNORE (1<<0) /* -z */ diff --git a/pager.c b/pager.c index 42abff6..5e64412 100644 --- a/pager.c +++ b/pager.c @@ -108,13 +108,11 @@ typedef struct _ansi_attr { static short InHelp = 0; -#if defined (HAVE_RESIZETERM) static struct resize { int line; int SearchCompiled; int SearchBack; } *Resize = NULL; -#endif #define NumSigLines 4 @@ -1440,7 +1438,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) SETCOLOR (MT_COLOR_NORMAL); } -#if defined (HAVE_RESIZETERM) if (Resize != NULL) { if ((SearchCompiled = Resize->SearchCompiled)) { REGCOMP @@ -1453,7 +1450,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) p_delete(&Resize); } -#endif if (IsHeader (extra) && PagerIndexLines) { if (pager_index == NULL) { @@ -1623,7 +1619,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) mutt_query_exit (); continue; } -#if defined (HAVE_RESIZETERM) else if (SigWinch) { mutt_resize_screen (); @@ -1667,7 +1662,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) clearok (stdscr, TRUE); /*force complete redraw */ continue; } -#endif else if (ch == -1) { ch = 0; continue; -- 2.20.1