if (chflags & (CH_DECODE | CH_PREFIX))
{
const char *pre = (chflags & CH_PREFIX) ? prefix : NULL;
- const int wraplen = mutt_window_wrap_cols(MuttIndexWindow, C_Wrap);
+ const int wraplen = mutt_window_wrap_cols(MuttIndexWindow->cols, C_Wrap);
if (mutt_write_one_header(fp_out, 0, headers[x], pre, wraplen, chflags) == -1)
{
}
if (mutt_write_one_header(
fp_out, "X-Label", temp_hdr, (chflags & CH_PREFIX) ? prefix : 0,
- mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
+ mutt_window_wrap_cols(MuttIndexWindow->cols, C_Wrap), chflags) == -1)
{
return -1;
}
}
if (mutt_write_one_header(
fp_out, "Subject", temp_hdr, (chflags & CH_PREFIX) ? prefix : 0,
- mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
+ mutt_window_wrap_cols(MuttIndexWindow->cols, C_Wrap), chflags) == -1)
+ {
return -1;
+ }
if (!(chflags & CH_DECODE))
FREE(&temp_hdr);
}
}
/**
- * mutt_window_wrap_cols - Calculate the wrap column for a Window
- * @param win Window
- * @param wrap Wrap config
+ * mutt_window_wrap_cols - Calculate the wrap column for a given screen width
+ * @param width Screen width
+ * @param wrap Wrap config
* @retval num Column that text should be wrapped at
*
* The wrap variable can be negative, meaning there should be a right margin.
*/
-int mutt_window_wrap_cols(struct MuttWindow *win, short wrap)
+int mutt_window_wrap_cols(int width, short wrap)
{
if (wrap < 0)
- return (win->cols > -wrap) ? (win->cols + wrap) : win->cols;
+ return (width > -wrap) ? (width + wrap) : width;
else if (wrap)
- return (wrap < win->cols) ? wrap : win->cols;
+ return (wrap < width) ? wrap : width;
else
- return win->cols;
+ return width;
}
/**
* format_line - Display a line of text in the pager
- * @param[out] line_info Line info
- * @param[in] n Line number (index into line_info)
- * @param[in] buf Text to display
- * @param[in] flags Flags, see #PagerFlags
- * @param[out] pa ANSI attributes used
- * @param[in] cnt Length of text buffer
- * @param[out] pspace Index of last whitespace character
- * @param[out] pvch Number of bytes read
- * @param[out] pcol Number of columns used
- * @param[out] pspecial Attribute flags, e.g. A_UNDERLINE
- * @param[in] pager_window Window to write to
+ * @param[out] line_info Line info
+ * @param[in] n Line number (index into line_info)
+ * @param[in] buf Text to display
+ * @param[in] flags Flags, see #PagerFlags
+ * @param[out] pa ANSI attributes used
+ * @param[in] cnt Length of text buffer
+ * @param[out] pspace Index of last whitespace character
+ * @param[out] pvch Number of bytes read
+ * @param[out] pcol Number of columns used
+ * @param[out] pspecial Attribute flags, e.g. A_UNDERLINE
+ * @param[in] width Width of screen (to wrap to)
* @retval num Number of characters displayed
*/
static int format_line(struct Line **line_info, int n, unsigned char *buf,
- PagerFlags flags, struct AnsiAttr *pa, int cnt, int *pspace,
- int *pvch, int *pcol, int *pspecial, struct MuttWindow *pager_window)
+ PagerFlags flags, struct AnsiAttr *pa, int cnt,
+ int *pspace, int *pvch, int *pcol, int *pspecial, int width)
{
int space = -1; /* index of the last space or TAB */
int col = C_Markers ? (*line_info)[n].continuation : 0;
int ch, vch, last_special = -1, special = 0, t;
wchar_t wc;
mbstate_t mbstate;
- int wrap_cols =
- mutt_window_wrap_cols(pager_window, (flags & MUTT_PAGER_NOWRAP) ? 0 : C_Wrap);
+ int wrap_cols = mutt_window_wrap_cols(width, (flags & MUTT_PAGER_NOWRAP) ? 0 : C_Wrap);
if (check_attachment_marker((char *) buf) == 0)
- wrap_cols = pager_window->cols;
+ wrap_cols = width;
/* FIXME: this should come from line_info */
memset(&mbstate, 0, sizeof(mbstate));
/* now chose a good place to break the line */
cnt = format_line(line_info, n, buf, flags, NULL, b_read, &ch, &vch, &col,
- &special, pager_window);
+ &special, pager_window->cols);
buf_ptr = buf + cnt;
/* move the break point only if smart_wrap is set */
}
/* display the line */
- format_line(line_info, n, buf, flags, &a, cnt, &ch, &vch, &col, &special, pager_window);
+ format_line(line_info, n, buf, flags, &a, cnt, &ch, &vch, &col, &special,
+ pager_window->cols);
/* avoid a bug in ncurses... */
#ifndef USE_SLANG_CURSES