- try to fix sidebar issue screwing up display when interactively changing $sidebar_w...
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sat, 11 Feb 2006 22:09:29 +0000 (22:09 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sat, 11 Feb 2006 22:09:29 +0000 (22:09 +0000)
git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@778 e385b8ad-14ed-0310-8656-cc95a2468c6d

VERSION.svn
compose.c
menu.c
muttlib.c
pager.c
sidebar.c

index 6e68a0f..451dd3f 100644 (file)
@@ -1 +1 @@
-777
+778
index cc62149..bb977da 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -85,9 +85,10 @@ enum {
 #endif
 };
 
-#define HDR_XOFFSET 14
-#define TITLE_FMT "%14s"        /* Used for Prompts, which are ASCII */
-#define W (COLS - HDR_XOFFSET - SidebarWidth)
+#define HDR_XOFFSET     14
+#define TITLE_FMT       "%14s"        /* Used for Prompts, which are ASCII */
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+#define W               (COLS - HDR_XOFFSET - SW)
 
 static char *Prompts[] = {
   "From: ",
@@ -147,16 +148,16 @@ static void redraw_crypt_lines (HEADER * msg)
 
   if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME)) {
     if (!msg->security)
-      mvaddstr (HDR_CRYPT, SidebarWidth, "    Security: ");
+      mvaddstr (HDR_CRYPT, SW, "    Security: ");
     else if (msg->security & APPLICATION_SMIME)
-      mvaddstr (HDR_CRYPT, SidebarWidth, "      S/MIME: ");
+      mvaddstr (HDR_CRYPT, SW, "      S/MIME: ");
     else if (msg->security & APPLICATION_PGP)
-      mvaddstr (HDR_CRYPT, SidebarWidth, "         PGP: ");
+      mvaddstr (HDR_CRYPT, SW, "         PGP: ");
   }
   else if ((WithCrypto & APPLICATION_SMIME))
-    mvaddstr (HDR_CRYPT, SidebarWidth, "      S/MIME: ");
+    mvaddstr (HDR_CRYPT, SW, "      S/MIME: ");
   else if ((WithCrypto & APPLICATION_PGP))
-    mvaddstr (HDR_CRYPT, SidebarWidth, "         PGP: ");
+    mvaddstr (HDR_CRYPT, SW, "         PGP: ");
   else
     return;
 
@@ -179,7 +180,7 @@ static void redraw_crypt_lines (HEADER * msg)
     }
   clrtoeol ();
 
-  move (HDR_CRYPTINFO, SidebarWidth);
+  move (HDR_CRYPTINFO, SW);
   clrtoeol ();
   if ((WithCrypto & APPLICATION_PGP)
       && msg->security & APPLICATION_PGP && msg->security & SIGN)
@@ -196,7 +197,7 @@ static void redraw_crypt_lines (HEADER * msg)
       && (msg->security & APPLICATION_SMIME)
       && (msg->security & ENCRYPT)
       && SmimeCryptAlg && *SmimeCryptAlg) {
-    mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
+    mvprintw (HDR_CRYPTINFO, SW + 40, "%s%s", _("Encrypt with: "),
               NONULL (SmimeCryptAlg));
     off = 20;
   }
@@ -210,7 +211,7 @@ static void redraw_mix_line (LIST * chain)
   int c;
   char *t;
 
-  mvaddstr (HDR_MIX, SidebarWidth, "         Mix: ");
+  mvaddstr (HDR_MIX, SW, "         Mix: ");
 
   if (!chain) {
     addstr ("<no chain defined>");
@@ -223,7 +224,7 @@ static void redraw_mix_line (LIST * chain)
     if (t && t[0] == '0' && t[1] == '\0')
       t = "<random>";
 
-    if (c + str_len (t) + 2 >= COLS - SidebarWidth)
+    if (c + str_len (t) + 2 >= COLS - SW)
       break;
 
     addstr (NONULL (t));
@@ -270,7 +271,7 @@ static void draw_envelope_addr (int line, ADDRESS * addr)
 
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), addr, 1);
-  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
+  mvprintw (line, SW, TITLE_FMT, Prompts[line - 1]);
   mutt_paddstr (W, buf);
 }
 
@@ -286,9 +287,9 @@ static void draw_envelope (HEADER * msg, char *fcc)
 #ifdef USE_NNTP
   }
   else {
-    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT, Prompts[HDR_NEWSGROUPS - 1]);
+    mvprintw (HDR_TO, SW, TITLE_FMT, Prompts[HDR_NEWSGROUPS - 1]);
     mutt_paddstr (W, NONULL (msg->env->newsgroups));
-    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT, Prompts[HDR_FOLLOWUPTO - 1]);
+    mvprintw (HDR_CC, SW, TITLE_FMT, Prompts[HDR_FOLLOWUPTO - 1]);
     mutt_paddstr (W, NONULL (msg->env->followup_to));
     if (option (OPTXCOMMENTTO)) {
       mvprintw (HDR_BCC, 0, TITLE_FMT, Prompts[HDR_XCOMMENTTO - 1]);
@@ -296,10 +297,10 @@ static void draw_envelope (HEADER * msg, char *fcc)
     }
   }
 #endif
-  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
+  mvprintw (HDR_SUBJECT, SW, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
   mutt_paddstr (W, NONULL (msg->env->subject));
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
-  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
+  mvprintw (HDR_FCC, SW, TITLE_FMT, Prompts[HDR_FCC - 1]);
   mutt_paddstr (W, fcc);
 
   if (WithCrypto)
@@ -310,7 +311,7 @@ static void draw_envelope (HEADER * msg, char *fcc)
 #endif
 
   SETCOLOR (MT_COLOR_STATUS);
-  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
+  mvaddstr (HDR_ATTACH - 1, SW, _("-- Attachments"));
   BKGDSET (MT_COLOR_STATUS);
   clrtoeol ();
 
@@ -345,7 +346,7 @@ static int edit_address_list (int line, ADDRESS ** addr)
   /* 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 + SidebarWidth);
+  move (line, HDR_XOFFSET + SW);
   mutt_paddstr (W, buf);
 
   return 0;
@@ -671,7 +672,7 @@ int mutt_compose_menu (HEADER * msg,    /* structure for new message */
         buf[0] = 0;
       if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) {
         str_replace (&msg->env->subject, buf);
-        move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
+        move (HDR_SUBJECT, HDR_XOFFSET + SW);
         clrtoeol ();
         if (msg->env->subject)
           mutt_paddstr (W, msg->env->subject);
@@ -687,7 +688,7 @@ int mutt_compose_menu (HEADER * msg,    /* structure for new message */
       if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0) {
         strfcpy (fcc, buf, _POSIX_PATH_MAX);
         mutt_pretty_mailbox (fcc);
-        move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
+        move (HDR_FCC, HDR_XOFFSET + SW);
         mutt_paddstr (W, fcc);
         fccSet = 1;
       }
diff --git a/menu.c b/menu.c
index 8afdc10..f8ea243 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -29,6 +29,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 extern int Charset_is_utf8;     /* FIXME: bad modularisation */
 
 extern size_t UngetCount;
@@ -217,18 +219,20 @@ void menu_redraw_index (MUTTMENU * menu)
         if (i == menu->current) {
           attrset (menu->color (i));
           ADDCOLOR (MT_COLOR_INDICATOR);
+          BKGDSET (MT_COLOR_INDICATOR);
           addstr ("->");
           attrset (menu->color (i));
           addch (' ');
         }
         else {
           attrset (menu->color (i));
-          move (i - menu->top + menu->offset, SidebarWidth);
+          move (i - menu->top + menu->offset, SW);
           addstr ("   ");
         }
 
         print_enriched_string (menu->color (i), (unsigned char *) buf, 1);
         SETCOLOR (MT_COLOR_NORMAL);
+        BKGDSET (MT_COLOR_NORMAL);
       }
       else {
         attrset (menu->color (i));
@@ -239,6 +243,8 @@ void menu_redraw_index (MUTTMENU * menu)
         }
 
         CLEARLINE_WIN (i - menu->top + menu->offset);
+
+        move (i - menu->top + menu->offset, SW);
         print_enriched_string (menu->color (i), (unsigned char *) buf,
                                i != menu->current);
         SETCOLOR (MT_COLOR_NORMAL);
@@ -260,7 +266,7 @@ void menu_redraw_motion (MUTTMENU * menu)
     return;
   }
 
-  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
+  move (menu->oldcurrent + menu->offset - menu->top, SW);
   SETCOLOR (MT_COLOR_NORMAL);
   BKGDSET (MT_COLOR_NORMAL);
 
@@ -273,14 +279,14 @@ void menu_redraw_motion (MUTTMENU * menu)
       clrtoeol ();
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
       menu_pad_string (buf, sizeof (buf));
-      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
+      move (menu->oldcurrent + menu->offset - menu->top, SW + 3);
       print_enriched_string (menu->color (menu->oldcurrent),
                              (unsigned char *) buf, 1);
       SETCOLOR (MT_COLOR_NORMAL);
     }
 
     /* now draw it in the new location */
-    move (menu->current + menu->offset - menu->top, SidebarWidth);
+    move (menu->current + menu->offset - menu->top, SW);
     attrset (menu->color (menu->current));
     ADDCOLOR (MT_COLOR_INDICATOR);
     addstr ("->");
@@ -302,6 +308,7 @@ void menu_redraw_motion (MUTTMENU * menu)
     ADDCOLOR (MT_COLOR_INDICATOR);
     BKGDSET (MT_COLOR_INDICATOR);
     CLEARLINE_WIN (menu->current - menu->top + menu->offset);
+    move (menu->current + menu->offset - menu->top, SW);
     print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
                            0);
     SETCOLOR (MT_COLOR_NORMAL);
@@ -314,7 +321,7 @@ void menu_redraw_current (MUTTMENU * menu)
 {
   char buf[STRING];
 
-  move (menu->current + menu->offset - menu->top, SidebarWidth);
+  move (menu->current + menu->offset - menu->top, SW);
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
   menu_pad_string (buf, sizeof (buf));
 
@@ -808,9 +815,9 @@ int mutt_menuLoop (MUTTMENU * menu)
     menu->oldcurrent = menu->current;
 
     if (option (OPTARROWCURSOR))
-      move (menu->current - menu->top + menu->offset, 2);
+      move (menu->current - menu->top + menu->offset, SW + 2);
     else if (option (OPTBRAILLEFRIENDLY))
-      move (menu->current - menu->top + menu->offset, 0);
+      move (menu->current - menu->top + menu->offset, SW);
     else
       move (menu->current - menu->top + menu->offset, COLS - 1);
 
index 757c34f..931c98b 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -49,6 +49,8 @@
 #include <sys/types.h>
 #include <utime.h>
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 BODY *mutt_new_body (void)
 {
   BODY *p = (BODY *) mem_calloc (1, sizeof (BODY));
@@ -1013,9 +1015,7 @@ void mutt_FormatString (char *dest,     /* output buffer */
         if (DrawFullLine || option (OPTSTATUSONTOP))
           count = (COLS < destlen ? COLS : destlen);
         else
-          count =
-            ((COLS - SidebarWidth) <
-             destlen ? (COLS - SidebarWidth) : destlen);
+          count = ((COLS - SW) < destlen ? (COLS - SW) : destlen);
         if (count > col) {
           count -= col;         /* how many columns left on this line */
           mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
diff --git a/pager.c b/pager.c
index 25396d7..7bb69ff 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -57,6 +57,7 @@
 #define IsSendAttach(x) (x && (x)->bdy && !(x)->fp)
 #define IsMsgAttach(x) (x && (x)->fp && (x)->bdy && (x)->bdy->hdr)
 #define IsHeader(x) (x && (x)->hdr && !(x)->bdy)
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
 
 static const char *Not_available_in_this_menu =
 N_("Not available in this menu.");
@@ -982,7 +983,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
 
   if (!(flags & (M_SHOWFLAT)))
     wrap_cols -= WrapMargin;
-  wrap_cols -= SidebarWidth;
+  wrap_cols -= SW;
 
   if (wrap_cols <= 0)
     wrap_cols = COLS;
@@ -1604,7 +1605,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
 
     if ((redraw & REDRAW_BODY) || topline != oldtopline) {
       do {
-        move (bodyoffset, SidebarWidth);
+        move (bodyoffset, SW);
         curline = oldtopline = topline;
         lines = 0;
         force_redraw = 0;
@@ -1617,7 +1618,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
                             &SearchRE) > 0)
             lines++;
           curline++;
-          move (lines + bodyoffset, SidebarWidth);
+          move (lines + bodyoffset, SW);
           redraw |= REDRAW_SIDEBAR;
         }
         last_offset = lineInfo[curline].offset;
@@ -1631,7 +1632,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
           addch ('~');
         addch ('\n');
         lines++;
-        move (lines + bodyoffset, SidebarWidth);
+        move (lines + bodyoffset, SW);
       }
       /* We are going to update the pager status bar, so it isn't
        * necessary to reset to normal color now. */
@@ -1660,10 +1661,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
       }
       if (option(OPTSTATUSONTOP)) {
         move(0,0);
+      } else {
+        move(LINES-2,SW);
       }
-      /*move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (InHelp?(LINES-2):(indexlen - 1))),
-            option (OPTSTATUSONTOP) ? 0 : SidebarWidth);*/
-      mutt_paddstr (COLS - 10 - (option(OPTSTATUSONTOP)?0:SidebarWidth), IsHeader (extra)
+      mutt_paddstr (COLS - 10 - (option(OPTSTATUSONTOP)?0:SW), IsHeader (extra)
                     || IsMsgAttach (extra) ? buffer : banner);
 
       addstr (" -- (");
@@ -1686,10 +1687,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
       /* print out the index status bar */
       menu_status_line (buffer, sizeof (buffer), index, NONULL (Status));
       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
-            option (OPTSTATUSONTOP) ? 0 : SidebarWidth);
+            option (OPTSTATUSONTOP) ? 0 : SW);
       SETCOLOR (MT_COLOR_STATUS);
       BKGDSET (MT_COLOR_STATUS);
-      mutt_paddstr (COLS - (option (OPTSTATUSONTOP) ? 0 : SidebarWidth),
+      mutt_paddstr (COLS - (option (OPTSTATUSONTOP) ? 0 : SW),
                     buffer);
       SETCOLOR (MT_COLOR_NORMAL);
       BKGDSET (MT_COLOR_NORMAL);
index 92a0d2a..42a3546 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -31,7 +31,6 @@ static int CurBuffy = 0;
 static int known_lines = 0;
 static short initialized = 0;
 static short prev_show_value;
-static short saveSidebarWidth;
 
 /* computes first entry to be shown */
 void calc_boundaries (int menu)
@@ -44,11 +43,8 @@ void calc_boundaries (int menu)
     CurBuffy = 0;
   if (TopBuffy < 0 || TopBuffy >= Incoming->length)
     TopBuffy = 0;
-  /* correct known_lines if it has changed because of a window resize */
-  /*  if (known_lines != LINES)
-    known_lines = LINES; */
 
-  lines = LINES - 2 - (menu != MENU_PAGER || option (OPTSTATUSONTOP));
+  lines = LINES - 2 - (option (OPTSTATUSONTOP));
   known_lines = lines;
   if (option (OPTSIDEBARNEWMAILONLY)) {
     int i = CurBuffy;
@@ -295,22 +291,14 @@ int sidebar_draw (int menu)
   /* initialize first time */
   if (!initialized) {
     prev_show_value = option (OPTMBOXPANE);
-    saveSidebarWidth = SidebarWidth;
-    if (!option (OPTMBOXPANE)){
-      SidebarWidth = 0;
+    if (!option (OPTMBOXPANE))
       draw_devider = 1;
-    }
     initialized = 1;
   }
 
   /* save or restore the value SidebarWidth */
   if (prev_show_value != option (OPTMBOXPANE)) {
-    if (prev_show_value && !option (OPTMBOXPANE)) {
-      saveSidebarWidth = SidebarWidth;
-      SidebarWidth = 0;
-    }
-    else if (!prev_show_value && option (OPTMBOXPANE)) {
-      SidebarWidth = saveSidebarWidth;
+    if (!prev_show_value && option (OPTMBOXPANE)) {
       /* after toggle: force recounting of all mail */
       buffy_check (2);
     }