]> granicus.if.org Git - neomutt/commitdiff
add handling index flags
authorEric Davis <edavis@insanum.com>
Sun, 31 Jan 2016 00:21:21 +0000 (00:21 +0000)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 02:33:23 +0000 (03:33 +0100)
color.c
doc/manual.xml.head
hdrline.c
menu.c
mutt_curses.h

diff --git a/color.c b/color.c
index 66459dbfbc2b8c264902a03c04327b0481f681b9..82f2a5c386ecd42c5505aa46b87131341e9fae67 100644 (file)
--- 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)
index eb4c3845b335fe3641834755b079cf2f1bef544a..98c6da66e7eebf961873fda79a07c8366520715e 100644 (file)
@@ -2642,7 +2642,7 @@ silently truncated at the screen width, and are not wrapped.
 
 <command>color</command>
 <arg choice="plain">
-<option>index-object</option>
+<option><emphasis>index-object</emphasis></option>
 </arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
@@ -2657,7 +2657,7 @@ silently truncated at the screen width, and are not wrapped.
 <command>uncolor</command>
 <group choice="req">
 <arg choice="plain">
-<option>index-object</option>
+<option><emphasis>index-object</emphasis></option>
 </arg>
 <arg choice="plain">
 <option>header</option>
@@ -2687,8 +2687,8 @@ specify one or the other).
 <para>
 <emphasis>header</emphasis> and <emphasis>body</emphasis> match
 <emphasis>regexp</emphasis> in the header/body of a message,
-<emphasis>index</emphasis> matches <emphasis>pattern</emphasis> (see
-<xref linkend="patterns"/>) in the message index.  Note that IMAP
+<emphasis>index-object</emphasis> can match <emphasis>pattern</emphasis>
+(see <xref linkend="patterns"/>) in the message index. Note that IMAP
 server-side searches (=b, =B, =h) are not supported for color index
 patterns.
 </para>
@@ -2724,6 +2724,24 @@ patterns.
 <listitem><para>underline (highlighting underlined patterns in the body of messages)</para></listitem>
 </itemizedlist>
 
+<para>
+<emphasis>index-object</emphasis> can be one of the following:
+</para>
+
+<itemizedlist>
+<listitem><para>index (default highlighting of the entire index line, uses <emphasis>pattern</emphasis>)</para></listitem>
+<listitem><para>index_date (the date field)</para></listitem>
+<listitem><para>index_flags (the message flags, %S %Z, uses <emphasis>pattern</emphasis>)</para></listitem>
+<listitem><para>index_number (the message number, %C)</para></listitem>
+<listitem><para>index_collapsed (the number of messages in a collapsed thread, %M)</para></listitem>
+<listitem><para>index_author (the author name, %A %a %F %L %n, uses <emphasis>pattern</emphasis>)</para></listitem>
+<listitem><para>index_subject (the subject, %s, uses <emphasis>pattern</emphasis>)</para></listitem>
+<listitem><para>index_size (the message size, %c %l)</para></listitem>
+<listitem><para>index_label (the message label, %y %Y)</para></listitem>
+<listitem><para>index_tags (the transformed message tags, %g)</para></listitem>
+<listitem><para>index_tag (an individual message tag, %G, uses <emphasis>pattern / tag name</emphasis>)</para></listitem>
+</itemizedlist>
+
 <para>
 <emphasis>foreground</emphasis> and <emphasis>background</emphasis> can
 be one of the following:
@@ -2841,7 +2859,7 @@ command. Usage:
 <command>unmono</command>
 <group choice="req">
 <arg choice="plain">
-<option>index</option>
+<option><emphasis>index-object</emphasis></option>
 </arg>
 <arg choice="plain">
 <option>header</option>
index 08efb90fb78d0e696c3cdcddc65ff57efbe6027f..6d15fb9a5bc6bce6e28bd3f2f93e6ab170cf15bc 100644 (file)
--- 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 e0646ee20f63edb73c50427967c579d848f63c89..1be3b94612a54a8edec78f4f523efe053f8f36f5 100644 (file)
--- a/menu.c
+++ b/menu.c
 
 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;
index f65e7c78d0fdda71fce8ff4eb5cdfbd25fd53420..56ede9b26b8e4577e0b6fdde3f1ac66fae8e0b0f 100644 (file)
@@ -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);