using stls should not enable new CAPAs
[apps/madmutt.git] / lib-ui / color.c
index 207d959..7aa0d16 100644 (file)
@@ -25,14 +25,6 @@ static int ColorQuoteSize;
 
 #define COLOR_DEFAULT (-2)
 
-typedef struct color_list {
-  short fg;
-  short bg;
-  short index;
-  short count;
-  struct color_list *next;
-} COLOR_LIST;
-
 static struct mapping_t Colors[] = {
   {"black", COLOR_BLACK},
   {"blue", COLOR_BLUE},
@@ -79,7 +71,7 @@ static COLOR_LINE *mutt_new_color_line (void)
 
   p->fg = p->bg = -1;
 
-  return (p);
+  return p;
 }
 
 static void mutt_free_color_line(COLOR_LINE ** l)
@@ -118,30 +110,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...] */
@@ -155,21 +134,21 @@ int mutt_parse_uncolor(BUFFER *buf, BUFFER *s, unsigned long data, BUFFER
 
   if ((object = mutt_getvaluebyname (buf->data, Fields)) == -1) {
     snprintf (err->data, err->dsize, _("%s: no such object"), buf->data);
-    return (-1);
+    return -1;
   }
 
   if (m_strncmp(buf->data, "index", 5) != 0) {
     snprintf (err->data, err->dsize,
               _("%s: command valid only for index object"), "uncolor");
-    return (-1);
+    return -1;
   }
 
   if (!MoreArgs (s)) {
     snprintf (err->data, err->dsize, _("%s: too few arguments"), "uncolor");
-    return (-1);
+    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);
@@ -216,7 +195,7 @@ int mutt_parse_uncolor(BUFFER *buf, BUFFER *s, unsigned long data, BUFFER
     for (i = 0; Context && i < Context->msgcount; i++)
       Context->hdrs[i]->pair = 0;
   }
-  return (0);
+  return 0;
 }
 
 
@@ -279,7 +258,7 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive,
                     (sensitive ? mutt_which_case (s) : REG_ICASE))) != 0) {
       regerror (r, &tmp->rx, err->data, err->dsize);
       mutt_free_color_line(&tmp);
-      return (-1);
+      return -1;
     }
     tmp->next = *top;
     tmp->pattern = m_strdup(s);
@@ -322,38 +301,35 @@ parse_object (BUFFER * buf, BUFFER * s, int *o, int *ql, BUFFER * err)
   }
   else if ((*o = mutt_getvaluebyname (buf->data, Fields)) == -1) {
     snprintf (err->data, err->dsize, _("%s: no such object"), buf->data);
-    return (-1);
+    return -1;
   }
 
   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)
 {
   if (!MoreArgs (s)) {
     m_strcpy(err->data, err->dsize, _("color: too few arguments"));
-    return (-1);
+    return -1;
   }
 
   mutt_extract_token (buf, s, 0);
 
   if (parse_color_name (buf->data, fg, attr, A_BOLD, err) != 0)
-    return (-1);
+    return -1;
 
   if (!MoreArgs (s)) {
     m_strcpy(err->data, err->dsize, _("color: too few arguments"));
-    return (-1);
+    return -1;
   }
 
   mutt_extract_token (buf, s, 0);
 
   if (parse_color_name (buf->data, bg, attr, A_BLINK, err) != 0)
-    return (-1);
+    return -1;
 
   return 0;
 }
@@ -371,7 +347,7 @@ parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
 
   if (!MoreArgs (s)) {
     m_strcpy(err->data, err->dsize, _("mono: too few arguments"));
-    return (-1);
+    return -1;
   }
 
   mutt_extract_token (buf, s, 0);
@@ -390,7 +366,7 @@ parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
     *attr = A_NORMAL;           /* needs use = instead of |= to clear other bits */
   else {
     snprintf (err->data, err->dsize, _("%s: no such attribute"), buf->data);
-    return (-1);
+    return -1;
   }
 
   return 0;
@@ -410,7 +386,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;
@@ -424,7 +399,7 @@ int mutt_parse_color(BUFFER *buf, BUFFER *s, unsigned long i, BUFFER *err)
       || object == MT_COLOR_INDEX) {
     if (!MoreArgs (s)) {
       m_strcpy(err->data, err->dsize, _("too few arguments"));
-      return (-1);
+      return -1;
     }
 
     mutt_extract_token (buf, s, 0);
@@ -432,21 +407,18 @@ int mutt_parse_color(BUFFER *buf, BUFFER *s, unsigned long i, BUFFER *err)
 
   if (MoreArgs (s)) {
     m_strcpy(err->data, err->dsize, _("too many arguments"));
-    return (-1);
+    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);
+    return -1;
   }
 
   if (object == MT_COLOR_HEADER)
@@ -473,15 +445,15 @@ 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);
+  return r;
 }