- 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++;
- redraw |= REDRAW_SIDEBAR;
+ 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;