set sidebar_visible = yes
set status_on_top = no

When the Sidebar is enabled, $status_on_top unset and the pager active,
the status line and the pager line are the wrong length.

I've changed mutt_make_string_info() and menu_status_line() to take a
cols parameter (max screen columns).  Before, they had a hard-coded
window reference which was only correct when $status_on_top was set.

For the two TS options, I've just set an arbirarily large number because
they aren't displayed on screen.

---
 commands.c  | 2 +-
 curs_main.c | 6 +++---
 hdrline.c   | 4 ++--
 mutt_menu.h | 2 +-
 pager.c     | 9 +++++----
 protos.h    | 2 +-
 status.c    | 4 ++--
 7 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/commands.c b/commands.c
index 3ae0003..4750121 100644
--- a/commands.c
+++ b/commands.c
@@ -140,7 +140,7 @@ int mutt_display_message (HEADER *cur)
     hfi.ctx = Context;
     hfi.pager_progress = ExtPagerProgress;
     hfi.hdr = cur;
-    mutt_make_string_info (buf, sizeof (buf), NONULL(PagerFmt), &hfi, 
MUTT_FORMAT_MAKEPRINT);
+    mutt_make_string_info (buf, sizeof (buf), MuttIndexWindow->cols, 
NONULL(PagerFmt), &hfi, MUTT_FORMAT_MAKEPRINT);
     fputs (buf, fpout);
     fputs ("\n\n", fpout);
   }
diff --git a/curs_main.c b/curs_main.c
index 68620fa..6406d89 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -644,7 +644,7 @@ int mutt_index_menu (void)
 
       if (menu->redraw & REDRAW_STATUS)
       {
-       menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
+       menu_status_line (buf, sizeof (buf), MuttStatusWindow->cols, menu, 
NONULL (Status));
         mutt_window_move (MuttStatusWindow, 0, 0);
        SETCOLOR (MT_COLOR_STATUS);
        mutt_paddstr (MuttStatusWindow->cols, buf);
@@ -652,9 +652,9 @@ int mutt_index_menu (void)
        menu->redraw &= ~REDRAW_STATUS;
        if (option(OPTTSENABLED) && TSSupported)
        {
-         menu_status_line (buf, sizeof (buf), menu, NONULL (TSStatusFormat));
+         menu_status_line (buf, sizeof (buf), MuttStatusWindow->cols, menu, 
NONULL (TSStatusFormat));
          mutt_ts_status(buf);
-         menu_status_line (buf, sizeof (buf), menu, NONULL (TSIconFormat));
+         menu_status_line (buf, sizeof (buf), MuttStatusWindow->cols, menu, 
NONULL (TSIconFormat));
          mutt_ts_icon(buf);
        }
       }
diff --git a/hdrline.c b/hdrline.c
index 93d6490..eef19e6 100644
--- a/hdrline.c
+++ b/hdrline.c
@@ -758,7 +758,7 @@ _mutt_make_string (char *dest, size_t destlen, const char 
*s, CONTEXT *ctx, HEAD
 }
 
 void
-mutt_make_string_info (char *dst, size_t dstlen, const char *s, struct 
hdr_format_info *hfi, format_flag flags)
+mutt_make_string_info (char *dst, size_t dstlen, int cols, const char *s, 
struct hdr_format_info *hfi, format_flag flags)
 {
-  mutt_FormatString (dst, dstlen, 0, MuttIndexWindow->cols, s, hdr_format_str, 
(unsigned long) hfi, flags);
+  mutt_FormatString (dst, dstlen, 0, cols, s, hdr_format_str, (unsigned long) 
hfi, flags);
 }
diff --git a/mutt_menu.h b/mutt_menu.h
index b229fd4..dc4df14 100644
--- a/mutt_menu.h
+++ b/mutt_menu.h
@@ -113,7 +113,7 @@ void menu_current_top (MUTTMENU *);
 void menu_current_middle (MUTTMENU *);
 void menu_current_bottom (MUTTMENU *);
 void menu_check_recenter (MUTTMENU *);
-void menu_status_line (char *, size_t, MUTTMENU *, const char *);
+void menu_status_line (char *, size_t, int, MUTTMENU *, const char *);
 short mutt_ts_capability (void);
 void mutt_ts_status (char *);
 void mutt_ts_icon (char *);
diff --git a/pager.c b/pager.c
index 1420d92..16313aa 100644
--- a/pager.c
+++ b/pager.c
@@ -1707,6 +1707,7 @@ mutt_pager (const char *banner, const char *fname, int 
flags, pager_t *extra)
 
           pager_window->rows -= index_window->rows + index_status_window->rows;
           pager_window->row_offset += index_window->rows + 
index_status_window->rows;
+          pager_status_window->cols = MuttHelpWindow->cols;
         }
       }
 
@@ -1854,7 +1855,7 @@ mutt_pager (const char *banner, const char *fname, int 
flags, pager_t *extra)
        size_t l1 = pager_status_window->cols * MB_LEN_MAX;
        size_t l2 = sizeof (buffer);
        hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
-       mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), 
&hfi, MUTT_FORMAT_MAKEPRINT);
+       mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, 
pager_status_window->cols, NONULL (PagerFmt), &hfi, MUTT_FORMAT_MAKEPRINT);
        mutt_paddstr (pager_status_window->cols, buffer);
       }
       else
@@ -1866,9 +1867,9 @@ mutt_pager (const char *banner, const char *fname, int 
flags, pager_t *extra)
       NORMAL_COLOR;
       if (option(OPTTSENABLED) && TSSupported)
       {
-       menu_status_line (buffer, sizeof (buffer), index, NONULL 
(TSStatusFormat));
+       menu_status_line (buffer, sizeof (buffer), 1024, index, NONULL 
(TSStatusFormat));
        mutt_ts_status(buffer);
-       menu_status_line (buffer, sizeof (buffer), index, NONULL 
(TSIconFormat));
+       menu_status_line (buffer, sizeof (buffer), 1024, index, NONULL 
(TSIconFormat));
        mutt_ts_icon(buffer);
       }
     }
@@ -1881,7 +1882,7 @@ mutt_pager (const char *banner, const char *fname, int 
flags, pager_t *extra)
         menu_redraw_current (index);
 
       /* print out the index status bar */
-      menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
+      menu_status_line (buffer, sizeof (buffer), index_status_window->cols, 
index, NONULL(Status));
  
       mutt_window_move (index_status_window, 0, 0);
       SETCOLOR (MT_COLOR_STATUS);
diff --git a/protos.h b/protos.h
index b953e76..c219515 100644
--- a/protos.h
+++ b/protos.h
@@ -36,7 +36,7 @@ struct hdr_format_info
   const char *pager_progress;
 };
 
-void mutt_make_string_info (char *, size_t, const char *, struct 
hdr_format_info *, format_flag);
+void mutt_make_string_info (char *, size_t, int, const char *, struct 
hdr_format_info *, format_flag);
 
 int mutt_extract_token (BUFFER *, BUFFER *, int);
 BUFFER *mutt_buffer_new (void);
diff --git a/status.c b/status.c
index 30dda73..655405e 100644
--- a/status.c
+++ b/status.c
@@ -302,7 +302,7 @@ static void _menu_status_line (char *buf, size_t buflen, 
size_t col, int cols, M
   mutt_FormatString (buf, buflen, col, cols, p, status_format_str, (unsigned 
long) menu, 0);
 }
 
-void menu_status_line (char *buf, size_t buflen, MUTTMENU *menu, const char *p)
+void menu_status_line (char *buf, size_t buflen, int cols, MUTTMENU *menu, 
const char *p)
 {
-  mutt_FormatString (buf, buflen, 0, MuttStatusWindow->cols, p, 
status_format_str, (unsigned long) menu, 0);
+  mutt_FormatString (buf, buflen, 0, cols, p, status_format_str, (unsigned 
long) menu, 0);
 }
-- 
2.8.2

Reply via email to