summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-10-28 16:39:53 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-10-28 16:39:53 +0000
commita5b53e11f704384044adf1c378627dd102d0cc03 (patch)
tree38e691b517533327556fbbde4408a3ddf9dd71b8
parent556dbd8900b46a08719b664a80e04568ce4d0e4a (diff)
Gero Treuner's help-wrap patch.
-rw-r--r--OPS1
-rw-r--r--attach.c3
-rw-r--r--commands.c2
-rw-r--r--curs_main.c20
-rw-r--r--doc/manual.sgml.in5
-rw-r--r--help.c255
-rw-r--r--keymap.c17
-rw-r--r--mutt_menu.h1
-rw-r--r--pager.c158
-rw-r--r--pager.h16
10 files changed, 329 insertions, 149 deletions
diff --git a/OPS b/OPS
index d3b32c4c..f228113f 100644
--- a/OPS
+++ b/OPS
@@ -123,6 +123,7 @@ OP_QUERY_APPEND "append new query results to current results"
OP_QUIT "save changes to mailbox and quit"
OP_RECALL_MESSAGE "recall a postponed message"
OP_REDRAW "clear and redraw the screen"
+OP_REFORMAT_WINCH "{internal}"
OP_REPLY "reply to a message"
OP_SAVE "save message/attachment to a file"
OP_SEARCH "search for a regular expression"
diff --git a/attach.c b/attach.c
index b3b19f33..b6a613e7 100644
--- a/attach.c
+++ b/attach.c
@@ -506,7 +506,8 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag)
info.fp = fp;
info.bdy = a;
info.ctx = Context;
- rc = mutt_do_pager (descrip, pagerfile, is_message, &info);
+ rc = mutt_do_pager (descrip, pagerfile,
+ is_message ? M_PAGER_MESSAGE : 0, &info);
}
else
rc = 0;
diff --git a/commands.c b/commands.c
index e2084c8e..c7a08923 100644
--- a/commands.c
+++ b/commands.c
@@ -210,7 +210,7 @@ int mutt_display_message (HEADER *cur)
memset (&info, 0, sizeof (pager_t));
info.hdr = cur;
info.ctx = Context;
- rc = mutt_pager (NULL, tempfile, 1, &info);
+ rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
}
else
{
diff --git a/curs_main.c b/curs_main.c
index ea210992..d1e0f96e 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -243,7 +243,6 @@ int mutt_index_menu (void)
{
char buf[LONG_STRING], helpstr[SHORT_STRING];
int op = OP_NULL;
- event_t event = {-1, 0};
int done = 0; /* controls when to exit the "event" loop */
int i = 0, j;
int tag = 0; /* has the tag-prefix command been pressed? */
@@ -473,24 +472,7 @@ int mutt_index_menu (void)
move (menu->current - menu->top + menu->offset, COLS - 1);
mutt_refresh ();
- if (Timeout > 0)
- {
- timeout (Timeout * 1000); /* milliseconds */
- event = mutt_getch ();
- dprint(4, (debugfile, "mutt_index_menu[%d]: Got event (%d, %d)\n", __LINE__,
- event.ch, event.op));
- timeout (-1); /* restore blocking operation */
- op = event.ch;
- if (op != -1)
- {
- dprint(4, (debugfile, "mutt_index_menu[%d]: Pushing event (%d, %d)\n", __LINE__,
- event.ch, event.op));
- mutt_ungetch (event.ch, event.op);
- op = km_dokey (MENU_MAIN);
- }
- }
- else
- op = km_dokey (MENU_MAIN);
+ op = km_dokey (MENU_MAIN);
dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
diff --git a/doc/manual.sgml.in b/doc/manual.sgml.in
index 03e34cd6..c843c545 100644
--- a/doc/manual.sgml.in
+++ b/doc/manual.sgml.in
@@ -3199,6 +3199,11 @@ This variable specifies which pager you would like to use to view messages.
<tt/builtin/ means to use the builtin pager, otherwise this variable should
specify the pathname of the external pager you would like to use.
+Using an external pager may have some disadvantages: Additional keystrokes
+are necessary because you can't call mutt functions directly from the
+pager, and screen resizes cause lines longer than the screen width to be
+badly formatted in the help menu.
+
<sect2>pager&lowbar;context<label id="pager_context">
<p>
Type: number<newline>
diff --git a/help.c b/help.c
index fbdd8dc8..75ecd7fb 100644
--- a/help.c
+++ b/help.c
@@ -85,54 +85,166 @@ mutt_compile_help (char *buf, size_t buflen, int menu, struct mapping_t *items)
return buf;
}
-static int print_macro (FILE *f, int maxchar, const char *macro)
+static int print_macro (FILE *f, int maxchar, const char **macro)
{
- int i;
+ int c = **macro;
+ int n = maxchar;
- for (i = 0; *macro && i < maxchar; macro++, i++)
+ while (c)
{
- switch (*macro)
+ if (!IsPrint(c))
+ {
+ if (c >= ' ')
+ c = '?';
+ else if (n < 2)
+ c = 0;
+ else
+ {
+ --n;
+ switch (c)
+ {
+ case '\033':
+ fputc ('\\', f);
+ c = 'e';
+ break;
+ case '\n':
+ fputc ('\\', f);
+ c = 'n';
+ break;
+ case '\r':
+ fputc ('\\', f);
+ c = 'r';
+ break;
+ case '\t':
+ fputc ('\\', f);
+ c = 't';
+ break;
+ default:
+ fputc ('^', f);
+ c += '@';
+ break;
+ }
+ }
+ }
+
+ if (c && n > 0)
{
- case '\033':
- fputs ("\\e", f);
- i++;
- break;
- case '\n':
- fputs ("\\n", f);
- i++;
- break;
- case '\r':
- fputs ("\\r", f);
- i++;
- break;
- case '\t':
- fputs ("\\t", f);
- i++;
- break;
- default:
- fputc (*macro, f);
- break;
+ --n;
+ fputc(c, f);
+ c = *++*macro;
}
+ else
+ c = 0;
}
- return (i);
+
+ return (maxchar - n);
}
static int pad (FILE *f, int col, int i)
{
char fmt[8];
- if (i < col)
+ if (col < i)
{
- snprintf (fmt, sizeof(fmt), "%%-%ds", col - i);
+ snprintf (fmt, sizeof(fmt), "%%-%ds", i - col);
fprintf (f, fmt, "");
- i = col;
+ return (i);
+ }
+ fputc (' ', f);
+ return (col + 1);
+}
+
+static void format_line (FILE *f, int ismacro,
+ const char *t1, const char *t2, const char *t3)
+{
+ int col;
+ int col_a, col_b;
+ int split;
+ int n;
+
+ fputs (t1, f);
+
+ /* don't try to press string into one line with less than 40 characters.
+ The double paranthesis avoid a gcc warning, sigh ... */
+ if ((split = COLS < 40))
+ {
+ col_a = col = 0;
+ col_b = LONG_STRING;
+ fputc ('\n', f);
}
else
{
- fputc (' ', f);
- ++i;
+ col_a = 12 + (COLS > 83 ? (COLS - 80) >> 2 : 0);
+ col_b = 19 + (COLS > 43 ? (COLS - 16) >> 2 : 0);
+ col = pad (f, strlen(t1), col_a);
}
- return (i);
+
+ if (ismacro > 0)
+ {
+ if (!strcmp (Pager, "builtin"))
+ fputs ("_\010", f);
+ fputs ("M ", f);
+ col += 2;
+
+ if (!split)
+ {
+ col += print_macro (f, col_b - col - 4, &t2);
+ if (strlen (t2) > col_b - col)
+ t2 = "...";
+ }
+ }
+
+ col += print_macro (f, col_b - col - 1, &t2);
+ if (split)
+ fputc ('\n', f);
+ else
+ col = pad (f, col, col_b);
+
+ if (split)
+ {
+ print_macro (f, LONG_STRING, &t3);
+ fputc ('\n', f);
+ }
+ else
+ {
+ while (*t3)
+ {
+ n = COLS - col;
+
+ if (ismacro >= 0)
+ {
+ SKIPWS(t3);
+
+ if ((n = strlen (t3)) > COLS - col)
+ {
+ n = COLS - col;
+ for (col_a = n; col_a > 0 && t3[col_a] != ' '; col_a--) ;
+ if (col_a)
+ n = col_a;
+ }
+ }
+
+ print_macro (f, n, &t3);
+
+ if (*t3)
+ {
+ if (strcmp (Pager, "builtin"))
+ {
+ fputc ('\n', f);
+ n = 0;
+ }
+ else
+ {
+ n += col - COLS;
+ if (option (OPTMARKERS))
+ ++n;
+ }
+ col = pad (f, n, col_b);
+ }
+ }
+ }
+
+ fputc ('\n', f);
}
static void dump_menu (FILE *f, int menu)
@@ -140,7 +252,6 @@ static void dump_menu (FILE *f, int menu)
struct keymap_t *map;
struct binding_t *b;
char buf[SHORT_STRING];
- int col;
/* browse through the keymap table */
for (map = Keymaps[menu]; map; map = map->next)
@@ -148,41 +259,18 @@ static void dump_menu (FILE *f, int menu)
if (map->op != OP_NULL)
{
km_expand_key (buf, sizeof (buf), map);
- fputs (buf, f);
- col = pad (f, 12, strlen (buf));
if (map->op == OP_MACRO)
{
if (map->descr == NULL)
- {
- fputs ("macro ", f);
- col = pad (f, 35, col + 6);
- print_macro (f, COLS - col, map->macro);
- }
- else
- {
- fputs ("macro: ", f);
- col += 7;
- if (strlen (map->macro) < (34 - col))
- {
- col += print_macro (f, 34 - col, map->macro);
- col = pad (f, 35, col);
- }
- else
- {
- if (col < 31)
- col += print_macro (f, 31 - col, map->macro);
- fputs ("... ", f);
- col += 4;
- }
- print_macro (f, COLS - col, map->descr);
- }
- fputc ('\n', f);
+ format_line (f, -1, buf, "macro", map->macro);
+ else
+ format_line (f, 1, buf, map->macro, map->descr);
}
else
{
b = help_lookupFunction (map->op, menu);
- fprintf (f, "%-22s %s\n", b ? b->name : "UNKNOWN",
+ format_line (f, 0, buf, b ? b->name : "UNKNOWN",
b ? _(HelpStrings[b->op]) : _("ERROR: please report this bug"));
}
}
@@ -208,7 +296,7 @@ static void dump_unbound (FILE *f,
{
if (! is_bound (map, funcs[i].op) &&
(!aux || ! is_bound (aux, funcs[i].op)))
- fprintf (f, "%-35s%s\n", funcs[i].name, _(HelpStrings[funcs[i].op]));
+ format_line (f, 0, funcs[i].name, "", _(HelpStrings[funcs[i].op]));
}
}
@@ -221,32 +309,39 @@ void mutt_help (int menu)
struct binding_t *funcs;
mutt_mktemp (t);
- if ((f = safe_fopen (t, "w")) == NULL)
- {
- mutt_perror (t);
- return;
- }
funcs = km_get_table (menu);
desc = mutt_getnamebyvalue (menu, Menus);
if (!desc)
desc = _("<UNKNOWN>");
- dump_menu (f, menu);
- if (menu != MENU_EDITOR && menu != MENU_PAGER)
- {
- fputs (_("\nGeneric bindings:\n\n"), f);
- dump_menu (f, MENU_GENERIC);
+ do {
+ if ((f = safe_fopen (t, "w")) == NULL)
+ {
+ mutt_perror (t);
+ return;
+ }
+
+ dump_menu (f, menu);
+ if (menu != MENU_EDITOR && menu != MENU_PAGER)
+ {
+ fputs (_("\nGeneric bindings:\n\n"), f);
+ dump_menu (f, MENU_GENERIC);
+ }
+
+ fputs (_("\nUnbound functions:\n\n"), f);
+ if (funcs)
+ dump_unbound (f, funcs, Keymaps[menu], NULL);
+ if (menu != MENU_PAGER)
+ dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
+
+ fclose (f);
+
+ snprintf (buf, sizeof (buf), _("Help for %s"), desc);
}
-
- fputs (_("\nUnbound functions:\n\n"), f);
- if (funcs)
- dump_unbound (f, funcs, Keymaps[menu], NULL);
- if (menu != MENU_PAGER)
- dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
-
- fclose (f);
-
- snprintf (buf, sizeof (buf), _("Help for %s"), desc);
- mutt_do_pager (buf, t, 0, NULL);
+ while
+ (mutt_do_pager (buf, t,
+ M_PAGER_RETWINCH | M_PAGER_MARKER | M_PAGER_NSKIP,
+ NULL)
+ == OP_REFORMAT_WINCH);
}
diff --git a/keymap.c b/keymap.c
index a58b699f..91bd2a69 100644
--- a/keymap.c
+++ b/keymap.c
@@ -343,7 +343,24 @@ int km_dokey (int menu)
FOREVER
{
+/* ncurses doesn't return on resized screen when timeout is set to zero */
+#if !defined (USE_SLANG_CURSES) && defined (HAVE_RESIZETERM)
+ if (menu == MENU_MAIN || menu == MENU_PAGER)
+ timeout (menu == MENU_MAIN && Timeout > 0 ? Timeout * 1000 : INT_MAX);
+#else
+ if (menu == MENU_MAIN && Timeout > 0)
+ timeout (Timeout * 1000); /* milliseconds */
+#endif
+
tmp = mutt_getch();
+
+#if !defined (USE_SLANG_CURSES) && defined (HAVE_RESIZETERM)
+ if (menu == MENU_MAIN || menu == MENU_PAGER)
+#else
+ if (menu == MENU_MAIN && Timeout > 0)
+#endif
+ timeout (-1); /* restore blocking operation */
+
LastKey = tmp.ch;
if (LastKey == -1)
return -1;
diff --git a/mutt_menu.h b/mutt_menu.h
index 10419ea0..0a480aef 100644
--- a/mutt_menu.h
+++ b/mutt_menu.h
@@ -31,6 +31,7 @@
#define REDRAW_STATUS (1<<4)
#define REDRAW_FULL (1<<5)
#define REDRAW_BODY (1<<6)
+#define REDRAW_SIGWINCH (1<<7)
#define M_MODEFMT "-- Mutt: %s"
diff --git a/pager.c b/pager.c
index 0de52322..7fa71301 100644
--- a/pager.c
+++ b/pager.c
@@ -47,14 +47,6 @@ static const char rcsid[]="$Id$";
#include <stdlib.h>
#include <string.h>
-#define M_NOSHOW 0
-#define M_SHOWFLAT (1 << 0)
-#define M_SHOWCOLOR (1 << 1)
-#define M_HIDE (1 << 2)
-#define M_SEARCH (1 << 3)
-#define M_TYPES (1 << 4)
-#define M_SHOW (M_SHOWCOLOR | M_SHOWFLAT)
-
#define ISHEADER(x) ((x) == MT_COLOR_HEADER || (x) == MT_COLOR_HDEFAULT)
#define IsAttach(x) (x && (x)->bdy)
@@ -126,6 +118,14 @@ typedef struct _ansi_attr {
static short InHelp = 0;
+#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
+static struct resize {
+ int line;
+ int SearchCompiled;
+ int SearchBack;
+} *Resize = NULL;
+#endif
+
#define NumSigLines 4
static int check_sig (const char *s, struct line_t *info, int n)
@@ -955,12 +955,14 @@ static int grok_ansi(unsigned char *buf, int pos, ansi_attr *a)
/*
* Args:
- * flags M_NOSHOW, don't show characters
- * M_SHOWFLAT, show characters (used for displaying help)
+ * flags M_SHOWFLAT, show characters (used for displaying help)
* M_SHOWCOLOR, show characters in color
+ * otherwise don't show characters
* M_HIDE, don't show quoted text
* M_SEARCH, resolve search patterns
* M_TYPES, compute line's type
+ * M_PAGER_NSKIP, keeps leading whitespace
+ * M_PAGER_MARKER, eventually show markers
*
* Return values:
* -1 EOF was reached
@@ -1022,7 +1024,7 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
/* this also prevents searching through the hidden lines */
if ((flags & M_HIDE) && (*lineInfo)[n].type == MT_COLOR_QUOTED)
- flags = M_NOSHOW;
+ flags = 0; /* M_NOSHOW */
}
/* At this point, (*lineInfo[n]).quote may still be undefined. We
@@ -1082,12 +1084,12 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
if (!(flags & M_SHOW) && (*lineInfo)[n+1].offset > 0)
{
/* we've already scanned this line, so just exit */
- return 0;
+ return (0);
}
if ((flags & M_SHOWCOLOR) && *force_redraw && (*lineInfo)[n+1].offset > 0)
{
/* no need to try to display this line... */
- return 1; /* fake display */
+ return (1); /* fake display */
}
if ((b_read = fill_buffer (f, last_pos, (*lineInfo)[n].offset, buf, fmt,
@@ -1178,9 +1180,10 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
else
buf_ptr = buf + cnt; /* a very long word... */
}
- /* skip leading blanks on the next line too */
- while (*buf_ptr == ' ' || *buf_ptr == '\t')
- buf_ptr++;
+ if (!(flags & M_PAGER_NSKIP))
+ /* skip leading blanks on the next line too */
+ while (*buf_ptr == ' ' || *buf_ptr == '\t')
+ buf_ptr++;
}
if (*buf_ptr == '\r')
@@ -1255,7 +1258,8 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
if (c == '\t')
{
- if ((flags & (M_SHOWCOLOR | M_SEARCH)) || last_special || a.attr)
+ if ((flags & (M_SHOWCOLOR | M_SEARCH | M_PAGER_MARKER)) || last_special
+ || a.attr)
{
resolve_color (*lineInfo, n, vch, flags, special, &a);
if (!special)
@@ -1271,8 +1275,8 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
}
else if (IsPrint (c))
{
- if ((flags & (M_SHOWCOLOR | M_SEARCH)) || special || last_special
- || a.attr)
+ if ((flags & (M_SHOWCOLOR | M_SEARCH | M_PAGER_MARKER)) || special
+ || last_special || a.attr)
resolve_color (*lineInfo, n, vch, flags, special, &a);
if (!special)
last_special = 0;
@@ -1284,7 +1288,8 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
{
if ((c != '\r' && c !='\n') || (buf[ch+1] != '\n' && buf[ch+1] != '\0'))
{
- if ((flags & (M_SHOWCOLOR | M_SEARCH)) || last_special || a.attr)
+ if ((flags & (M_SHOWCOLOR | M_SEARCH | M_PAGER_MARKER)) || last_special
+ || a.attr)
{
resolve_color (*lineInfo, n, vch, flags, special, &a);
if (!special)
@@ -1298,7 +1303,8 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
}
else
{
- if ((flags & (M_SHOWCOLOR | M_SEARCH)) || last_special || a.attr)
+ if ((flags & (M_SHOWCOLOR | M_SEARCH | M_PAGER_MARKER)) || last_special
+ || a.attr)
{
resolve_color (*lineInfo, n, vch, flags, special, &a);
if (!special)
@@ -1377,7 +1383,7 @@ static struct mapping_t PagerHelpExtra[] = {
is there so that we can do operations on the current message without the
need to pop back out to the main-menu. */
int
-mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
+mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
{
static char searchbuf[STRING];
char buffer[LONG_STRING];
@@ -1395,7 +1401,7 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
struct stat sb;
regex_t SearchRE;
int SearchCompiled = 0, SearchFlag = 0, SearchBack = 0;
- int has_types = (IsHeader(extra) || do_color); /* main message or rfc822 attachment */
+ int has_types = (IsHeader(extra) || (flags & M_SHOWCOLOR)) ? M_TYPES : 0; /* main message or rfc822 attachment */
int bodyoffset = 1; /* offset of first line of real text */
int statusoffset = 0; /* offset for the status bar */
@@ -1409,7 +1415,8 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
int old_PagerIndexLines; /* some people want to resize it
* while inside the pager... */
- do_color = do_color ? M_SHOWCOLOR : M_SHOWFLAT;
+ if (!(flags & M_SHOWCOLOR))
+ flags |= M_SHOWFLAT;
if ((fp = fopen (fname, "r")) == NULL)
{
@@ -1503,6 +1510,23 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
SETCOLOR (MT_COLOR_NORMAL);
}
+#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
+ if (Resize != NULL)
+ {
+ if ((SearchCompiled = Resize->SearchCompiled))
+ {
+ REGCOMP
+ (&SearchRE, searchbuf, REG_NEWLINE | mutt_which_case (searchbuf));
+ SearchFlag = M_SEARCH;
+ SearchBack = Resize->SearchBack;
+ }
+ lines = Resize->line;
+ redraw |= REDRAW_SIGWINCH;
+
+ safe_free ((void **) &Resize);
+ }
+#endif
+
if (IsHeader (extra) && PagerIndexLines)
{
if (index == NULL)
@@ -1537,6 +1561,21 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
mutt_show_error ();
}
+ if (redraw & REDRAW_SIGWINCH)
+ {
+ i = -1;
+ j = -1;
+ while (display_line (fp, &last_pos, &lineInfo, ++i, &lastLine, &maxLine,
+ has_types | SearchFlag, &QuoteList, &q_level, &force_redraw,
+ &SearchRE) == 0)
+ if (!lineInfo[i].continuation && ++j == lines)
+ {
+ topline = i;
+ if (!SearchFlag)
+ break;
+ }
+ }
+
if ((redraw & REDRAW_BODY) || topline != oldtopline)
{
do {
@@ -1548,7 +1587,8 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
while (lines < bodylen && lineInfo[curline].offset <= sb.st_size - 1)
{
if (display_line (fp, &last_pos, &lineInfo, curline, &lastLine,
- &maxLine, do_color | hideQuoted | SearchFlag,
+ &maxLine,
+ (flags & M_DISPLAYFLAGS) | hideQuoted | SearchFlag,
&QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
lines++;
curline++;
@@ -1626,33 +1666,48 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
{
mutt_resize_screen ();
- for (i = 0; i < maxLine; i++)
- {
- lineInfo[i].offset = 0;
- lineInfo[i].type = -1;
- lineInfo[i].continuation = 0;
- lineInfo[i].chunks = 0;
- lineInfo[i].search_cnt = -1;
- lineInfo[i].quote = NULL;
-
- safe_realloc ((void **)&(lineInfo[i].syntax), sizeof (struct syntax_t));
- if (SearchCompiled && lineInfo[i].search)
- safe_free ((void **) &(lineInfo[i].search));
- }
+ /* Store current position. */
+ lines = -1;
+ for (i = 0; i <= topline; i++)
+ if (!lineInfo[i].continuation)
+ lines++;
- if (SearchCompiled)
+ if (flags & M_PAGER_RETWINCH)
{
- regfree (&SearchRE);
- SearchCompiled = 0;
- SearchFlag = 0;
+ Resize = safe_malloc (sizeof (struct resize));
+
+ Resize->line = lines;
+ Resize->SearchCompiled = SearchCompiled;
+ Resize->SearchBack = SearchBack;
+
+ ch = -1;
+ rc = OP_REFORMAT_WINCH;
}
+ else
+ {
+ for (i = 0; i < maxLine; i++)
+ {
+ lineInfo[i].offset = 0;
+ lineInfo[i].type = -1;
+ lineInfo[i].continuation = 0;
+ lineInfo[i].chunks = 0;
+ lineInfo[i].search_cnt = -1;
+ lineInfo[i].quote = NULL;
+
+ safe_realloc ((void **)&(lineInfo[i].syntax),
+ sizeof (struct syntax_t));
+ if (SearchCompiled && lineInfo[i].search)
+ safe_free ((void **) &(lineInfo[i].search));
+ }
- lastLine = 0;
- topline = 0;
+ lastLine = 0;
+ topline = 0;
+
+ redraw = REDRAW_FULL | REDRAW_SIGWINCH;
+ ch = 0;
+ }
- redraw = REDRAW_FULL;
Signals &= ~S_SIGWINCH;
- ch = 0;
continue;
}
#endif
@@ -1902,7 +1957,7 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
case OP_PAGER_HIDE_QUOTED:
if (has_types)
{
- hideQuoted = hideQuoted ? 0 : M_HIDE;
+ hideQuoted ^= M_HIDE;
if (hideQuoted && lineInfo[topline].type == MT_COLOR_QUOTED)
topline = upNLines (1, lineInfo, topline, hideQuoted);
else
@@ -1951,7 +2006,7 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
i = curline;
/* make sure the types are defined to the end of file */
while (display_line (fp, &last_pos, &lineInfo, i, &lastLine,
- &maxLine, (has_types ? M_TYPES : M_NOSHOW),
+ &maxLine, has_types,
&QuoteList, &q_level, &force_redraw,
&SearchRE) == 0)
i++;
@@ -2053,6 +2108,13 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
if (option (OPTWRAP) != old_smart_wrap ||
option (OPTMARKERS) != old_markers)
{
+ if (flags & M_PAGER_RETWINCH)
+ {
+ ch = -1;
+ rc = OP_REFORMAT_WINCH;
+ continue;
+ }
+
/* count the real lines above */
j = 0;
for (i = 0; i <= topline; i++)
diff --git a/pager.h b/pager.h
index 02f529bb..5801232a 100644
--- a/pager.h
+++ b/pager.h
@@ -17,6 +17,22 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/* dynamic internal flags */
+#define M_SHOWFLAT (1<<0)
+#define M_SHOWCOLOR (1<<1)
+#define M_HIDE (1<<2)
+#define M_SEARCH (1<<3)
+#define M_TYPES (1<<4)
+#define M_SHOW (M_SHOWCOLOR | M_SHOWFLAT)
+
+/* exported flags for mutt_(do_)?pager */
+#define M_PAGER_NSKIP (1<<5) /* preserve whitespace with smartwrap */
+#define M_PAGER_MARKER (1<<6) /* use markers if option is set */
+#define M_PAGER_RETWINCH (1<<7) /* need reformatting on SIGWINCH */
+#define M_PAGER_MESSAGE (M_SHOWCOLOR | M_PAGER_MARKER)
+
+#define M_DISPLAYFLAGS (M_SHOW | M_PAGER_NSKIP | M_PAGER_MARKER)
+
typedef struct
{
CONTEXT *ctx; /* current mailbox */