NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
lib.h
Go to the documentation of this file.
1 
39 #ifndef MUTT_PAGER_LIB_H
40 #define MUTT_PAGER_LIB_H
41 
42 #include "config.h"
43 #include <stdbool.h>
44 #include <stdint.h>
45 #include <stdio.h>
46 
47 struct Buffer;
48 struct Email;
49 struct IndexSharedData;
50 struct MuttWindow;
52 
53 typedef uint16_t PagerFlags;
54 #define MUTT_PAGER_NO_FLAGS 0
55 #define MUTT_SHOWFLAT (1 << 0)
56 #define MUTT_SHOWCOLOR (1 << 1)
57 #define MUTT_HIDE (1 << 2)
58 #define MUTT_SEARCH (1 << 3)
59 #define MUTT_TYPES (1 << 4)
60 #define MUTT_SHOW (MUTT_SHOWCOLOR | MUTT_SHOWFLAT)
61 
62 /* exported flags for mutt_(do_)?pager */
63 #define MUTT_PAGER_NSKIP (1 << 5)
64 #define MUTT_PAGER_MARKER (1 << 6)
65 #define MUTT_PAGER_RETWINCH (1 << 7)
66 #define MUTT_PAGER_ATTACHMENT (1 << 8)
67 #define MUTT_PAGER_NOWRAP (1 << 9)
68 #define MUTT_PAGER_LOGS (1 << 10)
69 #define MUTT_PAGER_BOTTOM (1 << 11)
70 #define MUTT_PAGER_MESSAGE (MUTT_SHOWCOLOR | MUTT_PAGER_MARKER)
71 
72 #define MUTT_DISPLAYFLAGS (MUTT_SHOW | MUTT_PAGER_NSKIP | MUTT_PAGER_MARKER | MUTT_PAGER_LOGS)
73 
74 // Pager mode.
75 // There are 10 code paths that lead to mutt_pager() invocation:
76 //
77 // 1. mutt_index_menu -> mutt_display_message -> mutt_pager
78 //
79 // This path always results in mailbox and email set,
80 // the rest is unset - Body, fp.
81 // This invocation can be identified by IsEmail macro.
82 // The intent is to display an email message
83 //
84 // 2. mutt_view_attachment -> mutt_do_pager -> mutt_pager
85 //
86 // this path always results in email, body, ctx set
87 // this invocation can be identified by one of the two macros
88 // - IsAttach (viewing a regular attachment)
89 // - IsMsgAttach (viewing nested email)
90 //
91 // IsMsgAttach has extra->body->email set
92 // extra->email != extra->body->email
93 // the former is the message that contains the latter message as attachment
94 //
95 // NB. extra->email->body->email seems to be always NULL
96 //
97 // 3. The following 8 invocations are similar, because they all call
98 // mutt_do_page with info = NULL
99 //
100 // And so it results in mailbox, body, fp set to NULL.
101 // The intent is to show user some text that is not
102 // directly related to viewing emails,
103 // e.g. help, log messages,gpg key selection etc.
104 //
105 // No macro identifies these invocations
106 //
107 // mutt_index_menu -> mutt_do_pager -> mutt_pager
108 // mutt_help -> mutt_do_pager -> mutt_pager
109 // icmd_bind -> mutt_do_pager -> mutt_pager
110 // icmd_set -> mutt_do_pager -> mutt_pager
111 // icmd_version -> mutt_do_pager -> mutt_pager
112 // dlg_select_pgp_key -> mutt_do_pager -> mutt_pager
113 // verify_key -> mutt_do_pager -> mutt_pager
114 // mutt_invoke_sendmail -> mutt_do_pager -> mutt_pager
115 //
116 //
117 // - IsAttach(pager) (pager && (pager)->body)
118 // - IsMsgAttach(pager)
119 // (pager && (pager)->fp && (pager)->body && (pager)->body->email)
120 // - IsEmail(pager) (pager && (pager)->email && !(pager)->body)
121 // See nice infographic here:
122 // https://gist.github.com/flatcap/044ecbd2498c65ea9a85099ef317509a
123 
128 {
130 
136 
138 };
139 
143 struct PagerData
144 {
145  struct Body *body;
146  FILE *fp;
147  struct AttachCtx *actx;
148  const char *fname;
149 };
150 
154 struct PagerView
155 {
156  struct PagerData *pdata;
157  enum PagerMode mode;
159  const char *banner;
160 
165 };
166 
167 typedef uint8_t NotifyPager;
168 #define NT_PAGER_NO_FLAGS 0
169 #define NT_PAGER_CONFIG (1 << 0)
170 #define NT_PAGER_CONTEXT (1 << 1)
171 #define NT_PAGER_ACCOUNT (1 << 2)
172 #define NT_PAGER_MAILBOX (1 << 3)
173 #define NT_PAGER_EMAIL (1 << 4)
174 #define NT_PAGER_CLOSING (1 << 5)
175 #define NT_PAGER_SUBSET (1 << 6)
176 
177 int mutt_pager(struct PagerView *pview);
178 int mutt_do_pager(struct PagerView *pview, struct Email *e);
179 void mutt_buffer_strip_formatting(struct Buffer *dest, const char *src, bool strip_markers);
180 struct MuttWindow *ppanel_new(bool status_on_top, struct IndexSharedData *shared);
181 struct MuttWindow *pager_window_new(struct MuttWindow *parent, struct IndexSharedData *shared, struct PagerPrivateData *priv);
182 
183 void mutt_clear_pager_position(void);
184 
185 #endif /* MUTT_PAGER_LIB_H */
uint16_t PagerFlags
Flags for mutt_pager(), e.g. MUTT_SHOWFLAT.
Definition: lib.h:51
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:156
A default and invalid mode, should never be used.
Definition: lib.h:129
The envelope/body of an email.
Definition: email.h:37
struct MuttWindow * pager_window_new(struct MuttWindow *parent, struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create a new Pager Window (list of Emails)
Definition: pager.c:241
struct Body * body
Current attachment.
Definition: lib.h:145
String manipulation buffer.
Definition: buffer.h:33
Paged view into some data.
Definition: lib.h:154
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:36
A special case of PAGER_MODE_ATTACH - attachment is a full-blown email message.
Definition: lib.h:133
struct MuttWindow * win_index
Definition: lib.h:162
The body of an email.
Definition: body.h:34
uint8_t NotifyPager
Flags, e.g. NT_PAGER_ACCOUNT.
Definition: lib.h:167
struct MuttWindow * ppanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Pager panel.
Definition: ppanel.c:121
Private state data for the Pager.
Definition: private_data.h:39
Data to be displayed by PagerView.
Definition: lib.h:143
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
Pager is invoked via 3rd path to show help.
Definition: lib.h:134
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:131
void mutt_clear_pager_position(void)
Reset the pager&#39;s viewing position.
Definition: dlg_pager.c:1995
PagerFlags flags
Additional settings to tweak pager&#39;s function.
Definition: lib.h:158
struct AttachCtx * actx
Attachment information.
Definition: lib.h:147
FILE * fp
Source stream.
Definition: lib.h:146
void mutt_buffer_strip_formatting(struct Buffer *dest, const char *src, bool strip_markers)
Removes ANSI and backspace formatting.
Definition: dlg_pager.c:1395
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
Another invalid mode, should never be used.
Definition: lib.h:137
Pager is invoked via 2nd path. A user-selected attachment (mime part or a nested email) will be shown...
Definition: lib.h:132
struct MuttWindow * win_pager
Definition: lib.h:164
struct MuttWindow * win_pbar
Definition: lib.h:163
PagerMode
Determine the behaviour of the Pager.
Definition: lib.h:127
struct MuttWindow * win_ibar
Definition: lib.h:161
const char * fname
Name of the file to read.
Definition: lib.h:148
int mutt_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window.
Definition: dlg_pager.c:2360
const char * banner
Title to display in status bar.
Definition: lib.h:159
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:135
A set of attachments.
Definition: attach.h:49