]> 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>
Sun, 6 Mar 2016 00:43:58 +0000 (00:43 +0000)
color.c
doc/manual.xml.head
hdrline.c
menu.c
mutt_curses.h

diff --git a/color.c b/color.c
index c2fc7646d3a2f4124115c54b06f9df78dad2a3b6..874fe96250100a3bb54525a0555e3ce089ac200d 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;
@@ -484,6 +485,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))
   {
@@ -727,7 +730,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))
     {
@@ -783,6 +787,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 cf3cf35da89a4755284727bc9a634876c67fd55d..0cbf4e4790600f0c493333e9ad7efd1a335427ce 100644 (file)
@@ -2597,7 +2597,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>
@@ -2612,7 +2612,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>
@@ -2642,8 +2642,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>
@@ -2679,6 +2679,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:
@@ -2796,7 +2814,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 ce2384f6626277a50c50bbe2b1eb7e9e5979494a..5d0ea0074823c7b1f7939b0548082d364d570fe5 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -292,7 +292,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 */
@@ -300,7 +302,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';
@@ -537,7 +541,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':
@@ -638,8 +644,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 9867a7321dfcf92c4974f8f489f76a06ba56404a..87046968f813a2ba7b3ad4720a718a298939de9d 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -29,9 +29,10 @@ extern size_t UngetCount;
 
 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:
@@ -40,6 +41,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];
   }
@@ -191,7 +195,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 9d85363c358b17fb06a30e524d95212154a60818..9fd1a0861745be33fbde8d8752c6f9e27e6d1632 100644 (file)
@@ -123,11 +123,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,
@@ -186,6 +186,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);