From: Kevin McCarthy Date: Tue, 7 Jun 2016 20:27:45 +0000 (-0700) Subject: Fix columns used for $status_format and $pager_format in the pager. X-Git-Tag: neomutt-20160822~128 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b65edf2bee6aefaacb9147fec9e5a546b699d709;p=neomutt 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. --- diff --git a/commands.c b/commands.c index 3ae00038d..475012199 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 93d649014..eef19e6c5 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 1420d920c..f256a4ed1 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 b953e760c..c21951527 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 30dda73ba..a8921a93d 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); }