From: Pierre Habouzit Date: Sat, 10 Nov 2007 16:09:39 +0000 (+0100) Subject: Terminals without color are from another era. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=a4b9983ca0d2e7654b552c3648792cff279bdf9a;p=apps%2Fmadmutt.git Terminals without color are from another era. Signed-off-by: Pierre Habouzit --- diff --git a/lib-ui/color.c b/lib-ui/color.c index 207d959..756e299 100644 --- a/lib-ui/color.c +++ b/lib-ui/color.c @@ -118,30 +118,17 @@ void ci_start_color (void) static int parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err) { - char *eptr; - - if (m_strncasecmp(s, "bright", 6) == 0) { - *attr |= brite; - s += 6; - } + if (m_strncasecmp(s, "bright", 6) == 0) { + *attr |= brite; + s += 6; + } - /* allow aliases for xterm color resources */ - if (m_strncasecmp(s, "color", 5) == 0) { - s += 5; - *col = strtol (s, &eptr, 10); - if (!*s || *eptr || *col < 0 || - (*col >= COLORS && !option (OPTNOCURSES) && has_colors ())) { - snprintf (err->data, err->dsize, _("%s: color not supported by term"), - s); - return (-1); + if ((*col = mutt_getvaluebyname (s, Colors)) == -1) { + snprintf (err->data, err->dsize, _("%s: no such color"), s); + return (-1); } - } - else if ((*col = mutt_getvaluebyname (s, Colors)) == -1) { - snprintf (err->data, err->dsize, _("%s: no such color"), s); - return (-1); - } - return 0; + return 0; } /* usage: uncolor index pattern [pattern...] */ @@ -169,7 +156,7 @@ int mutt_parse_uncolor(BUFFER *buf, BUFFER *s, unsigned long data, BUFFER return (-1); } - if (option(OPTNOCURSES) || !has_colors()) { + if (option(OPTNOCURSES)) { /* just eat the command, but don't do anything real about it */ do { mutt_extract_token (buf, s, 0); @@ -328,9 +315,6 @@ parse_object (BUFFER * buf, BUFFER * s, int *o, int *ql, BUFFER * err) return 0; } -typedef int (*parser_callback_t) (BUFFER *, BUFFER *, int *, int *, int *, - BUFFER *); - static int parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, BUFFER * err) @@ -410,7 +394,6 @@ int mutt_parse_color(BUFFER *buf, BUFFER *s, unsigned long i, BUFFER *err) { int object = 0, attr = 0, fg = 0, bg = 0, q_level = 0; int r = 0; - int dry_run = option (OPTNOCURSES) || !has_colors (); if (parse_object (buf, s, &object, &q_level, err) == -1) return -1; @@ -435,16 +418,13 @@ int mutt_parse_color(BUFFER *buf, BUFFER *s, unsigned long i, BUFFER *err) return (-1); } - /* dry run? */ - - if (dry_run) + if (option(OPTNOCURSES)) return 0; - - if (!option (OPTNOCURSES) && has_colors () - /* delay use_default_colors() until needed, since it initializes things */ - && (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT) - && use_default_colors () != OK) { + /* delay use_default_colors() until needed, since it initializes things */ + if (has_colors () && (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT) + && use_default_colors () != OK) + { m_strcpy(err->data, err->dsize, _("default colors not supported")); return (-1); } @@ -473,14 +453,14 @@ int mutt_parse_color(BUFFER *buf, BUFFER *s, unsigned long i, BUFFER *err) if (ColorQuote[q_level] == A_NORMAL) ColorQuote[q_level] = ColorDefs[MT_COLOR_QUOTED]; } - } - else + } else { ColorQuote[q_level] = fgbgattr_to_color (fg, bg, attr); - } - else + } + } else { ColorDefs[object] = fgbgattr_to_color (fg, bg, attr); + } - if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors ()) + if (object == MT_COLOR_NORMAL) BKGDSET(main_w, MT_COLOR_NORMAL); return (r); diff --git a/lib-ui/curs_lib.c b/lib-ui/curs_lib.c index 437ffbc..a2b88c8 100644 --- a/lib-ui/curs_lib.c +++ b/lib-ui/curs_lib.c @@ -311,7 +311,8 @@ void mutt_show_error (void) void curses_initialize(void) { initscr(); - start_color(); + if (start_color() == ERR || !has_colors() || COLORS < 8) + mutt_exit(-1); madtty_init_colors(); ci_start_color(); noecho();