]> granicus.if.org Git - neomutt/commitdiff
add %z format strings to index_format
authorStefan Assmann <sassmann@redhat.com>
Fri, 24 Mar 2017 07:48:27 +0000 (08:48 +0100)
committerRichard Russon <rich@flatcap.org>
Fri, 12 May 2017 13:05:59 +0000 (14:05 +0100)
The %Z format string consists of three columns.
Split those up into individual columns to allow more fine grained
control over which flags should be displayed.
%zs message status flags
%zc message crypto flags
%zt message tag flags

There's a small difference compared to %Z which is that the delete flags
have been moved from the crypto column to the status column. %Z will not
be removed for backwards compatibility reasons.

Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
hdrline.c
init.h

index 5b47e534851dd08f1fe58efb7d9a4952332ba404..dd8c94d8ed3ecbb40b1f80028e689f9c2c54276d 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -445,7 +445,11 @@ static char *apply_subject_mods(ENVELOPE *env)
  * %X = number of MIME attachments
  * %y = `x-label:' field (if present)
  * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
- * %Z = status flags    */
+ * %zs = message status flags
+ * %zc = message crypto flags
+ * %zt = message tag flags
+ * %Z = combined message flags
+ */
 static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int cols,
                                   char op, const char *src, const char *prefix,
                                   const char *ifstring, const char *elsestring,
@@ -1062,6 +1066,74 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co
       break;
 #endif
 
+    case 'z':
+      if (src[0] == 's') /* status: deleted/new/old/replied */
+      {
+        char *ch;
+        if (hdr->deleted)
+          ch = get_nth_wchar(Flagchars, FlagCharDeleted);
+        else if (hdr->attach_del)
+          ch = get_nth_wchar(Flagchars, FlagCharDeletedAttach);
+        else if (THREAD_NEW)
+          ch = get_nth_wchar(Flagchars, FlagCharNewThread);
+        else if (THREAD_OLD)
+          ch = get_nth_wchar(Flagchars, FlagCharOldThread);
+        else if (hdr->read && (ctx && (ctx->msgnotreadyet != hdr->msgno)))
+        {
+          if (hdr->replied)
+            ch = get_nth_wchar(Flagchars, FlagCharReplied);
+          else
+            ch = get_nth_wchar(Flagchars, FlagCharZEmpty);
+        }
+        else
+        {
+          if (hdr->old)
+            ch = get_nth_wchar(Flagchars, FlagCharOld);
+          else
+            ch = get_nth_wchar(Flagchars, FlagCharNew);
+        }
+
+        snprintf(buf2, sizeof(buf2), "%s", ch);
+        src++;
+      }
+      else if (src[0] == 'c') /* crypto */
+      {
+        char *ch;
+        if (WithCrypto && (hdr->security & GOODSIGN))
+          ch = "S";
+        else if (WithCrypto && (hdr->security & ENCRYPT))
+          ch = "P";
+        else if (WithCrypto && (hdr->security & SIGN))
+          ch = "s";
+        else if ((WithCrypto & APPLICATION_PGP) && (hdr->security & PGPKEY))
+          ch = "K";
+        else
+          ch = " ";
+
+        snprintf(buf2, sizeof(buf2), "%s", ch);
+        src++;
+      }
+      else if (src[0] == 't') /* tagged, flagged, recipient */
+      {
+        char *ch;
+        if (hdr->tagged)
+          ch = get_nth_wchar(Flagchars, FlagCharTagged);
+        else if (hdr->flagged)
+          ch = get_nth_wchar(Flagchars, FlagCharImportant);
+        else
+          ch = get_nth_wchar(Tochars, user_is_recipient(hdr));
+
+        snprintf(buf2, sizeof(buf2), "%s", ch);
+        src++;
+      }
+      else /* fallthrough */
+        break;
+
+      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 'Z':
     {
       /* New/Old for threads; replied; New/Old for messages */
diff --git a/init.h b/init.h
index d24d217da5a548c4c67fd38286297fc674a3744c..af9e6eea9a8a9b48291d381393827c162b609efa 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1510,7 +1510,10 @@ struct option_t MuttVars[] = {
   ** .dt %Y .dd ``X-Label:'' field, if present, and \fI(1)\fP not at part of a thread tree,
   **            \fI(2)\fP at the top of a thread, or \fI(3)\fP ``X-Label:'' is different from
   **            preceding message's ``X-Label:''.
-  ** .dt %Z .dd message status flags
+  ** .dt %Z .dd Combined message flags
+  ** .dt %zs .dd message status flags
+  ** .dt %zc .dd message crypto flags
+  ** .dt %zt .dd message tag flags
   ** .dt %{fmt} .dd the date and time of the message is converted to sender's
   **                time zone, and ``fmt'' is expanded by the library function
   **                \fCstrftime(3)\fP; a leading bang disables locales