+static const char* sidebar_number_format (char* dest, size_t destlen, char op,
+ const char* src, const char* fmt,
+ const char* ifstr, const char* elstr,
+ unsigned long data, format_flag flags) {
+ char tmp[SHORT_STRING];
+ BUFFY* b = (BUFFY*) Incoming->data[data];
+ int opt = flags & M_FORMAT_OPTIONAL;
+ int c = Context && str_eq (Context->path, b->path);
+
+ switch (op) {
+ case 'c':
+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+ snprintf (dest, destlen, tmp, c ? Context->msgcount : b->msgcount);
+ break;
+ case 'n':
+ if (!opt) {
+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+ snprintf (dest, destlen, tmp, c ? Context->unread : b->msg_unread);
+ } else if ((c && Context->unread == 0) || (!c && b->msg_unread == 0))
+ opt = 0;
+ break;
+ case 'f':
+ if (!opt) {
+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+ snprintf (dest, destlen, tmp, c ? Context->flagged : b->msg_flagged);
+ } else if ((c && Context->flagged == 0) || (!c && b->msg_flagged == 0))
+ opt = 0;
+ break;
+ }
+
+ if (opt)
+ mutt_FormatString (dest, destlen, ifstr, sidebar_number_format,
+ data, M_FORMAT_OPTIONAL);
+ else if (flags & M_FORMAT_OPTIONAL)
+ mutt_FormatString (dest, destlen, elstr, sidebar_number_format,
+ data, M_FORMAT_OPTIONAL);
+ return (src);
+}
+
+int sidebar_need_count (void) {
+ if (!option (OPTMBOXPANE) || SidebarWidth == 0 ||
+ !SidebarNumberFormat || !*SidebarNumberFormat)
+ return (0);
+ return (1);
+}
+
+/* print single item
+ * returns:
+ * 0 item was not printed ('cause of $sidebar_newmail_only)
+ * 1 item was printed
+ */
+int make_sidebar_entry (char* box, int idx, size_t len)