diff -urp ../MUTT/mutt/PATCHES mutt/PATCHES --- ../MUTT/mutt/PATCHES 2002-12-09 18:44:54.000000000 +0100 +++ mutt/PATCHES 2005-02-27 14:16:46.000000000 +0100 @@ -0,0 +1 @@ +patch-1.5.8.greek0.indexcolor.2+cb diff -urp ../MUTT/mutt/color.c mutt/color.c --- ../MUTT/mutt/color.c 2005-02-10 00:26:03.000000000 +0100 +++ mutt/color.c 2005-02-27 16:45:45.000000000 +0100 @@ -93,6 +93,13 @@ static struct mapping_t Fields[] = { "bold", MT_COLOR_BOLD }, { "underline", MT_COLOR_UNDERLINE }, { "index", MT_COLOR_INDEX }, + { "index_author", MT_COLOR_INDEX_AUTHOR }, + { "index_date", MT_COLOR_INDEX_DATE }, + { "index_flags", MT_COLOR_INDEX_FLAGS }, + { "index_label", MT_COLOR_INDEX_LABEL }, + { "index_number", MT_COLOR_INDEX_NUMBER }, + { "index_size", MT_COLOR_INDEX_SIZE }, + { "index_subject", MT_COLOR_INDEX_SUBJECT }, { NULL, 0 } }; @@ -379,6 +386,13 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER return (-1); } + if (object > MT_COLOR_INDEX) /* uncolor index column */ + { + ColorDefs[object] = 0; + set_option (OPTFORCEREDRAWINDEX); + return (0); + } + if (mutt_strncmp (buf->data, "index", 5) != 0) { snprintf (err->data, err->dsize, @@ -762,7 +776,11 @@ _mutt_parse_color (BUFFER *buf, BUFFER * ColorQuote[q_level] = fgbgattr_to_color(fg, bg, attr); } else + { ColorDefs[object] = fgbgattr_to_color(fg, bg, attr); + if (object > MT_COLOR_INDEX) + set_option (OPTFORCEREDRAWINDEX); + } #ifdef HAVE_COLOR # ifdef HAVE_BKGDSET diff -urp ../MUTT/mutt/curs_lib.c mutt/curs_lib.c --- ../MUTT/mutt/curs_lib.c 2005-02-10 00:26:03.000000000 +0100 +++ mutt/curs_lib.c 2005-02-27 02:33:07.000000000 +0100 @@ -595,6 +595,7 @@ void mutt_format_string (char *dest, siz size_t k, k2; char scratch[MB_LEN_MAX]; mbstate_t mbstate1, mbstate2; + int escaped = 0; memset(&mbstate1, 0, sizeof (mbstate1)); memset(&mbstate2, 0, sizeof (mbstate2)); @@ -607,7 +608,15 @@ void mutt_format_string (char *dest, siz k = (k == (size_t)(-1)) ? 1 : n; wc = replacement_char (); } - if (arboreal && wc < M_TREE_MAX) + if (escaped) { + escaped = 0; + w = 0; + } + else if (arboreal && wc == M_SPECIAL_INDEX) { + escaped = 1; + w = 0; + } + else if (arboreal && wc < M_TREE_MAX) w = 1; /* hack */ else { diff -urp ../MUTT/mutt/hdrline.c mutt/hdrline.c --- ../MUTT/mutt/hdrline.c 2005-02-12 21:13:19.000000000 +0100 +++ mutt/hdrline.c 2005-02-27 17:05:40.000000000 +0100 @@ -99,6 +99,34 @@ static int first_mailing_list (char *buf return 0; } +/* Takes the color to embed, the buffer to manipulate and the buffer length as + * arguments. + * Returns the number of chars written. */ +static size_t add_index_color(char *buf, size_t buflen, + format_flag flags, char color) +{ + int len; + + /* only add color markers if we are operating on main index entries. */ + if (!(flags & M_FORMAT_INDEX)) + return 0; + + if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */ + len = mutt_strlen(buf); + buf += len; + buflen -= len; + } + + if (buflen < 2) + return 0; + + buf[0] = M_SPECIAL_INDEX; + buf[1] = color; + buf[2] = '\0'; + + return 2; +} + static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists) { int me; @@ -250,6 +278,7 @@ hdr_format_str (char *dest, #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1) #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2) size_t len; + size_t colorlen; hdr = hfi->hdr; ctx = hfi->ctx; @@ -301,12 +330,17 @@ hdr_format_str (char *dest, break; case 'c': + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length); - mutt_format_s (dest, destlen, prefix, buf2); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); break; case 'C': - snprintf (fmt, sizeof (fmt), "%%%sd", prefix); + colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER); + snprintf (fmt+colorlen, sizeof(fmt)-colorlen, "%%%sd", prefix); + add_index_color(fmt+colorlen, sizeof(fmt)-colorlen, flags, MT_COLOR_INDEX); + snprintf (dest, destlen, fmt, hdr->msgno + 1); break; @@ -405,7 +439,10 @@ hdr_format_str (char *dest, if (do_locales) setlocale (LC_TIME, "C"); - mutt_format_s (dest, destlen, prefix, buf2); + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_DATE); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */ src = cp + 1; } @@ -435,8 +472,10 @@ hdr_format_str (char *dest, case 'F': if (!optional) { + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); make_from (hdr->env, buf2, sizeof (buf2), 0); - mutt_format_s (dest, destlen, prefix, buf2); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); } else if (mutt_addr_is_user (hdr->env->from)) optional = 0; @@ -462,7 +501,9 @@ hdr_format_str (char *dest, if (!optional) { snprintf (fmt, sizeof (fmt), "%%%sd", prefix); - snprintf (dest, destlen, fmt, (int) hdr->lines); + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); + snprintf (dest+colorlen, destlen-colorlen, fmt, (int) hdr->lines); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); } else if (hdr->lines <= 0) optional = 0; @@ -471,8 +512,10 @@ hdr_format_str (char *dest, case 'L': if (!optional) { + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); make_from (hdr->env, buf2, sizeof (buf2), 1); - mutt_format_s (dest, destlen, prefix, buf2); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); } else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) && !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0)) @@ -547,15 +590,23 @@ hdr_format_str (char *dest, { if (flags & M_FORMAT_FORCESUBJ) { - mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject)); + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); + mutt_format_s (dest+colorlen, destlen-colorlen, "", + NONULL (hdr->env->subject)); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest); mutt_format_s_tree (dest, destlen, prefix, buf2); } else mutt_format_s_tree (dest, destlen, prefix, hdr->tree); } - else - mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject)); + else { + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, + NONULL (hdr->env->subject)); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + } break; case 'S': @@ -651,14 +702,20 @@ hdr_format_str (char *dest, hdr->tagged ? '*' : (hdr->flagged ? '!' : (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' '))); - mutt_format_s (dest, destlen, prefix, buf2); + + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + break; case 'y': if (optional) optional = hdr->env->x_label ? 1 : 0; - mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); break; case 'Y': @@ -684,10 +741,12 @@ hdr_format_str (char *dest, if (optional) optional = i; + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); if (i) - mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); else - mutt_format_s (dest, destlen, prefix, ""); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, ""); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); break; diff -urp ../MUTT/mutt/menu.c mutt/menu.c --- ../MUTT/mutt/menu.c 2005-02-12 21:13:20.000000000 +0100 +++ mutt/menu.c 2005-02-27 02:33:07.000000000 +0100 @@ -133,6 +133,18 @@ static void print_enriched_string (int a } if (do_color) attrset(attr); } + else if(*s == M_SPECIAL_INDEX) + { + s++; + if (do_color) { + if (*s == MT_COLOR_INDEX) + attrset(attr); + else + ADDCOLOR(*s); + } + s++; + n -= 2; + } else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0) { addnstr ((char *)s, k); diff -urp ../MUTT/mutt/mutt.h mutt/mutt.h --- ../MUTT/mutt/mutt.h 2005-02-12 21:13:20.000000000 +0100 +++ mutt/mutt.h 2005-02-27 02:33:07.000000000 +0100 @@ -176,6 +176,9 @@ typedef enum #define M_TREE_MISSING 13 #define M_TREE_MAX 14 +#define M_SPECIAL_INDEX M_TREE_MAX +#define M_SPECIAL_MAX (M_TREE_MAX+1) + #define M_THREAD_COLLAPSE (1<<0) #define M_THREAD_UNCOLLAPSE (1<<1) #define M_THREAD_GET_HIDDEN (1<<2) diff -urp ../MUTT/mutt/mutt_curses.h mutt/mutt_curses.h --- ../MUTT/mutt/mutt_curses.h 2004-06-18 17:24:22.000000000 +0200 +++ mutt/mutt_curses.h 2005-02-27 16:27:33.000000000 +0100 @@ -120,7 +120,14 @@ enum MT_COLOR_SEARCH, MT_COLOR_BOLD, MT_COLOR_UNDERLINE, - MT_COLOR_INDEX, + MT_COLOR_INDEX, /* please no non-MT_COLOR_INDEX objects after this point */ + MT_COLOR_INDEX_AUTHOR, + MT_COLOR_INDEX_DATE, + MT_COLOR_INDEX_FLAGS, + MT_COLOR_INDEX_LABEL, + MT_COLOR_INDEX_NUMBER, + MT_COLOR_INDEX_SIZE, + MT_COLOR_INDEX_SUBJECT, MT_COLOR_MAX };