]> granicus.if.org Git - neomutt/commitdiff
Add sidebar_format flag '%n' to display 'N' on new mail.
authorKevin McCarthy <kevin@8t8.us>
Wed, 8 Jun 2016 20:16:45 +0000 (13:16 -0700)
committerRichard Russon <rich@flatcap.org>
Thu, 16 Jun 2016 04:20:14 +0000 (05:20 +0100)
init.h
sidebar.c

diff --git a/init.h b/init.h
index 8b97d3a71a6bb113802c59ffff03a3c1bed84aad..47fdc23217b0a422ee97b2e413865a4b556291e7 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2709,6 +2709,7 @@ struct option_t MuttVars[] = {
   ** .dt %B  .dd Name of the mailbox
   ** .dt %S  .dd * Size of mailbox (total number of messages)
   ** .dt %N  .dd * Number of New messages in the mailbox
+  ** .dt %n  .dd N if mailbox has new mail, blank otherwise
   ** .dt %F  .dd * Number of Flagged messages in the mailbox
   ** .dt %!  .dd ``!'' : one flagged message;
   **             ``!!'' : two flagged messages;
index 84ccd8b5d8ee3af82f3ae77ecb70a7e3c85ce7cc..333ec609e33a24107a8f6fb472949d014328404f 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -127,9 +127,10 @@ static BUFFY *find_prev_new (int wrap)
  * @flags:       Format flags, e.g. M_FORMAT_OPTIONAL
  *
  * cb_format_str is a callback function for mutt_FormatString.  It understands
- * five operators. '%B' : Mailbox name, '%F' : Number of flagged messages,
+ * six operators. '%B' : Mailbox name, '%F' : Number of flagged messages,
  * '%N' : Number of new messages, '%S' : Size (total number of messages),
  * '%!' : Icon denoting number of flagged messages.
+ * '%n' : N if folder has new mail, blank otherwise.
  *
  * Returns: src (unchanged)
  */
@@ -200,6 +201,16 @@ static const char *cb_format_str(char *dest, size_t destlen, size_t col, char op
         optional = 0;
       break;
 
+    case 'n':
+      if (!optional)
+      {
+        snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+        snprintf (dest, destlen, fmt, b->new ? 'N' : ' ');
+      }
+      else if (b->new == 0)
+        optional = 0;
+      break;
+
     case 'S':
       if (!optional)
       {
@@ -705,7 +716,7 @@ static void draw_sidebar (int first_row, int num_rows, int div_width)
     else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) &&
                (mutt_strcmp (b->path, Spoolfile) == 0))
       SETCOLOR(MT_COLOR_SB_SPOOLFILE);
-    else if (b->msg_unread > 0)
+    else if ((b->msg_unread > 0) || (b->new))
       SETCOLOR(MT_COLOR_NEW);
     else if (b->msg_flagged > 0)
       SETCOLOR(MT_COLOR_FLAGGED);