NeoMutt  2025-09-05-43-g177ed6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h File Reference

GUI display a file/email/help in a viewport with paging. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/lib.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PagerData
 Data to be displayed by PagerView. More...
 
struct  PagerView
 Paged view into some data. More...
 

Macros

#define MUTT_PAGER_NO_FLAGS   0
 No flags are set.
 
#define MUTT_SHOWFLAT   (1 << 0)
 Show characters (used for displaying help)
 
#define MUTT_SHOWCOLOR   (1 << 1)
 Show characters in color otherwise don't show characters.
 
#define MUTT_HIDE   (1 << 2)
 Don't show quoted text.
 
#define MUTT_SEARCH   (1 << 3)
 Resolve search patterns.
 
#define MUTT_TYPES   (1 << 4)
 Compute line's type.
 
#define MUTT_SHOW   (MUTT_SHOWCOLOR | MUTT_SHOWFLAT)
 
#define MUTT_PAGER_MARKER   (1 << 5)
 Use markers if option is set.
 
#define MUTT_PAGER_ATTACHMENT   (1 << 6)
 Attachments may exist.
 
#define MUTT_PAGER_NOWRAP   (1 << 7)
 Format for term width, ignore $wrap.
 
#define MUTT_PAGER_LOGS   (1 << 8)
 Logview mode.
 
#define MUTT_PAGER_BOTTOM   (1 << 9)
 Start at the bottom.
 
#define MUTT_PAGER_STRIPES   (1 << 10)
 Striped highlighting.
 
#define MUTT_PAGER_MESSAGE   (MUTT_SHOWCOLOR | MUTT_PAGER_MARKER)
 
#define MUTT_DISPLAYFLAGS   (MUTT_SHOW | MUTT_PAGER_MARKER | MUTT_PAGER_LOGS)
 
#define NT_PAGER_NO_FLAGS   0
 No flags are set.
 
#define NT_PAGER_DELETE   (1 << 0)
 Pager Private Data is about to be freed.
 
#define NT_PAGER_VIEW   (1 << 1)
 Pager View has changed.
 
#define PAGER_REDRAW_NO_FLAGS   0
 No flags are set.
 
#define PAGER_REDRAW_PAGER   (1 << 1)
 Redraw the pager.
 
#define PAGER_REDRAW_FLOW   (1 << 2)
 Reflow the pager.
 

Typedefs

typedef uint16_t PagerFlags
 Flags for dlg_pager(), e.g. MUTT_SHOWFLAT.
 
typedef uint8_t NotifyPager
 Flags, e.g. NT_PAGER_DELETE.
 
typedef uint8_t PagerRedrawFlags
 Flags, e.g. PAGER_REDRAW_PAGER.
 

Enumerations

enum  PagerMode {
  PAGER_MODE_UNKNOWN = 0 , PAGER_MODE_EMAIL , PAGER_MODE_ATTACH , PAGER_MODE_ATTACH_E ,
  PAGER_MODE_HELP , PAGER_MODE_OTHER , PAGER_MODE_MAX
}
 Determine the behaviour of the Pager. More...
 
enum  PagerLoopMode { PAGER_LOOP_CONTINUE = -7 , PAGER_LOOP_QUIT = -6 , PAGER_LOOP_RELOAD = -5 }
 What the Pager Event Loop should do next. More...
 

Functions

int dlg_pager (struct PagerView *pview)
 Display an email, attachment, or help, in a window -.
 
int mutt_do_pager (struct PagerView *pview, struct Email *e)
 Display some page-able text to the user (help or attachment)
 
void buf_strip_formatting (struct Buffer *dest, const char *src, bool strip_markers)
 Removes ANSI and backspace formatting.
 
struct MuttWindowppanel_new (bool status_on_top, struct IndexSharedData *shared)
 Create the Windows for the Pager panel.
 
struct MuttWindowpager_window_new (struct IndexSharedData *shared, struct PagerPrivateData *priv)
 Create a new Pager Window (list of Emails)
 
int mutt_display_message (struct MuttWindow *win_index, struct IndexSharedData *shared)
 Display a message in the pager.
 
int external_pager (struct MailboxView *mv, struct Email *e, const char *command)
 Display a message in an external program.
 
void pager_queue_redraw (struct PagerPrivateData *priv, PagerRedrawFlags redraw)
 Queue a request for a redraw.
 
bool mutt_is_quote_line (char *buf, regmatch_t *pmatch)
 Is a line of message text a quote?
 
const char * pager_get_pager (struct ConfigSubset *sub)
 Get the value of $pager.
 
void mutt_clear_pager_position (void)
 
void dump_text_syntax (struct TextSyntax *ts, int num)
 
void dump_line (int i, struct Line *line)
 

Variables

int BrailleRow
 Braille display: row to leave the cursor.
 
int BrailleCol
 Braille display: column to leave the cursor.
 

Detailed Description

GUI display a file/email/help in a viewport with paging.

Authors
  • Richard Russon
  • Ihor Antonov

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file lib.h.

Macro Definition Documentation

◆ MUTT_PAGER_NO_FLAGS

#define MUTT_PAGER_NO_FLAGS   0

No flags are set.

Definition at line 60 of file lib.h.

◆ MUTT_SHOWFLAT

#define MUTT_SHOWFLAT   (1 << 0)

Show characters (used for displaying help)

Definition at line 61 of file lib.h.

◆ MUTT_SHOWCOLOR

#define MUTT_SHOWCOLOR   (1 << 1)

Show characters in color otherwise don't show characters.

Definition at line 62 of file lib.h.

◆ MUTT_HIDE

#define MUTT_HIDE   (1 << 2)

Don't show quoted text.

Definition at line 63 of file lib.h.

◆ MUTT_SEARCH

#define MUTT_SEARCH   (1 << 3)

Resolve search patterns.

Definition at line 64 of file lib.h.

◆ MUTT_TYPES

#define MUTT_TYPES   (1 << 4)

Compute line's type.

Definition at line 65 of file lib.h.

◆ MUTT_SHOW

#define MUTT_SHOW   (MUTT_SHOWCOLOR | MUTT_SHOWFLAT)

Definition at line 66 of file lib.h.

◆ MUTT_PAGER_MARKER

#define MUTT_PAGER_MARKER   (1 << 5)

Use markers if option is set.

Definition at line 69 of file lib.h.

◆ MUTT_PAGER_ATTACHMENT

#define MUTT_PAGER_ATTACHMENT   (1 << 6)

Attachments may exist.

Definition at line 70 of file lib.h.

◆ MUTT_PAGER_NOWRAP

#define MUTT_PAGER_NOWRAP   (1 << 7)

Format for term width, ignore $wrap.

Definition at line 71 of file lib.h.

◆ MUTT_PAGER_LOGS

#define MUTT_PAGER_LOGS   (1 << 8)

Logview mode.

Definition at line 72 of file lib.h.

◆ MUTT_PAGER_BOTTOM

#define MUTT_PAGER_BOTTOM   (1 << 9)

Start at the bottom.

Definition at line 73 of file lib.h.

◆ MUTT_PAGER_STRIPES

#define MUTT_PAGER_STRIPES   (1 << 10)

Striped highlighting.

Definition at line 74 of file lib.h.

◆ MUTT_PAGER_MESSAGE

#define MUTT_PAGER_MESSAGE   (MUTT_SHOWCOLOR | MUTT_PAGER_MARKER)

Definition at line 75 of file lib.h.

◆ MUTT_DISPLAYFLAGS

#define MUTT_DISPLAYFLAGS   (MUTT_SHOW | MUTT_PAGER_MARKER | MUTT_PAGER_LOGS)

Definition at line 77 of file lib.h.

◆ NT_PAGER_NO_FLAGS

#define NT_PAGER_NO_FLAGS   0

No flags are set.

Definition at line 183 of file lib.h.

◆ NT_PAGER_DELETE

#define NT_PAGER_DELETE   (1 << 0)

Pager Private Data is about to be freed.

Definition at line 184 of file lib.h.

◆ NT_PAGER_VIEW

#define NT_PAGER_VIEW   (1 << 1)

Pager View has changed.

Definition at line 185 of file lib.h.

◆ PAGER_REDRAW_NO_FLAGS

#define PAGER_REDRAW_NO_FLAGS   0

No flags are set.

Definition at line 188 of file lib.h.

◆ PAGER_REDRAW_PAGER

#define PAGER_REDRAW_PAGER   (1 << 1)

Redraw the pager.

Definition at line 189 of file lib.h.

◆ PAGER_REDRAW_FLOW

#define PAGER_REDRAW_FLOW   (1 << 2)

Reflow the pager.

Definition at line 190 of file lib.h.

Typedef Documentation

◆ PagerFlags

typedef uint16_t PagerFlags

Flags for dlg_pager(), e.g. MUTT_SHOWFLAT.

Definition at line 59 of file lib.h.

◆ NotifyPager

typedef uint8_t NotifyPager

Flags, e.g. NT_PAGER_DELETE.

Definition at line 182 of file lib.h.

◆ PagerRedrawFlags

typedef uint8_t PagerRedrawFlags

Flags, e.g. PAGER_REDRAW_PAGER.

Definition at line 187 of file lib.h.

Enumeration Type Documentation

◆ PagerMode

enum PagerMode

Determine the behaviour of the Pager.

Enumerator
PAGER_MODE_UNKNOWN 

A default and invalid mode, should never be used.

PAGER_MODE_EMAIL 

Pager is invoked via 1st path. The mime part is selected automatically.

PAGER_MODE_ATTACH 

Pager is invoked via 2nd path. A user-selected attachment (mime part or a nested email) will be shown.

PAGER_MODE_ATTACH_E 

A special case of PAGER_MODE_ATTACH - attachment is a full-blown email message.

PAGER_MODE_HELP 

Pager is invoked via 3rd path to show help.

PAGER_MODE_OTHER 

Pager is invoked via 3rd path. Non-email content is likely to be shown.

PAGER_MODE_MAX 

Another invalid mode, should never be used.

Definition at line 132 of file lib.h.

133{
135
141
143};
@ 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

◆ PagerLoopMode

What the Pager Event Loop should do next.

Enumerator
PAGER_LOOP_CONTINUE 

Stay in the Pager Event Loop.

PAGER_LOOP_QUIT 

Quit the Pager.

PAGER_LOOP_RELOAD 

Reload the Pager from scratch.

Definition at line 148 of file lib.h.

149{
151 PAGER_LOOP_QUIT = -6,
152 PAGER_LOOP_RELOAD = -5,
153};
@ PAGER_LOOP_RELOAD
Reload the Pager from scratch.
Definition lib.h:152
@ PAGER_LOOP_QUIT
Quit the Pager.
Definition lib.h:151
@ PAGER_LOOP_CONTINUE
Stay in the Pager Event Loop.
Definition lib.h:150

Function Documentation

◆ mutt_do_pager()

int mutt_do_pager ( struct PagerView * pview,
struct Email * e )

Display some page-able text to the user (help or attachment)

Parameters
pviewPagerView to construct Pager object
eEmail to use
Return values
0Success
-1Error

Definition at line 122 of file do_pager.c.

123{
124 ASSERT(pview);
125 ASSERT(pview->pdata);
126 ASSERT(pview->pdata->fname);
127 ASSERT((pview->mode == PAGER_MODE_ATTACH) ||
128 (pview->mode == PAGER_MODE_HELP) || (pview->mode == PAGER_MODE_OTHER));
129
133
134 struct IndexSharedData *shared = index_shared_data_new();
135 shared->email = e;
136
137 notify_set_parent(shared->notify, dlg->notify);
138
139 dlg->wdata = shared;
141
142 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
143 struct MuttWindow *panel_pager = ppanel_new(c_status_on_top, shared);
144 dlg->focus = panel_pager;
145 mutt_window_add_child(dlg, panel_pager);
146
149 dialog_push(dlg);
150
151 pview->win_index = NULL;
152 pview->win_pbar = window_find_child(panel_pager, WT_STATUS_BAR);
153 pview->win_pager = window_find_child(panel_pager, WT_CUSTOM);
154
155 int rc;
156
157 const char *const c_pager = pager_get_pager(NeoMutt->sub);
158 if (c_pager)
159 {
160 struct Buffer *cmd = buf_pool_get();
161
162 mutt_endwin();
163 buf_file_expand_fmt_quote(cmd, c_pager, pview->pdata->fname);
164 if (mutt_system(buf_string(cmd)) == -1)
165 {
166 mutt_error(_("Error running \"%s\""), buf_string(cmd));
167 rc = -1;
168 }
169 else
170 {
171 rc = 0;
172 }
174 buf_pool_release(&cmd);
175 }
176 else
177 {
178 rc = dlg_pager(pview);
179 }
180
181 dialog_pop();
182 mutt_window_free(&dlg);
183 return rc;
184}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
void mutt_endwin(void)
Shutdown curses.
Definition curs_lib.c:152
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition dialog.c:109
void dialog_pop(void)
Hide a Window from the user.
Definition dialog.c:142
void buf_file_expand_fmt_quote(struct Buffer *dest, const char *fmt, const char *src)
Replace s in a string with a filename.
Definition file.c:1349
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition file.c:159
int dlg_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window -.
Definition dlg_pager.c:218
#define mutt_error(...)
Definition logging2.h:93
static int dopager_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition do_pager.c:74
static int dopager_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition do_pager.c:94
void index_shared_data_free(struct MuttWindow *win, void **ptr)
Free Shared Index Data - Implements MuttWindow::wdata_free() -.
struct IndexSharedData * index_shared_data_new(void)
Create new Index Data.
#define _(a)
Definition message.h:28
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition notify.c:191
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
@ WT_CUSTOM
Window with a custom drawing function.
Definition mutt_window.h:95
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
@ WT_DLG_PAGER
Pager Dialog, dlg_pager()
Definition mutt_window.h:85
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:39
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition mutt_window.h:53
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:49
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
const char * pager_get_pager(struct ConfigSubset *sub)
Get the value of $pager.
Definition config.c:111
struct MuttWindow * ppanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Pager panel.
Definition ppanel.c:133
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:96
int mutt_system(const char *cmd)
Run an external command.
Definition system.c:52
#define ASSERT(COND)
Definition signal2.h:60
String manipulation buffer.
Definition buffer.h:36
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
struct Email * email
Currently selected Email.
Definition shared_data.h:42
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition shared_data.h:44
struct MuttWindow * focus
Focused Window.
void * wdata
Private data.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Container for Accounts, Notifications.
Definition neomutt.h:43
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
const char * fname
Name of the file to read.
Definition lib.h:163
struct MuttWindow * win_index
Index Window.
Definition lib.h:176
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:171
enum PagerMode mode
Pager mode.
Definition lib.h:172
struct MuttWindow * win_pbar
Pager Bar Window.
Definition lib.h:177
struct MuttWindow * win_pager
Pager Window.
Definition lib.h:178
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buf_strip_formatting()

void buf_strip_formatting ( struct Buffer * dest,
const char * src,
bool strip_markers )

Removes ANSI and backspace formatting.

Parameters
destBuffer for the result
srcString to strip
strip_markersRemove

Removes ANSI and backspace formatting, and optionally markers. This is separated out so that it can be used both by the pager and the autoview handler.

This logic is pulled from the pager fill_buffer() function, for use in stripping reply-quoted autoview output of ansi sequences.

Definition at line 730 of file display.c.

731{
732 const char *s = src;
733
734 buf_reset(dest);
735
736 if (!s)
737 return;
738
739 while (s[0] != '\0')
740 {
741 if ((s[0] == '\010') && (s > src))
742 {
743 if (s[1] == '_') /* underline */
744 {
745 s += 2;
746 }
747 else if (s[1] && buf_len(dest)) /* bold or overstrike */
748 {
749 dest->dptr--;
750 buf_addch(dest, s[1]);
751 s += 2;
752 }
753 else /* ^H */
754 {
755 buf_addch(dest, *s++);
756 }
757 continue;
758 }
759
760 int len = ansi_color_seq_length(s);
761 if (len > 0)
762 {
763 s += len;
764 }
765 else if (strip_markers && (s[0] == '\033') && (s[1] == ']') &&
767 {
768 mutt_debug(LL_DEBUG2, "Seen attachment marker\n");
769 while (*s++ != '\a')
770 ; /* skip pseudo-ANSI sequence */
771 }
772 else
773 {
774 buf_addch(dest, *s++);
775 }
776 }
777}
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition buffer.c:491
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition buffer.c:241
static int check_protected_header_marker(const char *p)
Check that the unique marker is present.
Definition display.c:308
static int check_attachment_marker(const char *p)
Check that the unique marker is present.
Definition display.c:298
#define mutt_debug(LEVEL,...)
Definition logging2.h:90
@ LL_DEBUG2
Log at debug level 2.
Definition logging2.h:45
int ansi_color_seq_length(const char *str)
Is this an ANSI escape sequence?
Definition parse_ansi.c:78
char * dptr
Current read/write position.
Definition buffer.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ppanel_new()

struct MuttWindow * ppanel_new ( bool status_on_top,
struct IndexSharedData * shared )

Create the Windows for the Pager panel.

Parameters
status_on_toptrue, if the Pager bar should be on top
sharedShared Index data
Return values
ptrNew Pager Panel

Definition at line 133 of file ppanel.c.

134{
138 panel_pager->state.visible = false; // The Pager and Pager Bar are initially hidden
139
141 panel_pager->wdata = priv;
142 panel_pager->wdata_free = pager_private_data_free;
143
144 struct MuttWindow *win_pager = pager_window_new(shared, priv);
145 panel_pager->focus = win_pager;
146
147 struct MuttWindow *win_pbar = pbar_new(shared, priv);
148 if (status_on_top)
149 {
150 mutt_window_add_child(panel_pager, win_pbar);
151 mutt_window_add_child(panel_pager, win_pager);
152 }
153 else
154 {
155 mutt_window_add_child(panel_pager, win_pager);
156 mutt_window_add_child(panel_pager, win_pbar);
157 }
158
160 notify_observer_add(panel_pager->notify, NT_WINDOW, ppanel_window_observer, panel_pager);
161
162 return panel_pager;
163}
static int ppanel_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition ppanel.c:72
static int ppanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition ppanel.c:94
@ WT_PAGER
A panel containing the Pager Window.
struct MuttWindow * pager_window_new(struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create a new Pager Window (list of Emails)
Definition pager.c:429
struct PagerPrivateData * pager_private_data_new(void)
Create new Pager Data.
void pager_private_data_free(struct MuttWindow *win, void **ptr)
Free Pager Data.
struct MuttWindow * pbar_new(struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create the Pager Bar.
Definition pbar.c:330
struct WindowState state
Current state of the Window.
Private state data for the Pager.
bool visible
Window is visible.
Definition mutt_window.h:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pager_window_new()

struct MuttWindow * pager_window_new ( struct IndexSharedData * shared,
struct PagerPrivateData * priv )

Create a new Pager Window (list of Emails)

Parameters
sharedShared Index Data
privPrivate Pager Data
Return values
ptrNew Window

Definition at line 429 of file pager.c.

431{
435 win->wdata = priv;
436 win->recalc = pager_recalc;
437 win->repaint = pager_repaint;
438
444
445 return win;
446}
void mutt_color_observer_add(observer_t callback, void *global_data)
Add an observer.
Definition notify.c:61
static int pager_pager_observer(struct NotifyCallback *nc)
Notification that the Pager has changed - Implements observer_t -.
Definition pager.c:367
static int pager_color_observer(struct NotifyCallback *nc)
Notification that a Color has changed - Implements observer_t -.
Definition pager.c:240
static int pager_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition pager.c:288
static int pager_index_observer(struct NotifyCallback *nc)
Notification that the Index has changed - Implements observer_t -.
Definition pager.c:324
static int pager_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition pager.c:388
static int pager_recalc(struct MuttWindow *win)
Recalculate the Pager display - Implements MuttWindow::recalc() -.
Definition pager.c:122
static int pager_repaint(struct MuttWindow *win)
Repaint the Pager display - Implements MuttWindow::repaint() -.
Definition pager.c:132
@ NT_PAGER
Pager data has changed, NotifyPager, PagerPrivateData.
Definition notify_type.h:53
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition notify_type.h:48
int(* repaint)(struct MuttWindow *win)
int(* recalc)(struct MuttWindow *win)
struct Notify * notify
Notifications: NotifyPager, PagerPrivateData.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_display_message()

int mutt_display_message ( struct MuttWindow * win_index,
struct IndexSharedData * shared )

Display a message in the pager.

Parameters
win_indexIndex Window
sharedShared Index data
Return values
0Success
-1Error

Definition at line 446 of file message.c.

447{
448 struct MuttWindow *dlg = dialog_find(win_index);
449 struct MuttWindow *win_pager = window_find_child(dlg, WT_CUSTOM);
450 struct MuttWindow *win_pbar = window_find_child(dlg, WT_STATUS_BAR);
451 struct Buffer *tempfile = buf_pool_get();
452 struct Message *msg = NULL;
453
454 squash_index_panel(shared->mailbox, win_index, win_pager);
455
456 int rc = PAGER_LOOP_QUIT;
457 do
458 {
459 msg = mx_msg_open(shared->mailbox, shared->email);
460 if (!msg)
461 break;
462
464
465 buf_reset(tempfile);
466 // win_pager might not be visible and have a size yet, so use win_index
467 rc = email_to_file(msg, tempfile, shared->mailbox, shared->email, NULL,
468 win_index->state.cols, &cmflags);
469 if (rc < 0)
470 break;
471
472 notify_crypto(shared->email, msg, cmflags);
473
474 /* Invoke the built-in pager */
475 struct PagerData pdata = { 0 };
476 struct PagerView pview = { &pdata };
477
478 pdata.fp = msg->fp;
479 pdata.fname = buf_string(tempfile);
480
481 pview.mode = PAGER_MODE_EMAIL;
482 pview.banner = NULL;
483 pview.flags = MUTT_PAGER_MESSAGE |
484 (shared->email->body->nowrap ? MUTT_PAGER_NOWRAP : 0);
485 pview.win_index = win_index;
486 pview.win_pbar = win_pbar;
487 pview.win_pager = win_pager;
488
489 rc = dlg_pager(&pview);
490 mx_msg_close(shared->mailbox, &msg);
491 } while (rc == PAGER_LOOP_RELOAD);
492
494
495 mx_msg_close(shared->mailbox, &msg);
496 buf_pool_release(&tempfile);
497 return rc;
498}
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition copy.h:40
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition copy.h:44
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition copy.h:36
#define MUTT_CM_DISPLAY
Output is displayed to the user.
Definition copy.h:41
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition dialog.c:89
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
Definition mx.c:1185
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
Definition mx.c:1139
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition lib.h:71
#define MUTT_PAGER_MESSAGE
Definition lib.h:75
static int email_to_file(struct Message *msg, struct Buffer *tempfile, struct Mailbox *m, struct Email *e, const char *header, int wrap_len, CopyMessageFlags *cmflags)
Decrypt, decode and weed an Email into a file.
Definition message.c:164
static void expand_index_panel(struct MuttWindow *win_index, struct MuttWindow *win_pager)
Restore the Index Panel.
Definition message.c:425
static void notify_crypto(struct Email *e, struct Message *msg, CopyMessageFlags cmflags)
Notify the user about the crypto status of the Email.
Definition message.c:360
static void squash_index_panel(struct Mailbox *m, struct MuttWindow *win_index, struct MuttWindow *win_pager)
Shrink or hide the Index Panel.
Definition message.c:398
bool nowrap
Do not wrap the output in the pager.
Definition body.h:89
struct Body * body
List of MIME parts.
Definition email.h:69
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:41
A local copy of an email.
Definition message.h:34
FILE * fp
pointer to the message data
Definition message.h:35
Data to be displayed by PagerView.
Definition lib.h:159
FILE * fp
Source stream.
Definition lib.h:161
Paged view into some data.
Definition lib.h:170
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:173
const char * banner
Title to display in status bar.
Definition lib.h:174
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ external_pager()

int external_pager ( struct MailboxView * mv,
struct Email * e,
const char * command )

Display a message in an external program.

Parameters
mvMailbox view
eEmail to display
commandExternal command to run
Return values
0Success
-1Error

Definition at line 299 of file message.c.

300{
301 if (!mv || !mv->mailbox)
302 return -1;
303
304 struct Mailbox *m = mv->mailbox;
305 struct Message *msg = mx_msg_open(m, e);
306 if (!msg)
307 return -1;
308
309 struct Buffer *buf = buf_pool_get();
310 const struct Expando *c_pager_format = cs_subset_expando(NeoMutt->sub, "pager_format");
311 const int screen_width = RootWindow->state.cols;
312 mutt_make_string(buf, screen_width, c_pager_format, m, -1, e,
314
315 struct Buffer *tempfile = buf_pool_get();
316
318 int rc = email_to_file(msg, tempfile, m, e, buf_string(buf), screen_width, &cmflags);
319 if (rc < 0)
320 goto cleanup;
321
322 mutt_endwin();
323
324 struct Buffer *cmd = buf_pool_get();
325 buf_printf(cmd, "%s %s", command, buf_string(tempfile));
326 int r = mutt_system(buf_string(cmd));
327 if (r == -1)
328 mutt_error(_("Error running \"%s\""), buf_string(cmd));
329 unlink(buf_string(tempfile));
330 buf_pool_release(&cmd);
331
332 if (OptGui)
333 keypad(stdscr, true);
334 if (r != -1)
335 mutt_set_flag(m, e, MUTT_READ, true, true);
336 const bool c_prompt_after = cs_subset_bool(NeoMutt->sub, "prompt_after");
337 if ((r != -1) && c_prompt_after)
338 {
341 }
342 else
343 {
344 rc = 0;
345 }
346
347cleanup:
348 buf_pool_release(&buf);
349 mx_msg_close(m, &msg);
350 buf_pool_release(&tempfile);
351 return rc;
352}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition curs_lib.c:174
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition get.c:115
int mutt_make_string(struct Buffer *buf, size_t max_cols, const struct Expando *exp, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
Definition dlg_index.c:803
void mutt_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
Set a flag on an email.
Definition flags.c:57
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition get.c:537
bool OptGui
(pseudo) when the gui (and curses) are started
Definition globals.c:59
#define GETCH_NO_FLAGS
No flags are set.
Definition lib.h:53
@ MUTT_READ
Messages that have been read.
Definition mutt.h:73
static const char * ExtPagerProgress
Status bar message when entire message is visible in the Pager.
Definition message.c:61
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition render.h:33
struct MuttWindow * RootWindow
Parent of all Windows.
Definition rootwin.c:106
Parsed Expando trees.
Definition expando.h:41
struct Mailbox * mailbox
Current Mailbox.
Definition mview.h:51
A mailbox.
Definition mailbox.h:79
@ MENU_PAGER
Pager pager (email viewer)
Definition type.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pager_queue_redraw()

void pager_queue_redraw ( struct PagerPrivateData * priv,
PagerRedrawFlags redraw )

Queue a request for a redraw.

Parameters
privPrivate Pager data
redrawItem to redraw, e.g. PAGER_REDRAW_PAGER

Definition at line 128 of file dlg_pager.c.

129{
130 priv->redraw |= redraw;
131
132 if (priv->pview && priv->pview->win_pager)
133 priv->pview->win_pager->actions |= WA_RECALC;
134}
#define WA_RECALC
Recalculate the contents of the Window.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
PagerRedrawFlags redraw
When to redraw the screen.
struct PagerView * pview
Object to view in the pager.
+ Here is the caller graph for this function:

◆ mutt_is_quote_line()

bool mutt_is_quote_line ( char * line,
regmatch_t * pmatch )

Is a line of message text a quote?

Parameters
[in]lineLine to test
[out]pmatchRegex sub-matches
Return values
trueLine is quoted

Checks if line matches the $quote_regex and doesn't match $smileys. This is used by the pager for calling qstyle_classify.

Definition at line 322 of file display.c.

323{
324 bool is_quote = false;
325 const struct Regex *c_smileys = cs_subset_regex(NeoMutt->sub, "smileys");
326 regmatch_t pmatch_internal[1] = { 0 };
327
328 if (!pmatch)
329 pmatch = pmatch_internal;
330
331 const struct Regex *c_quote_regex = cs_subset_regex(NeoMutt->sub, "quote_regex");
332 if (mutt_regex_capture(c_quote_regex, line, 1, pmatch))
333 {
334 regmatch_t smatch[1] = { 0 };
335 if (mutt_regex_capture(c_smileys, line, 1, smatch))
336 {
337 if (smatch[0].rm_so > 0)
338 {
339 char c = line[smatch[0].rm_so];
340 line[smatch[0].rm_so] = 0;
341
342 if (mutt_regex_capture(c_quote_regex, line, 1, pmatch))
343 is_quote = true;
344
345 line[smatch[0].rm_so] = c;
346 }
347 }
348 else
349 {
350 is_quote = true;
351 }
352 }
353
354 return is_quote;
355}
const struct Regex * cs_subset_regex(const struct ConfigSubset *sub, const char *name)
Get a regex config item by name.
Definition helpers.c:217
bool mutt_regex_capture(const struct Regex *regex, const char *str, size_t nmatch, regmatch_t matches[])
Match a regex against a string, with provided options.
Definition regex.c:597
Cached regular expression.
Definition regex3.h:86
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pager_get_pager()

const char * pager_get_pager ( struct ConfigSubset * sub)

Get the value of $pager.

Parameters
subConfig Subset
Return values
strExternal command to use
NULLThe internal pager will be used
Note
If $pager has the magic value of "builtin", NULL will be returned

Definition at line 111 of file config.c.

112{
113 const char *c_pager = cs_subset_string(sub, "pager");
114 if (!c_pager || mutt_str_equal(c_pager, "builtin"))
115 return NULL;
116
117 return c_pager;
118}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:660
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_clear_pager_position()

void mutt_clear_pager_position ( void )

◆ dump_text_syntax()

void dump_text_syntax ( struct TextSyntax * ts,
int num )

Definition at line 64 of file pager.c.

65{
66 if (!ts || (num == 0))
67 return;
68
69 for (int i = 0; i < num; i++)
70 {
71 int index = -1;
72 const char *swatch = "";
73 if (ts[i].attr_color)
74 {
75 struct CursesColor *cc = ts[i].attr_color->curses_color;
76 if (cc)
77 {
78 index = cc->index;
79 swatch = color_log_color(cc->fg, cc->bg);
80 }
81 }
82 mutt_debug(LL_DEBUG1, "\t\t(%d-%d) %d %s\n", ts[i].first, ts[i].last - 1, index, swatch);
83 }
84}
const char * color_log_color(color_t fg, color_t bg)
Get a colourful string to represent a colour in the log.
Definition debug.c:51
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:44
struct CursesColor * curses_color
Underlying Curses colour.
Definition attr.h:70
Colour in the ncurses palette.
Definition curses2.h:41
color_t fg
Foreground colour.
Definition curses2.h:42
color_t bg
Background colour.
Definition curses2.h:43
short index
Index number.
Definition curses2.h:44
const struct AttrColor * attr_color
Curses colour of text.
Definition display.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dump_line()

void dump_line ( int i,
struct Line * line )

Definition at line 86 of file pager.c.

87{
88 struct Buffer *buf = buf_pool_get();
89
90 buf_add_printf(buf, "%d [+%ld]", i, line->offset);
91
92 if ((line->cid > 0) && (line->cid != MT_COLOR_NORMAL))
93 {
94 const char *swatch = "";
95 struct AttrColor *ac = simple_color_get(line->cid);
96 if (ac && ac->curses_color)
97 {
98 struct CursesColor *cc = ac->curses_color;
99 swatch = color_log_color(cc->fg, cc->bg);
100 }
101
102 buf_add_printf(buf, " %s (%d) %s", name_color_id(line->cid), line->cid, swatch);
103 }
104 mutt_debug(LL_DEBUG1, "%s\n", buf_string(buf));
105
106 if (line->cont_line || line->cont_header)
107 {
108 mutt_debug(LL_DEBUG1, "\tcont: %s%s\n", line->cont_line ? "\033[1;32mL\033[0m" : "-",
109 line->cont_header ? "\033[1;32mH\033[0m" : "-");
110 }
111
112 if (line->syntax_arr_size > 0)
113 {
114 mutt_debug(LL_DEBUG1, "\tsyntax: %d %p\n", line->syntax_arr_size,
115 (void *) line->syntax);
117 }
118 if (line->search_arr_size > 0)
119 {
120 mutt_debug(LL_DEBUG1, "\t\033[1;36msearch\033[0m: %d %p\n",
121 line->search_arr_size, (void *) line->search);
123 }
124
125 buf_pool_release(&buf);
126}
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition buffer.c:204
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition simple.c:95
@ MT_COLOR_NORMAL
Plain text.
Definition color.h:54
const char * name_color_id(int cid)
Definition names.c:268
void dump_text_syntax(struct TextSyntax *ts, int num)
Definition pager.c:64
A curses colour and its attributes.
Definition attr.h:66
short search_arr_size
Number of items in search array.
Definition display.h:59
struct TextSyntax * search
Array of search text in the line.
Definition display.h:60
bool cont_line
Continuation of a previous line (wrapped by NeoMutt)
Definition display.h:53
short cid
Default line colour, e.g. MT_COLOR_SIGNATURE.
Definition display.h:52
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
Definition display.h:51
bool cont_header
Continuation of a header line (wrapped by MTA)
Definition display.h:54
short syntax_arr_size
Number of items in syntax array.
Definition display.h:56
struct TextSyntax * syntax
Array of coloured text in the line.
Definition display.h:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ BrailleRow

int BrailleRow
extern

Braille display: row to leave the cursor.

Definition at line 68 of file dlg_pager.c.

◆ BrailleCol

int BrailleCol
extern

Braille display: column to leave the cursor.

Definition at line 70 of file dlg_pager.c.