the “I found my first real bug” commit.
[apps/madmutt.git] / recvattach.c
index 50bc81d..30bcb49 100644 (file)
@@ -49,6 +49,8 @@ static char LastSaveFolder[_POSIX_PATH_MAX] = "";
     break; \
 }
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 static struct mapping_t AttachHelp[] = {
   {N_("Exit"), OP_EXIT},
   {N_("Save"), OP_SAVE},
@@ -302,6 +304,14 @@ const char *mutt_attach_fmt (char *dest,
       snprintf (dest, destlen, fmt, aptr->num + 1);
     }
     break;
+  case 'Q':
+    if (optional)
+      optional = aptr->content->attach_qualifies;
+    else {
+      snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+      mutt_format_s (dest, destlen, fmt, "Q");
+    }
+    break;
   case 's':
     if (flags & M_FORMAT_STAT_FILE) {
       struct stat st;
@@ -338,6 +348,14 @@ const char *mutt_attach_fmt (char *dest,
     else if (!aptr->content->unlink)
       optional = 0;
     break;
+  case 'X':
+    if (optional)
+      optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
+    else {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
+    }
+    break;
   default:
     *dest = 0;
   }
@@ -351,7 +369,8 @@ const char *mutt_attach_fmt (char *dest,
 
 static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
-  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
+  int w=(COLS-SW)>blen?blen:(COLS-SW);
+  mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
                      (unsigned long) (((ATTACHPTR **) menu->data)[num]),
                      M_FORMAT_ARROWCURSOR);
 }