Signed-off-by: Pierre Habouzit <madcoder@debian.org>
AC_CHECK_LIB(termlib, main)
fi
AC_DEFINE(USE_SLANG_CURSES,1, [ Define if you compile with SLang instead of curses/ncurses. ])
AC_CHECK_LIB(termlib, main)
fi
AC_DEFINE(USE_SLANG_CURSES,1, [ Define if you compile with SLang instead of curses/ncurses. ])
- AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
dnl --- now that we've found it, check the link
dnl --- now that we've found it, check the link
LIBS="$LIBS $MUTTLIBS"
CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
[start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
LIBS="$LIBS $MUTTLIBS"
CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
[start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
- if test "$ac_cv_func_decl_start_color" = yes; then
- AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
+ if test "$ac_cv_func_decl_start_color" != yes; then
+ AC_MSG_ERROR([Your curses library does not supports color.])
#ifdef USE_LIBESMTP
"libesmtp",
#endif
#ifdef USE_LIBESMTP
"libesmtp",
#endif
-#ifdef HAVE_COLOR
- "color",
-#endif
#ifdef CRYPT_BACKEND_GPGME
"gpgme",
#endif
#ifdef CRYPT_BACKEND_GPGME
"gpgme",
#endif
{"alternative_order", parse_list, UL &AlternativeOrderList},
{"bind", mutt_parse_bind, 0},
{"charset-hook", mutt_parse_hook, M_CHARSETHOOK},
{"alternative_order", parse_list, UL &AlternativeOrderList},
{"bind", mutt_parse_bind, 0},
{"charset-hook", mutt_parse_hook, M_CHARSETHOOK},
{"color", mutt_parse_color, 0},
{"uncolor", mutt_parse_uncolor, 0},
{"color", mutt_parse_color, 0},
{"uncolor", mutt_parse_uncolor, 0},
{"exec", mutt_parse_exec, 0},
{"fcc-hook", mutt_parse_hook, M_FCCHOOK},
{"fcc-save-hook", mutt_parse_hook, M_FCCHOOK|M_SAVEHOOK},
{"exec", mutt_parse_exec, 0},
{"fcc-hook", mutt_parse_hook, M_FCCHOOK},
{"fcc-save-hook", mutt_parse_hook, M_FCCHOOK|M_SAVEHOOK},
/* local to this file */
static int ColorQuoteSize;
/* local to this file */
static int ColorQuoteSize;
#define COLOR_DEFAULT (-2)
typedef struct color_list {
#define COLOR_DEFAULT (-2)
typedef struct color_list {
-#endif /* HAVE_COLOR */
-
static struct mapping_t Fields[] = {
{"hdrdefault", MT_COLOR_HDEFAULT},
{"quoted", MT_COLOR_QUOTED},
static struct mapping_t Fields[] = {
{"hdrdefault", MT_COLOR_HDEFAULT},
{"quoted", MT_COLOR_QUOTED},
if (free_colors && tmp->fg != -1 && tmp->bg != -1)
mutt_free_color (tmp->fg, tmp->bg);
if (free_colors && tmp->fg != -1 && tmp->bg != -1)
mutt_free_color (tmp->fg, tmp->bg);
- /* we should really introduce a container
- * type for regular expressions.
- */
+ /* we should really use the container type for regular expressions. */
regfree (&tmp->rx);
pattern_list_wipe(&tmp->color_pattern);
regfree (&tmp->rx);
pattern_list_wipe(&tmp->color_pattern);
ColorDefs[MT_COLOR_BOLD] = 0;
ColorDefs[MT_COLOR_UNDERLINE] = 0;
ColorDefs[MT_COLOR_BOLD] = 0;
ColorDefs[MT_COLOR_UNDERLINE] = 0;
#ifdef USE_SLANG_CURSES
static char *get_color_name (char *dest, size_t destlen, int val)
{
#ifdef USE_SLANG_CURSES
static char *get_color_name (char *dest, size_t destlen, int val)
{
-#endif /* HAVE_COLOR */
-
-
-#ifdef HAVE_COLOR
-
static int
parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err)
{
static int
parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err)
{
/* usage: uncolor index pattern [pattern...]
* unmono index pattern [pattern...]
*/
/* usage: uncolor index pattern [pattern...]
* unmono index pattern [pattern...]
*/
_mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
BUFFER * err, short parse_uncolor);
_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);
}
int mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
BUFFER * err)
{
return _mutt_parse_uncolor (buf, s, data, err, 1);
}
int mutt_parse_unmono (BUFFER * buf, BUFFER * s, unsigned long data,
BUFFER * err)
{
int mutt_parse_unmono (BUFFER * buf, BUFFER * s, unsigned long data,
BUFFER * err)
{
- if (
-#ifdef HAVE_COLOR
- /* we're running without curses */
- option (OPTNOCURSES)
- || /* we're parsing an uncolor command, and have no colors */
- (parse_uncolor && !has_colors ())
- /* we're parsing an unmono command, and have colors */
- || (!parse_uncolor && has_colors ())
-#else
- /* We don't even have colors compiled in */
- parse_uncolor
-#endif
- ) {
+ if (option (OPTNOCURSES) || (parse_uncolor != has_colors())) {
/* just eat the command, but don't do anything real about it */
/* just eat the command, but don't do anything real about it */
mutt_extract_token (buf, s, 0);
mutt_extract_token (buf, s, 0);
- while (MoreArgs (s));
-
do {
mutt_extract_token (buf, s, 0);
if (!m_strcmp("*", buf->data)) {
do {
mutt_extract_token (buf, s, 0);
if (!m_strcmp("*", buf->data)) {
if (fg != -1 && bg != -1) {
if (tmp->fg != fg || tmp->bg != bg) {
mutt_free_color (tmp->fg, tmp->bg);
if (fg != -1 && bg != -1) {
if (tmp->fg != fg || tmp->bg != bg) {
mutt_free_color (tmp->fg, tmp->bg);
else
attr |= (tmp->pair & ~A_BOLD);
}
else
attr |= (tmp->pair & ~A_BOLD);
}
}
tmp->next = *top;
tmp->pattern = m_strdup(s);
}
tmp->next = *top;
tmp->pattern = m_strdup(s);
if (fg != -1 && bg != -1) {
tmp->fg = fg;
tmp->bg = bg;
attr |= mutt_alloc_color (fg, bg);
}
if (fg != -1 && bg != -1) {
tmp->fg = fg;
tmp->bg = bg;
attr |= mutt_alloc_color (fg, bg);
}
tmp->pair = attr;
*top = tmp;
}
tmp->pair = attr;
*top = tmp;
}
typedef int (*parser_callback_t) (BUFFER *, BUFFER *, int *, int *, int *,
BUFFER *);
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)
static int
parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
BUFFER * err)
static int
parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
BUFFER * err)
static int
parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
BUFFER * err)
static int fgbgattr_to_color (int fg, int bg, int attr)
{
static int fgbgattr_to_color (int fg, int bg, int attr)
{
if (fg != -1 && bg != -1)
return attr | mutt_alloc_color (fg, bg);
else
if (fg != -1 && bg != -1)
return attr | mutt_alloc_color (fg, bg);
else
-#ifdef HAVE_COLOR
-# ifdef HAVE_USE_DEFAULT_COLORS
+#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)
if (!option (OPTNOCURSES) && has_colors ()
/* delay use_default_colors() until needed, since it initializes things */
&& (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT)
m_strcpy(err->data, err->dsize, _("default colors not supported"));
return (-1);
}
m_strcpy(err->data, err->dsize, _("default colors not supported"));
return (-1);
}
-# endif /* HAVE_USE_DEFAULT_COLORS */
-#endif
+#endif /* HAVE_USE_DEFAULT_COLORS */
if (object == MT_COLOR_HEADER)
r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err, 0);
if (object == MT_COLOR_HEADER)
r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err, 0);
else
ColorDefs[object] = fgbgattr_to_color (fg, bg, attr);
else
ColorDefs[object] = fgbgattr_to_color (fg, bg, attr);
-#ifdef HAVE_COLOR
-# ifdef HAVE_BKGDSET
if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors ())
BKGDSET (MT_COLOR_NORMAL);
if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors ())
BKGDSET (MT_COLOR_NORMAL);
int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)),
BUFFER * err)
{
int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)),
BUFFER * err)
{
return _mutt_parse_color (buff, s, err, parse_color_pair, dry_run);
}
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;
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;
if (option (OPTNOCURSES) || has_colors ())
dry_run = 1;
-#else
- if (option (OPTNOCURSES))
- dry_run = 1;
-#endif
return _mutt_parse_color (buff, s, err, parse_attr_spec, dry_run);
}
return _mutt_parse_color (buff, s, err, parse_attr_spec, dry_run);
}
"-HAVE_REGCOMP "
#endif
"\n "
"-HAVE_REGCOMP "
#endif
"\n "
-#ifdef HAVE_COLOR
- "+HAVE_COLOR "
-#else
- "-HAVE_COLOR "
-#endif
#ifdef HAVE_START_COLOR
"+HAVE_START_COLOR "
#else
#ifdef HAVE_START_COLOR
"+HAVE_START_COLOR "
#else
/* handle "special" bold & underlined characters */
if (special || a->attr) {
/* handle "special" bold & underlined characters */
if (special || a->attr) {
if ((a->attr & ANSI_COLOR)) {
if (a->pair == -1)
a->pair = mutt_alloc_color (a->fg, a->bg);
color = a->pair;
if (a->attr & ANSI_BOLD)
color |= A_BOLD;
if ((a->attr & ANSI_COLOR)) {
if (a->pair == -1)
a->pair = mutt_alloc_color (a->fg, a->bg);
color = a->pair;
if (a->attr & ANSI_BOLD)
color |= A_BOLD;
if ((special & A_BOLD) || (a->attr & ANSI_BOLD)) {
if (ColorDefs[MT_COLOR_BOLD] && !search)
color = ColorDefs[MT_COLOR_BOLD];
if ((special & A_BOLD) || (a->attr & ANSI_BOLD)) {
if (ColorDefs[MT_COLOR_BOLD] && !search)
color = ColorDefs[MT_COLOR_BOLD];
/* Character Attributes */
if (option (OPTALLOWANSI) && a != NULL && buf[x] == 'm') {
if (pos == x) {
/* Character Attributes */
if (option (OPTALLOWANSI) && a != NULL && buf[x] == 'm') {
if (pos == x) {
if (a->pair != -1)
mutt_free_color (a->fg, a->bg);
if (a->pair != -1)
mutt_free_color (a->fg, a->bg);
a->attr = ANSI_OFF;
a->pair = -1;
}
a->attr = ANSI_OFF;
a->pair = -1;
}
pos += 2;
}
else if (buf[pos] == '3' && isdigit (buf[pos + 1])) {
pos += 2;
}
else if (buf[pos] == '3' && isdigit (buf[pos + 1])) {
if (a->pair != -1)
mutt_free_color (a->fg, a->bg);
if (a->pair != -1)
mutt_free_color (a->fg, a->bg);
a->pair = -1;
a->attr |= ANSI_COLOR;
if (buf[pos + 1] != '9')
a->pair = -1;
a->attr |= ANSI_COLOR;
if (buf[pos + 1] != '9')
pos += 3;
}
else if (buf[pos] == '4' && isdigit (buf[pos + 1])) {
pos += 3;
}
else if (buf[pos] == '4' && isdigit (buf[pos + 1])) {
if (a->pair != -1)
mutt_free_color (a->fg, a->bg);
if (a->pair != -1)
mutt_free_color (a->fg, a->bg);
a->pair = -1;
a->attr |= ANSI_COLOR;
if (buf[pos + 1] != '9')
a->pair = -1;
a->attr |= ANSI_COLOR;
if (buf[pos + 1] != '9')