changeset: 6640:1ef1e39a7218
user:      Kevin McCarthy <ke...@8t8.us>
date:      Sat Apr 30 14:21:44 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/1ef1e39a7218

automatic post-release commit for mutt-1.6.1

changeset: 6641:2822cefa33d6
user:      Kevin McCarthy <ke...@8t8.us>
date:      Sat Apr 30 14:23:32 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/2822cefa33d6

Added tag mutt-1-6-1-rel for changeset 1ef1e39a7218

changeset: 6642:e3bc23cbe3d1
user:      Kevin McCarthy <ke...@8t8.us>
date:      Sat Apr 30 14:25:49 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/e3bc23cbe3d1

mutt-1.6.1 signed

changeset: 6643:fb68199318ae
user:      Kevin McCarthy <ke...@8t8.us>
date:      Sat Apr 30 14:39:19 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/fb68199318ae

merge stable

diffs (truncated from 6845 to 950 lines):

diff -r 23334e967dd7 -r fb68199318ae .hgsigs
--- a/.hgsigs   Wed Apr 27 13:08:52 2016 -0700
+++ b/.hgsigs   Sat Apr 30 14:39:19 2016 -0700
@@ -9,3 +9,4 @@
 b8a63730c8489a0dff577da8f1c8e31219a179e8 0 
iQIcBAABAgAGBQJTII72AAoJEFHk0k89vdxov4gP/0nART9SNLs70qa1k+bNsMz5U+SFmqNwjnznmVgkF+tlXFav+zPsYOiS7XNVmk9YdJkogwfEuAerf2mIL7HoTkZ0fg77gvyzfOXPEYxBhu5I4YlNUjObLRarDwHMo5hAud67ZNxvd8QMnappGc1sicutXTkDDXCwE6cLDClSRSIOtKH8qfPOdhQxwhahbWji8xrTUjqi8PReLmDit8KGmcsrFnXgfBKsnMu9NinKujNDdjRqTOvBr9OSa79qnfiholPESpAP5u+g/vTCE12o3OPzyZhgpYhzLoFHL5NSMNM+6jaOhYlamVrYyDGb9G9nLnsWkejleoGgob1aXN5fTpUm2NYJMoTqCOYLk0lfE4UTbnZMBT3hKWvpNjjcIONsmofq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WgACyOU3gjOavNWYOgRC0S6RUd2QAfxHynJ0BQ85VAcTIBx69pN1J05d+/BKCHggn5JpxXs/GpoLlSeMZKCEvjc77PW3pFC5HKLkOHbcpwA1wXkvTA8+g6+1CvfUO7wEX/G1O2I8bdQStxwyU/nwYQG2ZP0n2zZIJl/Jl9gKfFxXKWYxUazfsw3FF6HGQgGc7cDpXxZgE0V0TebdGSRZUua4SoGtLBAsnArLP6eEtLe6u9pE3EyyBgxsXh0U4IwhU0jdNvUYCleGcBBAzjLrJAyK1vUi3fGdf8WBPxLwJk3koixaJR1jOWCQvO/4wVyZGNag2cp28EXcuze01cg9KFoMbLT3eh6o7a+Druaq8MRY3EHOOCcj17hsmuhXBZNFE5miroYtdKNyP7wZ/3IleL
diff -r 23334e967dd7 -r fb68199318ae .hgtags
--- a/.hgtags   Wed Apr 27 13:08:52 2016 -0700
+++ b/.hgtags   Sat Apr 30 14:39:19 2016 -0700
@@ -101,3 +101,4 @@
 b8a63730c8489a0dff577da8f1c8e31219a179e8 mutt-1-5-23-rel
 08e81162482fb7b1680efa20b1740f693a8a35de mutt-1-5-24-rel
 be82a2fde82fdd9057641e39e4df853d7ae4d4f2 mutt-1-6-rel
+1ef1e39a7218704ebd715ffc8d29079ae7f63061 mutt-1-6-1-rel
diff -r 23334e967dd7 -r fb68199318ae ChangeLog
--- a/ChangeLog Wed Apr 27 13:08:52 2016 -0700
+++ b/ChangeLog Sat Apr 30 14:39:19 2016 -0700
@@ -1,3 +1,75 @@
+2016-04-27 13:08 -0700  Kevin McCarthy  <ke...@8t8.us>  (23334e967dd7)
+
+       * Makefile.am, getdomain.c, mutt_sasl.c, mutt_socket.c, mutt_tunnel.c,
+       sys_socket.h: Create a wrapper sys_socket.h to work around Solaris
+       namespace issues. (closes #3833)
+
+       Solaris includes "sys/stream.h" inside their "sys/socket.h". This
+       include file adds many non-reserved macros to Mutt's namespace, two
+       of which conflict with existing Mutt macros.
+
+       The simplest fix would be to rename those macros in Mutt, however
+       this will cause difficulty with out-of-tree patches. This fix
+       creates a wrapper include file that preserves those existing macros
+       and prevents the Solaris values from entering Mutt's namespace.
+
+2016-04-10 16:02 -0700  Kevin McCarthy  <ke...@8t8.us>  (a6a4d6ed0f19)
+
+       * crypt.c, send.c: Fix mutt_protect() when INLINE is set. (closes
+       #3828)
+
+       The oppenc changes allow security bits to be set even when not
+       encrypting or signing (for instance, OPPENCRYPT and INLINE).
+
+       mutt_protect() assumed that if INLINE is set, then either ENCRYPT or
+       SIGN must also be set. Specifically, it would end up inline-signing
+       the message even though neither was set.
+
+       Ensure mutt_protect() is a noop if neither SIGN or ENCRYPT are set.
+
+       In ci_send_message(), check for sign or encrypt before calling the
+       crypt_get_keys() / mutt_protect() block, and also in the fcc section
+       (since clear_content would be NULL if not).
+
+       The second change to the fcc part is somewhat redundant, but better
+       to be explicit and avoid the case where the subtype is somehow
+       "encrypted" or "signed" even though msg->security wasn't set thus.
+
+2016-04-05 14:31 -0700  Kevin McCarthy  <ke...@8t8.us>  (f7db9cefd3b0)
+
+       * Makefile.am, configure.ac, mutt_idna.h: Fix IDNA functions for
+       systems without iconv.
+
+       The IDNA changes for SMTPUTF8 support introduced a bug for systems
+       without iconv. For those systems, the local<->intl functions would
+       return an error due to the charset conversion failing.
+
+       Change mutt_idna.c back to being conditionally compiled, but this
+       time based on HAVE_ICONV. If there is no iconv, stub out the
+       functions in mutt_idna.h.
+
+2016-04-02 13:04 -0700  Kevin McCarthy  <ke...@8t8.us>  (b983eb6c1a04)
+
+       * merge default into stable
+
+2016-04-02 11:55 -0700  Kevin McCarthy  <ke...@8t8.us>  (b81408b02cbb)
+
+       * .hgsigs: mutt-1.6.0 signed
+
+2016-04-02 11:18 -0700  Kevin McCarthy  <ke...@8t8.us>  (349f9cb71427)
+
+       * .hgtags: Added tag mutt-1-6-rel for changeset be82a2fde82f
+
+2016-04-02 11:18 -0700  Kevin McCarthy  <ke...@8t8.us>  (be82a2fde82f)
+
+       * ChangeLog, UPDATING, VERSION, po/bg.po, po/ca.po, po/cs.po,
+       po/da.po, po/de.po, po/el.po, po/eo.po, po/es.po, po/et.po,
+       po/eu.po, po/fr.po, po/ga.po, po/gl.po, po/hu.po, po/id.po,
+       po/it.po, po/ja.po, po/ko.po, po/lt.po, po/nl.po, po/pl.po,
+       po/pt_BR.po, po/ru.po, po/sk.po, po/sv.po, po/tr.po, po/uk.po,
+       po/zh_CN.po, po/zh_TW.po: automatic post-release commit for
+       mutt-1.6.0
+
 2016-04-01 09:38 -0700  Kevin McCarthy  <ke...@8t8.us>  (503bd3a3c818)
 
        * Makefile.am: Fix hcversion.h generation error when using included
diff -r 23334e967dd7 -r fb68199318ae UPDATING
--- a/UPDATING  Wed Apr 27 13:08:52 2016 -0700
+++ b/UPDATING  Sat Apr 30 14:39:19 2016 -0700
@@ -4,6 +4,10 @@
 The keys used are:
   !: modified feature, -: deleted feature, +: new feature
 
+1.6.1 (2016-05-01):
+
+  ! Bug fix release.  No features were modified or added.
+
 1.6.0 (2016-04-04):
 
   + Enabled utf-8 mailbox support for IMAP.
diff -r 23334e967dd7 -r fb68199318ae VERSION
--- a/VERSION   Wed Apr 27 13:08:52 2016 -0700
+++ b/VERSION   Sat Apr 30 14:39:19 2016 -0700
@@ -1,1 +1,1 @@
-1.6.0
+1.6.1
diff -r 23334e967dd7 -r fb68199318ae addrbook.c
--- a/addrbook.c        Wed Apr 27 13:08:52 2016 -0700
+++ b/addrbook.c        Sat Apr 30 14:39:19 2016 -0700
@@ -43,7 +43,7 @@
 };
 
 static const char *
-alias_format_str (char *dest, size_t destlen, size_t col, char op, const char 
*src,
+alias_format_str (char *dest, size_t destlen, size_t col, int cols, char op, 
const char *src,
                  const char *fmt, const char *ifstring, const char *elsestring,
                  unsigned long data, format_flag flags)
 {
@@ -80,7 +80,7 @@
 
 static void alias_entry (char *s, size_t slen, MUTTMENU *m, int num)
 {
-  mutt_FormatString (s, slen, 0, NONULL (AliasFmt), alias_format_str, 
(unsigned long) ((ALIAS **) m->data)[num], M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL (AliasFmt), 
alias_format_str, (unsigned long) ((ALIAS **) m->data)[num], 
M_FORMAT_ARROWCURSOR);
 }
 
 static int alias_tag (MUTTMENU *menu, int n, int m)
diff -r 23334e967dd7 -r fb68199318ae alias.c
--- a/alias.c   Wed Apr 27 13:08:52 2016 -0700
+++ b/alias.c   Sat Apr 30 14:39:19 2016 -0700
@@ -423,6 +423,8 @@
     {
       if (dry)
        return -1;
+      if (l == (size_t)(-1))
+        memset (&mb, 0, sizeof (mbstate_t));
       *dest++ = '_';
       rv = -1;
     }
diff -r 23334e967dd7 -r fb68199318ae browser.c
--- a/browser.c Wed Apr 27 13:08:52 2016 -0700
+++ b/browser.c Sat Apr 30 14:39:19 2016 -0700
@@ -142,7 +142,7 @@
 }
 
 static const char *
-folder_format_str (char *dest, size_t destlen, size_t col, char op, const char 
*src,
+folder_format_str (char *dest, size_t destlen, size_t col, int cols, char op, 
const char *src,
                   const char *fmt, const char *ifstring, const char 
*elsestring,
                   unsigned long data, format_flag flags)
 {
@@ -317,9 +317,9 @@
   }
 
   if (optional)
-    mutt_FormatString (dest, destlen, col, ifstring, folder_format_str, data, 
0);
+    mutt_FormatString (dest, destlen, col, cols, ifstring, folder_format_str, 
data, 0);
   else if (flags & M_FORMAT_OPTIONAL)
-    mutt_FormatString (dest, destlen, col, elsestring, folder_format_str, 
data, 0);
+    mutt_FormatString (dest, destlen, col, cols, elsestring, 
folder_format_str, data, 0);
 
   return (src);
 }
@@ -515,7 +515,7 @@
   folder.ff = &((struct folder_file *) menu->data)[num];
   folder.num = num;
   
-  mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str, 
+  mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL(FolderFormat), 
folder_format_str, 
       (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
 }
 
diff -r 23334e967dd7 -r fb68199318ae buffy.c
--- a/buffy.c   Wed Apr 27 13:08:52 2016 -0700
+++ b/buffy.c   Sat Apr 30 14:39:19 2016 -0700
@@ -511,7 +511,8 @@
     strfcpy (path, tmp->path, sizeof (path));
     mutt_pretty_mailbox (path, sizeof (path));
     
-    if (!first && (COLS - 7 >= 0) && (pos + strlen (path) >= (size_t)COLS - 7))
+    if (!first && (MuttMessageWindow->cols >= 7) &&
+        (pos + strlen (path) >= (size_t)MuttMessageWindow->cols - 7))
       break;
     
     if (!first)
diff -r 23334e967dd7 -r fb68199318ae commands.c
--- a/commands.c        Wed Apr 27 13:08:52 2016 -0700
+++ b/commands.c        Sat Apr 30 14:39:19 2016 -0700
@@ -309,10 +309,10 @@
   snprintf (scratch, sizeof (scratch),
            (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);
 
-  if (mutt_strwidth (prompt) > COLS - extra_space)
+  if (mutt_strwidth (prompt) > MuttMessageWindow->cols - extra_space)
   {
     mutt_format_string (prompt, sizeof (prompt),
-                       0, COLS-extra_space, FMT_LEFT, 0,
+                       0, MuttMessageWindow->cols-extra_space, FMT_LEFT, 0,
                        scratch, sizeof (scratch), 0);
     safe_strcat (prompt, sizeof (prompt), "...?");
   }
@@ -322,12 +322,12 @@
   if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
   {
     rfc822_free_address (&adr);
-    CLEARLINE (LINES - 1);
+    mutt_window_clearline (MuttMessageWindow, 0);
     mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
     return;
   }
 
-  CLEARLINE (LINES - 1);
+  mutt_window_clearline (MuttMessageWindow, 0);
   
   rc = mutt_bounce_message (NULL, h, adr);
   rfc822_free_address (&adr);
@@ -598,7 +598,7 @@
       strfcpy (buf, Shell, sizeof (buf));
     if(buf[0])
     {
-      CLEARLINE (LINES-1);
+      mutt_window_clearline (MuttMessageWindow, 0);
       mutt_endwin (NULL);
       fflush (stdout);
       if (mutt_system (buf) != 0 || option (OPTWAITKEY))
diff -r 23334e967dd7 -r fb68199318ae compose.c
--- a/compose.c Wed Apr 27 13:08:52 2016 -0700
+++ b/compose.c Sat Apr 30 14:39:19 2016 -0700
@@ -52,7 +52,7 @@
 
 enum
 {
-  HDR_FROM  = 1,
+  HDR_FROM  = 0,
   HDR_TO,
   HDR_CC,
   HDR_BCC,
@@ -72,7 +72,7 @@
 
 #define HDR_XOFFSET 10
 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
-#define W (COLS - HDR_XOFFSET)
+#define W (MuttIndexWindow->cols - HDR_XOFFSET)
 
 static const char * const Prompts[] =
 {
@@ -99,7 +99,7 @@
 
 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
 {
-    mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
+  mutt_FormatString (b, blen, 0, MuttIndexWindow->cols, NONULL (AttachFormat), 
mutt_attach_fmt,
            (unsigned long)(((ATTACHPTR **) menu->data)[num]),
            M_FORMAT_STAT_FILE | M_FORMAT_ARROWCURSOR);
 }
@@ -110,7 +110,7 @@
 
 static void redraw_crypt_lines (HEADER *msg)
 {
-  mvaddstr (HDR_CRYPT, 0, "Security: ");
+  mutt_window_mvaddstr (MuttIndexWindow, HDR_CRYPT, 0, "Security: ");
 
   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
   {
@@ -144,9 +144,9 @@
   if (option (OPTCRYPTOPPORTUNISTICENCRYPT) && (msg->security & OPPENCRYPT))
       addstr (_(" (OppEnc mode)"));
 
-  clrtoeol ();
-  move (HDR_CRYPTINFO, 0);
-  clrtoeol ();
+  mutt_window_clrtoeol (MuttIndexWindow);
+  mutt_window_move (MuttIndexWindow, HDR_CRYPTINFO, 0);
+  mutt_window_clrtoeol (MuttIndexWindow);
 
   if ((WithCrypto & APPLICATION_PGP)
       && (msg->security & APPLICATION_PGP) && (msg->security & SIGN))
@@ -162,7 +162,7 @@
       && (msg->security & ENCRYPT)
       && SmimeCryptAlg
       && *SmimeCryptAlg) {
-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
+    mutt_window_mvprintw (MuttIndexWindow, HDR_CRYPTINFO, 40, "%s%s", 
_("Encrypt with: "),
                NONULL(SmimeCryptAlg));
   }
 }
@@ -175,12 +175,12 @@
   int c;
   char *t;
 
-  mvaddstr (HDR_MIX, 0,     "     Mix: ");
+  mutt_window_mvaddstr (MuttIndexWindow, HDR_MIX, 0,     "     Mix: ");
 
   if (!chain)
   {
     addstr ("<no chain defined>");
-    clrtoeol ();
+    mutt_window_clrtoeol (MuttIndexWindow);
     return;
   }
   
@@ -190,7 +190,7 @@
     if (t && t[0] == '0' && t[1] == '\0')
       t = "<random>";
     
-    if (c + mutt_strlen (t) + 2 >= COLS)
+    if (c + mutt_strlen (t) + 2 >= MuttIndexWindow->cols)
       break;
 
     addstr (NONULL(t));
@@ -242,7 +242,7 @@
 
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), addr, 1);
-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
+  mutt_window_mvprintw (MuttIndexWindow, line, 0, TITLE_FMT, Prompts[line]);
   mutt_paddstr (W, buf);
 }
 
@@ -252,10 +252,10 @@
   draw_envelope_addr (HDR_TO, msg->env->to);
   draw_envelope_addr (HDR_CC, msg->env->cc);
   draw_envelope_addr (HDR_BCC, msg->env->bcc);
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
+  mutt_window_mvprintw (MuttIndexWindow, HDR_SUBJECT, 0, TITLE_FMT, 
Prompts[HDR_SUBJECT]);
   mutt_paddstr (W, NONULL (msg->env->subject));
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
+  mutt_window_mvprintw (MuttIndexWindow, HDR_FCC, 0, TITLE_FMT, 
Prompts[HDR_FCC]);
   mutt_paddstr (W, fcc);
 
   if (WithCrypto)
@@ -266,8 +266,8 @@
 #endif
 
   SETCOLOR (MT_COLOR_STATUS);
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
-  clrtoeol ();
+  mutt_window_mvaddstr (MuttIndexWindow, HDR_ATTACH - 1, 0, _("-- 
Attachments"));
+  mutt_window_clrtoeol (MuttIndexWindow);
 
   NORMAL_COLOR;
 }
@@ -279,7 +279,7 @@
   
   mutt_addrlist_to_local (*addr);
   rfc822_write_address (buf, sizeof (buf), *addr, 0);
-  if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0)
+  if (mutt_get_field (Prompts[line], buf, sizeof (buf), M_ALIAS) == 0)
   {
     rfc822_free_address (addr);
     *addr = mutt_parse_adrlist (*addr, buf);
@@ -302,7 +302,7 @@
   /* redraw the expanded list so the user can see the result */
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
-  move (line, HDR_XOFFSET);
+  mutt_window_move (MuttIndexWindow, line, HDR_XOFFSET);
   mutt_paddstr (W, buf);
   
   return 0;
@@ -402,7 +402,7 @@
 }
 
 /* prototype for use below */
-static void compose_status_line (char *buf, size_t buflen, size_t col, 
MUTTMENU *menu, 
+static void compose_status_line (char *buf, size_t buflen, size_t col, int 
cols, MUTTMENU *menu, 
       const char *p);
 
 /*
@@ -418,7 +418,7 @@
  */
 
 static const char *
-compose_format_str (char *buf, size_t buflen, size_t col, char op, const char 
*src,
+compose_format_str (char *buf, size_t buflen, size_t col, int cols, char op, 
const char *src,
                   const char *prefix, const char *ifstring,
                   const char *elsestring,
                   unsigned long data, format_flag flags)
@@ -461,17 +461,17 @@
   }
 
   if (optional)
-    compose_status_line (buf, buflen, col, menu, ifstring);
+    compose_status_line (buf, buflen, col, cols, menu, ifstring);
   else if (flags & M_FORMAT_OPTIONAL)
-    compose_status_line (buf, buflen, col, menu, elsestring);
+    compose_status_line (buf, buflen, col, cols, menu, elsestring);
 
   return (src);
 }
 
-static void compose_status_line (char *buf, size_t buflen, size_t col, 
MUTTMENU *menu, 
-      const char *p)
+static void compose_status_line (char *buf, size_t buflen, size_t col, int 
cols,
+                                 MUTTMENU *menu, const char *p)
 {
-  mutt_FormatString (buf, buflen, col, p, compose_format_str, 
+  mutt_FormatString (buf, buflen, col, cols, p, compose_format_str, 
         (unsigned long) menu, 0);
 }
 
@@ -515,7 +515,7 @@
   menu->tag = mutt_tag_attach;
   menu->data = idx;
   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, 
ComposeHelp);
-  
+
   while (loop)
   {
     switch (op = mutt_menuLoop (menu))
@@ -523,7 +523,7 @@
       case OP_REDRAW:
        draw_envelope (msg, fcc);
        menu->offset = HDR_ATTACH;
-       menu->pagelen = LINES - HDR_ATTACH - 2;
+       menu->pagelen = MuttIndexWindow->rows - HDR_ATTACH;
        break;
       case OP_COMPOSE_EDIT_FROM:
        menu->redraw = edit_address_list (HDR_FROM, &msg->env->from);
@@ -564,11 +564,11 @@
        if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
        {
          mutt_str_replace (&msg->env->subject, buf);
-         move (HDR_SUBJECT, HDR_XOFFSET);
+         mutt_window_move (MuttIndexWindow, HDR_SUBJECT, HDR_XOFFSET);
          if (msg->env->subject)
            mutt_paddstr (W, msg->env->subject);
          else
-           clrtoeol();
+           mutt_window_clrtoeol(MuttIndexWindow);
        }
         mutt_message_hook (NULL, msg, M_SEND2HOOK);
         break;
@@ -582,7 +582,7 @@
        {
          strfcpy (fcc, buf, fcclen);
          mutt_pretty_mailbox (fcc, fcclen);
-         move (HDR_FCC, HDR_XOFFSET);
+         mutt_window_move (MuttIndexWindow, HDR_FCC, HDR_XOFFSET);
          mutt_paddstr (W, fcc);
          fccSet = 1;
        }
@@ -1055,7 +1055,7 @@
          int itype;
          FILE *fp;
 
-         CLEARLINE (LINES-1);
+          mutt_window_clearline (MuttMessageWindow, 0);
          fname[0] = 0;
          if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE)
              != 0 || !fname[0])
@@ -1313,10 +1313,10 @@
     /* Draw formatted compose status line */
     if (menu->redraw & REDRAW_STATUS) 
     {
-       compose_status_line (buf, sizeof (buf), 0, menu, NONULL(ComposeFormat));
-       move(option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
+        compose_status_line (buf, sizeof (buf), 0, MuttStatusWindow->cols, 
menu, NONULL(ComposeFormat));
+       mutt_window_move (MuttStatusWindow, 0, 0);
        SETCOLOR (MT_COLOR_STATUS);
-       mutt_paddstr (COLS, buf);
+       mutt_paddstr (MuttStatusWindow->cols, buf);
        NORMAL_COLOR;
        menu->redraw &= ~REDRAW_STATUS;
     }
diff -r 23334e967dd7 -r fb68199318ae copy.c
--- a/copy.c    Wed Apr 27 13:08:52 2016 -0700
+++ b/copy.c    Sat Apr 30 14:39:19 2016 -0700
@@ -288,7 +288,8 @@
       if (flags & (CH_DECODE|CH_PREFIX))
       {
        if (mutt_write_one_header (out, 0, headers[x], 
-                                  flags & CH_PREFIX ? prefix : 0, 
mutt_term_width (Wrap), flags) == -1)
+                                  flags & CH_PREFIX ? prefix : 0,
+                                   mutt_window_wrap_cols (MuttIndexWindow, 
Wrap), flags) == -1)
        {
          error = TRUE;
          break;
diff -r 23334e967dd7 -r fb68199318ae crypt-gpgme.c
--- a/crypt-gpgme.c     Wed Apr 27 13:08:52 2016 -0700
+++ b/crypt-gpgme.c     Sat Apr 30 14:39:19 2016 -0700
@@ -2744,6 +2744,7 @@
 static const char *crypt_entry_fmt (char *dest,
                                     size_t destlen,
                                    size_t col,
+                                    int cols,
                                     char op,
                                     const char *src,
                                     const char *prefix,
@@ -2941,9 +2942,9 @@
   }
 
   if (optional)
-    mutt_FormatString (dest, destlen, col, ifstring, mutt_attach_fmt, data, 0);
+    mutt_FormatString (dest, destlen, col, cols, ifstring, mutt_attach_fmt, 
data, 0);
   else if (flags & M_FORMAT_OPTIONAL)
-    mutt_FormatString (dest, destlen, col, elsestring, mutt_attach_fmt, data, 
0);
+    mutt_FormatString (dest, destlen, col, cols, elsestring, mutt_attach_fmt, 
data, 0);
   return (src);
 }
       
@@ -2956,7 +2957,7 @@
   entry.key = key_table[num];
   entry.num = num + 1;
 
-  mutt_FormatString (s, l, 0, NONULL (PgpEntryFormat), crypt_entry_fmt, 
+  mutt_FormatString (s, l, 0, MuttIndexWindow->cols, NONULL (PgpEntryFormat), 
crypt_entry_fmt, 
                     (unsigned long) &entry, M_FORMAT_ARROWCURSOR);
 }
 
diff -r 23334e967dd7 -r fb68199318ae curs_lib.c
--- a/curs_lib.c        Wed Apr 27 13:08:52 2016 -0700
+++ b/curs_lib.c        Sat Apr 30 14:39:19 2016 -0700
@@ -63,6 +63,14 @@
 static size_t UngetLen = 0;
 static event_t *UngetKeyEvents;
 
+mutt_window_t *MuttHelpWindow = NULL;
+mutt_window_t *MuttIndexWindow = NULL;
+mutt_window_t *MuttStatusWindow = NULL;
+mutt_window_t *MuttMessageWindow = NULL;
+#ifdef USE_SIDEBAR
+mutt_window_t *MuttSidebarWindow = NULL;
+#endif
+
 void mutt_refresh (void)
 {
   /* don't refresh when we are waiting for a child. */
@@ -146,22 +154,22 @@
 int _mutt_get_field (const char *field, char *buf, size_t buflen, int 
complete, int multiple, char ***files, int *numfiles)
 {
   int ret;
-  int x, y;
+  int x;
 
   ENTER_STATE *es = mutt_new_enter_state();
   
   do
   {
-    CLEARLINE (LINES-1);
+    mutt_window_clearline (MuttMessageWindow, 0);
     SETCOLOR (MT_COLOR_PROMPT);
     addstr ((char *)field); /* cast to get around bad prototypes */
     NORMAL_COLOR;
     mutt_refresh ();
-    getyx (stdscr, y, x);
-    ret = _mutt_enter_string (buf, buflen, y, x, complete, multiple, files, 
numfiles, es);
+    mutt_window_getyx (MuttMessageWindow, &ret, &x);  /* don't care about y: 
avoiding unused var warning */
+    ret = _mutt_enter_string (buf, buflen, x, complete, multiple, files, 
numfiles, es);
   }
   while (ret == 1);
-  CLEARLINE (LINES-1);
+  mutt_window_clearline (MuttMessageWindow, 0);
   mutt_free_enter_state (&es);
   
   return (ret);
@@ -182,7 +190,7 @@
 {
   Errorbuf[0] = 0;
   if (!option(OPTNOCURSES))
-    CLEARLINE (LINES-1);
+    mutt_window_clearline (MuttMessageWindow, 0);
 }
 
 void mutt_edit_file (const char *editor, const char *data)
@@ -229,7 +237,7 @@
             !REGCOMP (&reno, expr, REG_NOSUB);
 #endif
 
-  CLEARLINE(LINES-1);
+  mutt_window_clearline (MuttMessageWindow, 0);
 
   /*
    * In order to prevent the default answer to the question to wrapped
@@ -240,7 +248,7 @@
   safe_asprintf (&answer_string, " ([%s]/%s): ", def == M_YES ? yes : no, def 
== M_YES ? no : yes);
   answer_string_len = mutt_strwidth (answer_string);
   /* maxlen here is sort of arbitrary, so pick a reasonable upper bound */
-  msglen = mutt_wstr_trunc (msg, 4*COLS, COLS - answer_string_len, NULL);
+  msglen = mutt_wstr_trunc (msg, 4*MuttMessageWindow->cols, 
MuttMessageWindow->cols - answer_string_len, NULL);
   SETCOLOR (MT_COLOR_PROMPT);
   addnstr (msg, msglen);
   addstr (answer_string);
@@ -333,16 +341,16 @@
 
   dprint (1, (debugfile, "%s\n", scratch));
   mutt_format_string (Errorbuf, sizeof (Errorbuf),
-                     0, COLS, FMT_LEFT, 0, scratch, sizeof (scratch), 0);
+                     0, MuttMessageWindow->cols, FMT_LEFT, 0, scratch, sizeof 
(scratch), 0);
 
   if (!option (OPTKEEPQUIET))
   {
     if (error)
       BEEP ();
     SETCOLOR (error ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
-    mvaddstr (LINES-1, 0, Errorbuf);
+    mutt_window_mvaddstr (MuttMessageWindow, 0, 0, Errorbuf);
     NORMAL_COLOR;
-    clrtoeol ();
+    mutt_window_clrtoeol (MuttMessageWindow);
     mutt_refresh ();
   }
 
@@ -479,15 +487,161 @@
     mutt_clear_error ();
 }
 
+void mutt_init_windows ()
+{
+  MuttHelpWindow = safe_calloc (sizeof (mutt_window_t), 1);
+  MuttIndexWindow = safe_calloc (sizeof (mutt_window_t), 1);
+  MuttStatusWindow = safe_calloc (sizeof (mutt_window_t), 1);
+  MuttMessageWindow = safe_calloc (sizeof (mutt_window_t), 1);
+#ifdef USE_SIDEBAR
+  MuttSidebarWindow = safe_calloc (sizeof (mutt_window_t), 1);
+#endif
+
+  mutt_reflow_windows ();
+}
+
+void mutt_free_windows ()
+{
+  FREE (&MuttHelpWindow);
+  FREE (&MuttIndexWindow);
+  FREE (&MuttStatusWindow);
+  FREE (&MuttMessageWindow);
+#ifdef USE_SIDEBAR
+  FREE (&MuttSidebarWindow);
+#endif
+}
+
+void mutt_reflow_windows (void)
+{
+  if (option (OPTNOCURSES))
+    return;
+
+  dprint (2, (debugfile, "In mutt_reflow_windows\n"));
+
+  MuttStatusWindow->rows = 1;
+  MuttStatusWindow->cols = COLS;
+  MuttStatusWindow->row_offset = option (OPTSTATUSONTOP) ? 0 : LINES - 2;
+  MuttStatusWindow->col_offset = 0;
+
+  memcpy (MuttHelpWindow, MuttStatusWindow, sizeof (mutt_window_t));
+  if (! option (OPTHELP))
+    MuttHelpWindow->rows = 0;
+  else
+    MuttHelpWindow->row_offset = option (OPTSTATUSONTOP) ? LINES - 2 : 0;
+
+  memcpy (MuttMessageWindow, MuttStatusWindow, sizeof (mutt_window_t));
+  MuttMessageWindow->row_offset = LINES - 1;
+
+  memcpy (MuttIndexWindow, MuttStatusWindow, sizeof (mutt_window_t));
+  MuttIndexWindow->rows = LINES - MuttStatusWindow->rows - 
MuttHelpWindow->rows -
+                          MuttMessageWindow->rows;
+  MuttIndexWindow->row_offset = option (OPTSTATUSONTOP) ? 
MuttStatusWindow->rows :
+                                                          MuttHelpWindow->rows;
+
+#ifdef USE_SIDEBAR
+  if (option (OPTSIDEBAR))
+  {
+    memcpy (MuttSidebarWindow, MuttIndexWindow, sizeof (mutt_window_t));
+    MuttSidebarWindow->cols = SidebarWidth;
+
+    MuttIndexWindow->cols -= SidebarWidth;
+    MuttIndexWindow->col_offset += SidebarWidth;
+  }
+#endif
+}
+
+int mutt_window_move (mutt_window_t *win, int row, int col)
+{
+  return move (win->row_offset + row, win->col_offset + col);
+}
+
+int mutt_window_mvaddch (mutt_window_t *win, int row, int col, const chtype ch)
+{
+  return mvaddch (win->row_offset + row, win->col_offset + col, ch);
+}
+
+int mutt_window_mvaddstr (mutt_window_t *win, int row, int col, const char 
*str)
+{
+  return mvaddstr (win->row_offset + row, win->col_offset + col, str);
+}
+
+#ifdef USE_SLANG_CURSES
+static int vw_printw (SLcurses_Window_Type *win, const char *fmt, va_list ap)
+{
+  char buf[LONG_STRING];
+
+  (void) SLvsnprintf (buf, sizeof (buf), (char *)fmt, ap);
+  SLcurses_waddnstr (win, buf, -1);
+  return 0;
+}
+#endif
+
+int mutt_window_mvprintw (mutt_window_t *win, int row, int col, const char 
*fmt, ...)
+{
+  va_list ap;
+  int rv;
+
+  if ((rv = mutt_window_move (win, row, col) != ERR))
+  {
+    va_start (ap, fmt);
+    rv = vw_printw (stdscr, fmt, ap);
+    va_end (ap);
+  }
+
+  return rv;
+}
+
+/* Assumes the cursor has already been positioned within the
+ * window.
+ */
+void mutt_window_clrtoeol (mutt_window_t *win)
+{
+  int row, col, curcol;
+
+  if (win->col_offset + win->cols == COLS)
+    clrtoeol ();
+  else
+  {
+    getyx (stdscr, row, col);
+    curcol = col;
+    while (curcol < win->col_offset + win->cols)
+    {
+      addch (' ');
+      curcol++;
+    }
+    move (row, col);
+  }
+}
+
+void mutt_window_clearline (mutt_window_t *win, int row)
+{
+  mutt_window_move (win, row, 0);
+  mutt_window_clrtoeol (win);
+}
+
+/* Assumes the current position is inside the window.
+ * Otherwise it will happily return negative or values outside
+ * the window boundaries
+ */
+void mutt_window_getyx (mutt_window_t *win, int *y, int *x)
+{
+  int row, col;
+
+  getyx (stdscr, row, col);
+  *y = row - win->row_offset;
+  *x = col - win->col_offset;
+}
+
+
 void mutt_show_error (void)
 {
   if (option (OPTKEEPQUIET))
     return;
   
   SETCOLOR (option (OPTMSGERR) ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
-  mvaddstr(LINES-1, 0, Errorbuf);
+  mutt_window_mvaddstr (MuttMessageWindow, 0, 0, Errorbuf);
   NORMAL_COLOR;
-  clrtoeol();
+  mutt_window_clrtoeol(MuttMessageWindow);
 }
 
 void mutt_endwin (const char *msg)
@@ -582,18 +736,18 @@
   event_t ch;
 
   SETCOLOR (MT_COLOR_PROMPT);
-  mvaddstr (LINES-1, 0, (char *) prompt);
+  mutt_window_mvaddstr (MuttMessageWindow, 0, 0, (char *) prompt);
   addstr (_(" ('?' for list): "));
   NORMAL_COLOR;
   if (buf[0])
     addstr (buf);
-  clrtoeol ();
+  mutt_window_clrtoeol (MuttMessageWindow);
   mutt_refresh ();
 
   ch = mutt_getch();
   if (ch.ch < 0)
   {
-    CLEARLINE (LINES-1);
+    mutt_window_clearline (MuttMessageWindow, 0);
     return (-1);
   }
   else if (ch.ch == '?')
@@ -706,9 +860,9 @@
   char *p;
 
   SETCOLOR (MT_COLOR_PROMPT);
-  mvaddstr (LINES - 1, 0, prompt);
+  mutt_window_mvaddstr (MuttMessageWindow, 0, 0, prompt);
   NORMAL_COLOR;
-  clrtoeol ();
+  mutt_window_clrtoeol (MuttMessageWindow);
   FOREVER
   {
     mutt_refresh ();
@@ -736,7 +890,7 @@
     }
     BEEP ();
   }
-  CLEARLINE (LINES - 1);
+  mutt_window_clearline (MuttMessageWindow, 0);
   mutt_refresh ();
   return choice;
 }
@@ -1034,6 +1188,8 @@
   {
     if (k == (size_t)(-1) || k == (size_t)(-2))
     {
+      if (k == (size_t)(-1))
+        memset (&mbstate, 0, sizeof (mbstate));
       k = (k == (size_t)(-1)) ? 1 : n;
       wc = replacement_char ();
     }
diff -r 23334e967dd7 -r fb68199318ae curs_main.c
--- a/curs_main.c       Wed Apr 27 13:08:52 2016 -0700
+++ b/curs_main.c       Sat Apr 30 14:39:19 2016 -0700
@@ -510,8 +510,6 @@
   int attach_msg = option(OPTATTACHMSG);
 
   menu = mutt_new_menu (MENU_MAIN);
-  menu->offset = 1;
-  menu->pagelen = LINES - 3;
   menu->make_entry = index_make_entry;
   menu->color = index_color;
   menu->current = ci_first_message ();
@@ -631,9 +629,9 @@
       if (menu->redraw & REDRAW_STATUS)
       {
        menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
-       move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
+        mutt_window_move (MuttStatusWindow, 0, 0);
        SETCOLOR (MT_COLOR_STATUS);
-       mutt_paddstr (COLS, buf);
+       mutt_paddstr (MuttStatusWindow->cols, buf);
        NORMAL_COLOR;
        menu->redraw &= ~REDRAW_STATUS;
        if (option(OPTTSENABLED) && TSSupported)
@@ -652,11 +650,12 @@
        menu->oldcurrent = -1;
 
       if (option (OPTARROWCURSOR))
-       move (menu->current - menu->top + menu->offset, 2);
+       mutt_window_move (MuttIndexWindow, menu->current - menu->top + 
menu->offset, 2);
       else if (option (OPTBRAILLEFRIENDLY))
-       move (menu->current - menu->top + menu->offset, 0);
+       mutt_window_move (MuttIndexWindow, menu->current - menu->top + 
menu->offset, 0);
       else
-       move (menu->current - menu->top + menu->offset, COLS - 1);
+       mutt_window_move (MuttIndexWindow, menu->current - menu->top + 
menu->offset,
+                          MuttIndexWindow->cols - 1);
       mutt_refresh ();
 
 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
@@ -703,14 +702,14 @@
        tag = 1;
 
        /* give visual indication that the next command is a tag- command */
-       mvaddstr (LINES - 1, 0, "tag-");
-       clrtoeol ();
+       mutt_window_mvaddstr (MuttMessageWindow, 0, 0, "tag-");
+       mutt_window_clrtoeol (MuttMessageWindow);
 
        /* get the real command */
        if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
        {
          /* abort tag sequence */
-         CLEARLINE (LINES-1);
+          mutt_window_clearline (MuttMessageWindow, 0);
          continue;
        }
       }
@@ -734,14 +733,14 @@
        tag = 1;
 
        /* give visual indication that the next command is a tag- command */
-       mvaddstr (LINES - 1, 0, "tag-");
-       clrtoeol ();
+       mutt_window_mvaddstr (MuttMessageWindow, 0, 0, "tag-");
+       mutt_window_clrtoeol (MuttMessageWindow);
 
        /* get the real command */
        if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
        {
          /* abort tag sequence */
-         CLEARLINE (LINES-1);
+         mutt_window_clearline (MuttMessageWindow, 0);
          continue;
        }
       }
@@ -1193,7 +1192,7 @@
          }
          if (!buf[0])
          {
-           CLEARLINE (LINES-1);
+            mutt_window_clearline (MuttMessageWindow, 0);
            break;
          }
        }
diff -r 23334e967dd7 -r fb68199318ae edit.c
--- a/edit.c    Wed Apr 27 13:08:52 2016 -0700
+++ b/edit.c    Sat Apr 30 14:39:19 2016 -0700
@@ -234,7 +234,7 @@
 {
   char tmp[HUGE_STRING];
 
-  move (LINES-1, 0);
+  mutt_window_move (MuttMessageWindow, 0, 0);
 
   addstr ("To: ");
   tmp[0] = 0;
@@ -242,7 +242,7 @@
   rfc822_write_address (tmp, sizeof (tmp), e->to, 0);
   if (!e->to || force)
   {
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 4, 0) == 0)
+    if (mutt_enter_string (tmp, sizeof (tmp), 4, 0) == 0)
     {
       rfc822_free_address (&e->to);
       e->to = mutt_parse_adrlist (e->to, tmp);
@@ -250,7 +250,7 @@
       mutt_addrlist_to_intl (e->to, NULL);     /* XXX - IDNA error reporting? 
*/
       tmp[0] = 0;
       rfc822_write_address (tmp, sizeof (tmp), e->to, 1);
-      mvaddstr (LINES - 1, 4, tmp);
+      mutt_window_mvaddstr (MuttMessageWindow, 0, 4, tmp);
     }
   }
   else
@@ -264,7 +264,7 @@
   {
     addstr ("Subject: ");
     strfcpy (tmp, e->subject ? e->subject: "", sizeof (tmp));
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 9, 0) == 0)
+    if (mutt_enter_string (tmp, sizeof (tmp), 9, 0) == 0)

Reply via email to