NeoMutt  2024-04-25-89-g194907
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:394
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:52
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:61
+ 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 && (priv->lines[priv->top_line].cid == MT_COLOR_QUOTED))
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}
@ MT_COLOR_QUOTED
Pager: quoted text.
Definition: color.h:63
@ 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
short cid
Default line colour, e.g. MT_COLOR_QUOTED.
Definition: display.h:53
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 (priv->lines[priv->top_line].cid == MT_COLOR_QUOTED))
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 || (priv->lines[i].cid != MT_COLOR_QUOTED)) &&
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 || (priv->lines[i].cid != MT_COLOR_QUOTED)) &&
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:1042
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:55
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:45
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:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
#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
short search_arr_size
Number of items in search array.
Definition: display.h:60
struct TextSyntax * search
Array of search text in the line.
Definition: display.h:61
bool cont_line
Continuation of a previous line (wrapped by NeoMutt)
Definition: display.h:54
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 || (priv->lines[i].cid != MT_COLOR_QUOTED)) &&
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 || (priv->has_types && (priv->lines[i].cid != MT_COLOR_QUOTED))) &&
779 !priv->lines[i].cont_line && (priv->lines[i].search_arr_size > 0))
780 {
781 break;
782 }
783 }
784
785 const bool c_wrap_search = cs_subset_bool(NeoMutt->sub, "wrap_search");
786 if (i >= 0)
787 {
788 priv->top_line = i;
789 }
790 else if (priv->wrapped || !c_wrap_search)
791 {
792 mutt_error(_("Not found"));
793 }
794 else
795 {
796 mutt_message(_("Search wrapped to bottom"));
797 priv->wrapped = true;
798 goto search_next;
799 }
800 }
801
802 if (priv->lines[priv->top_line].search_arr_size > 0)
803 {
804 priv->search_flag = MUTT_SEARCH;
805 /* give some context for search results */
806 if (priv->top_line - priv->searchctx > 0)
807 priv->top_line -= priv->searchctx;
808 }
809
811 return FR_SUCCESS;
812 }
813
814 /* no previous search pattern */
815 return op_pager_search(shared, priv, op);
816}
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 821 of file functions.c.

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

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

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

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

975{
976 priv->rc = -1;
977 priv->loop = PAGER_LOOP_QUIT;
978 return FR_DONE;
979}
@ 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 984 of file functions.c.

985{
986 if (priv->pview->mode == PAGER_MODE_HELP)
987 {
988 /* don't let the user enter the help-menu from the help screen! */
989 mutt_error(_("Help is currently being shown"));
990 return FR_ERROR;
991 }
994 return FR_SUCCESS;
995}
@ 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:55
+ 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 1000 of file functions.c.

1001{
1002 struct PagerView *pview = priv->pview;
1003 if (pview->mode != PAGER_MODE_OTHER)
1004 return FR_UNKNOWN;
1005
1006 if (!priv->fp)
1007 return FR_UNKNOWN;
1008
1009 int rc = FR_ERROR;
1010 FILE *fp_save = NULL;
1011 struct Buffer *buf = buf_pool_get();
1012
1013 // Save the current read position
1014 long pos = ftell(priv->fp);
1015 rewind(priv->fp);
1016
1017 struct FileCompletionData cdata = { false, NULL, NULL, NULL };
1018 if ((mw_get_field(_("Save to file: "), buf, MUTT_COMP_CLEAR, HC_FILE,
1019 &CompleteFileOps, &cdata) != 0) ||
1020 buf_is_empty(buf))
1021 {
1022 rc = FR_SUCCESS;
1023 goto done;
1024 }
1025
1026 buf_expand_path(buf);
1027 fp_save = mutt_file_fopen(buf_string(buf), "a+");
1028 if (!fp_save)
1029 {
1030 mutt_perror("%s", buf_string(buf));
1031 goto done;
1032 }
1033
1034 int bytes = mutt_file_copy_stream(priv->fp, fp_save);
1035 if (bytes == -1)
1036 {
1037 mutt_perror("%s", buf_string(buf));
1038 goto done;
1039 }
1040
1041 // Restore the read position
1042 if (pos >= 0)
1043 mutt_file_seek(priv->fp, pos, SEEK_CUR);
1044
1045 mutt_message(_("Saved to: %s"), buf_string(buf));
1046 rc = FR_SUCCESS;
1047
1048done:
1049 mutt_file_fclose(&fp_save);
1050 buf_pool_release(&buf);
1051
1052 return rc;
1053}
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:149
#define mutt_file_fopen(PATH, MODE)
Definition: file.h:148
#define mutt_perror(...)
Definition: logging2.h:93
@ HC_FILE
Files.
Definition: lib.h:54
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 1058 of file functions.c.

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

1074{
1075 struct PagerView *pview = priv->pview;
1076
1077 // This needs to be delegated
1078 if (pview->flags & MUTT_PAGER_ATTACHMENT)
1079 return FR_UNKNOWN;
1080
1081 if (!assert_pager_mode(pview->mode == PAGER_MODE_EMAIL))
1082 return FR_NOT_IMPL;
1083 dlg_attachment(NeoMutt->sub, shared->mailbox_view, shared->email,
1084 pview->pdata->fp, shared->attach_msg);
1085 if (shared->email->attach_del)
1086 shared->mailbox->changed = true;
1088 return FR_SUCCESS;
1089}
@ 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:539
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:102
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: