- switch (ch)
- {
- case OP_EXIT:
- rc = -1;
- ch = -1;
- break;
-
- case OP_NEXT_PAGE:
- if (lineInfo[curline].offset < sb.st_size-1)
- {
- topline = upNLines (PagerContext, lineInfo, curline, hideQuoted);
- }
- else if (option (OPTPAGERSTOP))
- {
- /* emulate "less -q" and don't go on to the next message. */
- mutt_error _("Bottom of message is shown.");
- }
- else
- {
- /* end of the current message, so display the next message. */
- rc = OP_MAIN_NEXT_UNDELETED;
- ch = -1;
- }
- break;
-
- case OP_PREV_PAGE:
- if (topline != 0)
- {
- topline = upNLines (bodylen-PagerContext, lineInfo, topline, hideQuoted);
- }
- else
- mutt_error _("Top of message is shown.");
- break;
-
- case OP_NEXT_LINE:
- if (lineInfo[curline].offset < sb.st_size-1)
- {
- topline++;
- if (hideQuoted)
- {
- while (lineInfo[topline].type == MT_COLOR_QUOTED &&
- topline < lastLine)
- topline++;
- }
- }
- else
- mutt_error _("Bottom of message is shown.");
- break;
-
- case OP_PREV_LINE:
- if (topline)
- topline = upNLines (1, lineInfo, topline, hideQuoted);
- else
- mutt_error _("Top of message is shown.");
- break;
-
- case OP_PAGER_TOP:
- if (topline)
- topline = 0;
- else
- mutt_error _("Top of message is shown.");
- break;
-
- case OP_HALF_UP:
- if (topline)
- topline = upNLines (bodylen/2, lineInfo, topline, hideQuoted);
- else
- mutt_error _("Top of message is shown.");
- break;
-
- case OP_HALF_DOWN:
- if (lineInfo[curline].offset < sb.st_size-1)
- {
- topline = upNLines (bodylen/2, lineInfo, curline, hideQuoted);
- }
- else if (option (OPTPAGERSTOP))
- {
- /* emulate "less -q" and don't go on to the next message. */
- mutt_error _("Bottom of message is shown.");
- }
- else
- {
- /* end of the current message, so display the next message. */
- rc = OP_MAIN_NEXT_UNDELETED;
- ch = -1;
- }
- break;
-
- case OP_SEARCH_NEXT:
- case OP_SEARCH_OPPOSITE:
- if (SearchCompiled)
- {
-search_next:
- if ((!SearchBack && ch==OP_SEARCH_NEXT) ||
- (SearchBack &&ch==OP_SEARCH_OPPOSITE))
- {
- /* searching forward */
- for (i = topline + 1; i < lastLine; i++)
- {
- if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) &&
- !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
- break;
- }
-
- if (i < lastLine)
- topline = i;
- else
- mutt_error _("Not found.");
- }
- else
- {
- /* searching backward */
- for (i = topline - 1; i >= 0; i--)
- {
- if ((!hideQuoted || (has_types &&
- lineInfo[i].type != MT_COLOR_QUOTED)) &&
- !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
- break;
- }
-
- if (i >= 0)
- topline = i;
- else
- mutt_error _("Not found.");
- }
-
- if (lineInfo[topline].search_cnt > 0)
- SearchFlag = M_SEARCH;
-
- break;
- }
- /* no previous search pattern, so fall through to search */
-
- case OP_SEARCH:
- case OP_SEARCH_REVERSE:
- strfcpy (buffer, searchbuf, sizeof (buffer));
- if (mutt_get_field ((SearchBack ? _("Reverse search: ") :
- _("Search: ")), buffer, sizeof (buffer),
- M_CLEAR) != 0)
- break;
-
- if (!strcmp (buffer, searchbuf))
- {
- if (SearchCompiled)
- {
- /* do an implicit search-next */
- if (ch == OP_SEARCH)
- ch = OP_SEARCH_NEXT;
- else
- ch = OP_SEARCH_OPPOSITE;
-
- goto search_next;
- }
- }
-
- if (!buffer[0])
- break;
-
- strfcpy (searchbuf, buffer, sizeof (searchbuf));
-
- /* leave SearchBack alone if ch == OP_SEARCH_NEXT */
- if (ch == OP_SEARCH)
- SearchBack = 0;
- else if (ch == OP_SEARCH_REVERSE)
- SearchBack = 1;
-
- if (SearchCompiled)
- {
- regfree (&SearchRE);
- for (i = 0; i < lastLine; i++)
- {
- if (lineInfo[i].search)
- FREE (&(lineInfo[i].search));
- lineInfo[i].search_cnt = -1;
- }
- }
-
- if ((err = REGCOMP (&SearchRE, searchbuf, REG_NEWLINE | mutt_which_case (searchbuf))) != 0)
- {
- regerror (err, &SearchRE, buffer, sizeof (buffer));
- mutt_error ("%s", buffer);
- regfree (&SearchRE);
- for (i = 0; i < maxLine ; i++)
- {
- /* cleanup */
- if (lineInfo[i].search)
- FREE (&(lineInfo[i].search));
- lineInfo[i].search_cnt = -1;
- }
- SearchFlag = 0;
- SearchCompiled = 0;
- }
- else
- {
- SearchCompiled = 1;
- /* update the search pointers */
- i = 0;
- while (display_line (fp, &last_pos, &lineInfo, i, &lastLine,
- &maxLine, M_SEARCH | (flags & M_PAGER_NSKIP),
- &QuoteList, &q_level,
- &force_redraw, &SearchRE) == 0)
- i++;
-
- if (!SearchBack)
- {
- /* searching forward */
- for (i = topline; i < lastLine; i++)
- {
- if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) &&
- !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
- break;
- }
-
- if (i < lastLine) topline = i;
- }
- else
- {
- /* searching backward */
- for (i = topline; i >= 0; i--)
- {
- if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) &&
- !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
- break;
- }
-
- if (i >= 0) topline = i;
- }
-
- if (lineInfo[topline].search_cnt == 0)
- {
- SearchFlag = 0;
- mutt_error _("Not found.");
- }
- else
- SearchFlag = M_SEARCH;
- }
- redraw = REDRAW_BODY;
- break;
-
- case OP_SEARCH_TOGGLE:
- if (SearchCompiled)
- {
- SearchFlag ^= M_SEARCH;
- redraw = REDRAW_BODY;
- }
- break;
-
- case OP_HELP:
- /* don't let the user enter the help-menu from the help screen! */
- if (! InHelp)
- {
- InHelp = 1;
- mutt_clear_xface ();
- mutt_help (MENU_PAGER);
- mutt_show_xface ();
- redraw = REDRAW_FULL;
- InHelp = 0;
- }
- else
- mutt_error _("Help is currently being shown.");
- break;
-
- case OP_PAGER_HIDE_QUOTED:
- if (has_types)
- {
- hideQuoted ^= M_HIDE;
- if (hideQuoted && lineInfo[topline].type == MT_COLOR_QUOTED)
- topline = upNLines (1, lineInfo, topline, hideQuoted);
- else
- redraw = REDRAW_BODY;
- }
- break;
-
- case OP_PAGER_SKIP_QUOTED:
- if (has_types)
- {
- int dretval = 0;
- int new_topline = topline;
-
- while ((new_topline < lastLine ||
- (0 == (dretval = display_line (fp, &last_pos, &lineInfo,
- new_topline, &lastLine, &maxLine, M_TYPES,
- &QuoteList, &q_level, &force_redraw, &SearchRE))))
- && lineInfo[new_topline].type != MT_COLOR_QUOTED)
- new_topline++;
-
- if (dretval < 0)
- {
- mutt_error _("No more quoted text.");
- break;
- }
-
- while ((new_topline < lastLine ||
- (0 == (dretval = display_line (fp, &last_pos, &lineInfo,
- new_topline, &lastLine, &maxLine, M_TYPES,
- &QuoteList, &q_level, &force_redraw, &SearchRE))))
- && lineInfo[new_topline].type == MT_COLOR_QUOTED)
- new_topline++;
-
- if (dretval < 0)
- {
- mutt_error _("No more unquoted text after quoted text.");
- break;
- }
- topline = new_topline;
- }
- break;
-
- case OP_PAGER_BOTTOM: /* move to the end of the file */
- if (lineInfo[curline].offset < sb.st_size - 1)
- {
- 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,
- &QuoteList, &q_level, &force_redraw,
- &SearchRE) == 0)
- i++;
- topline = upNLines (bodylen, lineInfo, lastLine, hideQuoted);
- }
- else
- mutt_error _("Bottom of message is shown.");
- break;
-
- case OP_REDRAW:
- clearok (stdscr, TRUE);
- redraw = REDRAW_FULL;
- break;
-
- case OP_NULL:
- km_error_key (MENU_PAGER);
- break;
-
- /* --------------------------------------------------------------------
- * The following are operations on the current message rather than
- * adjusting the view of the message.
- */
-
- case OP_BOUNCE_MESSAGE:
- CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra))
- CHECK_ATTACH;
- if (IsMsgAttach (extra))
- mutt_attach_bounce (extra->fp, extra->hdr,
- extra->idx, extra->idxlen,
- extra->bdy);
- else
- ci_bounce_message (extra->hdr, &redraw);
- break;
+ switch (ch) {
+ case OP_EXIT:
+ rc = -1;
+ ch = -1;
+ break;
+
+ case OP_NEXT_PAGE:
+ if (lineInfo[curline].offset < sb.st_size - 1) {
+ topline = upNLines (PagerContext, lineInfo, curline, hideQuoted);
+ }
+ else if (option (OPTPAGERSTOP)) {
+ /* emulate "less -q" and don't go on to the next message. */
+ mutt_error _("Bottom of message is shown.");
+ } else {
+ /* end of the current message, so display the next message. */
+ rc = OP_MAIN_NEXT_UNDELETED;
+ ch = -1;
+ }
+ break;
+
+ case OP_PREV_PAGE:
+ if (topline != 0) {
+ topline =
+ upNLines (bodylen - PagerContext, lineInfo, topline, hideQuoted);
+ }
+ else
+ mutt_error _("Top of message is shown.");
+ break;
+
+ case OP_NEXT_LINE:
+ if (lineInfo[curline].offset < sb.st_size - 1) {
+ topline++;
+ if (hideQuoted) {
+ while (lineInfo[topline].type == MT_COLOR_QUOTED &&
+ topline < lastLine)
+ topline++;
+ }
+ }
+ else
+ mutt_error _("Bottom of message is shown.");
+ break;
+
+ case OP_PREV_LINE:
+ if (topline)
+ topline = upNLines (1, lineInfo, topline, hideQuoted);
+ else
+ mutt_error _("Top of message is shown.");
+ break;
+
+ case OP_PAGER_TOP:
+ if (topline)
+ topline = 0;
+ else
+ mutt_error _("Top of message is shown.");
+ break;
+
+ case OP_HALF_UP:
+ if (topline)
+ topline = upNLines (bodylen / 2, lineInfo, topline, hideQuoted);
+ else
+ mutt_error _("Top of message is shown.");
+ break;
+
+ case OP_HALF_DOWN:
+ if (lineInfo[curline].offset < sb.st_size - 1) {
+ topline = upNLines (bodylen / 2, lineInfo, curline, hideQuoted);
+ }
+ else if (option (OPTPAGERSTOP)) {
+ /* emulate "less -q" and don't go on to the next message. */
+ mutt_error _("Bottom of message is shown.");
+ } else {
+ /* end of the current message, so display the next message. */
+ rc = OP_MAIN_NEXT_UNDELETED;
+ ch = -1;
+ }
+ break;
+
+ case OP_SEARCH_NEXT:
+ case OP_SEARCH_OPPOSITE:
+ if (SearchCompiled) {
+ search_next:
+ if ((!SearchBack && ch == OP_SEARCH_NEXT) ||
+ (SearchBack && ch == OP_SEARCH_OPPOSITE)) {
+ /* searching forward */
+ for (i = topline + 1; i < lastLine; i++) {
+ if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) &&
+ !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
+ break;
+ }
+
+ if (i < lastLine)
+ topline = i;
+ else
+ mutt_error _("Not found.");
+ }
+ else {
+ /* searching backward */
+ for (i = topline - 1; i >= 0; i--) {
+ if ((!hideQuoted || (has_types &&
+ lineInfo[i].type != MT_COLOR_QUOTED)) &&
+ !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
+ break;
+ }
+
+ if (i >= 0)
+ topline = i;
+ else
+ mutt_error _("Not found.");
+ }
+
+ if (lineInfo[topline].search_cnt > 0)
+ SearchFlag = M_SEARCH;