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