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-20160709~25^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25721f2612d6612e3fcc04492f0259b44bacba99;p=neomutt Add sidebar_format flag '%n' to display 'N' on new mail. --- diff --git a/init.h b/init.h index 8b97d3a71..47fdc2321 100644 --- 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; diff --git a/sidebar.c b/sidebar.c index 84ccd8b5d..333ec609e 100644 --- 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);