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