From: Kevin McCarthy Date: Wed, 8 Jun 2016 20:16:45 +0000 (-0700) Subject: Add sidebar_format flag '%n' to display 'N' on new mail. X-Git-Tag: neomutt-20160822~123 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48a973085f6201cd12effe89bf44e6ef6b50eb21;p=neomutt Add sidebar_format flag '%n' to display 'N' on new mail. --- diff --git a/init.h b/init.h index 66df8d204..cf1c4cd8d 100644 --- a/init.h +++ b/init.h @@ -2710,6 +2710,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; diff --git a/sidebar.c b/sidebar.c index f0752c654..5f26bd05f 100644 --- a/sidebar.c +++ b/sidebar.c @@ -125,9 +125,10 @@ static BUFFY *find_prev_new (int wrap) * @flags: Format flags, e.g. MUTT_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) */ @@ -198,6 +199,16 @@ static const char *cb_format_str(char *dest, size_t destlen, size_t col, int col 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) { @@ -630,7 +641,7 @@ static void draw_sidebar (int num_rows, int num_cols, 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);