1 diff -ur mutt-1.5.20/PATCHES mutt-indexcolor/PATCHES
2 --- mutt-1.5.20/PATCHES 2010-07-11 19:32:01.396756181 -0400
3 +++ mutt-indexcolor/PATCHES 2010-07-11 19:33:38.536226982 -0400
5 +mutt-1.5.8-indexcolor-3
6 diff -ur mutt-1.5.20/color.c mutt-indexcolor/color.c
7 --- mutt-1.5.20/color.c 2010-07-11 19:32:01.310095183 -0400
8 +++ mutt-indexcolor/color.c 2010-07-11 19:41:38.359613634 -0400
10 COLOR_LINE *ColorHdrList = NULL;
11 COLOR_LINE *ColorBodyList = NULL;
12 COLOR_LINE *ColorIndexList = NULL;
13 +COLOR_LINE *ColorIndexSubjectList = NULL;
14 +COLOR_LINE *ColorIndexAuthorList = NULL;
16 /* local to this file */
17 static int ColorQuoteSize;
19 { "bold", MT_COLOR_BOLD },
20 { "underline", MT_COLOR_UNDERLINE },
21 { "index", MT_COLOR_INDEX },
22 + { "index_subject", MT_COLOR_INDEX_SUBJECT },
23 + { "index_author", MT_COLOR_INDEX_AUTHOR },
24 + { "index_collapsed", MT_COLOR_INDEX_COLLAPSED },
25 + { "index_date", MT_COLOR_INDEX_DATE },
26 + { "index_flags", MT_COLOR_INDEX_FLAGS },
27 + { "index_label", MT_COLOR_INDEX_LABEL },
28 + { "index_number", MT_COLOR_INDEX_NUMBER },
29 + { "index_size", MT_COLOR_INDEX_SIZE },
30 { "sidebar_new", MT_COLOR_NEW },
31 { "sidebar_flagged", MT_COLOR_FLAGGED },
34 return _mutt_parse_uncolor(buf, s, data, err, 0);
38 +mutt_do_uncolor (BUFFER *buf, BUFFER *s, COLOR_LINE **ColorList,
39 + int *do_cache, int parse_uncolor)
41 + COLOR_LINE *tmp, *last = NULL;
45 + mutt_extract_token (buf, s, 0);
46 + if (!mutt_strcmp ("*", buf->data))
48 + for (tmp = *ColorList; tmp; )
54 + mutt_free_color_line(&last, parse_uncolor);
60 + for (last = NULL, tmp = *ColorList; tmp; last = tmp, tmp = tmp->next)
62 + if (!mutt_strcmp (buf->data, tmp->pattern))
66 + dprint(1,(debugfile,"Freeing pattern \"%s\" from ColorList\n",
69 + last->next = tmp->next;
71 + *ColorList = tmp->next;
72 + mutt_free_color_line(&tmp, parse_uncolor);
78 + while (MoreArgs (s));
82 static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
83 BUFFER *err, short parse_uncolor)
89 + if (object > MT_COLOR_INDEX_AUTHOR) /* uncolor index column */
91 + ColorDefs[object] = 0;
92 + set_option (OPTFORCEREDRAWINDEX);
96 if (mutt_strncmp (buf->data, "index", 5) == 0)
97 list = &ColorIndexList;
98 else if (mutt_strncmp (buf->data, "body", 4) == 0)
105 - mutt_extract_token (buf, s, 0);
106 - if (!mutt_strcmp ("*", buf->data))
108 - for (tmp = *list; tmp; )
114 - mutt_free_color_line(&last, parse_uncolor);
120 - for (last = NULL, tmp = *list; tmp; last = tmp, tmp = tmp->next)
122 - if (!mutt_strcmp (buf->data, tmp->pattern))
126 - dprint(1,(debugfile,"Freeing pattern \"%s\" from color list\n",
129 - last->next = tmp->next;
132 - mutt_free_color_line(&tmp, parse_uncolor);
138 - while (MoreArgs (s));
139 + if (object == MT_COLOR_INDEX)
140 + mutt_do_uncolor(buf, s, &ColorIndexList, &do_cache, parse_uncolor);
141 + if (object == MT_COLOR_INDEX_SUBJECT)
142 + mutt_do_uncolor(buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor);
143 + if (object == MT_COLOR_INDEX_AUTHOR)
144 + mutt_do_uncolor(buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor);
147 if (do_cache && !option (OPTNOCURSES))
150 /* extract a regular expression if needed */
152 - if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX)
153 + if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX || object == MT_COLOR_INDEX_SUBJECT || object == MT_COLOR_INDEX_AUTHOR)
158 r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1);
159 set_option (OPTFORCEREDRAWINDEX);
161 + else if (object == MT_COLOR_INDEX_SUBJECT)
163 + r = add_pattern (&ColorIndexSubjectList, buf->data,
164 + 1, fg, bg, attr, err, 1);
165 + set_option (OPTFORCEREDRAWINDEX);
167 + else if (object == MT_COLOR_INDEX_AUTHOR)
169 + r = add_pattern (&ColorIndexAuthorList, buf->data,
170 + 1, fg, bg, attr, err, 1);
171 + set_option (OPTFORCEREDRAWINDEX);
173 else if (object == MT_COLOR_QUOTED)
175 if (q_level >= ColorQuoteSize)
177 ColorQuote[q_level] = fgbgattr_to_color(fg, bg, attr);
181 ColorDefs[object] = fgbgattr_to_color(fg, bg, attr);
182 + if (object > MT_COLOR_INDEX_AUTHOR)
183 + set_option (OPTFORCEREDRAWINDEX);
188 diff -ur mutt-1.5.20/curs_lib.c mutt-indexcolor/curs_lib.c
189 --- mutt-1.5.20/curs_lib.c 2009-03-31 02:52:43.000000000 -0400
190 +++ mutt-indexcolor/curs_lib.c 2010-07-11 19:33:38.532584661 -0400
193 char scratch[MB_LEN_MAX];
194 mbstate_t mbstate1, mbstate2;
197 memset(&mbstate1, 0, sizeof (mbstate1));
198 memset(&mbstate2, 0, sizeof (mbstate2));
200 k = (k == (size_t)(-1)) ? 1 : n;
201 wc = replacement_char ();
203 - if (arboreal && wc < M_TREE_MAX)
208 + else if (arboreal && wc == M_SPECIAL_INDEX) {
212 + else if (arboreal && wc < M_TREE_MAX)
216 diff -ur mutt-1.5.20/doc/manual.xml.head mutt-indexcolor/doc/manual.xml.head
217 --- mutt-1.5.20/doc/manual.xml.head 2010-07-11 19:32:01.400093495 -0400
218 +++ mutt-indexcolor/doc/manual.xml.head 2010-07-11 19:50:28.489149038 -0400
219 @@ -2470,7 +2470,7 @@
221 <command>color</command>
223 -<option>index</option>
224 +<option>object</option>
227 <replaceable class="parameter">foreground</replaceable>
228 @@ -2485,7 +2485,7 @@
229 <command>uncolor</command>
232 -<option>index</option>
233 +<option>object</option>
236 <option>header</option>
237 @@ -2526,6 +2526,14 @@
238 <listitem><para>bold (hiliting bold patterns in the body of messages)</para></listitem>
239 <listitem><para>error (error messages printed by Mutt)</para></listitem>
240 <listitem><para>hdrdefault (default color of the message header in the pager)</para></listitem>
241 +<listitem><para>index_author (color of the author name in the index, uses <emphasis>pattern</emphasis>)</para></listitem>
242 +<listitem><para>index_collapsed (the number of messages in a collapsed thread in the index)</para></listitem>
243 +<listitem><para>index_date (color of the date field in the index)</para></listitem>
244 +<listitem><para>index_flags (color of the message flags in the index)</para></listitem>
245 +<listitem><para>index_label (color of the message label in the index)</para></listitem>
246 +<listitem><para>index_number (color of the message number in the index)</para></listitem>
247 +<listitem><para>index_size (color of the message size and line number in the index)</para></listitem>
248 +<listitem><para>index_subject (color of the subject in the index, uses <emphasis>pattern</emphasis>)</para></listitem>
249 <listitem><para>indicator (arrow or bar used to indicate the current item in a menu)</para></listitem>
250 <listitem><para>markers (the <quote>+</quote> markers at the beginning of wrapped lines in the pager)</para></listitem>
251 <listitem><para>message (informational messages)</para></listitem>
252 diff -ur mutt-1.5.20/hdrline.c mutt-indexcolor/hdrline.c
253 --- mutt-1.5.20/hdrline.c 2010-07-11 19:32:01.373422137 -0400
254 +++ mutt-indexcolor/hdrline.c 2010-07-11 19:33:38.532584661 -0400
259 +/* Takes the color to embed, the buffer to manipulate and the buffer length as
261 + * Returns the number of chars written. */
262 +static size_t add_index_color(char *buf, size_t buflen,
263 + format_flag flags, char color)
267 + /* only add color markers if we are operating on main index entries. */
268 + if (!(flags & M_FORMAT_INDEX))
271 + if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */
272 + len = mutt_strlen(buf);
280 + buf[0] = M_SPECIAL_INDEX;
287 static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
291 #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1)
292 #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2)
298 @@ -308,12 +337,17 @@
302 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE);
303 mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length);
304 - mutt_format_s (dest, destlen, prefix, buf2);
305 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
306 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
310 - snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
311 + colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER);
312 + snprintf (fmt+colorlen, sizeof(fmt)-colorlen, "%%%sd", prefix);
313 + add_index_color(fmt+colorlen, sizeof(fmt)-colorlen, flags, MT_COLOR_INDEX);
315 snprintf (dest, destlen, fmt, hdr->msgno + 1);
320 setlocale (LC_TIME, "C");
322 - mutt_format_s (dest, destlen, prefix, buf2);
323 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_DATE);
324 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
325 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
327 if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */
334 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
335 make_from (hdr->env, buf2, sizeof (buf2), 0);
336 - mutt_format_s (dest, destlen, prefix, buf2);
337 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
338 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
340 else if (mutt_addr_is_user (hdr->env->from))
345 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
346 - snprintf (dest, destlen, fmt, (int) hdr->lines);
347 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE);
348 + snprintf (dest+colorlen, destlen-colorlen, fmt, (int) hdr->lines);
349 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
351 else if (hdr->lines <= 0)
357 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
358 make_from (hdr->env, buf2, sizeof (buf2), 1);
359 - mutt_format_s (dest, destlen, prefix, buf2);
360 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
361 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
363 else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) &&
364 !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0))
365 @@ -565,10 +608,16 @@
366 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
369 - if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1)
370 - snprintf (dest, destlen, fmt, hdr->num_hidden);
371 - else if (is_index && threads)
372 - mutt_format_s (dest, destlen, prefix, " ");
373 + colorlen = add_index_color(dest, destlen, flags,
374 + MT_COLOR_INDEX_COLLAPSED);
375 + if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) {
376 + snprintf (dest+colorlen, destlen-colorlen, fmt, hdr->num_hidden);
377 + add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX);
379 + else if (is_index && threads) {
380 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, " ");
381 + add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX);
386 @@ -598,15 +647,23 @@
388 if (flags & M_FORMAT_FORCESUBJ)
390 - mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject));
391 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT);
392 + mutt_format_s (dest+colorlen, destlen-colorlen, "",
393 + NONULL (hdr->env->subject));
394 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
396 snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
397 mutt_format_s_tree (dest, destlen, prefix, buf2);
400 mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
403 - mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject));
405 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT);
406 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix,
407 + NONULL (hdr->env->subject));
408 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
415 (hdr->flagged ? '!' :
416 (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' ')));
417 - mutt_format_s (dest, destlen, prefix, buf2);
418 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS);
419 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
420 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
426 optional = hdr->env->x_label ? 1 : 0;
428 - mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
429 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL);
430 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label));
431 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
435 @@ -755,10 +816,12 @@
439 + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL);
441 - mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
442 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label));
444 - mutt_format_s (dest, destlen, prefix, "");
445 + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, "");
446 + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
450 diff -ur mutt-1.5.20/menu.c mutt-indexcolor/menu.c
451 --- mutt-1.5.20/menu.c 2010-07-11 19:32:01.313427608 -0400
452 +++ mutt-indexcolor/menu.c 2010-07-11 19:44:52.525857008 -0400
455 char* SearchBuffers[MENU_MAX];
457 -static void print_enriched_string (int attr, unsigned char *s, int do_color)
458 +static int get_color(int index, int type) {
460 + HEADER *hdr = Context->hdrs[index];
463 + case MT_COLOR_INDEX_SUBJECT:
464 + color = ColorIndexSubjectList;
466 + case MT_COLOR_INDEX_AUTHOR:
467 + color = ColorIndexAuthorList;
470 + return ColorDefs[type];
473 + for (; color; color = color->next)
474 + if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS,
476 + return color->pair;
481 +static void print_enriched_string (int index, int attr, unsigned char *s, int do_color)
487 if (do_color) attrset(attr);
489 + else if(*s == M_SPECIAL_INDEX)
493 + if (*s == MT_COLOR_INDEX)
496 + attron(get_color(index, *s));
501 else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0)
503 addnstr ((char *)s, k);
508 - print_enriched_string (menu->color(i), (unsigned char *) buf, 1);
509 + print_enriched_string (i, menu->color(i), (unsigned char *) buf, 1);
510 SETCOLOR (MT_COLOR_NORMAL);
516 CLEARLINE_WIN (i - menu->top + menu->offset);
517 - print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
518 + print_enriched_string (i, menu->color(i), (unsigned char *) buf, i != menu->current);
519 SETCOLOR (MT_COLOR_NORMAL);
520 BKGDSET (MT_COLOR_NORMAL);
523 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
524 menu_pad_string (buf, sizeof (buf));
525 move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
526 - print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
527 + print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
528 SETCOLOR (MT_COLOR_NORMAL);
533 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
534 menu_pad_string (buf, sizeof (buf));
535 - print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
536 + print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
538 /* now draw the new one to reflect the change */
539 menu_make_entry (buf, sizeof (buf), menu, menu->current);
541 ADDCOLOR (MT_COLOR_INDICATOR);
542 BKGDSET (MT_COLOR_INDICATOR);
543 CLEARLINE_WIN (menu->current - menu->top + menu->offset);
544 - print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
545 + print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0);
546 SETCOLOR (MT_COLOR_NORMAL);
547 BKGDSET (MT_COLOR_NORMAL);
552 menu_pad_string (buf, sizeof (buf));
553 - print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 1);
554 + print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 1);
555 SETCOLOR (MT_COLOR_NORMAL);
559 ADDCOLOR (MT_COLOR_INDICATOR);
560 BKGDSET (MT_COLOR_INDICATOR);
562 - print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
563 + print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0);
564 SETCOLOR (MT_COLOR_NORMAL);
565 BKGDSET (MT_COLOR_NORMAL);
567 diff -ur mutt-1.5.20/mutt.h mutt-indexcolor/mutt.h
568 --- mutt-1.5.20/mutt.h 2010-07-11 19:32:01.390091196 -0400
569 +++ mutt-indexcolor/mutt.h 2010-07-11 19:33:38.536226982 -0400
571 #define M_TREE_MISSING 13
572 #define M_TREE_MAX 14
574 +#define M_SPECIAL_INDEX M_TREE_MAX
576 #define M_THREAD_COLLAPSE (1<<0)
577 #define M_THREAD_UNCOLLAPSE (1<<1)
578 #define M_THREAD_GET_HIDDEN (1<<2)
579 diff -ur mutt-1.5.20/mutt_curses.h mutt-indexcolor/mutt_curses.h
580 --- mutt-1.5.20/mutt_curses.h 2010-07-11 19:32:01.313427608 -0400
581 +++ mutt-indexcolor/mutt_curses.h 2010-07-11 19:45:49.266254982 -0400
586 + /* please no non-MT_COLOR_INDEX objects after this point */
587 + MT_COLOR_INDEX_SUBJECT,
588 + MT_COLOR_INDEX_AUTHOR,
589 + /* below only index coloring stuff that doesn't have a colorline! */
590 + MT_COLOR_INDEX_COLLAPSED,
591 + MT_COLOR_INDEX_DATE,
592 + MT_COLOR_INDEX_FLAGS,
593 + MT_COLOR_INDEX_LABEL,
594 + MT_COLOR_INDEX_NUMBER,
595 + MT_COLOR_INDEX_SIZE,
600 extern COLOR_LINE *ColorHdrList;
601 extern COLOR_LINE *ColorBodyList;
602 extern COLOR_LINE *ColorIndexList;
603 +extern COLOR_LINE *ColorIndexSubjectList;
604 +extern COLOR_LINE *ColorIndexAuthorList;
606 void ci_init_color (void);
607 void ci_start_color (void);