From: Richard Russon Date: Mon, 4 Apr 2016 15:24:05 +0000 (+0100) Subject: merge: index-color - theme the email index X-Git-Tag: neomutt-20160404~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec30db547226768d9c0158e433ae78ef0d1ad28f;p=neomutt merge: index-color - theme the email index * feature: index-color * add handling index flags * fix width calculation * fix uncolor * tidy code * add docs * add ident to PATCHES --- ec30db547226768d9c0158e433ae78ef0d1ad28f diff --cc PATCHES index 743886721,3fbe4b5d9..493b3c4bb --- a/PATCHES +++ b/PATCHES @@@ -1,3 -1,1 +1,4 @@@ +patch-quasi-delete-neo-UNKNOWN +patch-progress-neo-UNKNOWN +patch-status-color-neo-UNKNOWN + patch-index-color-neo-UNKNOWN diff --cc color.c index a319468cd,07663b690..9759288f1 --- a/color.c +++ b/color.c @@@ -34,8 -34,10 +34,11 @@@ int ColorQuoteUsed int ColorDefs[MT_COLOR_MAX]; COLOR_LINE *ColorHdrList = NULL; COLOR_LINE *ColorBodyList = NULL; +COLOR_LINE *ColorStatusList = NULL; COLOR_LINE *ColorIndexList = NULL; + COLOR_LINE *ColorIndexAuthorList = NULL; + COLOR_LINE *ColorIndexFlagsList = NULL; + COLOR_LINE *ColorIndexSubjectList = NULL; /* local to this file */ static int ColorQuoteSize; @@@ -94,7 -96,14 +97,15 @@@ static const struct mapping_t Fields[] { "bold", MT_COLOR_BOLD }, { "underline", MT_COLOR_UNDERLINE }, { "index", MT_COLOR_INDEX }, + { "progress", MT_COLOR_PROGRESS }, + { "index_author", MT_COLOR_INDEX_AUTHOR }, + { "index_collapsed", MT_COLOR_INDEX_COLLAPSED }, + { "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 }, { "prompt", MT_COLOR_PROMPT }, { NULL, 0 } }; @@@ -755,38 -785,22 +788,50 @@@ _mutt_parse_color (BUFFER *buf, BUFFER #endif if (object == MT_COLOR_HEADER) - r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err,0); + r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err, 0, match); else if (object == MT_COLOR_BODY) - r = add_pattern (&ColorBodyList, buf->data, 1, fg, bg, attr, err, 0); + r = add_pattern (&ColorBodyList, buf->data, 1, fg, bg, attr, err, 0, match); + else if ((object == MT_COLOR_STATUS) && MoreArgs (s)) { + /* 'color status fg bg' can have upto 2 arguments: + * 0 arguments: sets the default status color (handled below by else part) + * 1 argument : colorize pattern on match + * 2 arguments: colorize nth submatch of pattern + */ + mutt_extract_token (buf, s, 0); + + if (MoreArgs (s)) { + BUFFER temporary; + memset (&temporary, 0, sizeof (BUFFER)); + mutt_extract_token (&temporary, s, 0); + match = atoi (temporary.data); + FREE(&temporary.data); + } + + if (MoreArgs (s)) { + strfcpy (err->data, _("too many arguments"), err->dsize); + return -1; + } + + r = add_pattern (&ColorStatusList, buf->data, 1, + fg, bg, attr, err, 0, match); + } else if (object == MT_COLOR_INDEX) { - r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1); + r = add_pattern (&ColorIndexList, buf->data, 1, + fg, bg, attr, err, 1, match); set_option (OPTFORCEREDRAWINDEX); + } else if (object == MT_COLOR_INDEX_AUTHOR) { - r = add_pattern (&ColorIndexAuthorList, buf->data, 1, fg, bg, attr, err, 1); ++ r = add_pattern (&ColorIndexAuthorList, buf->data, 1, ++ fg, bg, attr, err, 1, match); + set_option (OPTFORCEREDRAWINDEX); + } else if (object == MT_COLOR_INDEX_FLAGS) { - r = add_pattern (&ColorIndexFlagsList, buf->data, 1, fg, bg, attr, err, 1); ++ r = add_pattern (&ColorIndexFlagsList, buf->data, 1, ++ fg, bg, attr, err, 1, match); + set_option (OPTFORCEREDRAWINDEX); + } else if (object == MT_COLOR_INDEX_SUBJECT) { - r = add_pattern (&ColorIndexSubjectList, buf->data, 1, fg, bg, attr, err, 1); ++ r = add_pattern (&ColorIndexSubjectList, buf->data, 1, ++ fg, bg, attr, err, 1, match); + set_option (OPTFORCEREDRAWINDEX); } else if (object == MT_COLOR_QUOTED) { diff --cc doc/manual.xml.head index 96ddf35ed,93f28f15b..fabd057ca --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@@ -8082,448 -8107,232 +8108,674 @@@ please have a look at the mixmaster doc + + Quasi-Delete Patch + Mark emails that should be hidden, but not deleted + + + Patch + + + To check if Mutt supports Quasi-Delete, look for + patch-quasi-delete in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The quasi-delete function marks an email that should be + hidden from the index, but NOT deleted. + + + + On its own, this patch isn't very useful. It forms a useful part of + the notmuch plugin. + + + + + + + Functions + + Quasi-Delete Functions + + + + Menus + Default Key + Function + Description + + + + + index,pager + (none) + <quasi-delete> + delete from mutt, don't touch on disk + + + +
+
+ + + + + Muttrc + +# Example Mutt config file for the 'quasi-delete' feature. + +# The 'quasi-delete' function marks an email that should be hidden +# from the index, but NOT deleted. +bind index,pager Q quasi-delete + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + notmuch patch + + + + + Known Bugs + None + + + + Credits + + Karel Zak kzak@redhat.com + Richard Russon rich@flatcap.org + + +
+ + + Progress Bar Patch + Show a visual progress bar on slow operations + + + Patch + + + To check if Mutt supports Progress Bar, look for + patch-progress in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The progress patch shows a visual progress bar on slow + tasks, such as indexing a large folder over the net. + + + + + + + Colors + + Progress Colors + + + + Name + Default Color + Description + + + + + progress + default + Visual progress bar + + + +
+
+ + + + + Muttrc + +# Example Mutt config file for the 'progress' patch. + +# The 'progress' patch provides clear visual feedback for +# slow tasks, such as indexing a large folder over the net. + +# Set the color of the progress bar +# White text on a red background +color progress white red + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + Color command + + + + + Known Bugs + None + + + + Credits + + Rocco Rutte pdmef@gmx.net + Vincent Lefevre vincent@vinc17.org + Stefan Kuhn wuodan@hispeed.ch + Karel Zak kzak@redhat.com + Richard Russon rich@flatcap.org + + +
+ + + Status Color Patch + Custom rules for theming the status bar + + + Patch + + + To check if Mutt supports Status Color, look for + patch-status-color in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The status-color patch allows you to theme different + parts of the status bar (also when it's used by the index). + + + + Unlike normal color commands, color status can now + take up to 2 extra parameters (regex, num). + + + + + + + Commands + + color + + + + + foreground + + + background + + + + regex + + + + num + + + + + + + With zero parameters, Mutt will set the default color for the entire + status bar. + + + + With one parameter, Mutt will only color the parts matching the + regex. + + + + With two parameters, Mutt will only color the num'th sub-match of + the regex. + + + + + Colors + + + Status Colors + + + + Name + Default Color + Description + + + + + status + reverse + Status bar + + + +
+
+ + + + + Muttrc + +# Example Mutt config file for the 'status-color' patch. + +# The 'status-color' patch allows you to theme different parts of +# the status bar (also when it's used by the index). + +# For the examples below, set some defaults +set status_format='-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---' +set index_format='%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s' +set sort=threads +set sort_aux=last-date-received + +# 'status color' can take up to 2 extra parameters + +# color status foreground background [ regex [ num ]] + +# 0 extra parameters +# Set the default color for the entire status line +color status blue white + +# 1 extra parameter +# Set the color for a matching pattern +# color status foreground background regexp + +# Highlight New, Deleted, or Flagged emails +color status brightred white '(New|Del|Flag):[0-9]+' + +# Highlight mailbox ordering if it's different from the default +# First, highlight anything (*/*) +color status brightred default '\([^)]+/[^)]+\)' + +# Then override the color for one specfic case +color status default default '\(threads/last-date-received\)' + +# 2 extra parameters +# Set the color for the nth submatch of a pattern +# color status foreground background regexp num + +# Highlight the contents of the []s but not the [] themselves +color status red default '\[([^]]+)\]' 1 + +# The '1' refers to the first regex submatch, which is the inner +# part in ()s + +# Highlight the mailbox +color status brightwhite default 'Mutt: ([^ ]+)' 1 + +# Search for 'Mutt: ' but only highlight what comes after it + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + Compile-Time Features + Regular Expressions + Patterns + index-color patch + Color command + + + + + Known Bugs + None + + + + Credits + + David Sterba dsterba@suse.cz + Thomas Glanzmann thomas@glanzmann.de + Kirill A. Shutemov kirill@shutemov.name + Richard Russon rich@flatcap.org + + +
+ + + Index Color Patch + Custom rules for theming the email index + + + Patch + + + To check if Mutt supports Index Color, look for + patch-index-color in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + status-color patch + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The index-color patch allows you to specify colors for + individual parts of the email index. e.g. Subject, Author, Flags. + + + + First choose which part of the index you'd like to color. + Then, if needed, pick a pattern to match. + + + + Note: The pattern does not have to refer to the object you wish to + color. e.g. + + + + color index_author red default "~smutt" + + + + The author appears red when the subject (~s) contains mutt. + + + + + + + Colors + + + All the colors default to default, i.e. unset. + + + + The index objects can be themed using the color command. + Some objects require a pattern. + + + + color index-object foreground background + color index-object foreground background pattern + + + + Index Colors + + + + Object + Pattern + Highlights + + + + + index + yes + Entire index line + + + index_author + yes + Author name, %A %a %F %L %n + + + index_collapsed + no + Number of messages in a collapsed thread, %M + + + index_date + no + Date field + + + index_flags + yes + Message flags, %S %Z + + + index_label + no + Message label, %y %Y + + + index_number + no + Message number, %C + + + index_size + no + Message size, %c %l + + + index_subject + yes + Subject, %s + + + +
+
+ + + + + Muttrc + + # Example Mutt config file for the 'index-color' feature. + + # Entire index line + color index white black '.*' + + # Author name, %A %a %F %L %n + + # Give the author column a dark grey background + color index_author default color234 '.*' + + # Highlight a particular from (~f) + color index_author brightyellow color234 '~fRay Charles' + + # Message flags, %S %Z + # Highlight the flags for flagged (~F) emails + color index_flags default red '~F' + + # Subject, %s + # Look for a particular subject (~s) + color index_subject brightcyan default '~s\(closes #[0-9]+\)' + + # Number of messages in a collapsed thread, %M + color index_collapsed default brightblue + + # Date field + color index_date green default + + # Message label, %y %Y + color index_label default brightgreen + + # Message number, %C + color index_number red default + + # Message size, %c %l + color index_size cyan default + + # vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + Regular Expressions + Patterns + $index_format + Color command + Status-Color patch + Keywords patch + + + + + Known Bugs + None + + + + Credits + + Christian Aichinger Greek0@gmx.net + Christoph Myon Berg myon@debian.org + Elimar Riesebieter riesebie@lxtec.de + Eric Davis edavis@insanum.com + Vladimir Marek Vladimir.Marek@oracle.com + Richard Russon rich@flatcap.org + + +
+ diff --cc mutt_curses.h index ef80f9740,e8bb9aa01..b7bf5fb1f --- a/mutt_curses.h +++ b/mutt_curses.h @@@ -122,9 -122,18 +122,19 @@@ enu MT_COLOR_SEARCH, MT_COLOR_BOLD, MT_COLOR_UNDERLINE, - MT_COLOR_INDEX, MT_COLOR_PROMPT, + MT_COLOR_PROGRESS, + /* please no non-MT_COLOR_INDEX objects after this point */ + MT_COLOR_INDEX, + MT_COLOR_INDEX_AUTHOR, + MT_COLOR_INDEX_FLAGS, + MT_COLOR_INDEX_SUBJECT, + /* below here - only index coloring stuff that doesn't have a pattern */ + MT_COLOR_INDEX_COLLAPSED, + MT_COLOR_INDEX_DATE, + MT_COLOR_INDEX_LABEL, + MT_COLOR_INDEX_NUMBER, + MT_COLOR_INDEX_SIZE, MT_COLOR_MAX }; @@@ -178,8 -186,10 +188,11 @@@ extern int ColorQuoteUsed extern int ColorDefs[]; extern COLOR_LINE *ColorHdrList; extern COLOR_LINE *ColorBodyList; +extern COLOR_LINE *ColorStatusList; extern COLOR_LINE *ColorIndexList; + extern COLOR_LINE *ColorIndexAuthorList; + extern COLOR_LINE *ColorIndexFlagsList; + extern COLOR_LINE *ColorIndexSubjectList; void ci_init_color (void); void ci_start_color (void);