From: Eric Davis Date: Sun, 31 Jan 2016 00:21:21 +0000 (+0000) Subject: add handling index flags X-Git-Tag: neomutt-20160404~18^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60328c223ae4b776ad18d5d15eba96eaf9e8119c;p=neomutt add handling index flags --- diff --git a/color.c b/color.c index 66459dbfb..82f2a5c38 100644 --- a/color.c +++ b/color.c @@ -37,6 +37,7 @@ COLOR_LINE *ColorBodyList = NULL; COLOR_LINE *ColorIndexList = NULL; COLOR_LINE *ColorIndexSubjectList = NULL; COLOR_LINE *ColorIndexAuthorList = NULL; +COLOR_LINE *ColorIndexFlagsList = NULL; /* local to this file */ static int ColorQuoteSize; @@ -503,6 +504,8 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, mutt_do_uncolor(buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor); else if (object == MT_COLOR_INDEX_AUTHOR) mutt_do_uncolor(buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor); + else if (object == MT_COLOR_INDEX_FLAGS) + mutt_do_uncolor(buf, s, &ColorIndexFlagsList, &do_cache, parse_uncolor); if (do_cache && !option (OPTNOCURSES)) { @@ -746,7 +749,8 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, object == MT_COLOR_BODY || object == MT_COLOR_INDEX || object == MT_COLOR_INDEX_SUBJECT || - object == MT_COLOR_INDEX_AUTHOR) + object == MT_COLOR_INDEX_AUTHOR || + object == MT_COLOR_INDEX_FLAGS) { if (!MoreArgs (s)) { @@ -802,6 +806,12 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, 1, fg, bg, attr, err, 1); set_option (OPTFORCEREDRAWINDEX); } + else if (object == MT_COLOR_INDEX_FLAGS) + { + r = add_pattern (&ColorIndexFlagsList, buf->data, + 1, fg, bg, attr, err, 1); + set_option (OPTFORCEREDRAWINDEX); + } else if (object == MT_COLOR_QUOTED) { if (q_level >= ColorQuoteSize) diff --git a/doc/manual.xml.head b/doc/manual.xml.head index eb4c3845b..98c6da66e 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -2642,7 +2642,7 @@ silently truncated at the screen width, and are not wrapped. color - + foreground @@ -2657,7 +2657,7 @@ silently truncated at the screen width, and are not wrapped. uncolor - + @@ -2687,8 +2687,8 @@ specify one or the other). header and body match regexp in the header/body of a message, -index matches pattern (see -) in the message index. Note that IMAP +index-object can match pattern +(see ) in the message index. Note that IMAP server-side searches (=b, =B, =h) are not supported for color index patterns. @@ -2724,6 +2724,24 @@ patterns. underline (highlighting underlined patterns in the body of messages) + +index-object can be one of the following: + + + +index (default highlighting of the entire index line, uses pattern) +index_date (the date field) +index_flags (the message flags, %S %Z, uses pattern) +index_number (the message number, %C) +index_collapsed (the number of messages in a collapsed thread, %M) +index_author (the author name, %A %a %F %L %n, uses pattern) +index_subject (the subject, %s, uses pattern) +index_size (the message size, %c %l) +index_label (the message label, %y %Y) +index_tags (the transformed message tags, %g) +index_tag (an individual message tag, %G, uses pattern / tag name) + + foreground and background can be one of the following: @@ -2841,7 +2859,7 @@ command. Usage: unmono - + diff --git a/hdrline.c b/hdrline.c index 08efb90fb..6d15fb9a5 100644 --- a/hdrline.c +++ b/hdrline.c @@ -294,7 +294,9 @@ hdr_format_str (char *dest, case 'A': if(hdr->env->reply_to && hdr->env->reply_to->mailbox) { - mutt_format_s (dest, destlen, prefix, mutt_addr_for_display (hdr->env->reply_to)); + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, mutt_addr_for_display (hdr->env->reply_to)); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); break; } /* fall through if 'A' returns nothing */ @@ -302,7 +304,9 @@ hdr_format_str (char *dest, case 'a': if(hdr->env->from && hdr->env->from->mailbox) { - mutt_format_s (dest, destlen, prefix, mutt_addr_for_display (hdr->env->from)); + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, mutt_addr_for_display (hdr->env->from)); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); } else dest[0] = '\0'; @@ -539,7 +543,9 @@ hdr_format_str (char *dest, break; case 'n': - mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->from)); + colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); + mutt_format_s (dest+colorlen, destlen-colorlen, prefix, mutt_get_name (hdr->env->from)); + add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); break; case 'N': @@ -656,8 +662,11 @@ hdr_format_str (char *dest, /* FOO - this is probably unsafe, but we are not likely to have such a short string passed into this routine */ - *dest = ch; - *(dest + 1) = 0; + buf2[0] = ch; + buf2[1] = 0; + 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 't': diff --git a/menu.c b/menu.c index e0646ee20..1be3b9461 100644 --- a/menu.c +++ b/menu.c @@ -27,9 +27,10 @@ char* SearchBuffers[MENU_MAX]; -static int get_color(int index, int type) { +static int get_color(int index, unsigned char *s) { COLOR_LINE *color; - HEADER *hdr = Context->hdrs[index]; + HEADER *hdr = Context->hdrs[Context->v2r[index]]; + int type = *s; switch (type) { case MT_COLOR_INDEX_SUBJECT: @@ -38,6 +39,9 @@ static int get_color(int index, int type) { case MT_COLOR_INDEX_AUTHOR: color = ColorIndexAuthorList; break; + case MT_COLOR_INDEX_FLAGS: + color = ColorIndexFlagsList; + break; default: return ColorDefs[type]; } @@ -189,7 +193,12 @@ static void print_enriched_string (int index, int attr, unsigned char *s, int do if (*s == MT_COLOR_INDEX) attrset(attr); else - attron(get_color(index, *s)); + { + if (get_color(index, s) == 0) + attron(attr); + else + attron(get_color(index, s)); + } } s++; n -= 2; diff --git a/mutt_curses.h b/mutt_curses.h index f65e7c78d..56ede9b26 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -126,11 +126,11 @@ enum /* 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 only index coloring stuff that doesn't have a colorline! */ + /* below here - only index coloring stuff that doesn't have a pattern */ MT_COLOR_INDEX_COLLAPSED, MT_COLOR_INDEX_DATE, - MT_COLOR_INDEX_FLAGS, MT_COLOR_INDEX_LABEL, MT_COLOR_INDEX_NUMBER, MT_COLOR_INDEX_SIZE, @@ -189,6 +189,7 @@ extern COLOR_LINE *ColorBodyList; extern COLOR_LINE *ColorIndexList; extern COLOR_LINE *ColorIndexSubjectList; extern COLOR_LINE *ColorIndexAuthorList; +extern COLOR_LINE *ColorIndexFlagsList; void ci_init_color (void); void ci_start_color (void);