From 0e3d502ea09ffae28b93e47a4dfb4db9471259b9 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 7 Jun 2016 13:27:45 -0700 Subject: [PATCH] Fix columns used for $status_format and $pager_format in the pager. The code was hardcoding use of MuttIndexWindow->cols in mutt_make_string_info() and MuttStatusWindow->cols in menu_status_line(). Add a parameter to mutt_make_info_string(). Change menu_status_line() to use menu->statuswin->cols, falling back to MuttStatusWindow if no menu is passed in. Set menu->statuswin appropriately inside pager.c. Thanks to Richard Russon for tracking down this problem, and for the initial patch. --- commands.c | 2 +- hdrline.c | 4 ++-- pager.c | 3 ++- protos.h | 2 +- status.c | 4 +++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/commands.c b/commands.c index 3ae00038..47501219 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/hdrline.c b/hdrline.c index 93d64901..eef19e6c 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/pager.c b/pager.c index 1420d920..f256a4ed 100644 --- a/pager.c +++ b/pager.c @@ -1747,6 +1747,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) index->max = Context->vcount; index->current = extra->hdr->virtual; index->indexwin = index_window; + index->statuswin = index_status_window; } NORMAL_COLOR; @@ -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 diff --git a/protos.h b/protos.h index b953e760..c2195152 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 30dda73b..a8921a93 100644 --- a/status.c +++ b/status.c @@ -304,5 +304,7 @@ static void _menu_status_line (char *buf, size_t buflen, size_t col, int cols, M void menu_status_line (char *buf, size_t buflen, 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, + menu ? menu->statuswin->cols : MuttStatusWindow->cols, + p, status_format_str, (unsigned long) menu, 0); } -- 2.40.0