NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
Go to the documentation of this file.
70#include "config.h"
71#include <stdbool.h>
72#include <stdio.h>
73#include "mutt/lib.h"
74#include "config/lib.h"
75#include "core/lib.h"
76#include "gui/lib.h"
77#include "menu/lib.h"
78#include "format_flags.h"
79#include "functions.h"
80#include "hdrline.h"
81#include "keymap.h"
82#include "mutt_logging.h"
83#include "opcodes.h"
85struct Email;
88static const struct Mapping PostponeHelp[] = {
89 // clang-format off
90 { N_("Exit"), OP_EXIT },
91 { N_("Del"), OP_DELETE },
92 { N_("Undel"), OP_UNDELETE },
93 { N_("Help"), OP_HELP },
94 { NULL, 0 },
95 // clang-format on
101static void post_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
103 struct Mailbox *m = menu->mdata;
105 const char *const c_index_format = cs_subset_string(NeoMutt->sub, "index_format");
106 mutt_make_string(buf, buflen, menu->win->state.cols, NONULL(c_index_format),
107 m, -1, m->emails[line], MUTT_FORMAT_ARROWCURSOR, NULL);
117 if (nc->event_type != NT_CONFIG)
118 return 0;
119 if (!nc->global_data || !nc->event_data)
120 return -1;
122 struct EventConfig *ev_c = nc->event_data;
124 if (!mutt_str_equal(ev_c->name, "index_format") && !mutt_str_equal(ev_c->name, "sort"))
125 return 0;
127 struct Menu *menu = nc->global_data;
129 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
131 return 0;
143 if (nc->event_type != NT_WINDOW)
144 return 0;
145 if (!nc->global_data || !nc->event_data)
146 return -1;
148 return 0;
150 struct MuttWindow *win_menu = nc->global_data;
151 struct EventWindow *ev_w = nc->event_data;
152 if (ev_w->win != win_menu)
153 return 0;
155 struct Menu *menu = win_menu->wdata;
160 mutt_debug(LL_DEBUG5, "window delete done\n");
161 return 0;
173 struct Menu *menu = dlg->wdata;
175 menu->max = m->msg_count;
176 menu->mdata = m;
177 menu->mdata_free = NULL; // Menu doesn't own the data
178 menu->custom_search = true;
180 struct PostponeData pd = { false, m, menu, NULL };
181 dlg->wdata = &pd;
183 // NT_COLOR is handled by the SimpleDialog
187 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
188 sbar_set_title(sbar, _("Postponed Messages"));
190 /* The postponed mailbox is setup to have sorting disabled, but the global
191 * `$sort` variable may indicate something different. Sorting has to be
192 * disabled while the postpone menu is being displayed. */
193 const short c_sort = cs_subset_sort(NeoMutt->sub, "sort");
196 // ---------------------------------------------------------------------------
197 // Event Loop
198 int op = OP_NULL;
199 do
200 {
201 menu_tagging_dispatcher(menu->win, op);
202 window_redraw(NULL);
205 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
206 if (op < 0)
207 continue;
208 if (op == OP_NULL)
209 {
211 continue;
212 }
215 int rc = postpone_function_dispatcher(dlg, op);
217 if (rc == FR_UNKNOWN)
218 rc = menu_function_dispatcher(menu->win, op);
219 if (rc == FR_UNKNOWN)
220 rc = global_function_dispatcher(NULL, op);
221 } while (!pd.done);
222 // ---------------------------------------------------------------------------
224 cs_subset_str_native_set(NeoMutt->sub, "sort", c_sort, NULL);
225 simple_dialog_free(&dlg);
227 return;
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:292
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
Unknown function.
Definition: dispatcher.h:33
struct Email * dlg_select_postponed_email(struct Mailbox *m)
Create a Menu to select a postponed message.
Definition: dlg_postpone.c:169
static const struct Mapping PostponeHelp[]
Help Bar for the Postponed email selection dialog.
Definition: dlg_postpone.c:88
Flags to control mutt_expando_format()
Reserve space for arrow_cursor.
Definition: format_flags.h:35
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int postpone_function_dispatcher(struct MuttWindow *win, int op)
Perform a Postpone function - Implements function_dispatcher_t -.
Definition: functions.c:129
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static void post_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the email list - Implements Menu::make_entry() -.
Definition: dlg_postpone.c:101
static int postponed_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_postpone.c:141
static int postponed_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_postpone.c:115
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
void mutt_make_string(char *buf, size_t buflen, int cols, const char *s, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
Definition: hdrline.c:1405
String processing routines to generate the mail index.
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
Manage keymappings.
Log at debug level 5.
Definition: logging.h:44
Log at debug level 1.
Definition: logging.h:40
GUI present the user with a selectable list.
Redraw everything.
Definition: lib.h:59
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:178
Convenience wrapper for the library headers.
#define N_(a)
Definition: message.h:32
#define _(a)
Definition: message.h:28
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:228
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
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:807
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:89
Window is about to be deleted.
Definition: mutt_window.h:206
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:46
All user-callable functions.
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
Sidebar functions.
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:48
#define NONULL(x)
Definition: string2.h:37
The envelope/body of an email.
Definition: email.h:37
A config-change event.
Definition: subset.h:70
const char * name
Name of config item that changed.
Definition: subset.h:72
An Event that happened to a Window.
Definition: mutt_window.h:216
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
A mailbox.
Definition: mailbox.h:79
int msg_count
Total number of messages.
Definition: mailbox.h:88
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
Mapping between user-readable string and a constant.
Definition: mapping.h:32
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
void * mdata
Private data.
Definition: lib.h:137
int max
Number of entries in the menu.
Definition: lib.h:71
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:84
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
Data passed to a notification function.
Definition: observer.h:34
void * event_data
Data from notify_send()
Definition: observer.h:38
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:37
void * global_data
Data from notify_observer_add()
Definition: observer.h:39
Data to pass to the Postpone Functions.
Definition: functions.h:34
struct Email * email
Selected Email.
Definition: functions.h:38
bool done
Should we close the Dialog?
Definition: functions.h:35
struct Menu * menu
Postponed Menu.
Definition: functions.h:37
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: subset.c:305
Select a postponed email.
Definition: type.h:56