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