NeoMutt  2021-10-29-220-g2b1eec
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 "menu/lib.h"
50 
51 struct Buffer;
52 struct Email;
53 struct IndexSharedData;
54 struct Mailbox;
55 struct MuttWindow;
56 struct PagerPrivateData;
57 
58 typedef uint16_t PagerFlags;
59 #define MUTT_PAGER_NO_FLAGS 0
60 #define MUTT_SHOWFLAT (1 << 0)
61 #define MUTT_SHOWCOLOR (1 << 1)
62 #define MUTT_HIDE (1 << 2)
63 #define MUTT_SEARCH (1 << 3)
64 #define MUTT_TYPES (1 << 4)
65 #define MUTT_SHOW (MUTT_SHOWCOLOR | MUTT_SHOWFLAT)
66 
67 /* exported flags for mutt_(do_)?pager */
68 #define MUTT_PAGER_NSKIP (1 << 5)
69 #define MUTT_PAGER_MARKER (1 << 6)
70 #define MUTT_PAGER_RETWINCH (1 << 7)
71 #define MUTT_PAGER_ATTACHMENT (1 << 8)
72 #define MUTT_PAGER_NOWRAP (1 << 9)
73 #define MUTT_PAGER_LOGS (1 << 10)
74 #define MUTT_PAGER_BOTTOM (1 << 11)
75 #define MUTT_PAGER_MESSAGE (MUTT_SHOWCOLOR | MUTT_PAGER_MARKER)
76 
77 #define MUTT_DISPLAYFLAGS (MUTT_SHOW | MUTT_PAGER_NSKIP | MUTT_PAGER_MARKER | MUTT_PAGER_LOGS)
78 
79 // Pager mode.
80 // There are 10 code paths that lead to mutt_pager() invocation:
81 //
82 // 1. mutt_index_menu -> mutt_display_message -> mutt_pager
83 //
84 // This path always results in mailbox and email set,
85 // the rest is unset - Body, fp.
86 // This invocation can be identified by IsEmail macro.
87 // The intent is to display an email message
88 //
89 // 2. mutt_view_attachment -> mutt_do_pager -> mutt_pager
90 //
91 // this path always results in email, body, ctx set
92 // this invocation can be identified by one of the two macros
93 // - IsAttach (viewing a regular attachment)
94 // - IsMsgAttach (viewing nested email)
95 //
96 // IsMsgAttach has extra->body->email set
97 // extra->email != extra->body->email
98 // the former is the message that contains the latter message as attachment
99 //
100 // NB. extra->email->body->email seems to be always NULL
101 //
102 // 3. The following 8 invocations are similar, because they all call
103 // mutt_do_page with info = NULL
104 //
105 // And so it results in mailbox, body, fp set to NULL.
106 // The intent is to show user some text that is not
107 // directly related to viewing emails,
108 // e.g. help, log messages,gpg key selection etc.
109 //
110 // No macro identifies these invocations
111 //
112 // mutt_index_menu -> mutt_do_pager -> mutt_pager
113 // mutt_help -> mutt_do_pager -> mutt_pager
114 // icmd_bind -> mutt_do_pager -> mutt_pager
115 // icmd_set -> mutt_do_pager -> mutt_pager
116 // icmd_version -> mutt_do_pager -> mutt_pager
117 // dlg_select_pgp_key -> mutt_do_pager -> mutt_pager
118 // verify_key -> mutt_do_pager -> mutt_pager
119 // mutt_invoke_sendmail -> mutt_do_pager -> mutt_pager
120 //
121 //
122 // - IsAttach(pager) (pager && (pager)->body)
123 // - IsMsgAttach(pager)
124 // (pager && (pager)->fp && (pager)->body && (pager)->body->email)
125 // - IsEmail(pager) (pager && (pager)->email && !(pager)->body)
126 // See nice infographic here:
127 // https://gist.github.com/flatcap/044ecbd2498c65ea9a85099ef317509a
128 
133 {
135 
141 
143 };
144 
148 struct PagerData
149 {
150  struct Body *body;
151  FILE *fp;
152  struct AttachCtx *actx;
153  const char *fname;
154 };
155 
159 struct PagerView
160 {
161  struct PagerData *pdata;
162  enum PagerMode mode;
164  const char *banner;
165 
169 };
170 
171 typedef uint8_t NotifyPager;
172 #define NT_PAGER_NO_FLAGS 0
173 #define NT_PAGER_DELETE (1 << 0)
174 #define NT_PAGER_VIEW (1 << 1)
175 
176 extern int braille_row;
177 extern int braille_col;
178 
179 int mutt_pager(struct PagerView *pview);
180 int mutt_do_pager(struct PagerView *pview, struct Email *e);
181 void mutt_buffer_strip_formatting(struct Buffer *dest, const char *src, bool strip_markers);
182 struct MuttWindow *ppanel_new(bool status_on_top, struct IndexSharedData *shared);
183 struct MuttWindow *pager_window_new(struct IndexSharedData *shared, struct PagerPrivateData *priv);
184 int mutt_display_message(struct MuttWindow *win_index, struct MuttWindow *win_pager, struct MuttWindow *win_pbar, struct Mailbox *m, struct Email *e);
185 int external_pager(struct Mailbox *m, struct Email *e, const char *command);
186 void pager_queue_redraw(struct PagerPrivateData *priv, MenuRedrawFlags redraw);
187 
188 void mutt_clear_pager_position(void);
189 
190 #endif /* MUTT_PAGER_LIB_H */
GUI present the user with a selectable list.
uint8_t MenuRedrawFlags
Flags, e.g. MENU_REDRAW_INDEX.
Definition: lib.h:48
void mutt_buffer_strip_formatting(struct Buffer *dest, const char *src, bool strip_markers)
Removes ANSI and backspace formatting.
Definition: display.c:740
struct MuttWindow * pager_window_new(struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create a new Pager Window (list of Emails)
Definition: pager.c:239
uint8_t NotifyPager
Flags, e.g. NT_PAGER_DELETE.
Definition: lib.h:171
uint16_t PagerFlags
Flags for mutt_pager(), e.g. MUTT_SHOWFLAT.
Definition: lib.h:56
void mutt_clear_pager_position(void)
Reset the pager's viewing position.
Definition: dlg_pager.c:143
int braille_col
Definition: dlg_pager.c:83
int external_pager(struct Mailbox *m, struct Email *e, const char *command)
Display a message in an external program.
Definition: message.c:317
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:133
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:140
@ PAGER_MODE_HELP
Pager is invoked via 3rd path to show help.
Definition: lib.h:139
@ 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:137
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:136
@ PAGER_MODE_ATTACH_E
A special case of PAGER_MODE_ATTACH - attachment is a full-blown email message.
Definition: lib.h:138
@ PAGER_MODE_UNKNOWN
A default and invalid mode, should never be used.
Definition: lib.h:134
@ PAGER_MODE_MAX
Another invalid mode, should never be used.
Definition: lib.h:142
int mutt_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window.
Definition: dlg_pager.c:466
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
int mutt_display_message(struct MuttWindow *win_index, struct MuttWindow *win_pager, struct MuttWindow *win_pbar, struct Mailbox *m, struct Email *e)
Display a message in the pager.
Definition: message.c:410
void pager_queue_redraw(struct PagerPrivateData *priv, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: dlg_pager.c:154
int braille_row
Definition: dlg_pager.c:82
A set of attachments.
Definition: attach.h:50
The body of an email.
Definition: body.h:35
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 mailbox.
Definition: mailbox.h:82
Data to be displayed by PagerView.
Definition: lib.h:149
const char * fname
Name of the file to read.
Definition: lib.h:153
FILE * fp
Source stream.
Definition: lib.h:151
struct Body * body
Current attachment.
Definition: lib.h:150
struct AttachCtx * actx
Attachment information.
Definition: lib.h:152
Private state data for the Pager.
Definition: private_data.h:41
Paged view into some data.
Definition: lib.h:160
struct MuttWindow * win_index
Index Window.
Definition: lib.h:166
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:161
enum PagerMode mode
Pager mode.
Definition: lib.h:162
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:163
const char * banner
Title to display in status bar.
Definition: lib.h:164
struct MuttWindow * win_pbar
Pager Bar Window.
Definition: lib.h:167
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:168