NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
Go to the documentation of this file.
60 #include "config.h"
61 #include <stddef.h>
62 #include <assert.h>
63 #include <stdbool.h>
64 #include "mutt/lib.h"
65 #include "config/lib.h"
66 #include "core/lib.h"
67 #include "gui/lib.h"
68 #include "lib.h"
69 #include "index/lib.h"
70 #include "protos.h"
76 {
77  if ((nc->event_type != NT_CONFIG) || !nc->global_data || !nc->event_data)
78  return -1;
80  struct EventConfig *ev_c = nc->event_data;
81  if (!mutt_str_equal(ev_c->name, "status_on_top"))
82  return 0;
84  struct MuttWindow *dlg = nc->global_data;
86  mutt_debug(LL_DEBUG5, "config done, request WA_REFLOW\n");
87  return 0;
88 }
94 {
95  if ((nc->event_type != NT_WINDOW) || !nc->global_data || !nc->event_data)
96  return -1;
99  return 0;
101  struct MuttWindow *dlg = nc->global_data;
102  struct EventWindow *ev_w = nc->event_data;
103  if (ev_w->win != dlg)
104  return 0;
108  mutt_debug(LL_DEBUG5, "window delete done\n");
110  return 0;
111 }
120 int mutt_do_pager(struct PagerView *pview, struct Email *e)
121 {
122  assert(pview);
123  assert(pview->pdata);
124  assert(pview->pdata->fname);
125  assert((pview->mode == PAGER_MODE_ATTACH) ||
126  (pview->mode == PAGER_MODE_HELP) || (pview->mode == PAGER_MODE_OTHER));
128  struct MuttWindow *dlg =
132  struct IndexSharedData *shared = index_shared_data_new();
133  shared->email = e;
135  notify_set_parent(shared->notify, dlg->notify);
137  dlg->wdata = shared;
140  const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
141  struct MuttWindow *panel_pager = ppanel_new(c_status_on_top, shared);
142  dlg->focus = panel_pager;
143  mutt_window_add_child(dlg, panel_pager);
147  dialog_push(dlg);
149  pview->win_ibar = NULL;
150  pview->win_index = NULL;
151  pview->win_pbar = window_find_child(panel_pager, WT_STATUS_BAR);
152  pview->win_pager = window_find_child(panel_pager, WT_CUSTOM);
154  int rc;
156  const char *const c_pager = cs_subset_string(NeoMutt->sub, "pager");
157  if (!c_pager || mutt_str_equal(c_pager, "builtin"))
158  {
159  rc = mutt_pager(pview);
160  }
161  else
162  {
163  struct Buffer *cmd = mutt_buffer_pool_get();
165  mutt_endwin();
166  mutt_buffer_file_expand_fmt_quote(cmd, c_pager, pview->pdata->fname);
167  if (mutt_system(mutt_buffer_string(cmd)) == -1)
168  {
169  mutt_error(_("Error running \"%s\""), mutt_buffer_string(cmd));
170  rc = -1;
171  }
172  else
173  rc = 0;
174  mutt_file_unlink(pview->pdata->fname);
176  }
178  dialog_pop();
179  mutt_window_free(&dlg);
180  return rc;
181 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
Convenience wrapper for the gui headers.
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:550
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:156
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
The envelope/body of an email.
Definition: email.h:37
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
Data passed to a notification function.
Definition: observer.h:39
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
An Event that happened to a Window.
Definition: mutt_window.h:215
#define mutt_error(...)
Definition: logging.h:88
static int dopager_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: do_pager.c:93
Window uses all available vertical space.
Definition: mutt_window.h:38
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:780
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:195
A config-change event.
Definition: subset.h:69
String manipulation buffer.
Definition: buffer.h:33
Paged view into some data.
Definition: lib.h:154
#define _(a)
Definition: message.h:28
Window is about to be deleted.
Definition: mutt_window.h:206
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:36
void index_shared_data_free(struct MuttWindow *win, void **ptr)
Free Index Data.
Definition: shared_data.c:273
struct MuttWindow * win_index
Definition: lib.h:162
Container for Accounts, Notifications.
Definition: neomutt.h:36
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition: shared_data.h:44
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
Convenience wrapper for the config headers.
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:200
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
struct MuttWindow * ppanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Pager panel.
Definition: ppanel.c:121
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:43
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
int mutt_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window.
Definition: dlg_pager.c:2360
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:140
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
static int dopager_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: do_pager.c:75
Convenience wrapper for the core headers.
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition: dialog.c:105
Window with a custom drawing function.
Definition: mutt_window.h:95
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:189
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
Pager is invoked via 3rd path to show help.
Definition: lib.h:134
enum PagerMode mode
Pager mode.
Definition: lib.h:157
Prototypes for many functions.
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:422
Use as much space as possible.
Definition: mutt_window.h:52
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
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
Pager Dialog, mutt_do_pager()
Definition: mutt_window.h:84
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void * event_data
Data from notify_send()
Definition: observer.h:44
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:468
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
void dialog_pop(void)
Hide a Window from the user.
Definition: dialog.c:139
void mutt_buffer_file_expand_fmt_quote(struct Buffer *dest, const char *fmt, const char *src)
Replace s in a string with a filename.
Definition: file.c:1435
Pager is invoked via 2nd path. A user-selected attachment (mime part or a nested email) will be shown...
Definition: lib.h:132
struct MuttWindow * win_pager
Definition: lib.h:164
struct MuttWindow * win_pbar
Definition: lib.h:163
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:228
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:93
struct IndexSharedData * index_shared_data_new(void)
Create new Index Data.
Definition: shared_data.c:300
struct MuttWindow * win_ibar
Definition: lib.h:161
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
const char * fname
Name of the file to read.
Definition: lib.h:148
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:180
Log at debug level 5.
Definition: logging.h:44
Convenience wrapper for the library headers.
GUI manage the main index (list of emails)
Window wants as much space as possible.
Definition: mutt_window.h:48
void * wdata
Private data.
Definition: mutt_window.h:145
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:135
const char * name
Name of config item that changed.
Definition: subset.h:72
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51