NeoMutt  2025-09-05-55-g97fc89
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 IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to the bottom of the message - Implements pager_function_t -.
 
static int op_pager_half_down (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll down 1/2 page - Implements pager_function_t -.
 
static int op_pager_half_up (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll up 1/2 page - Implements pager_function_t -.
 
static int op_pager_hide_quoted (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Toggle display of quoted text - Implements pager_function_t -.
 
static int op_pager_next_line (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll down one line - Implements pager_function_t -.
 
static int op_pager_next_page (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Move to the next page - Implements pager_function_t -.
 
static int op_pager_prev_line (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll up one line - Implements pager_function_t -.
 
static int op_pager_prev_page (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Move to the previous page - Implements pager_function_t -.
 
static int op_pager_search (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Search for a regular expression - Implements pager_function_t -.
 
static int op_pager_search_next (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Search for next match - Implements pager_function_t -.
 
static int op_pager_skip_headers (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to first line after headers - Implements pager_function_t -.
 
static int op_pager_skip_quoted (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Skip beyond quoted text - Implements pager_function_t -.
 
static int op_pager_top (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to the top of the message - Implements pager_function_t -.
 
static int op_exit (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Exit this menu - Implements pager_function_t -.
 
static int op_help (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Help screen - Implements pager_function_t -.
 
static int op_save (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Save the Pager text - Implements pager_function_t -.
 
static int op_search_toggle (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Toggle search pattern coloring - Implements pager_function_t -.
 
static int op_view_attachments (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Show MIME attachments - Implements pager_function_t -.
 

Detailed Description

Prototype for a Pager Function.

Parameters
sharedShared Index data
privPrivate Index data
opOperation to perform, e.g. OP_MAIN_LIMIT
Return values
enumFunctionRetval

Function Documentation

◆ op_pager_bottom()

static int op_pager_bottom ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

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

Definition at line 403 of file functions.c.

405{
406 if (!jump_to_bottom(priv, priv->pview))
407 mutt_message(_("Bottom of message is shown"));
408
409 return FR_SUCCESS;
410}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:39
#define mutt_message(...)
Definition logging2.h:92
#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:375
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 IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Scroll down 1/2 page - Implements pager_function_t -.

Definition at line 415 of file functions.c.

417{
418 const bool c_pager_stop = cs_subset_bool(NeoMutt->sub, "pager_stop");
419 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
420 {
421 priv->top_line = up_n_lines(priv->pview->win_pager->state.rows / 2,
422 priv->lines, priv->cur_line, priv->hide_quoted);
424 }
425 else if (c_pager_stop)
426 {
427 /* emulate "less -q" and don't go on to the next message. */
428 mutt_message(_("Bottom of message is shown"));
429 }
430 else
431 {
432 /* end of the current message, so display the next message. */
434 }
435 return FR_SUCCESS;
436}
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:390
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:53
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:356
#define NT_PAGER_VIEW
Pager View has changed.
Definition lib.h:185
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
Definition display.h:51
struct WindowState state
Current state of the Window.
Container for Accounts, Notifications.
Definition neomutt.h:43
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
PagerFlags hide_quoted
Set to MUTT_HIDE when quoted email is hidden <toggle-quoted>
int cur_line
Current line (last line visible on screen)
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:176
struct MuttWindow * win_pager
Pager Window.
Definition lib.h:178
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:62
+ Here is the call graph for this function:

◆ op_pager_half_up()

static int op_pager_half_up ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Scroll up 1/2 page - Implements pager_function_t -.

Definition at line 441 of file functions.c.

443{
444 if (priv->top_line)
445 {
446 priv->top_line = up_n_lines(priv->pview->win_pager->state.rows / 2 +
447 (priv->pview->win_pager->state.rows % 2),
448 priv->lines, priv->top_line, priv->hide_quoted);
450 }
451 else
452 {
453 mutt_message(_("Top of message is shown"));
454 }
455 return FR_SUCCESS;
456}
+ Here is the call graph for this function:

◆ op_pager_hide_quoted()

static int op_pager_hide_quoted ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Toggle display of quoted text - Implements pager_function_t -.

Definition at line 461 of file functions.c.

463{
464 if (!priv->has_types)
465 return FR_NO_ACTION;
466
467 priv->hide_quoted ^= MUTT_HIDE;
468 if (priv->hide_quoted && COLOR_QUOTED(priv->lines[priv->top_line].cid))
469 {
470 priv->top_line = up_n_lines(1, priv->lines, priv->top_line, priv->hide_quoted);
471 }
472 else
473 {
475 }
477 return FR_SUCCESS;
478}
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:37
void pager_queue_redraw(struct PagerPrivateData *priv, PagerRedrawFlags redraw)
Queue a request for a redraw.
Definition dlg_pager.c:128
#define MUTT_HIDE
Don't show quoted text.
Definition lib.h:63
#define PAGER_REDRAW_PAGER
Redraw the pager.
Definition lib.h:189
#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 IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Scroll down one line - Implements pager_function_t -.

Definition at line 483 of file functions.c.

485{
486 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
487 {
488 priv->top_line++;
489 if (priv->hide_quoted)
490 {
491 while ((priv->top_line < priv->lines_used) &&
492 COLOR_QUOTED(priv->lines[priv->top_line].cid))
493 {
494 priv->top_line++;
495 }
496 }
498 }
499 else
500 {
501 mutt_message(_("Bottom of message is shown"));
502 }
503 return FR_SUCCESS;
504}
int lines_used
Size of lines array (used entries)
+ Here is the call graph for this function:

◆ op_pager_next_page()

static int op_pager_next_page ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Move to the next page - Implements pager_function_t -.

Definition at line 509 of file functions.c.

511{
512 const bool c_pager_stop = cs_subset_bool(NeoMutt->sub, "pager_stop");
513 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
514 {
515 const short c_pager_context = cs_subset_number(NeoMutt->sub, "pager_context");
516 priv->top_line = up_n_lines(c_pager_context, priv->lines, priv->cur_line, priv->hide_quoted);
518 }
519 else if (c_pager_stop)
520 {
521 /* emulate "less -q" and don't go on to the next message. */
522 mutt_message(_("Bottom of message is shown"));
523 }
524 else
525 {
526 /* end of the current message, so display the next message. */
528 }
529 return FR_SUCCESS;
530}
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 IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Scroll up one line - Implements pager_function_t -.

Definition at line 535 of file functions.c.

537{
538 if (priv->top_line)
539 {
540 priv->top_line = up_n_lines(1, priv->lines, priv->top_line, priv->hide_quoted);
542 }
543 else
544 {
545 mutt_message(_("Top of message is shown"));
546 }
547 return FR_SUCCESS;
548}
+ Here is the call graph for this function:

◆ op_pager_prev_page()

static int op_pager_prev_page ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Move to the previous page - Implements pager_function_t -.

Definition at line 553 of file functions.c.

555{
556 if (priv->top_line == 0)
557 {
558 mutt_message(_("Top of message is shown"));
559 }
560 else
561 {
562 const short c_pager_context = cs_subset_number(NeoMutt->sub, "pager_context");
563 priv->top_line = up_n_lines(priv->pview->win_pager->state.rows - c_pager_context,
564 priv->lines, priv->top_line, priv->hide_quoted);
566 }
567 return FR_SUCCESS;
568}
+ Here is the call graph for this function:

◆ op_pager_search()

static int op_pager_search ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Search for a regular expression - Implements pager_function_t -.

This function handles:

  • OP_SEARCH
  • OP_SEARCH_REVERSE

Definition at line 577 of file functions.c.

579{
580 struct PagerView *pview = priv->pview;
581
582 int rc = FR_NO_ACTION;
583 struct Buffer *buf = buf_pool_get();
584
585 buf_strcpy(buf, priv->search_str);
586 if (mw_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? _("Search for: ") : _("Reverse search for: "),
588 {
589 goto done;
590 }
591
592 if (mutt_str_equal(buf_string(buf), priv->search_str))
593 {
594 if (priv->search_compiled)
595 {
596 /* do an implicit search-next */
597 if (op == OP_SEARCH)
598 op = OP_SEARCH_NEXT;
599 else
600 op = OP_SEARCH_OPPOSITE;
601
602 priv->wrapped = false;
603 op_pager_search_next(shared, priv, op);
604 }
605 }
606
607 if (buf_is_empty(buf))
608 goto done;
609
610 mutt_str_copy(priv->search_str, buf_string(buf), sizeof(priv->search_str));
611
612 /* leave search_back alone if op == OP_SEARCH_NEXT */
613 if (op == OP_SEARCH)
614 priv->search_back = false;
615 else if (op == OP_SEARCH_REVERSE)
616 priv->search_back = true;
617
618 if (priv->search_compiled)
619 {
620 regfree(&priv->search_re);
621 for (size_t i = 0; i < priv->lines_used; i++)
622 {
623 FREE(&(priv->lines[i].search));
624 priv->lines[i].search_arr_size = -1;
625 }
626 }
627
628 uint16_t rflags = mutt_mb_is_lower(priv->search_str) ? REG_ICASE : 0;
629 int err = REG_COMP(&priv->search_re, priv->search_str, REG_NEWLINE | rflags);
630 if (err != 0)
631 {
632 regerror(err, &priv->search_re, buf->data, buf->dsize);
633 mutt_error("%s", buf_string(buf));
634 for (size_t i = 0; i < priv->lines_max; i++)
635 {
636 /* cleanup */
637 FREE(&(priv->lines[i].search));
638 priv->lines[i].search_arr_size = -1;
639 }
640 priv->search_flag = 0;
641 priv->search_compiled = false;
642 }
643 else
644 {
645 priv->search_compiled = true;
646 /* update the search pointers */
647 int line_num = 0;
648 while (display_line(priv->fp, &priv->bytes_read, &priv->lines, line_num,
649 &priv->lines_used, &priv->lines_max,
650 MUTT_SEARCH | (pview->flags & MUTT_PAGER_NOWRAP) | priv->has_types,
651 &priv->quote_list, &priv->q_level, &priv->force_redraw,
652 &priv->search_re, priv->pview->win_pager, &priv->ansi_list) == 0)
653 {
654 line_num++;
655 }
656
657 if (priv->search_back)
658 {
659 /* searching backward */
660 int i;
661 for (i = priv->top_line; i >= 0; i--)
662 {
663 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
664 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
665 {
666 break;
667 }
668 }
669
670 if (i >= 0)
671 priv->top_line = i;
672 }
673 else
674 {
675 /* searching forward */
676 int i;
677 for (i = priv->top_line; i < priv->lines_used; i++)
678 {
679 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
680 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
681 {
682 break;
683 }
684 }
685
686 if (i < priv->lines_used)
687 priv->top_line = i;
688 }
689
690 if (priv->lines[priv->top_line].search_arr_size == 0)
691 {
692 priv->search_flag = 0;
693 mutt_error(_("Not found"));
694 }
695 else
696 {
697 const short c_search_context = cs_subset_number(NeoMutt->sub, "search_context");
698 priv->search_flag = MUTT_SEARCH;
699 /* give some context for search results */
700 if (c_search_context < priv->pview->win_pager->state.rows)
701 priv->searchctx = c_search_context;
702 else
703 priv->searchctx = 0;
704 if (priv->top_line - priv->searchctx > 0)
705 priv->top_line -= priv->searchctx;
706 }
707 }
710 rc = FR_SUCCESS;
711
712done:
713 buf_pool_release(&buf);
714 return rc;
715}
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:1051
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:272
#define mutt_error(...)
Definition logging2.h:93
static int op_pager_search_next(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Search for next match - Implements pager_function_t -.
Definition functions.c:724
@ HC_PATTERN
Patterns.
Definition lib.h:58
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
Definition mbyte.c:354
#define FREE(x)
Definition memory.h:62
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:660
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:581
#define MUTT_COMP_CLEAR
Clear input if printable character is pressed.
Definition mutt.h:57
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition lib.h:71
#define MUTT_SEARCH
Resolve search patterns.
Definition lib.h:64
const struct CompleteOps CompletePatternOps
Auto-Completion of Patterns.
Definition complete.c:82
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:96
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition regex3.h:50
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
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:170
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:173
+ 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 IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Search for next match - Implements pager_function_t -.

This function handles:

  • OP_SEARCH_NEXT
  • OP_SEARCH_OPPOSITE

Definition at line 724 of file functions.c.

726{
727 if (priv->search_compiled)
728 {
729 const short c_search_context = cs_subset_number(NeoMutt->sub, "search_context");
730 priv->wrapped = false;
731
732 if (c_search_context < priv->pview->win_pager->state.rows)
733 priv->searchctx = c_search_context;
734 else
735 priv->searchctx = 0;
736
737 search_next:
738 if ((!priv->search_back && (op == OP_SEARCH_NEXT)) ||
739 (priv->search_back && (op == OP_SEARCH_OPPOSITE)))
740 {
741 /* searching forward */
742 int i;
743 for (i = priv->wrapped ? 0 : priv->top_line + priv->searchctx + 1;
744 i < priv->lines_used; i++)
745 {
746 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
747 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
748 {
749 break;
750 }
751 }
752
753 const bool c_wrap_search = cs_subset_bool(NeoMutt->sub, "wrap_search");
754 if (i < priv->lines_used)
755 {
756 priv->top_line = i;
757 }
758 else if (priv->wrapped || !c_wrap_search)
759 {
760 mutt_error(_("Not found"));
761 }
762 else
763 {
764 mutt_message(_("Search wrapped to top"));
765 priv->wrapped = true;
766 goto search_next;
767 }
768 }
769 else
770 {
771 /* searching backward */
772 int i;
773 for (i = priv->wrapped ? priv->lines_used : priv->top_line + priv->searchctx - 1;
774 i >= 0; i--)
775 {
776 if ((!priv->hide_quoted ||
777 (priv->has_types && !COLOR_QUOTED(priv->lines[i].cid))) &&
778 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
779 {
780 break;
781 }
782 }
783
784 const bool c_wrap_search = cs_subset_bool(NeoMutt->sub, "wrap_search");
785 if (i >= 0)
786 {
787 priv->top_line = i;
788 }
789 else if (priv->wrapped || !c_wrap_search)
790 {
791 mutt_error(_("Not found"));
792 }
793 else
794 {
795 mutt_message(_("Search wrapped to bottom"));
796 priv->wrapped = true;
797 goto search_next;
798 }
799 }
800
801 if (priv->lines[priv->top_line].search_arr_size > 0)
802 {
803 priv->search_flag = MUTT_SEARCH;
804 /* give some context for search results */
805 if (priv->top_line - priv->searchctx > 0)
806 priv->top_line -= priv->searchctx;
807 }
808
810 return FR_SUCCESS;
811 }
812
813 /* no previous search pattern */
814 return op_pager_search(shared, priv, op);
815}
static int op_pager_search(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Search for a regular expression - Implements pager_function_t -.
Definition functions.c:577
+ 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 IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Jump to first line after headers - Implements pager_function_t -.

Definition at line 820 of file functions.c.

822{
823 struct PagerView *pview = priv->pview;
824
825 if (!priv->has_types)
826 return FR_NO_ACTION;
827
828 int rc = 0;
829 int new_topline = 0;
830
831 while (((new_topline < priv->lines_used) ||
832 (0 == (rc = display_line(priv->fp, &priv->bytes_read, &priv->lines,
833 new_topline, &priv->lines_used, &priv->lines_max,
834 MUTT_TYPES | (pview->flags & MUTT_PAGER_NOWRAP), &priv->quote_list,
835 &priv->q_level, &priv->force_redraw, &priv->search_re,
836 priv->pview->win_pager, &priv->ansi_list)))) &&
837 color_is_header(priv->lines[new_topline].cid))
838 {
839 new_topline++;
840 }
841
842 if (rc < 0)
843 {
844 /* L10N: Displayed if <skip-headers> is invoked in the pager, but
845 there is no text past the headers.
846 (I don't think this is actually possible in Mutt's code, but
847 display some kind of message in case it somehow occurs.) */
848 mutt_warning(_("No text past headers"));
849 return FR_NO_ACTION;
850 }
851 priv->top_line = new_topline;
853 return FR_SUCCESS;
854}
bool color_is_header(enum ColorId cid)
Colour is for an Email header.
Definition display.c:486
#define mutt_warning(...)
Definition logging2.h:91
#define MUTT_TYPES
Compute line's type.
Definition lib.h:65
+ Here is the call graph for this function:

◆ op_pager_skip_quoted()

static int op_pager_skip_quoted ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Skip beyond quoted text - Implements pager_function_t -.

Definition at line 859 of file functions.c.

861{
862 struct PagerView *pview = priv->pview;
863
864 if (!priv->has_types)
865 return FR_NO_ACTION;
866
867 const short c_pager_skip_quoted_context = cs_subset_number(NeoMutt->sub, "pager_skip_quoted_context");
868 int rc = 0;
869 int new_topline = priv->top_line;
870 int num_quoted = 0;
871
872 /* In a header? Skip all the email headers, and done */
873 if (color_is_header(priv->lines[new_topline].cid))
874 {
875 while (((new_topline < priv->lines_used) ||
876 (0 == (rc = display_line(priv->fp, &priv->bytes_read, &priv->lines,
877 new_topline, &priv->lines_used, &priv->lines_max,
878 MUTT_TYPES | (pview->flags & MUTT_PAGER_NOWRAP), &priv->quote_list,
879 &priv->q_level, &priv->force_redraw, &priv->search_re,
880 priv->pview->win_pager, &priv->ansi_list)))) &&
881 color_is_header(priv->lines[new_topline].cid))
882 {
883 new_topline++;
884 }
885 priv->top_line = new_topline;
887 return FR_SUCCESS;
888 }
889
890 /* Already in the body? Skip past previous "context" quoted lines */
891 if (c_pager_skip_quoted_context > 0)
892 {
893 while (((new_topline < priv->lines_used) ||
894 (0 == (rc = display_line(priv->fp, &priv->bytes_read, &priv->lines,
895 new_topline, &priv->lines_used, &priv->lines_max,
896 MUTT_TYPES | (pview->flags & MUTT_PAGER_NOWRAP), &priv->quote_list,
897 &priv->q_level, &priv->force_redraw, &priv->search_re,
898 priv->pview->win_pager, &priv->ansi_list)))) &&
899 COLOR_QUOTED(priv->lines[new_topline].cid))
900 {
901 new_topline++;
902 num_quoted++;
903 }
904
905 if (rc < 0)
906 {
907 mutt_error(_("No more unquoted text after quoted text"));
908 return FR_NO_ACTION;
909 }
910 }
911
912 if (num_quoted <= c_pager_skip_quoted_context)
913 {
914 num_quoted = 0;
915
916 while (((new_topline < priv->lines_used) ||
917 (0 == (rc = display_line(priv->fp, &priv->bytes_read, &priv->lines,
918 new_topline, &priv->lines_used, &priv->lines_max,
919 MUTT_TYPES | (pview->flags & MUTT_PAGER_NOWRAP), &priv->quote_list,
920 &priv->q_level, &priv->force_redraw, &priv->search_re,
921 priv->pview->win_pager, &priv->ansi_list)))) &&
922 !COLOR_QUOTED(priv->lines[new_topline].cid))
923 {
924 new_topline++;
925 }
926
927 if (rc < 0)
928 {
929 mutt_error(_("No more quoted text"));
930 return FR_NO_ACTION;
931 }
932
933 while (((new_topline < priv->lines_used) ||
934 (0 == (rc = display_line(priv->fp, &priv->bytes_read, &priv->lines,
935 new_topline, &priv->lines_used, &priv->lines_max,
936 MUTT_TYPES | (pview->flags & MUTT_PAGER_NOWRAP), &priv->quote_list,
937 &priv->q_level, &priv->force_redraw, &priv->search_re,
938 priv->pview->win_pager, &priv->ansi_list)))) &&
939 COLOR_QUOTED(priv->lines[new_topline].cid))
940 {
941 new_topline++;
942 num_quoted++;
943 }
944
945 if (rc < 0)
946 {
947 mutt_error(_("No more unquoted text after quoted text"));
948 return FR_NO_ACTION;
949 }
950 }
951 priv->top_line = new_topline - MIN(c_pager_skip_quoted_context, num_quoted);
953 return FR_SUCCESS;
954}
#define MIN(a, b)
Definition memory.h:37
+ Here is the call graph for this function:

◆ op_pager_top()

static int op_pager_top ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

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

Definition at line 959 of file functions.c.

960{
961 if (priv->top_line == 0)
962 {
963 mutt_message(_("Top of message is shown"));
964 }
965 else
966 {
967 priv->top_line = 0;
969 }
970
971 return FR_SUCCESS;
972}
+ Here is the call graph for this function:

◆ op_exit()

static int op_exit ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Exit this menu - Implements pager_function_t -.

Definition at line 979 of file functions.c.

980{
981 priv->rc = -1;
982 priv->loop = PAGER_LOOP_QUIT;
983 return FR_DONE;
984}
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:35
@ PAGER_LOOP_QUIT
Quit the Pager.
Definition lib.h:151
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 IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Help screen - Implements pager_function_t -.

Definition at line 989 of file functions.c.

990{
991 if (priv->pview->mode == PAGER_MODE_HELP)
992 {
993 /* don't let the user enter the help-menu from the help screen! */
994 mutt_error(_("Help is currently being shown"));
995 return FR_ERROR;
996 }
999 return FR_SUCCESS;
1000}
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:38
void mutt_help(enum MenuType menu)
Display the Help Page.
Definition help.c:148
@ PAGER_MODE_HELP
Pager is invoked via 3rd path to show help.
Definition lib.h:139
enum PagerMode mode
Pager mode.
Definition lib.h:172
@ MENU_PAGER
Pager pager (email viewer)
Definition type.h:47
+ Here is the call graph for this function:

◆ op_save()

static int op_save ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Save the Pager text - Implements pager_function_t -.

Definition at line 1005 of file functions.c.

1006{
1007 struct PagerView *pview = priv->pview;
1008 if (pview->mode != PAGER_MODE_OTHER)
1009 return FR_UNKNOWN;
1010
1011 if (!priv->fp)
1012 return FR_UNKNOWN;
1013
1014 int rc = FR_ERROR;
1015 FILE *fp_save = NULL;
1016 struct Buffer *buf = buf_pool_get();
1017
1018 // Save the current read position
1019 long pos = ftell(priv->fp);
1020 rewind(priv->fp);
1021
1022 struct FileCompletionData cdata = { false, NULL, NULL, NULL };
1023 if ((mw_get_field(_("Save to file: "), buf, MUTT_COMP_CLEAR, HC_FILE,
1024 &CompleteFileOps, &cdata) != 0) ||
1025 buf_is_empty(buf))
1026 {
1027 rc = FR_SUCCESS;
1028 goto done;
1029 }
1030
1031 buf_expand_path(buf);
1032 fp_save = mutt_file_fopen(buf_string(buf), "a+");
1033 if (!fp_save)
1034 {
1035 mutt_perror("%s", buf_string(buf));
1036 goto done;
1037 }
1038
1039 int bytes = mutt_file_copy_stream(priv->fp, fp_save);
1040 if (bytes == -1)
1041 {
1042 mutt_perror("%s", buf_string(buf));
1043 goto done;
1044 }
1045
1046 // Restore the read position
1047 if (pos >= 0)
1048 mutt_file_seek(priv->fp, pos, SEEK_CUR);
1049
1050 mutt_message(_("Saved to: %s"), buf_string(buf));
1051 rc = FR_SUCCESS;
1052
1053done:
1054 mutt_file_fclose(&fp_save);
1055 buf_pool_release(&buf);
1056
1057 return rc;
1058}
const struct CompleteOps CompleteFileOps
Auto-Completion of Files.
Definition complete.c:152
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:33
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition file.c:225
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
Definition file.c:655
#define mutt_file_fclose(FP)
Definition file.h:139
#define mutt_file_fopen(PATH, MODE)
Definition file.h:138
#define mutt_perror(...)
Definition logging2.h:94
@ HC_FILE
Files.
Definition lib.h:57
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Definition muttlib.c:314
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition lib.h:140
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 IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Toggle search pattern coloring - Implements pager_function_t -.

Definition at line 1063 of file functions.c.

1065{
1066 if (priv->search_compiled)
1067 {
1068 priv->search_flag ^= MUTT_SEARCH;
1070 }
1071 return FR_SUCCESS;
1072}
+ Here is the call graph for this function:

◆ op_view_attachments()

static int op_view_attachments ( struct IndexSharedData * shared,
struct PagerPrivateData * priv,
int op )
static

Show MIME attachments - Implements pager_function_t -.

Definition at line 1077 of file functions.c.

1079{
1080 struct PagerView *pview = priv->pview;
1081
1082 // This needs to be delegated
1083 if (pview->flags & MUTT_PAGER_ATTACHMENT)
1084 return FR_UNKNOWN;
1085
1086 if (!assert_pager_mode(pview->mode == PAGER_MODE_EMAIL))
1087 return FR_NOT_IMPL;
1088 dlg_attachment(NeoMutt->sub, shared->mailbox_view, shared->email,
1089 pview->pdata->fp, shared->attach_msg);
1090 if (shared->email->attach_del)
1091 shared->mailbox->changed = true;
1093 return FR_SUCCESS;
1094}
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition dispatcher.h:36
void dlg_attachment(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:338
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition lib.h:136
#define MUTT_PAGER_ATTACHMENT
Attachments may exist.
Definition lib.h:70
bool attach_del
Has an attachment marked for deletion.
Definition email.h:99
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:110
FILE * fp
Source stream.
Definition lib.h:161
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:171
+ Here is the call graph for this function: