/*
* Copyright (C) 1996-2002,2012 Michael R. Elkins <me@mutt.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "mutt.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mapping.h"
#include "color.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
/* globals */
COLOR_ATTR *ColorQuote;
int ColorQuoteUsed;
COLOR_ATTR ColorDefs[MT_COLOR_MAX];
COLOR_LINE *ColorHdrList = NULL;
COLOR_LINE *ColorBodyList = NULL;
COLOR_LINE *ColorIndexList = NULL;
/* local to this file */
static int ColorQuoteSize;
#if defined(HAVE_COLOR) && defined(HAVE_USE_DEFAULT_COLORS)
static int HaveDefaultColors = 0;
static int DefaultColorsInit = 0;
#endif
#ifdef HAVE_COLOR
#define COLOR_DEFAULT (-2)
typedef struct color_list
{
short fg;
short bg;
short pair;
short count;
unsigned int ansi : 1;
unsigned int overlay : 1;
struct color_list *next;
} COLOR_LIST;
/* color type for mutt_alloc_color() */
#define MUTT_COLOR_TYPE_NORMAL 1
#define MUTT_COLOR_TYPE_ANSI 2
#define MUTT_COLOR_TYPE_OVERLAY 3
static COLOR_LIST *ColorList = NULL;
static int UserColors = 0;
static int AnsiColors = 0;
static const struct mapping_t Colors[] =
{
{ "black", COLOR_BLACK },
{ "blue", COLOR_BLUE },
{ "cyan", COLOR_CYAN },
{ "green", COLOR_GREEN },
{ "magenta", COLOR_MAGENTA },
{ "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 }
};
#endif /* HAVE_COLOR */
static const struct mapping_t Fields[] =
{
{ "hdrdefault", MT_COLOR_HDEFAULT },
{ "quoted", MT_COLOR_QUOTED },
{ "signature", MT_COLOR_SIGNATURE },
{ "indicator", MT_COLOR_INDICATOR },
{ "status", MT_COLOR_STATUS },
{ "tree", MT_COLOR_TREE },
{ "error", MT_COLOR_ERROR },
{ "normal", MT_COLOR_NORMAL },
{ "tilde", MT_COLOR_TILDE },
{ "markers", MT_COLOR_MARKERS },
{ "header", MT_COLOR_HEADER },
{ "body", MT_COLOR_BODY },
{ "message", MT_COLOR_MESSAGE },
{ "attachment", MT_COLOR_ATTACHMENT },
{ "search", MT_COLOR_SEARCH },
{ "bold", MT_COLOR_BOLD },
{ "underline", MT_COLOR_UNDERLINE },
{ "index", MT_COLOR_INDEX },
{ "prompt", MT_COLOR_PROMPT },
#ifdef USE_SIDEBAR
{ "sidebar_divider", MT_COLOR_DIVIDER },
{ "sidebar_flagged", MT_COLOR_FLAGGED },
{ "sidebar_highlight",MT_COLOR_HIGHLIGHT },
{ "sidebar_indicator",MT_COLOR_SB_INDICATOR },
{ "sidebar_new", MT_COLOR_NEW },
{ "sidebar_spoolfile",MT_COLOR_SB_SPOOLFILE },
#endif
{ NULL, 0 }
};
static const struct mapping_t ComposeFields[] =
{
{ "header", MT_COLOR_COMPOSE_HEADER },
{ "security_encrypt", MT_COLOR_COMPOSE_SECURITY_ENCRYPT },
{ "security_sign", MT_COLOR_COMPOSE_SECURITY_SIGN },
{ "security_both", MT_COLOR_COMPOSE_SECURITY_BOTH },
{ "security_none", MT_COLOR_COMPOSE_SECURITY_NONE },
{ NULL, 0