Teaching an old dog new tricks
No Matches
do_pager.c File Reference

Simple Pager Dialog. More...

#include "config.h"
#include <stddef.h>
#include <assert.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "index/lib.h"
#include "protos.h"
+ Include dependency graph for do_pager.c:

Go to the source code of this file.


static int dopager_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
static int dopager_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
int mutt_do_pager (struct PagerView *pview, struct Email *e)
 Display some page-able text to the user (help or attachment)

Detailed Description

Simple Pager Dialog.

  • Michael R. Elkins
  • R Primus

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

Definition in file do_pager.c.

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)

pviewPagerView to construct Pager object
eEmail to use
Return values

Definition at line 123 of file do_pager.c.

125 assert(pview);
126 assert(pview->pdata);
127 assert(pview->pdata->fname);
128 assert((pview->mode == PAGER_MODE_ATTACH) ||
129 (pview->mode == PAGER_MODE_HELP) || (pview->mode == PAGER_MODE_OTHER));
135 struct IndexSharedData *shared = index_shared_data_new();
136 shared->email = e;
138 notify_set_parent(shared->notify, dlg->notify);
140 dlg->wdata = shared;
143 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
144 struct MuttWindow *panel_pager = ppanel_new(c_status_on_top, shared);
145 dlg->focus = panel_pager;
146 mutt_window_add_child(dlg, panel_pager);
150 dialog_push(dlg);
152 pview->win_index = NULL;
153 pview->win_pbar = window_find_child(panel_pager, WT_STATUS_BAR);
154 pview->win_pager = window_find_child(panel_pager, WT_CUSTOM);
156 int rc;
158 const char *const c_pager = pager_get_pager(NeoMutt->sub);
159 if (c_pager)
160 {
161 struct Buffer *cmd = buf_pool_get();
163 mutt_endwin();
164 buf_file_expand_fmt_quote(cmd, c_pager, pview->pdata->fname);
165 if (mutt_system(buf_string(cmd)) == -1)
166 {
167 mutt_error(_("Error running \"%s\""), buf_string(cmd));
168 rc = -1;
169 }
170 else
171 {
172 rc = 0;
173 }
175 buf_pool_release(&cmd);
176 }
177 else
178 {
179 rc = dlg_pager(pview);
180 }
182 dialog_pop();
183 mutt_window_free(&dlg);
184 return rc;
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
void mutt_endwin(void)
Shutdown curses.
Definition: curs_lib.c:154
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:1497
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:196
int dlg_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window -.
Definition: dlg_pager.c:220
#define mutt_error(...)
Definition: logging2.h:92
static int dopager_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: do_pager.c:75
static int dopager_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: do_pager.c:95
void index_shared_data_free(struct MuttWindow *win, void **ptr)
Free Shared Index Data - Implements MuttWindow::wdata_free() -.
Definition: shared_data.c:277
struct IndexSharedData * index_shared_data_new(void)
Create new Index Data.
Definition: shared_data.c:306
#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.
Definition: mutt_window.c:202
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:446
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
Definition: mutt_window.c:182
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:533
Window with a custom drawing function.
Definition: mutt_window.h:95
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
Pager Dialog, dlg_pager()
Definition: mutt_window.h:84
Window uses all available vertical space.
Definition: mutt_window.h:38
Use as much space as possible.
Definition: mutt_window.h:52
Window wants as much space as possible.
Definition: mutt_window.h:48
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
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:103
struct MuttWindow * ppanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Pager panel.
Definition: ppanel.c:122
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:141
Pager is invoked via 3rd path to show help.
Definition: lib.h:140
Pager is invoked via 2nd path. A user-selected attachment (mime part or a nested email) will be shown...
Definition: lib.h:138
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:52
String manipulation buffer.
Definition: buffer.h:34
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
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.
Definition: mutt_window.h:140
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:159
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
const char * fname
Name of the file to read.
Definition: lib.h:164
struct MuttWindow * win_index
Index Window.
Definition: lib.h:177
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:172
enum PagerMode mode
Pager mode.
Definition: lib.h:173
struct MuttWindow * win_pbar
Pager Bar Window.
Definition: lib.h:178
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:179
+ Here is the call graph for this function:
+ Here is the caller graph for this function: