-#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) {
- (p->count)++;
- return (COLOR_PAIR (p->index));
- }
- p = p->next;
- }
-
- /* check to see if there are colors left */
- if (++UserColors > COLOR_PAIRS)
- return (A_NORMAL);
-
- /* find the smallest available index (object) */
- i = 1;
- for (;;) {
- p = ColorList;
- while (p) {
- if (p->index == i)
- break;
- p = p->next;
- }
- if (p == NULL)
- break;
- i++;
- }
-
- p = p_new(COLOR_LIST, 1);
- p->next = ColorList;
- ColorList = p;
-
- p->index = i;
- p->count = 1;
- 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);
-
- return (COLOR_PAIR (p->index));
-}
-
-void mutt_free_color (int fg, int bg)
-{
- COLOR_LIST *p, *q;
-
- p = ColorList;
- while (p) {
- if (p->fg == fg && p->bg == bg) {
- (p->count)--;
- if (p->count > 0)
- return;
-
- UserColors--;
-
- if (p == ColorList) {
- ColorList = ColorList->next;
- p_delete(&p);
- return;
- }
- q = ColorList;
- while (q) {
- if (q->next == p) {
- q->next = p->next;
- p_delete(&p);
- return;
- }
- q = q->next;
- }
- /* can't get here */
- }
- p = p->next;
- }
-}
-
-#endif /* HAVE_COLOR */
-
-
-#ifdef HAVE_COLOR