Nico Golde:
[apps/madmutt.git] / status.c
index 3d175f6..8f58fec 100644 (file)
--- a/status.c
+++ b/status.c
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  */ 
 
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "mutt.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
@@ -37,6 +41,7 @@ static char *get_sort_str (char *buf, size_t buflen, int method)
 }
 
 /* %b = number of incoming folders with unread messages [option]
+ * %B = short mailbox path
  * %d = number of deleted messages [option]
  * %f = full mailbox path
  * %F = number of flagged messages [option]
@@ -51,7 +56,7 @@ static char *get_sort_str (char *buf, size_t buflen, int method)
  * %s = current sorting method ($sort)
  * %S = current aux sorting method ($sort_aux)
  * %t = # of tagged messages [option]
- * %v = Mutt version 
+ * %v = Mutt-ng version 
  * %V = currently active limit pattern [option] */
 static const char *
 status_format_str (char *buf, size_t buflen, char op, const char *src,
@@ -59,7 +64,7 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
                   const char *elsestring,
                   unsigned long data, format_flag flags)
 {
-  char fmt[SHORT_STRING], tmp[SHORT_STRING], *cp;
+  char fmt[SHORT_STRING], tmp[SHORT_STRING], *cp, *p;
   int count, optional = (flags & M_FORMAT_OPTIONAL);
   MUTTMENU *menu = (MUTTMENU *) data;
 
@@ -76,6 +81,30 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
        optional = 0;
       break;
 
+    case 'B':
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+#ifdef USE_COMPRESSED
+      if (Context && Context->compressinfo && Context->realpath)
+      {
+       if ((p = strrchr (Context->realpath, '/')))
+         strfcpy (tmp, p + 1, sizeof (tmp));
+       else
+         strfcpy (tmp, Context->realpath, sizeof (tmp));
+      } 
+      else
+#endif
+      if (Context && Context->path)
+      {
+       if ((p = strrchr (Context->path, '/')))
+         strfcpy (tmp, p + 1, sizeof (tmp));
+       else
+         strfcpy (tmp, Context->path, sizeof (tmp));
+      }
+      else
+         strfcpy (tmp, _("no mailbox"), sizeof (tmp));
+      snprintf (buf, buflen, fmt, tmp);
+      break;
+
     case 'd':
       if (!optional)
       {
@@ -93,6 +122,14 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
 
     case 'f':
       snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
+#ifdef USE_COMPRESSED
+      if (Context && Context->compressinfo && Context->realpath)
+      {
+        strfcpy (tmp, Context->realpath, sizeof (tmp));
+        mutt_pretty_mailbox (tmp);
+      }
+      else
+#endif
       if (Context && Context->path)
       {
        strfcpy (tmp, Context->path, sizeof (tmp));
@@ -258,7 +295,7 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
       break;
 
     case 'v':
-      snprintf (fmt, sizeof (fmt), "Mutt %%s");
+      snprintf (fmt, sizeof (fmt), "Mutt-ng %%s");
       snprintf (buf, buflen, fmt, MUTT_VERSION);
       break;
 
@@ -266,7 +303,7 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
       if (!optional)
       {
        snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->pattern : 0);
+       snprintf (buf, buflen, fmt, (Context && Context->pattern) ? Context->pattern : "");
       }
       else if (!Context || !Context->pattern)
        optional = 0;