From: Pierre Habouzit Date: Sun, 3 Dec 2006 23:18:13 +0000 (+0100) Subject: yes, we always have colors, screw stupid antiquated ncurses. X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=486de69aa30a7bfca3625a1b521411dc7a15c55c yes, we always have colors, screw stupid antiquated ncurses. Signed-off-by: Pierre Habouzit --- diff --git a/configure.ac b/configure.ac index 42d1806..9162271 100644 --- a/configure.ac +++ b/configure.ac @@ -135,7 +135,6 @@ main () AC_CHECK_LIB(termlib, main) fi AC_DEFINE(USE_SLANG_CURSES,1, [ Define if you compile with SLang instead of curses/ncurses. ]) - AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ]) dnl --- now that we've found it, check the link @@ -179,8 +178,8 @@ main () LIBS="$LIBS $MUTTLIBS" CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>], [start_color typeahead bkgdset curs_set meta use_default_colors resizeterm]) - if test "$ac_cv_func_decl_start_color" = yes; then - AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ]) + if test "$ac_cv_func_decl_start_color" != yes; then + AC_MSG_ERROR([Your curses library does not supports color.]) fi LIBS="$old_LIBS" ]) diff --git a/init.h b/init.h index 841ae38..6346c29 100644 --- a/init.h +++ b/init.h @@ -3700,9 +3700,6 @@ static const char* Features[] = { #ifdef USE_LIBESMTP "libesmtp", #endif -#ifdef HAVE_COLOR - "color", -#endif #ifdef CRYPT_BACKEND_GPGME "gpgme", #endif @@ -3822,10 +3819,8 @@ struct command_t Commands[] = { {"alternative_order", parse_list, UL &AlternativeOrderList}, {"bind", mutt_parse_bind, 0}, {"charset-hook", mutt_parse_hook, M_CHARSETHOOK}, -#ifdef HAVE_COLOR {"color", mutt_parse_color, 0}, {"uncolor", mutt_parse_uncolor, 0}, -#endif {"exec", mutt_parse_exec, 0}, {"fcc-hook", mutt_parse_hook, M_FCCHOOK}, {"fcc-save-hook", mutt_parse_hook, M_FCCHOOK|M_SAVEHOOK}, diff --git a/lib-ui/color.c b/lib-ui/color.c index afb84a5..4d87857 100644 --- a/lib-ui/color.c +++ b/lib-ui/color.c @@ -25,8 +25,6 @@ COLOR_LINE *ColorIndexList = NULL; /* local to this file */ static int ColorQuoteSize; -#ifdef HAVE_COLOR - #define COLOR_DEFAULT (-2) typedef struct color_list { @@ -55,8 +53,6 @@ static struct mapping_t Colors[] = { {0, 0} }; -#endif /* HAVE_COLOR */ - static struct mapping_t Fields[] = { {"hdrdefault", MT_COLOR_HDEFAULT}, {"quoted", MT_COLOR_QUOTED}, @@ -102,14 +98,10 @@ static void mutt_free_color_line (COLOR_LINE ** l, int free_colors) tmp = *l; -#ifdef HAVE_COLOR if (free_colors && tmp->fg != -1 && tmp->bg != -1) mutt_free_color (tmp->fg, tmp->bg); -#endif - /* we should really introduce a container - * type for regular expressions. - */ + /* we should really use the container type for regular expressions. */ regfree (&tmp->rx); pattern_list_wipe(&tmp->color_pattern); @@ -134,13 +126,9 @@ void ci_start_color (void) ColorDefs[MT_COLOR_BOLD] = 0; ColorDefs[MT_COLOR_UNDERLINE] = 0; -#ifdef HAVE_COLOR start_color (); -#endif } -#ifdef HAVE_COLOR - #ifdef USE_SLANG_CURSES static char *get_color_name (char *dest, size_t destlen, int val) { @@ -272,11 +260,6 @@ void mutt_free_color (int fg, int bg) } } -#endif /* HAVE_COLOR */ - - -#ifdef HAVE_COLOR - static int parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err) { @@ -306,9 +289,6 @@ parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err) return 0; } -#endif - - /* usage: uncolor index pattern [pattern...] * unmono index pattern [pattern...] */ @@ -317,17 +297,12 @@ static int _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data, BUFFER * err, short parse_uncolor); - -#ifdef HAVE_COLOR - int mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data, BUFFER * err) { return _mutt_parse_uncolor (buf, s, data, err, 1); } -#endif - int mutt_parse_unmono (BUFFER * buf, BUFFER * s, unsigned long data, BUFFER * err) { @@ -362,28 +337,14 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data __attribute__ return (-1); } - if ( -#ifdef HAVE_COLOR - /* we're running without curses */ - option (OPTNOCURSES) - || /* we're parsing an uncolor command, and have no colors */ - (parse_uncolor && !has_colors ()) - /* we're parsing an unmono command, and have colors */ - || (!parse_uncolor && has_colors ()) -#else - /* We don't even have colors compiled in */ - parse_uncolor -#endif - ) { + if (option (OPTNOCURSES) || (parse_uncolor != has_colors())) { /* just eat the command, but don't do anything real about it */ - do + do { mutt_extract_token (buf, s, 0); - while (MoreArgs (s)); - + } while (MoreArgs(s)); return 0; } - do { mutt_extract_token (buf, s, 0); if (!m_strcmp("*", buf->data)) { @@ -451,7 +412,6 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive, } if (tmp) { -#ifdef HAVE_COLOR if (fg != -1 && bg != -1) { if (tmp->fg != fg || tmp->bg != bg) { mutt_free_color (tmp->fg, tmp->bg); @@ -462,10 +422,8 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive, else attr |= (tmp->pair & ~A_BOLD); } -#endif /* HAVE_COLOR */ tmp->pair = attr; - } - else { + } else { int r; char buf[STRING]; @@ -494,13 +452,11 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive, } tmp->next = *top; tmp->pattern = m_strdup(s); -#ifdef HAVE_COLOR if (fg != -1 && bg != -1) { tmp->fg = fg; tmp->bg = bg; attr |= mutt_alloc_color (fg, bg); } -#endif tmp->pair = attr; *top = tmp; } @@ -544,8 +500,6 @@ parse_object (BUFFER * buf, BUFFER * s, int *o, int *ql, BUFFER * err) typedef int (*parser_callback_t) (BUFFER *, BUFFER *, int *, int *, int *, BUFFER *); -#ifdef HAVE_COLOR - static int parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, BUFFER * err) @@ -573,8 +527,6 @@ parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, return 0; } -#endif - static int parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, BUFFER * err) @@ -614,11 +566,9 @@ parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, static int fgbgattr_to_color (int fg, int bg, int attr) { -#ifdef HAVE_COLOR if (fg != -1 && bg != -1) return attr | mutt_alloc_color (fg, bg); else -#endif return attr; } @@ -662,8 +612,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, return 0; -#ifdef HAVE_COLOR -# ifdef HAVE_USE_DEFAULT_COLORS +#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) @@ -671,8 +620,7 @@ _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 */ -#endif +#endif /* HAVE_USE_DEFAULT_COLORS */ if (object == MT_COLOR_HEADER) r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err, 0); @@ -705,18 +653,14 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, else ColorDefs[object] = fgbgattr_to_color (fg, bg, attr); -#ifdef HAVE_COLOR -# ifdef HAVE_BKGDSET +#ifdef HAVE_BKGDSET if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors ()) BKGDSET (MT_COLOR_NORMAL); -# endif #endif return (r); } -#ifdef HAVE_COLOR - int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)), BUFFER * err) { @@ -728,20 +672,13 @@ int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data __attribute_ return _mutt_parse_color (buff, s, err, parse_color_pair, dry_run); } -#endif - int mutt_parse_mono (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)), BUFFER * err) { int dry_run = 0; -#ifdef HAVE_COLOR if (option (OPTNOCURSES) || has_colors ()) dry_run = 1; -#else - if (option (OPTNOCURSES)) - dry_run = 1; -#endif return _mutt_parse_color (buff, s, err, parse_attr_spec, dry_run); } diff --git a/main.c b/main.c index 2d2a789..1c6982f 100644 --- a/main.c +++ b/main.c @@ -269,11 +269,6 @@ static void show_version (void) "-HAVE_REGCOMP " #endif "\n " -#ifdef HAVE_COLOR - "+HAVE_COLOR " -#else - "-HAVE_COLOR " -#endif #ifdef HAVE_START_COLOR "+HAVE_START_COLOR " #else diff --git a/pager.c b/pager.c index a25490c..083c9b0 100644 --- a/pager.c +++ b/pager.c @@ -217,16 +217,13 @@ resolve_color (struct line_t *lineInfo, int n, int cnt, int flags, /* handle "special" bold & underlined characters */ if (special || a->attr) { -#ifdef HAVE_COLOR if ((a->attr & ANSI_COLOR)) { if (a->pair == -1) a->pair = mutt_alloc_color (a->fg, a->bg); color = a->pair; if (a->attr & ANSI_BOLD) color |= A_BOLD; - } - else -#endif + } else if ((special & A_BOLD) || (a->attr & ANSI_BOLD)) { if (ColorDefs[MT_COLOR_BOLD] && !search) color = ColorDefs[MT_COLOR_BOLD]; @@ -771,10 +768,8 @@ static int grok_ansi (unsigned char *buf, int pos, ansi_attr * a) /* Character Attributes */ if (option (OPTALLOWANSI) && a != NULL && buf[x] == 'm') { if (pos == x) { -#ifdef HAVE_COLOR if (a->pair != -1) mutt_free_color (a->fg, a->bg); -#endif a->attr = ANSI_OFF; a->pair = -1; } @@ -803,10 +798,8 @@ static int grok_ansi (unsigned char *buf, int pos, ansi_attr * a) pos += 2; } else if (buf[pos] == '3' && isdigit (buf[pos + 1])) { -#ifdef HAVE_COLOR if (a->pair != -1) mutt_free_color (a->fg, a->bg); -#endif a->pair = -1; a->attr |= ANSI_COLOR; if (buf[pos + 1] != '9') @@ -814,10 +807,8 @@ static int grok_ansi (unsigned char *buf, int pos, ansi_attr * a) pos += 3; } else if (buf[pos] == '4' && isdigit (buf[pos + 1])) { -#ifdef HAVE_COLOR if (a->pair != -1) mutt_free_color (a->fg, a->bg); -#endif a->pair = -1; a->attr |= ANSI_COLOR; if (buf[pos + 1] != '9')