Move the rest of mutt "things" into a window as well.
[apps/madmutt.git] / lib-ui / color.c
index 4d87857..9a1a65d 100644 (file)
@@ -7,10 +7,7 @@
  * please see the file GPL in the top level source directory.
  */
 
-#include <lib-lib/lib-lib.h>
-
-#include "curses.h"
-
+#include <lib-ui/lib-ui.h>
 #include "pattern.h"
 #include "mutt.h"
 
@@ -47,9 +44,7 @@ static struct mapping_t Colors[] = {
   {"red", COLOR_RED},
   {"white", COLOR_WHITE},
   {"yellow", COLOR_YELLOW},
-#if defined (USE_SLANG_CURSES) || defined (HAVE_USE_DEFAULT_COLORS)
   {"default", COLOR_DEFAULT},
-#endif
   {0, 0}
 };
 
@@ -129,51 +124,11 @@ void ci_start_color (void)
     start_color ();
 }
 
-#ifdef USE_SLANG_CURSES
-static char *get_color_name (char *dest, size_t destlen, int val)
-{
-  static char *missing[3] = { "brown", "lightgray", "default" };
-  int i;
-
-  switch (val) {
-  case COLOR_YELLOW:
-    m_strcpy(dest, destlen, missing[0]);
-    return dest;
-
-  case COLOR_WHITE:
-    m_strcpy(dest, destlen, missing[1]);
-    return dest;
-
-  case COLOR_DEFAULT:
-    m_strcpy(dest, destlen, missing[2]);
-    return dest;
-  }
-
-  for (i = 0; Colors[i].name; i++) {
-    if (Colors[i].value == val) {
-      m_strcpy(dest, destlen, Colors[i].name);
-      return dest;
-    }
-  }
-
-  /* Sigh. If we got this far, the color is of the form 'colorN'
-   * Slang can handle this itself, so just return 'colorN'
-   */
-
-  snprintf (dest, destlen, "color%d", val);
-  return dest;
-}
-#endif
-
 int mutt_alloc_color (int fg, int bg)
 {
   COLOR_LIST *p = ColorList;
   int i;
 
-#if defined (USE_SLANG_CURSES)
-  char fgc[STRING], bgc[STRING];
-#endif
-
   /* check to see if this color is already allocated to save space */
   while (p) {
     if (p->fg == fg && p->bg == bg) {
@@ -210,17 +165,10 @@ int mutt_alloc_color (int fg, int bg)
   p->bg = bg;
   p->fg = fg;
 
-#if defined (USE_SLANG_CURSES)
-  if (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT)
-    SLtt_set_color (i, NULL, get_color_name (fgc, sizeof (fgc), fg),
-                    get_color_name (bgc, sizeof (bgc), bg));
-  else
-#elif defined (HAVE_USE_DEFAULT_COLORS)
   if (fg == COLOR_DEFAULT)
     fg = -1;
   if (bg == COLOR_DEFAULT)
     bg = -1;
-#endif
 
   init_pair (i, fg, bg);
 
@@ -612,7 +560,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)
@@ -620,7 +567,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);
@@ -653,10 +599,8 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err,
   else
     ColorDefs[object] = fgbgattr_to_color (fg, bg, attr);
 
-#ifdef HAVE_BKGDSET
   if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors ())
-    BKGDSET (MT_COLOR_NORMAL);
-#endif
+    BKGDSET(main_w, MT_COLOR_NORMAL);
 
   return (r);
 }