NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Pager Function API

Prototype for a Pager Function. More...

+ Collaboration diagram for Pager Function API:

Functions

static int op_pager_bottom (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Jump to the bottom of the message - Implements pager_function_t -.
 
static int op_pager_half_down (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Scroll down 1/2 page - Implements pager_function_t -.
 
static int op_pager_half_up (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Scroll up 1/2 page - Implements pager_function_t -.
 
static int op_pager_hide_quoted (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Toggle display of quoted text - Implements pager_function_t -.
 
static int op_pager_next_line (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Scroll down one line - Implements pager_function_t -.
 
static int op_pager_next_page (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Move to the next page - Implements pager_function_t -.
 
static int op_pager_prev_line (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Scroll up one line - Implements pager_function_t -.
 
static int op_pager_prev_page (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Move to the previous page - Implements pager_function_t -.
 
static int op_pager_search (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Search for a regular expression - Implements pager_function_t -.
 
static int op_pager_search_next (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Search for next match - Implements pager_function_t -.
 
static int op_pager_skip_headers (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Jump to first line after headers - Implements pager_function_t -.
 
static int op_pager_skip_quoted (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Skip beyond quoted text - Implements pager_function_t -.
 
static int op_pager_top (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Jump to the top of the message - Implements pager_function_t -.
 
static int op_exit (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Exit this menu - Implements pager_function_t -.
 
static int op_help (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Help screen - Implements pager_function_t -.
 
static int op_save (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Save the Pager text - Implements pager_function_t -.
 
static int op_search_toggle (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Toggle search pattern coloring - Implements pager_function_t -.
 
static int op_view_attachments (struct PagerFunctionData *fdata, const struct KeyEvent *event)
 Show MIME attachments - Implements pager_function_t -.
 

Detailed Description

Prototype for a Pager Function.

Parameters
fdataPager Function context data
eventEvent to process
Return values
enumFunctionRetval
Precondition
fdata is not NULL
event is not NULL

Function Documentation

◆ op_pager_bottom()

static int op_pager_bottom ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to the bottom of the message - Implements pager_function_t -.

Definition at line 416 of file functions.c.

417{
418 struct PagerPrivateData *priv = fdata->priv;
419 if (!jump_to_bottom(priv, priv->pview))
420 {
421 mutt_message(_("Bottom of message is shown"));
422 return FR_ERROR;
423 }
424
425 return FR_SUCCESS;
426}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
#define mutt_message(...)
Definition logging2.h:93
#define _(a)
Definition message.h:28
bool jump_to_bottom(struct PagerPrivateData *priv, struct PagerView *pview)
Make sure the bottom line is displayed.
Definition functions.c:388
struct PagerPrivateData * priv
Private Pager data.
Definition functions.h:41
Private state data for the Pager.
struct PagerView * pview
Object to view in the pager.
+ Here is the call graph for this function:

◆ op_pager_half_down()

static int op_pager_half_down ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Scroll down 1/2 page - Implements pager_function_t -.

Definition at line 431 of file functions.c.

432{
433 struct PagerPrivateData *priv = fdata->priv;
434 const bool c_pager_stop = cs_subset_bool(fdata->n->sub, "pager_stop");
435 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
436 {
437 int rows = priv->pview->win_pager->state.rows;
438 if (event->count > 0)
439 {
440 int advance = event->count * (rows / 2);
441 priv->top_line = down_n_lines(advance, priv->lines, priv->top_line,
442 priv->lines_used, priv->hide_quoted);
443 }
444 else
445 {
446 priv->top_line = up_n_lines(rows / 2, priv->lines, priv->cur_line, priv->hide_quoted);
447 }
449 }
450 else if (c_pager_stop)
451 {
452 /* emulate "less -q" and don't go on to the next message. */
453 if (event->count == 0)
454 {
455 mutt_message(_("Bottom of message is shown"));
456 return FR_ERROR;
457 }
458 }
459 else
460 {
461 /* end of the current message, so display the next message. */
463 }
464 return FR_SUCCESS;
465}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
bool index_next_undeleted(struct MuttWindow *win_index)
Select the next undeleted Email (if possible)
Definition functions.c:466
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
@ NT_PAGER
Pager data has changed, NotifyPager, PagerPrivateData.
Definition notify_type.h:54
static int up_n_lines(int nlines, struct Line *info, int cur, bool hiding)
Reposition the pager's view up by n lines.
Definition functions.c:345
static int down_n_lines(int nlines, struct Line *info, int cur, int max, bool hiding)
Reposition the pager's view down by n lines.
Definition functions.c:366
@ NT_PAGER_VIEW
Pager View has changed.
Definition lib.h:192
int count
Optional count prefix, e.g. 3 for 3j
Definition get.h:78
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
Definition display.h:51
struct WindowState state
Current state of the Window.
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
struct NeoMutt * n
NeoMutt application data.
Definition functions.h:38
PagerFlags hide_quoted
Set to MUTT_HIDE when quoted email is hidden <toggle-quoted>
int cur_line
Current line (last line visible on screen)
int lines_used
Size of lines array (used entries)
struct Line * lines
Array of text lines in pager.
struct Notify * notify
Notifications: NotifyPager, PagerPrivateData.
int top_line
First visible line on screen.
struct stat st
Stats about Email file.
struct MuttWindow * win_index
Index Window.
Definition lib.h:179
struct MuttWindow * win_pager
Pager Window.
Definition lib.h:181
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
+ Here is the call graph for this function:

◆ op_pager_half_up()

static int op_pager_half_up ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Scroll up 1/2 page - Implements pager_function_t -.

Definition at line 470 of file functions.c.

471{
472 struct PagerPrivateData *priv = fdata->priv;
473 const int old_top_line = priv->top_line;
474 if (priv->top_line)
475 {
476 int rows = priv->pview->win_pager->state.rows;
477 int n = MAX(event->count, 1) * (rows / 2 + rows % 2);
478 priv->top_line = up_n_lines(n, priv->lines, priv->top_line, priv->hide_quoted);
480 }
481 else if (event->count == 0)
482 {
483 mutt_message(_("Top of message is shown"));
484 }
485 return (old_top_line == 0) ? FR_ERROR : FR_SUCCESS;
486}
#define MAX(a, b)
Return the maximum of two values.
Definition memory.h:38
int old_top_line
Old top line, used for repainting.
+ Here is the call graph for this function:

◆ op_pager_hide_quoted()

static int op_pager_hide_quoted ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Toggle display of quoted text - Implements pager_function_t -.

Definition at line 491 of file functions.c.

492{
493 struct PagerPrivateData *priv = fdata->priv;
494 if (!priv->has_types)
495 return FR_NO_ACTION;
496
497 priv->hide_quoted ^= MUTT_HIDE;
498 if (priv->hide_quoted && COLOR_QUOTED(priv->lines[priv->top_line].cid))
499 {
500 priv->top_line = up_n_lines(1, priv->lines, priv->top_line, priv->hide_quoted);
501 }
502 else
503 {
505 }
507 return FR_SUCCESS;
508}
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
void pager_queue_redraw(struct PagerPrivateData *priv, PagerRedrawFlags redraw)
Queue a request for a redraw.
Definition dlg_pager.c:121
@ PAGER_REDRAW_PAGER
Redraw the pager.
Definition lib.h:202
#define MUTT_HIDE
Don't show quoted text.
Definition lib.h:66
#define COLOR_QUOTED(cid)
Definition quoted.h:28
short cid
Default line colour, e.g. MT_COLOR_SIGNATURE.
Definition display.h:52
int has_types
Set to MUTT_TYPES for PAGER_MODE_EMAIL or MUTT_SHOWCOLOR.
+ Here is the call graph for this function:

◆ op_pager_next_line()

static int op_pager_next_line ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Scroll down one line - Implements pager_function_t -.

Definition at line 513 of file functions.c.

514{
515 struct PagerPrivateData *priv = fdata->priv;
516 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
517 {
518 int n = MAX(event->count, 1);
519 priv->top_line = down_n_lines(n, priv->lines, priv->top_line,
520 priv->lines_used, priv->hide_quoted);
522 }
523 else if (event->count == 0)
524 {
525 mutt_message(_("Bottom of message is shown"));
526 return FR_ERROR;
527 }
528 return FR_SUCCESS;
529}
+ Here is the call graph for this function:

◆ op_pager_next_page()

static int op_pager_next_page ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Move to the next page - Implements pager_function_t -.

Definition at line 534 of file functions.c.

535{
536 struct PagerPrivateData *priv = fdata->priv;
537 const bool c_pager_stop = cs_subset_bool(fdata->n->sub, "pager_stop");
538 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
539 {
540 const short c_pager_context = cs_subset_number(fdata->n->sub, "pager_context");
541 if (event->count > 0)
542 {
543 int advance = event->count * (priv->pview->win_pager->state.rows - c_pager_context);
544 priv->top_line = down_n_lines(advance, priv->lines, priv->top_line,
545 priv->lines_used, priv->hide_quoted);
546 }
547 else
548 {
549 priv->top_line = up_n_lines(c_pager_context, priv->lines, priv->cur_line,
550 priv->hide_quoted);
551 }
553 }
554 else if (c_pager_stop)
555 {
556 /* emulate "less -q" and don't go on to the next message. */
557 if (event->count == 0)
558 {
559 mutt_message(_("Bottom of message is shown"));
560 return FR_ERROR;
561 }
562 }
563 else
564 {
565 /* end of the current message, so display the next message. */
567 }
568 return FR_SUCCESS;
569}
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition helpers.c:143
+ Here is the call graph for this function:

◆ op_pager_prev_line()

static int op_pager_prev_line ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Scroll up one line - Implements pager_function_t -.

Definition at line 574 of file functions.c.

575{
576 struct PagerPrivateData *priv = fdata->priv;
577 if (priv->top_line)
578 {
579 int n = MAX(event->count, 1);
580 priv->top_line = up_n_lines(n, priv->lines, priv->top_line, priv->hide_quoted);
582 }
583 else if (event->count == 0)
584 {
585 mutt_message(_("Top of message is shown"));
586 return FR_ERROR;
587 }
588 return FR_SUCCESS;
589}
+ Here is the call graph for this function:

◆ op_pager_prev_page()

static int op_pager_prev_page ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Move to the previous page - Implements pager_function_t -.

Definition at line 594 of file functions.c.

595{
596 struct PagerPrivateData *priv = fdata->priv;
597 if (priv->top_line == 0)
598 {
599 if (event->count == 0)
600 {
601 mutt_message(_("Top of message is shown"));
602 return FR_ERROR;
603 }
604 }
605 else
606 {
607 const short c_pager_context = cs_subset_number(fdata->n->sub, "pager_context");
608 int n = MAX(event->count, 1) * (priv->pview->win_pager->state.rows - c_pager_context);
609 priv->top_line = up_n_lines(n, priv->lines, priv->top_line, priv->hide_quoted);
611 }
612 return FR_SUCCESS;
613}
+ Here is the call graph for this function:

◆ op_pager_search()

static int op_pager_search ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Search for a regular expression - Implements pager_function_t -.

This function handles:

  • OP_SEARCH
  • OP_SEARCH_REVERSE

Definition at line 622 of file functions.c.

623{
624 struct PagerPrivateData *priv = fdata->priv;
625 struct PagerView *pview = priv->pview;
626
627 int rc = FR_NO_ACTION;
628 struct Buffer *buf = buf_pool_get();
629
630 buf_strcpy(buf, priv->search_str);
631 const int op = event->op;
632 if (mw_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? _("Search for: ") : _("Reverse search for: "),
634 {
635 goto done;
636 }
637
638 if (mutt_str_equal(buf_string(buf), priv->search_str))
639 {
640 if (priv->search_compiled)
641 {
642 struct KeyEvent event_s = { 0, OP_NULL };
643
644 /* do an implicit search-next */
645 if (op == OP_SEARCH)
646 event_s.op = OP_SEARCH_NEXT;
647 else
648 event_s.op = OP_SEARCH_OPPOSITE;
649
650 priv->wrapped = false;
651 op_pager_search_next(fdata, &event_s);
652 }
653 }
654
655 if (buf_is_empty(buf))
656 goto done;
657
658 mutt_str_copy(priv->search_str, buf_string(buf), sizeof(priv->search_str));
659
660 /* leave search_back alone if op == OP_SEARCH_NEXT */
661 if (op == OP_SEARCH)
662 priv->search_back = false;
663 else if (op == OP_SEARCH_REVERSE)
664 priv->search_back = true;
665
666 if (priv->search_compiled)
667 {
668 regfree(&priv->search_re);
669 for (size_t i = 0; i < priv->lines_used; i++)
670 {
671 FREE(&(priv->lines[i].search));
672 priv->lines[i].search_arr_size = -1;
673 }
674 }
675
676 uint16_t rflags = mutt_mb_is_lower(priv->search_str) ? REG_ICASE : 0;
677 int err = REG_COMP(&priv->search_re, priv->search_str, REG_NEWLINE | rflags);
678 if (err != 0)
679 {
680 regerror(err, &priv->search_re, buf->data, buf->dsize);
681 mutt_error("%s", buf_string(buf));
682 for (size_t i = 0; i < priv->lines_max; i++)
683 {
684 /* cleanup */
685 FREE(&(priv->lines[i].search));
686 priv->lines[i].search_arr_size = -1;
687 }
688 priv->search_flag = 0;
689 priv->search_compiled = false;
690 rc = FR_ERROR;
691 }
692 else
693 {
694 priv->search_compiled = true;
695 /* update the search pointers */
696 int line_num = 0;
697 while (display_line(priv->fp, &priv->bytes_read, &priv->lines, line_num,
698 &priv->lines_used, &priv->lines_max,
699 MUTT_SEARCH | (pview->flags & MUTT_PAGER_NOWRAP) | priv->has_types,
700 &priv->quote_list, &priv->q_level, &priv->force_redraw,
701 &priv->search_re, priv->pview->win_pager, &priv->ansi_list) == 0)
702 {
703 line_num++;
704 }
705
706 if (priv->search_back)
707 {
708 /* searching backward */
709 int i;
710 for (i = priv->top_line; i >= 0; i--)
711 {
712 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
713 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
714 {
715 break;
716 }
717 }
718
719 if (i >= 0)
720 priv->top_line = i;
721 }
722 else
723 {
724 /* searching forward */
725 int i;
726 for (i = priv->top_line; i < priv->lines_used; i++)
727 {
728 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
729 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
730 {
731 break;
732 }
733 }
734
735 if (i < priv->lines_used)
736 priv->top_line = i;
737 }
738
739 if (priv->lines[priv->top_line].search_arr_size == 0)
740 {
741 priv->search_flag = 0;
742 mutt_error(_("Not found"));
743 rc = FR_ERROR;
744 }
745 else
746 {
747 const short c_search_context = cs_subset_number(fdata->n->sub, "search_context");
748 priv->search_flag = MUTT_SEARCH;
749 /* give some context for search results */
750 if (c_search_context < priv->pview->win_pager->state.rows)
751 priv->searchctx = c_search_context;
752 else
753 priv->searchctx = 0;
754 if (priv->top_line - priv->searchctx > 0)
755 priv->top_line -= priv->searchctx;
756 rc = FR_SUCCESS;
757 }
758 }
761
762done:
763 buf_pool_release(&buf);
764 return rc;
765}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
int display_line(FILE *fp, LOFF_T *bytes_read, struct Line **lines, int line_num, int *lines_used, int *lines_max, PagerFlags flags, struct QuoteStyle **quote_list, int *q_level, bool *force_redraw, regex_t *search_re, struct MuttWindow *win_pager, struct AttrColorList *ansi_list)
Print a line on screen.
Definition display.c:1058
@ MUTT_COMP_CLEAR
Clear input if printable character is pressed.
Definition wdata.h:47
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition window.c:502
#define mutt_error(...)
Definition logging2.h:94
static int op_pager_search_next(struct PagerFunctionData *fdata, const struct KeyEvent *event)
Search for next match - Implements pager_function_t -.
Definition functions.c:774
@ HC_PATTERN
Patterns.
Definition lib.h:60
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
Definition mbyte.c:355
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition string.c:586
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition lib.h:74
#define MUTT_SEARCH
Resolve search patterns.
Definition lib.h:67
const struct CompleteOps CompletePatternOps
Auto-Completion of Patterns.
Definition complete.c:98
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition regex3.h:49
String manipulation buffer.
Definition buffer.h:36
size_t dsize
Length of data.
Definition buffer.h:39
char * data
Pointer to data.
Definition buffer.h:37
An event such as a keypress.
Definition get.h:75
int op
Function opcode, e.g. OP_HELP.
Definition get.h:77
short search_arr_size
Number of items in search array.
Definition display.h:59
struct TextSyntax * search
Array of search text in the line.
Definition display.h:60
bool cont_line
Continuation of a previous line (wrapped by NeoMutt)
Definition display.h:53
int q_level
Number of unique quoting levels.
bool wrapped
Has the search/next wrapped around?
char search_str[256]
Current search string.
int lines_max
Capacity of lines array (total entries)
bool force_redraw
Repaint is needed.
LOFF_T bytes_read
Number of bytes read from file.
bool search_back
Search backwards.
struct QuoteStyle * quote_list
Tree of quoting levels.
struct AttrColorList ansi_list
List of ANSI colours used in the Pager.
int searchctx
Space to show around search matches.
regex_t search_re
Compiled search string.
FILE * fp
File containing decrypted/decoded/weeded Email.
PagerFlags search_flag
Set to MUTT_SEARCH when search results are visible <search-toggle>
bool search_compiled
Search regex is in use.
Paged view into some data.
Definition lib.h:173
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:176
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_pager_search_next()

static int op_pager_search_next ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Search for next match - Implements pager_function_t -.

This function handles:

  • OP_SEARCH_NEXT
  • OP_SEARCH_OPPOSITE

Definition at line 774 of file functions.c.

775{
776 struct PagerPrivateData *priv = fdata->priv;
777 if (priv->search_compiled)
778 {
779 const short c_search_context = cs_subset_number(fdata->n->sub, "search_context");
780 bool found = false;
781 priv->wrapped = false;
782
783 if (c_search_context < priv->pview->win_pager->state.rows)
784 priv->searchctx = c_search_context;
785 else
786 priv->searchctx = 0;
787
788 const int op = event->op;
789
790 search_next:
791 if ((!priv->search_back && (op == OP_SEARCH_NEXT)) ||
792 (priv->search_back && (op == OP_SEARCH_OPPOSITE)))
793 {
794 /* searching forward */
795 int i;
796 for (i = priv->wrapped ? 0 : priv->top_line + priv->searchctx + 1;
797 i < priv->lines_used; i++)
798 {
799 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
800 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
801 {
802 break;
803 }
804 }
805
806 const bool c_wrap_search = cs_subset_bool(fdata->n->sub, "wrap_search");
807 if (i < priv->lines_used)
808 {
809 priv->top_line = i;
810 found = true;
811 }
812 else if (priv->wrapped || !c_wrap_search)
813 {
814 mutt_error(_("Not found"));
815 }
816 else
817 {
818 mutt_message(_("Search wrapped to top"));
819 priv->wrapped = true;
820 goto search_next;
821 }
822 }
823 else
824 {
825 /* searching backward */
826 int i;
827 for (i = priv->wrapped ? priv->lines_used : priv->top_line + priv->searchctx - 1;
828 i >= 0; i--)
829 {
830 if ((!priv->hide_quoted ||
831 (priv->has_types && !COLOR_QUOTED(priv->lines[i].cid))) &&
832 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
833 {
834 break;
835 }
836 }
837
838 const bool c_wrap_search = cs_subset_bool(fdata->n->sub, "wrap_search");
839 if (i >= 0)
840 {
841 priv->top_line = i;
842 found = true;
843 }
844 else if (priv->wrapped || !c_wrap_search)
845 {
846 mutt_error(_("Not found"));
847 }
848 else
849 {
850 mutt_message(_("Search wrapped to bottom"));
851 priv->wrapped = true;
852 goto search_next;
853 }
854 }
855
856 if (!found)
857 return FR_ERROR;
858
859 if (priv->lines[priv->top_line].search_arr_size > 0)
860 {
861 priv->search_flag = MUTT_SEARCH;
862 /* give some context for search results */
863 if (priv->top_line - priv->searchctx > 0)
864 priv->top_line -= priv->searchctx;
865 }
866
868 return FR_SUCCESS;
869 }
870
871 /* no previous search pattern */
872 return op_pager_search(fdata, event);
873}
static int op_pager_search(struct PagerFunctionData *fdata, const struct KeyEvent *event)
Search for a regular expression - Implements pager_function_t -.
Definition functions.c:622
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_pager_skip_headers()

static int op_pager_skip_headers ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to first line after headers - Implements pager_function_t -.

Definition at line 878 of file functions.c.

879{
880 struct PagerPrivateData *priv = fdata->priv;
881 struct PagerView *pview = priv->pview;
882
883 if (!priv->has_types)
884 return FR_NO_ACTION;
885
886 int rc = 0;
887 int new_topline = 0;
888
889 while (((new_topline < priv->lines_used) ||
890 (0 == (rc = display_line(priv->fp, &priv->bytes_read, &priv->lines,
891 new_topline, &priv->lines_used, &priv->lines_max,
892 MUTT_TYPES | (pview->flags & MUTT_PAGER_NOWRAP), &priv->quote_list,
893 &priv->q_level, &priv->force_redraw, &priv->search_re,
894 priv->pview->win_pager, &priv->ansi_list)))) &&
895 color_is_header(priv->lines[new_topline].cid))
896 {
897 new_topline++;
898 }
899
900 if (rc < 0)
901 {
902 /* L10N: Displayed if <skip-headers> is invoked in the pager, but
903 there is no text past the headers.
904 (I don't think this is actually possible in Mutt's code, but
905 display some kind of message in case it somehow occurs.) */
906 mutt_warning(_("No text past headers"));
907 return FR_ERROR;
908 }
909 priv->top_line = new_topline;
911 return FR_SUCCESS;
912}
bool color_is_header(enum ColorId cid)
Colour is for an Email header.
Definition display.c:488
#define mutt_warning(...)
Definition logging2.h:92
#define MUTT_TYPES
Compute line's type.
Definition lib.h:68
+ Here is the call graph for this function:

◆ op_pager_skip_quoted()

static int op_pager_skip_quoted ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Skip beyond quoted text - Implements pager_function_t -.

With a count prefix, skip N quoted blocks instead of 1.

Definition at line 1009 of file functions.c.

1010{
1011 struct PagerPrivateData *priv = fdata->priv;
1012
1013 if (!priv->has_types)
1014 return FR_NO_ACTION;
1015
1016 const int count = MAX(event->count, 1);
1017
1018 for (int i = 0; i < count; i++)
1019 {
1020 if (pager_skip_quoted_once(priv, fdata) < 0)
1021 return FR_NO_ACTION;
1022 }
1023
1024 return FR_SUCCESS;
1025}
static int pager_skip_quoted_once(struct PagerPrivateData *priv, struct PagerFunctionData *fdata)
Skip to next unquoted block.
Definition functions.c:921
+ Here is the call graph for this function:

◆ op_pager_top()

static int op_pager_top ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to the top of the message - Implements pager_function_t -.

Definition at line 1030 of file functions.c.

1031{
1032 struct PagerPrivateData *priv = fdata->priv;
1033 if (priv->top_line == 0)
1034 {
1035 mutt_message(_("Top of message is shown"));
1036 return FR_ERROR;
1037 }
1038 else
1039 {
1040 priv->top_line = 0;
1042 }
1043
1044 return FR_SUCCESS;
1045}
+ Here is the call graph for this function:

◆ op_exit()

static int op_exit ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Exit this menu - Implements pager_function_t -.

Definition at line 1052 of file functions.c.

1053{
1054 struct PagerPrivateData *priv = fdata->priv;
1055 priv->rc = -1;
1056 priv->loop = PAGER_LOOP_QUIT;
1057 return FR_DONE;
1058}
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:36
@ PAGER_LOOP_QUIT
Quit the Pager.
Definition lib.h:154
int rc
Return code from functions.
enum PagerLoopMode loop
What the Event Loop should do next, e.g. PAGER_LOOP_CONTINUE.

◆ op_help()

static int op_help ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Help screen - Implements pager_function_t -.

Definition at line 1063 of file functions.c.

1064{
1065 struct PagerPrivateData *priv = fdata->priv;
1066 if (priv->pview->mode == PAGER_MODE_HELP)
1067 {
1068 /* don't let the user enter the help-menu from the help screen! */
1069 mutt_error(_("Help is currently being shown"));
1070 return FR_ERROR;
1071 }
1072 mutt_help(fdata->mod_data->menu_pager);
1074 return FR_SUCCESS;
1075}
void mutt_help(const struct MenuDefinition *md)
Display the Help Page.
Definition help.c:146
@ PAGER_MODE_HELP
Pager is invoked via 3rd path to show help.
Definition lib.h:142
struct PagerModuleData * mod_data
Pager module data.
Definition functions.h:39
struct MenuDefinition * menu_pager
Pager menu definition.
Definition module_data.h:32
enum PagerMode mode
Pager mode.
Definition lib.h:175
+ Here is the call graph for this function:

◆ op_save()

static int op_save ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Save the Pager text - Implements pager_function_t -.

Definition at line 1080 of file functions.c.

1081{
1082 struct PagerPrivateData *priv = fdata->priv;
1083 struct PagerView *pview = priv->pview;
1084 if (pview->mode != PAGER_MODE_OTHER)
1085 return FR_UNKNOWN;
1086
1087 if (!priv->fp)
1088 return FR_UNKNOWN;
1089
1090 int rc = FR_ERROR;
1091 FILE *fp_save = NULL;
1092 struct Buffer *buf = buf_pool_get();
1093
1094 // Save the current read position
1095 long pos = ftell(priv->fp);
1096 rewind(priv->fp);
1097
1098 struct FileCompletionData cdata = { false, NULL, NULL, NULL, NULL };
1099 if ((mw_get_field(_("Save to file: "), buf, MUTT_COMP_CLEAR, HC_FILE,
1100 &CompleteFileOps, &cdata) != 0) ||
1101 buf_is_empty(buf))
1102 {
1103 rc = FR_SUCCESS;
1104 goto done;
1105 }
1106
1107 expand_path(buf, false);
1108 fp_save = mutt_file_fopen(buf_string(buf), "a+");
1109 if (!fp_save)
1110 {
1111 mutt_perror("%s", buf_string(buf));
1112 goto done;
1113 }
1114
1115 int bytes = mutt_file_copy_stream(priv->fp, fp_save);
1116 if (bytes == -1)
1117 {
1118 mutt_perror("%s", buf_string(buf));
1119 goto done;
1120 }
1121
1122 mutt_message(_("Saved to: %s"), buf_string(buf));
1123 rc = FR_SUCCESS;
1124
1125done:
1126 // Restore the read position (rewound at start of function)
1127 if (pos >= 0)
1128 (void) mutt_file_seek(priv->fp, pos, SEEK_SET);
1129
1130 mutt_file_fclose(&fp_save);
1131 buf_pool_release(&buf);
1132
1133 return rc;
1134}
const struct CompleteOps CompleteFileOps
Auto-Completion of Files.
Definition complete.c:152
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:34
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition file.c:224
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
Definition file.c:648
#define mutt_file_fclose(FP)
Definition file.h:144
#define mutt_file_fopen(PATH, MODE)
Definition file.h:143
#define mutt_perror(...)
Definition logging2.h:95
@ HC_FILE
Files.
Definition lib.h:59
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:122
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition lib.h:143
Input for the file completion function.
Definition curs_lib.h:39
+ Here is the call graph for this function:

◆ op_search_toggle()

static int op_search_toggle ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Toggle search pattern coloring - Implements pager_function_t -.

Definition at line 1139 of file functions.c.

1140{
1141 struct PagerPrivateData *priv = fdata->priv;
1142 if (priv->search_compiled)
1143 {
1144 priv->search_flag ^= MUTT_SEARCH;
1146 }
1147 return FR_SUCCESS;
1148}
+ Here is the call graph for this function:

◆ op_view_attachments()

static int op_view_attachments ( struct PagerFunctionData * fdata,
const struct KeyEvent * event )
static

Show MIME attachments - Implements pager_function_t -.

Definition at line 1153 of file functions.c.

1154{
1155 struct IndexSharedData *shared = fdata->shared;
1156 struct PagerPrivateData *priv = fdata->priv;
1157 struct PagerView *pview = priv->pview;
1158
1159 // This needs to be delegated
1160 if (pview->flags & MUTT_PAGER_ATTACHMENT)
1161 return FR_UNKNOWN;
1162
1163 if (!assert_pager_mode(pview->mode == PAGER_MODE_EMAIL))
1164 return FR_NOT_IMPL;
1165 dlg_attach(fdata->n->sub, shared->mailbox_view, shared->email,
1166 pview->pdata->fp, shared->attach_msg);
1167 if (shared->email->attach_del)
1168 shared->mailbox->changed = true;
1170 return FR_SUCCESS;
1171}
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition dispatcher.h:37
void dlg_attach(struct ConfigSubset *sub, struct MailboxView *mv, struct Email *e, FILE *fp, bool attach_msg)
Show the attachments in a Menu -.
Definition dlg_attach.c:208
static bool assert_pager_mode(bool test)
Check that pager is in correct mode.
Definition functions.c:327
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition lib.h:139
#define MUTT_PAGER_ATTACHMENT
Attachments may exist.
Definition lib.h:73
bool attach_del
Has an attachment marked for deletion.
Definition email.h:99
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
struct Email * email
Currently selected Email.
Definition shared_data.h:42
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:41
bool attach_msg
Are we in "attach message" mode?
Definition shared_data.h:46
struct MailboxView * mailbox_view
Current Mailbox view.
Definition shared_data.h:40
bool changed
Mailbox has been modified.
Definition mailbox.h:112
FILE * fp
Source stream.
Definition lib.h:164
struct IndexSharedData * shared
Shared Index data.
Definition functions.h:40
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:174
+ Here is the call graph for this function: