NeoMutt  2024-12-12-14-g7b49f7
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)
 This 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 404 of file functions.c.

406{
407 if (!jump_to_bottom(priv, priv->pview))
408 mutt_message(_("Bottom of message is shown"));
409
410 return FR_SUCCESS;
411}
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
#define mutt_message(...)
Definition: logging2.h:91
#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:376
struct PagerView * pview
Object to view in the pager.
Definition: private_data.h:42
+ 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 416 of file functions.c.

418{
419 const bool c_pager_stop = cs_subset_bool(NeoMutt->sub, "pager_stop");
420 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
421 {
422 priv->top_line = up_n_lines(priv->pview->win_pager->state.rows / 2,
423 priv->lines, priv->cur_line, priv->hide_quoted);
425 }
426 else if (c_pager_stop)
427 {
428 /* emulate "less -q" and don't go on to the next message. */
429 mutt_message(_("Bottom of message is shown"));
430 }
431 else
432 {
433 /* end of the current message, so display the next message. */
435 }
436 return FR_SUCCESS;
437}
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:357
#define NT_PAGER_VIEW
Pager View has changed.
Definition: lib.h:187
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
Definition: display.h:51
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
PagerFlags hide_quoted
Set to MUTT_HIDE when quoted email is hidden <toggle-quoted>
Definition: private_data.h:60
int cur_line
Current line (last line visible on screen)
Definition: private_data.h:51
struct Line * lines
Array of text lines in pager.
Definition: private_data.h:48
struct Notify * notify
Notifications: NotifyPager, PagerPrivateData.
Definition: private_data.h:71
int top_line
First visible line on screen.
Definition: private_data.h:55
struct stat st
Stats about Email file.
Definition: private_data.h:45
struct MuttWindow * win_index
Index Window.
Definition: lib.h:178
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:180
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 442 of file functions.c.

444{
445 if (priv->top_line)
446 {
447 priv->top_line = up_n_lines(priv->pview->win_pager->state.rows / 2 +
448 (priv->pview->win_pager->state.rows % 2),
449 priv->lines, priv->top_line, priv->hide_quoted);
451 }
452 else
453 {
454 mutt_message(_("Top of message is shown"));
455 }
456 return FR_SUCCESS;
457}
+ 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 462 of file functions.c.

464{
465 if (!priv->has_types)
466 return FR_NO_ACTION;
467
468 priv->hide_quoted ^= MUTT_HIDE;
469 if (priv->hide_quoted && COLOR_QUOTED(priv->lines[priv->top_line].cid))
470 {
471 priv->top_line = up_n_lines(1, priv->lines, priv->top_line, priv->hide_quoted);
472 }
473 else
474 {
476 }
478 return FR_SUCCESS;
479}
@ 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:127
#define MUTT_HIDE
Don't show quoted text.
Definition: lib.h:63
#define PAGER_REDRAW_PAGER
Redraw the pager.
Definition: lib.h:191
#define COLOR_QUOTED(cid)
Definition: quoted.h:39
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.
Definition: private_data.h:56
+ 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 484 of file functions.c.

486{
487 if (priv->lines[priv->cur_line].offset < (priv->st.st_size - 1))
488 {
489 priv->top_line++;
490 if (priv->hide_quoted)
491 {
492 while ((priv->top_line < priv->lines_used) &&
493 COLOR_QUOTED(priv->lines[priv->top_line].cid))
494 {
495 priv->top_line++;
496 }
497 }
499 }
500 else
501 {
502 mutt_message(_("Bottom of message is shown"));
503 }
504 return FR_SUCCESS;
505}
int lines_used
Size of lines array (used entries)
Definition: private_data.h:49
+ 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 510 of file functions.c.

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

538{
539 if (priv->top_line)
540 {
541 priv->top_line = up_n_lines(1, priv->lines, priv->top_line, priv->hide_quoted);
543 }
544 else
545 {
546 mutt_message(_("Top of message is shown"));
547 }
548 return FR_SUCCESS;
549}
+ 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 554 of file functions.c.

556{
557 if (priv->top_line == 0)
558 {
559 mutt_message(_("Top of message is shown"));
560 }
561 else
562 {
563 const short c_pager_context = cs_subset_number(NeoMutt->sub, "pager_context");
564 priv->top_line = up_n_lines(priv->pview->win_pager->state.rows - c_pager_context,
565 priv->lines, priv->top_line, priv->hide_quoted);
567 }
568 return FR_SUCCESS;
569}
+ 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 578 of file functions.c.

580{
581 struct PagerView *pview = priv->pview;
582
583 int rc = FR_NO_ACTION;
584 struct Buffer *buf = buf_pool_get();
585
586 buf_strcpy(buf, priv->search_str);
587 if (mw_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? _("Search for: ") : _("Reverse search for: "),
589 {
590 goto done;
591 }
592
593 if (mutt_str_equal(buf_string(buf), priv->search_str))
594 {
595 if (priv->search_compiled)
596 {
597 /* do an implicit search-next */
598 if (op == OP_SEARCH)
599 op = OP_SEARCH_NEXT;
600 else
601 op = OP_SEARCH_OPPOSITE;
602
603 priv->wrapped = false;
604 op_pager_search_next(shared, priv, op);
605 }
606 }
607
608 if (buf_is_empty(buf))
609 goto done;
610
611 mutt_str_copy(priv->search_str, buf_string(buf), sizeof(priv->search_str));
612
613 /* leave search_back alone if op == OP_SEARCH_NEXT */
614 if (op == OP_SEARCH)
615 priv->search_back = false;
616 else if (op == OP_SEARCH_REVERSE)
617 priv->search_back = true;
618
619 if (priv->search_compiled)
620 {
621 regfree(&priv->search_re);
622 for (size_t i = 0; i < priv->lines_used; i++)
623 {
624 FREE(&(priv->lines[i].search));
625 priv->lines[i].search_arr_size = -1;
626 }
627 }
628
629 uint16_t rflags = mutt_mb_is_lower(priv->search_str) ? REG_ICASE : 0;
630 int err = REG_COMP(&priv->search_re, priv->search_str, REG_NEWLINE | rflags);
631 if (err != 0)
632 {
633 regerror(err, &priv->search_re, buf->data, buf->dsize);
634 mutt_error("%s", buf_string(buf));
635 for (size_t i = 0; i < priv->lines_max; i++)
636 {
637 /* cleanup */
638 FREE(&(priv->lines[i].search));
639 priv->lines[i].search_arr_size = -1;
640 }
641 priv->search_flag = 0;
642 priv->search_compiled = false;
643 }
644 else
645 {
646 priv->search_compiled = true;
647 /* update the search pointers */
648 int line_num = 0;
649 while (display_line(priv->fp, &priv->bytes_read, &priv->lines, line_num,
650 &priv->lines_used, &priv->lines_max,
651 MUTT_SEARCH | (pview->flags & MUTT_PAGER_NSKIP) |
652 (pview->flags & MUTT_PAGER_NOWRAP) | priv->has_types,
653 &priv->quote_list, &priv->q_level, &priv->force_redraw,
654 &priv->search_re, priv->pview->win_pager, &priv->ansi_list) == 0)
655 {
656 line_num++;
657 }
658
659 if (priv->search_back)
660 {
661 /* searching backward */
662 int i;
663 for (i = priv->top_line; i >= 0; i--)
664 {
665 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
666 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
667 {
668 break;
669 }
670 }
671
672 if (i >= 0)
673 priv->top_line = i;
674 }
675 else
676 {
677 /* searching forward */
678 int i;
679 for (i = priv->top_line; i < priv->lines_used; i++)
680 {
681 if ((!priv->hide_quoted || !COLOR_QUOTED(priv->lines[i].cid)) &&
682 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
683 {
684 break;
685 }
686 }
687
688 if (i < priv->lines_used)
689 priv->top_line = i;
690 }
691
692 if (priv->lines[priv->top_line].search_arr_size == 0)
693 {
694 priv->search_flag = 0;
695 mutt_error(_("Not found"));
696 }
697 else
698 {
699 const short c_search_context = cs_subset_number(NeoMutt->sub, "search_context");
700 priv->search_flag = MUTT_SEARCH;
701 /* give some context for search results */
702 if (c_search_context < priv->pview->win_pager->state.rows)
703 priv->searchctx = c_search_context;
704 else
705 priv->searchctx = 0;
706 if (priv->top_line - priv->searchctx > 0)
707 priv->top_line -= priv->searchctx;
708 }
709 }
712 rc = FR_SUCCESS;
713
714done:
715 buf_pool_release(&buf);
716 return rc;
717}
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:1052
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:274
#define mutt_error(...)
Definition: logging2.h:92
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:726
@ HC_PATTERN
Patterns.
Definition: lib.h:57
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:55
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_NSKIP
Preserve whitespace with smartwrap.
Definition: lib.h:69
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition: lib.h:73
#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.
Definition: private_data.h:59
bool wrapped
Has the search/next wrapped around?
Definition: private_data.h:76
char search_str[256]
Current search string.
Definition: private_data.h:63
int lines_max
Capacity of lines array (total entries)
Definition: private_data.h:50
bool force_redraw
Repaint is needed.
Definition: private_data.h:68
LOFF_T bytes_read
Number of bytes read from file.
Definition: private_data.h:46
bool search_back
Search backwards.
Definition: private_data.h:66
struct QuoteStyle * quote_list
Tree of quoting levels.
Definition: private_data.h:58
struct AttrColorList ansi_list
List of ANSI colours used in the Pager.
Definition: private_data.h:70
int searchctx
Space to show around search matches.
Definition: private_data.h:74
regex_t search_re
Compiled search string.
Definition: private_data.h:65
FILE * fp
File containing decrypted/decoded/weeded Email.
Definition: private_data.h:44
PagerFlags search_flag
Set to MUTT_SEARCH when search results are visible <search-toggle>
Definition: private_data.h:62
bool search_compiled
Search regex is in use.
Definition: private_data.h:64
Paged view into some data.
Definition: lib.h:172
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:175
+ 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 726 of file functions.c.

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

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

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

962{
963 if (priv->top_line)
964 priv->top_line = 0;
965 else
966 mutt_message(_("Top of message is shown"));
967 return FR_SUCCESS;
968}

◆ 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 975 of file functions.c.

976{
977 priv->rc = -1;
978 priv->loop = PAGER_LOOP_QUIT;
979 return FR_DONE;
980}
@ FR_DONE
Exit the Dialog.
Definition: dispatcher.h:35
@ PAGER_LOOP_QUIT
Quit the Pager.
Definition: lib.h:153
int rc
Return code from functions.
Definition: private_data.h:73
enum PagerLoopMode loop
What the Event Loop should do next, e.g. PAGER_LOOP_CONTINUE.
Definition: private_data.h:79

◆ op_help()

static int op_help ( struct IndexSharedData shared,
struct PagerPrivateData priv,
int  op 
)
static

This screen - Implements pager_function_t -.

Definition at line 985 of file functions.c.

986{
987 if (priv->pview->mode == PAGER_MODE_HELP)
988 {
989 /* don't let the user enter the help-menu from the help screen! */
990 mutt_error(_("Help is currently being shown"));
991 return FR_ERROR;
992 }
995 return FR_SUCCESS;
996}
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
void mutt_help(enum MenuType menu)
Display the help menu.
Definition: help.c:467
@ PAGER_MODE_HELP
Pager is invoked via 3rd path to show help.
Definition: lib.h:141
enum PagerMode mode
Pager mode.
Definition: lib.h:174
@ MENU_PAGER
Pager pager (email viewer)
Definition: type.h:52
+ 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 1001 of file functions.c.

1002{
1003 struct PagerView *pview = priv->pview;
1004 if (pview->mode != PAGER_MODE_OTHER)
1005 return FR_UNKNOWN;
1006
1007 if (!priv->fp)
1008 return FR_UNKNOWN;
1009
1010 int rc = FR_ERROR;
1011 FILE *fp_save = NULL;
1012 struct Buffer *buf = buf_pool_get();
1013
1014 // Save the current read position
1015 long pos = ftell(priv->fp);
1016 rewind(priv->fp);
1017
1018 struct FileCompletionData cdata = { false, NULL, NULL, NULL };
1019 if ((mw_get_field(_("Save to file: "), buf, MUTT_COMP_CLEAR, HC_FILE,
1020 &CompleteFileOps, &cdata) != 0) ||
1021 buf_is_empty(buf))
1022 {
1023 rc = FR_SUCCESS;
1024 goto done;
1025 }
1026
1027 buf_expand_path(buf);
1028 fp_save = mutt_file_fopen(buf_string(buf), "a+");
1029 if (!fp_save)
1030 {
1031 mutt_perror("%s", buf_string(buf));
1032 goto done;
1033 }
1034
1035 int bytes = mutt_file_copy_stream(priv->fp, fp_save);
1036 if (bytes == -1)
1037 {
1038 mutt_perror("%s", buf_string(buf));
1039 goto done;
1040 }
1041
1042 // Restore the read position
1043 if (pos >= 0)
1044 mutt_file_seek(priv->fp, pos, SEEK_CUR);
1045
1046 mutt_message(_("Saved to: %s"), buf_string(buf));
1047 rc = FR_SUCCESS;
1048
1049done:
1050 mutt_file_fclose(&fp_save);
1051 buf_pool_release(&buf);
1052
1053 return rc;
1054}
const struct CompleteOps CompleteFileOps
Auto-Completion of Files.
Definition: complete.c:153
@ 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:287
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
Definition: file.c:778
#define mutt_file_fclose(FP)
Definition: file.h:138
#define mutt_file_fopen(PATH, MODE)
Definition: file.h:137
#define mutt_perror(...)
Definition: logging2.h:93
@ HC_FILE
Files.
Definition: lib.h:56
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:315
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:142
Input for the file completion function.
Definition: curs_lib.h:40
+ 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 1059 of file functions.c.

1061{
1062 if (priv->search_compiled)
1063 {
1064 priv->search_flag ^= MUTT_SEARCH;
1066 }
1067 return FR_SUCCESS;
1068}
+ 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 1073 of file functions.c.

1075{
1076 struct PagerView *pview = priv->pview;
1077
1078 // This needs to be delegated
1079 if (pview->flags & MUTT_PAGER_ATTACHMENT)
1080 return FR_UNKNOWN;
1081
1082 if (!assert_pager_mode(pview->mode == PAGER_MODE_EMAIL))
1083 return FR_NOT_IMPL;
1084 dlg_attachment(NeoMutt->sub, shared->mailbox_view, shared->email,
1085 pview->pdata->fp, shared->attach_msg);
1086 if (shared->email->attach_del)
1087 shared->mailbox->changed = true;
1089 return FR_SUCCESS;
1090}
@ 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:339
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:138
#define MUTT_PAGER_ATTACHMENT
Attachments may exist.
Definition: lib.h:72
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:163
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:173
+ Here is the call graph for this function: