Nico Golde:
[apps/madmutt.git] / pager.c
diff --git a/pager.c b/pager.c
index 095aa69..17a08b9 100644 (file)
--- a/pager.c
+++ b/pager.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_curses.h"
 #include "mutt_regex.h"
@@ -971,7 +975,7 @@ fill_buffer (FILE *f, long *last_pos, long offset, unsigned char *buf,
             unsigned char *fmt, size_t blen, int *buf_ready)
 {
   unsigned char *p;
-  static int b_read;
+  static int b_read = 0;
 
   if (*buf_ready == 0)
   {
@@ -1038,8 +1042,11 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
   wchar_t wc;
   mbstate_t mbstate;
 
-  int wrap_cols = COLS - WrapMargin - SidebarWidth;
-  
+  int wrap_cols = COLS;
+  if (!(flags & (M_SHOWFLAT)))
+    wrap_cols -= WrapMargin;
+  wrap_cols -= SidebarWidth;
+
   if (wrap_cols <= 0)
     wrap_cols = COLS;
   
@@ -1735,17 +1742,17 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       CLEARLINE_WIN(statusoffset);
       if (IsHeader (extra))
       {
-       _mutt_make_string (buffer,
-                          COLS-9-SidebarWidth < sizeof (buffer) ?
-                          COLS-9-SidebarWidth : sizeof (buffer),
-                          NONULL (PagerFmt), Context, extra->hdr, M_FORMAT_MAKEPRINT);
+       size_t l1 = (COLS - 9) * MB_LEN_MAX;
+       size_t l2 = sizeof (buffer);
+       _mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
+                          Context, extra->hdr, M_FORMAT_MAKEPRINT);
       }
       else if (IsMsgAttach (extra))
       {
-       _mutt_make_string (buffer,
-                          COLS - 9 - SidebarWidth < sizeof (buffer) ?
-                          COLS - 9 - SidebarWidth : sizeof (buffer),
-                          NONULL (PagerFmt), Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
+       size_t l1 = (COLS - 9) * MB_LEN_MAX;
+       size_t l2 = sizeof (buffer);
+       _mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
+                          Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
       }
       mutt_paddstr (COLS-10-SidebarWidth, IsHeader (extra) || IsMsgAttach (extra) ?
                    buffer : banner);
@@ -1766,13 +1773,12 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       /* redraw the pager_index indicator, because the
        * flags for this message might have changed. */
       menu_redraw_current (index);
-         draw_sidebar(MENU_PAGER);
+      draw_sidebar(MENU_PAGER);
       /* print out the index status bar */
       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
-                 SidebarWidth);
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),option(OPTSTATUSONTOP)?0:SidebarWidth);
       SETCOLOR (MT_COLOR_STATUS);
-      mutt_paddstr (COLS-SidebarWidth, buffer);
+      mutt_paddstr (COLS-(option(OPTSTATUSONTOP)?0:SidebarWidth), buffer);
       SETCOLOR (MT_COLOR_NORMAL);
     }
        /* if we're not using the index, update every time */
@@ -2218,6 +2224,17 @@ search_next:
          mutt_resend_message (NULL, extra->ctx, extra->hdr);
         redraw = REDRAW_FULL;
         break;
+
+      case OP_CHECK_TRADITIONAL:
+        CHECK_MODE (IsHeader (extra));
+        if (!(WithCrypto & APPLICATION_PGP))
+         break;
+        if (!(extra->hdr->security & PGP_TRADITIONAL_CHECKED)) 
+        {
+         ch = -1;
+         rc = OP_CHECK_TRADITIONAL;
+       }
+        break;
       
       case OP_CREATE_ALIAS:
        CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
@@ -2430,7 +2447,7 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
       case OP_MAIL:
        CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
         CHECK_ATTACH;      
-       ci_send_message (0, NULL, NULL, extra->ctx, extra->hdr);
+       ci_send_message (0, NULL, NULL, extra->ctx, NULL);
        redraw = REDRAW_FULL;
        break;
 
@@ -2501,7 +2518,7 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
        break;
 
       case OP_RECALL_MESSAGE:
-       CHECK_MODE(IsHeader (extra));
+       CHECK_MODE(IsHeader (extra) && !IsAttach(extra));
         CHECK_ATTACH;
        ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr);
        redraw = REDRAW_FULL;
@@ -2682,6 +2699,7 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
 
       case OP_BUFFY_LIST:
        mutt_buffy_list ();
+    redraw |= REDRAW_SIDEBAR;
        break;
 
       case OP_VIEW_ATTACHMENTS:
@@ -2730,7 +2748,9 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
          case OP_SIDEBAR_SCROLL_UP:
          case OP_SIDEBAR_SCROLL_DOWN:
          case OP_SIDEBAR_NEXT:
+         case OP_SIDEBAR_NEXT_NEW:
          case OP_SIDEBAR_PREV:
+         case OP_SIDEBAR_PREV_NEW:
            scroll_sidebar(ch, MENU_PAGER);
                break;
       default: