NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h
Go to the documentation of this file.
1
43#ifndef MUTT_PAGER_LIB_H
44#define MUTT_PAGER_LIB_H
45
46#include "config.h"
47#include <stdbool.h>
48#include <stdint.h>
49#include <stdio.h>
50#include "mutt/lib.h"
51
52struct Email;
53struct IndexSharedData;
54struct ConfigSubset;
55struct MailboxView;
56struct MuttWindow;
57struct PagerPrivateData;
58
59typedef uint16_t PagerFlags;
60#define MUTT_PAGER_NO_FLAGS 0
61#define MUTT_SHOWFLAT (1 << 0)
62#define MUTT_SHOWCOLOR (1 << 1)
63#define MUTT_HIDE (1 << 2)
64#define MUTT_SEARCH (1 << 3)
65#define MUTT_TYPES (1 << 4)
66#define MUTT_SHOW (MUTT_SHOWCOLOR | MUTT_SHOWFLAT)
67
68/* exported flags for mutt_(do_)?pager */
69#define MUTT_PAGER_NSKIP (1 << 5)
70#define MUTT_PAGER_MARKER (1 << 6)
71#define MUTT_PAGER_RETWINCH (1 << 7)
72#define MUTT_PAGER_ATTACHMENT (1 << 8)
73#define MUTT_PAGER_NOWRAP (1 << 9)
74#define MUTT_PAGER_LOGS (1 << 10)
75#define MUTT_PAGER_BOTTOM (1 << 11)
76#define MUTT_PAGER_STRIPES (1 << 12)
77#define MUTT_PAGER_MESSAGE (MUTT_SHOWCOLOR | MUTT_PAGER_MARKER)
78
79#define MUTT_DISPLAYFLAGS (MUTT_SHOW | MUTT_PAGER_NSKIP | MUTT_PAGER_MARKER | MUTT_PAGER_LOGS)
80
81// Pager mode.
82// There are 10 code paths that lead to dlg_pager() invocation:
83//
84// 1. dlg_index -> mutt_display_message -> dlg_pager
85//
86// This path always results in mailbox and email set,
87// the rest is unset - Body, fp.
88// This invocation can be identified by IsEmail macro.
89// The intent is to display an email message
90//
91// 2. mutt_view_attachment -> mutt_do_pager -> dlg_pager
92//
93// this path always results in email, body, mailbox_view set
94// this invocation can be identified by one of the two macros
95// - IsAttach (viewing a regular attachment)
96// - IsMsgAttach (viewing nested email)
97//
98// IsMsgAttach has extra->body->email set
99// extra->email != extra->body->email
100// the former is the message that contains the latter message as attachment
101//
102// NB. extra->email->body->email seems to be always NULL
103//
104// 3. The following 8 invocations are similar, because they all call
105// mutt_do_page with info = NULL
106//
107// And so it results in mailbox, body, fp set to NULL.
108// The intent is to show user some text that is not
109// directly related to viewing emails,
110// e.g. help, log messages,gpg key selection etc.
111//
112// No macro identifies these invocations
113//
114// dlg_index -> mutt_do_pager -> dlg_pager
115// mutt_help -> mutt_do_pager -> dlg_pager
116// icmd_bind -> mutt_do_pager -> dlg_pager
117// icmd_set -> mutt_do_pager -> dlg_pager
118// icmd_version -> mutt_do_pager -> dlg_pager
119// dlg_pgp -> mutt_do_pager -> dlg_pager
120// verify_key -> mutt_do_pager -> dlg_pager
121// mutt_invoke_sendmail -> mutt_do_pager -> dlg_pager
122//
123//
124// - IsAttach(pager) (pager && (pager)->body)
125// - IsMsgAttach(pager)
126// (pager && (pager)->fp && (pager)->body && (pager)->body->email)
127// - IsEmail(pager) (pager && (pager)->email && !(pager)->body)
128// See nice infographic here:
129// https://gist.github.com/flatcap/044ecbd2498c65ea9a85099ef317509a
130
135{
137
143
145};
146
151{
155};
156
161{
162 struct Body *body;
163 FILE *fp;
164 struct AttachCtx *actx;
165 const char *fname;
166};
167
172{
173 struct PagerData *pdata;
176 const char *banner;
177
181};
182
183// Observers of #NT_PAGER will be passed a #PagerPrivateData.
184typedef uint8_t NotifyPager;
185#define NT_PAGER_NO_FLAGS 0
186#define NT_PAGER_DELETE (1 << 0)
187#define NT_PAGER_VIEW (1 << 1)
188
189typedef uint8_t PagerRedrawFlags;
190#define PAGER_REDRAW_NO_FLAGS 0
191#define PAGER_REDRAW_PAGER (1 << 1)
192#define PAGER_REDRAW_FLOW (1 << 2)
193
194extern int BrailleRow;
195extern int BrailleCol;
196
197int dlg_pager(struct PagerView *pview);
198int mutt_do_pager(struct PagerView *pview, struct Email *e);
199void buf_strip_formatting(struct Buffer *dest, const char *src, bool strip_markers);
200struct MuttWindow *ppanel_new(bool status_on_top, struct IndexSharedData *shared);
201struct MuttWindow *pager_window_new(struct IndexSharedData *shared, struct PagerPrivateData *priv);
202int mutt_display_message(struct MuttWindow *win_index, struct IndexSharedData *shared);
203int external_pager(struct MailboxView *mv, struct Email *e, const char *command);
204void pager_queue_redraw(struct PagerPrivateData *priv, PagerRedrawFlags redraw);
205bool mutt_is_quote_line(char *buf, regmatch_t *pmatch);
206const char *pager_get_pager(struct ConfigSubset *sub);
207
209
210struct TextSyntax;
211struct Line;
212void dump_text_syntax(struct TextSyntax *ts, int num);
213void dump_line(int i, struct Line *line);
214
215#ifdef USE_DEBUG_COLOR
216void dump_pager(struct PagerPrivateData *priv);
217#else
218static inline void dump_pager(struct PagerPrivateData *priv) {}
219#endif
220
221#endif /* MUTT_PAGER_LIB_H */
void dump_pager(struct PagerPrivateData *priv)
Definition: pager.c:101
int dlg_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window -.
Definition: dlg_pager.c:215
Convenience wrapper for the library headers.
PagerLoopMode
What the Pager Event Loop should do next.
Definition: lib.h:151
@ PAGER_LOOP_RELOAD
Reload the Pager from scratch.
Definition: lib.h:154
@ PAGER_LOOP_QUIT
Quit the Pager.
Definition: lib.h:153
@ PAGER_LOOP_CONTINUE
Stay in the Pager Event Loop.
Definition: lib.h:152
void dump_text_syntax(struct TextSyntax *ts, int num)
Definition: pager.c:37
int BrailleRow
Braille display: row to leave the cursor.
Definition: dlg_pager.c:67
const char * pager_get_pager(struct ConfigSubset *sub)
Get the value of $pager.
Definition: config.c:111
uint8_t NotifyPager
Flags, e.g. NT_PAGER_DELETE.
Definition: lib.h:184
uint16_t PagerFlags
Flags for dlg_pager(), e.g. MUTT_SHOWFLAT.
Definition: lib.h:59
bool mutt_is_quote_line(char *buf, regmatch_t *pmatch)
Is a line of message text a quote?
Definition: display.c:323
void mutt_clear_pager_position(void)
int BrailleCol
Braille display: column to leave the cursor.
Definition: dlg_pager.c:69
struct MuttWindow * ppanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Pager panel.
Definition: ppanel.c:133
void buf_strip_formatting(struct Buffer *dest, const char *src, bool strip_markers)
Removes ANSI and backspace formatting.
Definition: display.c:731
int mutt_display_message(struct MuttWindow *win_index, struct IndexSharedData *shared)
Display a message in the pager.
Definition: message.c:447
PagerMode
Determine the behaviour of the Pager.
Definition: lib.h:135
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:142
@ PAGER_MODE_HELP
Pager is invoked via 3rd path to show help.
Definition: lib.h:141
@ PAGER_MODE_ATTACH
Pager is invoked via 2nd path. A user-selected attachment (mime part or a nested email) will be shown...
Definition: lib.h:139
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:138
@ PAGER_MODE_ATTACH_E
A special case of PAGER_MODE_ATTACH - attachment is a full-blown email message.
Definition: lib.h:140
@ PAGER_MODE_UNKNOWN
A default and invalid mode, should never be used.
Definition: lib.h:136
@ PAGER_MODE_MAX
Another invalid mode, should never be used.
Definition: lib.h:144
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition: do_pager.c:122
void pager_queue_redraw(struct PagerPrivateData *priv, PagerRedrawFlags redraw)
Queue a request for a redraw.
Definition: dlg_pager.c:127
struct MuttWindow * pager_window_new(struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create a new Pager Window (list of Emails)
Definition: pager.c:418
uint8_t PagerRedrawFlags
Flags, e.g. PAGER_REDRAW_PAGER.
Definition: lib.h:189
int external_pager(struct MailboxView *mv, struct Email *e, const char *command)
Display a message in an external program.
Definition: message.c:300
void dump_line(int i, struct Line *line)
Definition: pager.c:58
A set of attachments.
Definition: attach.h:63
The body of an email.
Definition: body.h:36
String manipulation buffer.
Definition: buffer.h:36
A set of inherited config items.
Definition: subset.h:47
The envelope/body of an email.
Definition: email.h:39
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:37
A line of text in the pager.
Definition: display.h:50
View of a Mailbox.
Definition: mview.h:40
Data to be displayed by PagerView.
Definition: lib.h:161
const char * fname
Name of the file to read.
Definition: lib.h:165
FILE * fp
Source stream.
Definition: lib.h:163
struct Body * body
Current attachment.
Definition: lib.h:162
struct AttachCtx * actx
Attachment information.
Definition: lib.h:164
Private state data for the Pager.
Definition: private_data.h:41
Paged view into some data.
Definition: lib.h:172
struct MuttWindow * win_index
Index Window.
Definition: lib.h:178
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:173
enum PagerMode mode
Pager mode.
Definition: lib.h:174
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:175
const char * banner
Title to display in status bar.
Definition: lib.h:176
struct MuttWindow * win_pbar
Pager Bar Window.
Definition: lib.h:179
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:180
Highlighting for a piece of text.
Definition: display.h:39