dead code
[apps/madmutt.git] / lib-ui / color.c
index a927e9a..96b0cc2 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},
@@ -118,55 +110,22 @@ 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;
-  }
-
-  /* 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 (m_strncasecmp(s, "bright", 6) == 0) {
+        *attr |= brite;
+        s += 6;
     }
-  }
-  else if ((*col = mutt_getvaluebyname (s, Colors)) == -1) {
-    snprintf (err->data, err->dsize, _("%s: no such color"), s);
-    return (-1);
-  }
-
-  return 0;
-}
 
-/* usage: uncolor index pattern [pattern...]
- *       unmono  index pattern [pattern...]
- */
-
-static int
-_mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
-                     BUFFER * err, short parse_uncolor);
-
-int mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
-                        BUFFER * err)
-{
-  return _mutt_parse_uncolor (buf, s, data, err, 1);
-}
+    if ((*col = mutt_getvaluebyname (s, Colors)) == -1) {
+        snprintf (err->data, err->dsize, _("%s: no such color"), s);
+        return (-1);
+    }
 
-int mutt_parse_unmono (BUFFER * buf, BUFFER * s, unsigned long data,
-                       BUFFER * err)
-{
-  return _mutt_parse_uncolor (buf, s, data, err, 0);
+    return 0;
 }
 
-static int
-_mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data __attribute__ ((unused)),
-                     BUFFER * err, short parse_uncolor)
+/* usage: uncolor index pattern [pattern...] */
+int mutt_parse_uncolor(BUFFER *buf, BUFFER *s, unsigned long data, BUFFER
+                       *err)
 {
   int object = 0, do_cache = 0;
   COLOR_LINE *tmp, *last = NULL;
@@ -180,19 +139,16 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data __attribute__
 
   if (m_strncmp(buf->data, "index", 5) != 0) {
     snprintf (err->data, err->dsize,
-              _("%s: command valid only for index object"),
-              parse_uncolor ? "uncolor" : "unmono");
+              _("%s: command valid only for index object"), "uncolor");
     return (-1);
   }
 
   if (!MoreArgs (s)) {
-    snprintf (err->data, err->dsize,
-              _("%s: too few arguments"),
-              parse_uncolor ? "uncolor" : "unmono");
+    snprintf (err->data, err->dsize, _("%s: too few arguments"), "uncolor");
     return (-1);
   }
 
-  if (option (OPTNOCURSES) || (parse_uncolor != has_colors())) {
+  if (option(OPTNOCURSES)) {
     /* just eat the command, but don't do anything real about it */
     do {
       mutt_extract_token (buf, s, 0);
@@ -351,9 +307,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)
@@ -381,6 +334,7 @@ parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
   return 0;
 }
 
+#if 0
 static int
 parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
                  BUFFER * err)
@@ -417,6 +371,7 @@ parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
 
   return 0;
 }
+#endif
 
 static int fgbgattr_to_color (int fg, int bg, int attr)
 {
@@ -426,13 +381,8 @@ static int fgbgattr_to_color (int fg, int bg, int attr)
     return attr;
 }
 
-/* usage: color <object> <fg> <bg> [ <regexp> ] 
- *       mono  <object> <attr> [ <regexp> ]
- */
-
-static int
-_mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err,
-                   parser_callback_t callback, short dry_run)
+/* usage: color <object> <fg> <bg> [ <regexp> ] */
+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;
@@ -440,7 +390,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err,
   if (parse_object (buf, s, &object, &q_level, err) == -1)
     return -1;
 
-  if (callback (buf, s, &fg, &bg, &attr, err) == -1)
+  if (parse_color_pair(buf, s, &fg, &bg, &attr, err) == -1)
     return -1;
 
   /* extract a regular expression if needed */
@@ -460,16 +410,13 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, 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);
   }
@@ -498,37 +445,15 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, 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);
 }
-
-int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)),
-                      BUFFER * err)
-{
-  int dry_run = 0;
-
-  if (option (OPTNOCURSES) || !has_colors ())
-    dry_run = 1;
-
-  return _mutt_parse_color (buff, s, err, parse_color_pair, dry_run);
-}
-
-int mutt_parse_mono (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)),
-                     BUFFER * err)
-{
-  int dry_run = 0;
-
-  if (option (OPTNOCURSES) || has_colors ())
-    dry_run = 1;
-
-  return _mutt_parse_color (buff, s, err, parse_attr_spec, dry_run);
-}