[RFC] [PATCH] seperate coloring of index fields
Hi,
I've written a patch for mutt that allows different fields of the
index display to be colored separately. The patch can be seen in
action at <URL:http://greek0.net/~greek0/mutt/mutt-indexcolor.png>.
I'd appreciate comments, since this is my first patch for mutt and
I'm not really sure that my implementation is the best way to do it.
Please note that this patch isn't ready for inclusion (though it
works fine).
The patch is available at
<URL:http://greek0.net/~greek0/mutt/mutt-indexcolor.diff>, it should
apply cleanly against the latest version from CVS.
Usage:
The patch is fully backwards compatible. The coloring is done on top
of the normal whole-line index coloring. Without modifications to
your muttrc only the normal index coloring is active. The patch
takes effect when add color entries for
author/subject/index_number/flags/date/size (cf. screenshot above).
Technical details:
The problem with implementing this patch was that the code layer
that is responsible for printing on the screen doesn't have any
information what parts of the index line correspond to which fields
(subject/author/date/...).
So that information has to be somehow passed on from hdr_format_str
to print_enriched_string. There are two possibilities: pass the
information in a separate data structure or embed the information
into the string.
I chose the second way to do it, since I thought it was the least
invasive approach.
Mutt already uses chars 0-13 to encode the thread tree within the
string, so I'm using char 14 (alias M_SPECIAL_INDEX). Following that
marker comes 1 char which can be used as index into the ColorDefs
array.
When print_enriched_string finds M_SPECIAL_INDEX it reads the next
char, and calls ADDCOLOR on it. MT_COLOR_INDEX is treated
differently here, since it causes the default index color/attr to be
set again. Perhaps some other special value would be better here, eg
MT_COLOR_SPECIAL == MT_COLOR_MAX.
Comments? Ideas for a better name for the patch?
Cheers,
Greek0