NeoMutt  2025-09-05-55-g97fc89
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
GUI: Dialog Windows

A Dialog is an interactive set of windows allowing the user to perform some task. More...

Functions

static bool dlg_alias (struct AliasMenuData *mdata)
 Display a menu of Aliases -.
 
static bool dlg_query (struct Buffer *buf, struct AliasMenuData *mdata)
 Get the user to enter an Address Query -.
 
void dlg_attachment (struct ConfigSubset *sub, struct MailboxView *mv, struct Email *e, FILE *fp, bool attach_msg)
 Show the attachments in a Menu -.
 
void dlg_autocrypt (void)
 Display the Autocrypt account Menu -.
 
void dlg_browser (struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
 Let the user select a file -.
 
int dlg_compose (struct Email *e, struct Buffer *fcc, uint8_t flags, struct ConfigSubset *sub)
 Allow the user to edit the message envelope -.
 
int dlg_certificate (const char *title, struct StringArray *carr, bool allow_always, bool allow_skip)
 Ask the user to validate the certificate -.
 
void dlg_history (struct Buffer *buf, struct StringArray *matches)
 Select an item from a history list -.
 
struct Mailboxdlg_index (struct MuttWindow *dlg, struct Mailbox *m_init)
 Display a list of emails -.
 
struct CryptKeyInfodlg_gpgme (struct CryptKeyInfo *keys, struct Address *p, const char *s, unsigned int app, bool *forced_valid)
 Get the user to select a key -.
 
struct PgpKeyInfodlg_pgp (struct PgpKeyInfo *keys, struct Address *p, const char *s)
 Let the user select a key to use -.
 
struct SmimeKeydlg_smime (struct SmimeKey *keys, const char *query)
 Get the user to select a key -.
 
int dlg_pager (struct PagerView *pview)
 Display an email, attachment, or help, in a window -.
 
bool dlg_pattern (struct Buffer *buf)
 Show menu to select a Pattern -.
 
struct Emaildlg_postponed (struct Mailbox *m)
 Create a Menu to select a postponed message -.
 

Detailed Description

A Dialog is an interactive set of windows allowing the user to perform some task.

The All Dialogs window is a container window and not visible. All active dialogs will be children of this window, though only one will be active at a time.

Windows

Name Type Constructor
All Dialogs WT_ALL_DIALOGS alldialogs_new()

Parent

Children

The All Dialogs window has many possible children, e.g.

Data

The All Dialogs window has no data.

Events

Once constructed, it is controlled by the following events:

Event Type Handler
NT_WINDOW alldialogs_window_observer()

The All Dialogs window does not implement MuttWindow::recalc() or MuttWindow::repaint().

Function Documentation

◆ dlg_alias()

static bool dlg_alias ( struct AliasMenuData * mdata)
static

Display a menu of Aliases -.

Parameters
mdataMenu data holding Aliases
Return values
trueSelection was made

The Alias Dialog is an Address Book. The user can select addresses to add to an Email.

Definition at line 266 of file dlg_alias.c.

267{
268 if (ARRAY_EMPTY(&mdata->ava))
269 {
270 mutt_warning(_("You have no aliases"));
271 return false;
272 }
273
274 mdata->title = mutt_str_dup(_("Aliases"));
275
276 struct SimpleDialogWindows sdw = alias_dialog_new(mdata);
277 struct Menu *menu = sdw.menu;
278 mdata->menu = menu;
279 mdata->sbar = sdw.sbar;
280
281 alias_array_sort(&mdata->ava, mdata->sub);
282
283 struct AliasView *avp = NULL;
284 ARRAY_FOREACH(avp, &mdata->ava)
285 {
286 avp->num = ARRAY_FOREACH_IDX_avp;
287 }
288
289 struct MuttWindow *old_focus = window_set_focus(menu->win);
290 // ---------------------------------------------------------------------------
291 // Event Loop
292 int rc = 0;
293 int op = OP_NULL;
294 do
295 {
296 menu_tagging_dispatcher(menu->win, op);
297 window_redraw(NULL);
298
300 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
301 if (op < 0)
302 continue;
303 if (op == OP_NULL)
304 {
306 continue;
307 }
309
310 rc = alias_function_dispatcher(sdw.dlg, op);
311 if (rc == FR_UNKNOWN)
312 rc = menu_function_dispatcher(menu->win, op);
313 if (rc == FR_UNKNOWN)
314 rc = global_function_dispatcher(NULL, op);
315 } while ((rc != FR_DONE) && (rc != FR_CONTINUE));
316 // ---------------------------------------------------------------------------
317
318 window_set_focus(old_focus);
320 window_redraw(NULL);
321 return (rc == FR_CONTINUE); // Was a selection made?
322}
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition sort.c:235
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:214
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:35
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:33
@ FR_CONTINUE
Remain in the Dialog.
Definition dispatcher.h:34
static struct SimpleDialogWindows alias_dialog_new(struct AliasMenuData *mdata)
Create an Alias Selection Dialog.
Definition dlg_alias.c:231
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition get.c:537
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition get.c:294
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition tagging.c:230
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition global.c:181
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition functions.c:319
int alias_function_dispatcher(struct MuttWindow *win, int op)
Perform a Alias function - Implements function_dispatcher_t -.
Definition functions.c:466
#define mutt_warning(...)
Definition logging2.h:91
#define mutt_debug(LEVEL,...)
Definition logging2.h:90
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition simple.c:168
#define GETCH_NO_FLAGS
No flags are set.
Definition lib.h:53
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:44
#define _(a)
Definition message.h:28
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:255
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition opcodes.c:48
struct AliasViewArray ava
All Aliases/Queries.
Definition gui.h:55
char * title
Title for the status bar.
Definition gui.h:62
GUI data wrapping an Alias.
Definition gui.h:38
int num
Index number in list.
Definition gui.h:39
Definition lib.h:79
struct MuttWindow * win
Window holding the Menu.
Definition lib.h:86
void * mdata
Private data.
Definition lib.h:147
Tuple for the results of simple_dialog_new()
Definition simple.h:35
struct MuttWindow * sbar
Simple Bar.
Definition simple.h:37
struct Menu * menu
Menu.
Definition simple.h:38
struct MuttWindow * dlg
Main Dialog Window.
Definition simple.h:36
@ MENU_ALIAS
Select an email address by its alias.
Definition type.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_query()

static bool dlg_query ( struct Buffer * buf,
struct AliasMenuData * mdata )
static

Get the user to enter an Address Query -.

Parameters
bufBuffer for the query
mdataMenu data holding Aliases
Return values
trueSelection was made

The Select Query Dialog is an Address Book. It is dynamically created from an external source using $query_command.

The user can select addresses to add to an Email.

Definition at line 347 of file dlg_query.c.

348{
349 struct SimpleDialogWindows sdw = query_dialog_new(mdata, buf_string(buf));
350 struct Menu *menu = sdw.menu;
351 mdata->menu = menu;
352 mdata->sbar = sdw.sbar;
353 mdata->query = buf;
354
355 alias_array_sort(&mdata->ava, mdata->sub);
356
357 struct AliasView *avp = NULL;
358 ARRAY_FOREACH(avp, &mdata->ava)
359 {
360 avp->num = ARRAY_FOREACH_IDX_avp;
361 }
362
363 struct MuttWindow *old_focus = window_set_focus(menu->win);
364 // ---------------------------------------------------------------------------
365 // Event Loop
366 int rc = 0;
367 int op = OP_NULL;
368 do
369 {
370 menu_tagging_dispatcher(menu->win, op);
371 window_redraw(NULL);
372
374 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
375 if (op < 0)
376 continue;
377 if (op == OP_NULL)
378 {
380 continue;
381 }
383
384 rc = alias_function_dispatcher(sdw.dlg, op);
385 if (rc == FR_UNKNOWN)
386 rc = menu_function_dispatcher(menu->win, op);
387 if (rc == FR_UNKNOWN)
388 rc = global_function_dispatcher(NULL, op);
389 } while ((rc != FR_DONE) && (rc != FR_CONTINUE));
390 // ---------------------------------------------------------------------------
391
392 window_set_focus(old_focus);
394 window_redraw(NULL);
395 return (rc == FR_CONTINUE); // Was a selection made?
396}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
static struct SimpleDialogWindows query_dialog_new(struct AliasMenuData *mdata, const char *query)
Create an Query Selection Dialog.
Definition dlg_query.c:306
@ MENU_QUERY
Select from results of external query.
Definition type.h:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_attachment()

void dlg_attachment ( struct ConfigSubset * sub,
struct MailboxView * mv,
struct Email * e,
FILE * fp,
bool attach_msg )

Show the attachments in a Menu -.

Parameters
subConfig Subset
mvMailbox view
eEmail
fpFile with the content of the email, or NULL
attach_msgAre we in "attach message" mode?

The Select Attachment dialog shows an Email's attachments. They can be viewed using the Pager or Mailcap programs. They can also be saved, printed, deleted, etc.

Definition at line 208 of file dlg_attach.c.

210{
211 if (!mv || !mv->mailbox || !e || !fp)
212 return;
213
214 struct Mailbox *m = mv->mailbox;
215
216 /* make sure we have parsed this message */
219
222 struct Menu *menu = sdw.menu;
224 menu->tag = attach_tag;
225
226 struct AttachCtx *actx = mutt_actx_new();
227 actx->email = e;
228 actx->fp_root = fp;
229 mutt_update_recvattach_menu(actx, menu, true);
230
232 priv->menu = menu;
233 priv->actx = actx;
234 priv->sub = sub;
235 priv->mailbox = m;
236 priv->attach_msg = attach_msg;
237 menu->mdata = priv;
239
240 // NT_COLOR is handled by the SimpleDialog
243
244 sbar_set_title(sdw.sbar, _("Attachments"));
245
246 struct MuttWindow *old_focus = window_set_focus(menu->win);
247 // ---------------------------------------------------------------------------
248 // Event Loop
249 int rc = 0;
250 int op = OP_NULL;
251 do
252 {
253 menu_tagging_dispatcher(menu->win, op);
254 window_redraw(NULL);
255
257 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
258 if (op < 0)
259 continue;
260 if (op == OP_NULL)
261 {
263 continue;
264 }
266
267 rc = attach_function_dispatcher(sdw.dlg, op);
268 if (rc == FR_UNKNOWN)
269 rc = menu_function_dispatcher(menu->win, op);
270 if (rc == FR_UNKNOWN)
271 rc = global_function_dispatcher(NULL, op);
272
273 if (rc == FR_CONTINUE)
274 {
275 op = priv->op;
276 }
277
278 } while (rc != FR_DONE);
279 // ---------------------------------------------------------------------------
280
281 window_set_focus(old_focus);
283}
struct AttachCtx * mutt_actx_new(void)
Create a new Attachment Context.
Definition attach.c:189
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition commands.c:596
struct AttachPrivateData * attach_private_data_new(void)
Create new Attach Data.
static const struct Mapping AttachmentHelp[]
Help Bar for the Attachment selection dialog.
Definition dlg_attach.c:92
int attach_function_dispatcher(struct MuttWindow *win, int op)
Perform a Attach function - Implements function_dispatcher_t -.
Definition functions.c:711
static int attach_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Attachment for the Menu - Implements Menu::make_entry() -.
Definition dlg_attach.c:132
void attach_private_data_free(struct Menu *menu, void **ptr)
Free the Attach Data - Implements Menu::mdata_free() -.
static int attach_tag(struct Menu *menu, int sel, int act)
Tag an attachment - Implements Menu::tag() -.
Definition dlg_attach.c:154
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition dlg_attach.c:108
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition dlg_attach.c:173
struct SimpleDialogWindows simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition simple.c:132
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition hook.c:699
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition hook.h:44
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
@ WT_DLG_ATTACHMENT
Attachment Dialog, dlg_attachment()
Definition mutt_window.h:79
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition sbar.c:227
A set of attachments.
Definition attach.h:63
FILE * fp_root
Used by recvattach for updating.
Definition attach.h:65
struct Email * email
Used by recvattach for updating.
Definition attach.h:64
Private state data for Attachments.
int op
Op returned from the Pager, e.g. OP_NEXT_ENTRY.
struct Menu * menu
Current Menu.
struct ConfigSubset * sub
Config subset.
struct AttachCtx * actx
List of all Attachments.
bool attach_msg
Are we in "attach message" mode?
struct Mailbox * mailbox
Current Mailbox.
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
struct Mailbox * mailbox
Current Mailbox.
Definition mview.h:51
A mailbox.
Definition mailbox.h:79
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition lib.h:161
int(* tag)(struct Menu *menu, int sel, int act)
Definition lib.h:131
int(* make_entry)(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Definition lib.h:106
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Container for Accounts, Notifications.
Definition neomutt.h:43
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
@ MENU_ATTACHMENT
Select an attachment.
Definition type.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_autocrypt()

void dlg_autocrypt ( void )

Display the Autocrypt account Menu -.

The Autocrypt Dialog lets the user select an Autocrypt Account to use.

Definition at line 240 of file dlg_autocrypt.c.

241{
242 const bool c_autocrypt = cs_subset_bool(NeoMutt->sub, "autocrypt");
243 if (!c_autocrypt)
244 return;
245
246 if (mutt_autocrypt_init(false))
247 return;
248
251
252 struct Menu *menu = sdw.menu;
253
254 struct AutocryptData *ad = autocrypt_data_new();
255 ad->menu = menu;
256
258 menu->mdata = ad;
260
262
263 // L10N: Autocrypt Account Management Menu title
264 sbar_set_title(sdw.sbar, _("Autocrypt Accounts"));
265
266 // NT_COLOR is handled by the SimpleDialog
269
270 struct MuttWindow *old_focus = window_set_focus(menu->win);
271 // ---------------------------------------------------------------------------
272 // Event Loop
273 int op = OP_NULL;
274 do
275 {
276 menu_tagging_dispatcher(menu->win, op);
277 window_redraw(NULL);
278
280 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
281 if (op < 0)
282 continue;
283 if (op == OP_NULL)
284 {
286 continue;
287 }
289
290 int rc = autocrypt_function_dispatcher(sdw.dlg, op);
291
292 if (rc == FR_UNKNOWN)
293 rc = menu_function_dispatcher(menu->win, op);
294 if (rc == FR_UNKNOWN)
295 rc = global_function_dispatcher(NULL, op);
296 } while (!ad->done);
297 // ---------------------------------------------------------------------------
298
299 window_set_focus(old_focus);
301}
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition autocrypt.c:99
struct AutocryptData * autocrypt_data_new(void)
Create new Autocrypt Data.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
static const struct Mapping AutocryptHelp[]
Help Bar for the Autocrypt Account selection dialog.
bool populate_menu(struct Menu *menu)
Add the Autocrypt data to a Menu.
int autocrypt_function_dispatcher(struct MuttWindow *win, int op)
Perform a Autocrypt function - Implements function_dispatcher_t -.
Definition functions.c:214
static int autocrypt_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Autocrypt Account for the Menu - Implements Menu::make_entry() -.
void autocrypt_data_free(struct Menu *menu, void **ptr)
Free Autocrypt Data - Implements Menu::mdata_free() -.
static int autocrypt_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
static int autocrypt_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
@ WT_DLG_AUTOCRYPT
Autocrypt Dialog, dlg_autocrypt()
Definition mutt_window.h:80
Data to pass to the Autocrypt Functions.
bool done
Should we close the Dialog?
struct Menu * menu
Autocrypt Menu.
@ MENU_AUTOCRYPT
Autocrypt Account menu.
Definition type.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_browser()

void dlg_browser ( struct Buffer * file,
SelectFileFlags flags,
struct Mailbox * m,
char *** files,
int * numfiles )

Let the user select a file -.

Parameters
[in]fileBuffer for the result
[in]flagsFlags, see SelectFileFlags
[in]mMailbox
[out]filesArray of selected files
[out]numfilesNumber of selected files

The Select File Dialog is a file browser. It allows the user to select a file or directory to use.

Definition at line 852 of file dlg_browser.c.

854{
856 priv->file = file;
857 priv->mailbox = m;
858 priv->files = files;
859 priv->numfiles = numfiles;
860 priv->multiple = (flags & MUTT_SEL_MULTI);
861 priv->folder = (flags & MUTT_SEL_FOLDER);
862 priv->state.is_mailbox_list = (flags & MUTT_SEL_MAILBOX) && priv->folder;
863 priv->last_selected_mailbox = -1;
864
865 init_lastdir();
866
867 if (OptNews)
868 {
869 if (buf_is_empty(file))
870 {
872
873 /* default state for news reader mode is browse subscribed newsgroups */
874 priv->state.is_mailbox_list = false;
875 for (size_t i = 0; i < adata->groups_num; i++)
876 {
877 struct NntpMboxData *mdata = adata->groups_list[i];
878 if (mdata && mdata->subscribed)
879 {
880 priv->state.is_mailbox_list = true;
881 break;
882 }
883 }
884 }
885 else
886 {
887 buf_copy(priv->prefix, file);
888 }
889 }
890 else if (!buf_is_empty(file))
891 {
892 buf_expand_path(file);
893 if (imap_path_probe(buf_string(file), NULL) == MUTT_IMAP)
894 {
895 init_state(&priv->state);
896 priv->state.imap_browse = true;
897 if (imap_browse(buf_string(file), &priv->state) == 0)
898 {
899 buf_strcpy(&LastDir, priv->state.folder);
900 browser_sort(&priv->state);
901 }
902 }
903 else
904 {
905 int i = buf_len(file);
906 i--;
907 for (; (i > 0) && ((buf_string(file))[i] != '/'); i--)
908 {
909 ; // do nothing
910 }
911
912 if (i > 0)
913 {
914 if ((buf_string(file))[0] == '/')
915 {
916 buf_strcpy_n(&LastDir, buf_string(file), i);
917 }
918 else
919 {
921 buf_addch(&LastDir, '/');
922 buf_addstr_n(&LastDir, buf_string(file), i);
923 }
924 }
925 else
926 {
927 if ((buf_string(file))[0] == '/')
928 buf_strcpy(&LastDir, "/");
929 else
931 }
932
933 if ((i <= 0) && (buf_string(file)[0] != '/'))
934 buf_copy(priv->prefix, file);
935 else
936 buf_strcpy(priv->prefix, buf_string(file) + i + 1);
937 priv->kill_prefix = true;
938 }
939 }
940 else
941 {
942 if (priv->folder)
943 {
944 /* Whether we use the tracking feature of the browser depends
945 * on which sort method we chose to use. This variable is defined
946 * only to help readability of the code. */
947 bool browser_track = false;
948
949 const enum EmailSortType c_browser_sort = cs_subset_sort(NeoMutt->sub, "browser_sort");
950 switch (c_browser_sort & SORT_MASK)
951 {
955 browser_track = true;
956 break;
957 }
958
959 /* We use mutt_browser_select_dir to initialize the two
960 * variables (LastDir, LastDirBackup) at the appropriate
961 * values.
962 *
963 * We do it only when LastDir is not set (first pass there)
964 * or when CurrentFolder and LastDirBackup are not the same.
965 * This code is executed only when we list files, not when
966 * we press up/down keys to navigate in a displayed list.
967 *
968 * We only do this when CurrentFolder has been set (ie, not
969 * when listing folders on startup with "neomutt -y").
970 *
971 * This tracker is only used when browser_track is true,
972 * meaning only with sort methods SUBJECT/DESC for now. */
973 if (CurrentFolder)
974 {
975 if (buf_is_empty(&LastDir))
976 {
977 /* If browsing in "local"-mode, than we chose to define LastDir to
978 * MailDir */
980 {
981 case MUTT_IMAP:
982 case MUTT_MAILDIR:
983 case MUTT_MBOX:
984 case MUTT_MH:
985 case MUTT_MMDF:
986 {
987 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
988 const char *const c_spool_file = cs_subset_string(NeoMutt->sub, "spool_file");
989 if (c_folder)
990 buf_strcpy(&LastDir, c_folder);
991 else if (c_spool_file)
992 mutt_browser_select_dir(c_spool_file);
993 break;
994 }
995 default:
997 break;
998 }
999 }
1001 {
1003 }
1004 }
1005
1006 /* When browser tracking feature is disabled, clear LastDirBackup */
1007 if (!browser_track)
1009 }
1010 else
1011 {
1013 }
1014
1015 if (!priv->state.is_mailbox_list &&
1017 {
1018 init_state(&priv->state);
1019 priv->state.imap_browse = true;
1020 imap_browse(buf_string(&LastDir), &priv->state);
1021 browser_sort(&priv->state);
1022 }
1023 else
1024 {
1025 size_t i = buf_len(&LastDir);
1026 while ((i > 0) && (buf_string(&LastDir)[--i] == '/'))
1027 LastDir.data[i] = '\0';
1029 if (buf_is_empty(&LastDir))
1031 }
1032 }
1033
1034 buf_reset(file);
1035
1036 const struct Mapping *help_data = NULL;
1037
1038 if (OptNews)
1039 help_data = FolderNewsHelp;
1040 else
1041 help_data = FolderHelp;
1042
1044
1045 struct Menu *menu = sdw.menu;
1047 menu->search = select_file_search;
1048 menu->mdata = priv;
1049
1050 priv->menu = menu;
1051 if (priv->multiple)
1052 priv->menu->tag = file_tag;
1053
1054 priv->sbar = sdw.sbar;
1055
1056 struct MuttWindow *win_menu = priv->menu->win;
1057
1058 // NT_COLOR is handled by the SimpleDialog
1062
1063 struct MuttWindow *old_focus = window_set_focus(priv->menu->win);
1064
1065 if (priv->state.is_mailbox_list)
1066 {
1067 examine_mailboxes(m, NULL, &priv->state);
1068 }
1069 else if (!priv->state.imap_browse)
1070 {
1071 // examine_directory() calls browser_add_folder() which needs the menu
1072 if (examine_directory(m, priv->menu, &priv->state, buf_string(&LastDir),
1073 buf_string(priv->prefix)) == -1)
1074 {
1075 goto bail;
1076 }
1077 }
1078
1079 init_menu(&priv->state, priv->menu, m, priv->sbar);
1080
1081 // ---------------------------------------------------------------------------
1082 // Event Loop
1083 int op = OP_NULL;
1084 do
1085 {
1086 menu_tagging_dispatcher(priv->menu->win, op);
1087 window_redraw(NULL);
1088
1090 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
1091 if (op < 0)
1092 continue;
1093 if (op == OP_NULL)
1094 {
1096 continue;
1097 }
1099
1100 int rc = browser_function_dispatcher(sdw.dlg, op);
1101
1102 if (rc == FR_UNKNOWN)
1103 rc = menu_function_dispatcher(menu->win, op);
1104 if (rc == FR_UNKNOWN)
1105 rc = global_function_dispatcher(NULL, op);
1106 } while (!priv->done);
1107 // ---------------------------------------------------------------------------
1108
1109bail:
1110 window_set_focus(old_focus);
1111 simple_dialog_free(&sdw.dlg);
1113}
int imap_browse(const char *path, struct BrowserState *state)
IMAP hook into the folder browser.
Definition browse.c:197
int browser_function_dispatcher(struct MuttWindow *win, int op)
Perform a Browser function.
Definition functions.c:1130
#define MUTT_SEL_MAILBOX
Select a mailbox.
Definition lib.h:58
void browser_sort(struct BrowserState *state)
Sort the entries in the browser.
Definition sort.c:186
#define MUTT_SEL_FOLDER
Select a local directory.
Definition lib.h:60
#define MUTT_SEL_MULTI
Multi-selection is enabled.
Definition lib.h:59
struct BrowserPrivateData * browser_private_data_new(void)
Create new Browser Data.
@ BROWSER_SORT_ALPHA
Sort by name.
Definition sort.h:31
@ BROWSER_SORT_UNSORTED
Sort into the raw order.
Definition sort.h:37
@ BROWSER_SORT_DESC
Sort by description.
Definition sort.h:34
size_t buf_addstr_n(struct Buffer *buf, const char *s, size_t len)
Add a string to a Buffer, expanding it if necessary.
Definition buffer.c:96
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
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition buffer.c:182
size_t buf_strcpy_n(struct Buffer *buf, const char *s, size_t len)
Copy a string into a Buffer.
Definition buffer.c:416
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition buffer.c:241
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition buffer.c:601
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition helpers.c:266
#define SORT_MASK
Mask for the sort id.
Definition sort.h:38
@ MUTT_MMDF
'mmdf' Mailbox type
Definition mailbox.h:46
@ MUTT_MH
'MH' Mailbox type
Definition mailbox.h:47
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:50
@ MUTT_MBOX
'mbox' Mailbox type
Definition mailbox.h:45
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition mailbox.h:48
int examine_directory(struct Mailbox *m, struct Menu *menu, struct BrowserState *state, const char *dirname, const char *prefix)
Get list of all files/newsgroups with mask.
void init_menu(struct BrowserState *state, struct Menu *menu, struct Mailbox *m, struct MuttWindow *sbar)
Set up a new menu.
static void init_lastdir(void)
Initialise the browser directories.
static const struct Mapping FolderNewsHelp[]
Help Bar for the NNTP Mailbox browser dialog.
struct Buffer LastDir
Browser: previous selected directory.
void mutt_browser_select_dir(const char *f)
Remember the last directory selected.
void init_state(struct BrowserState *state)
Initialise a browser state.
struct Buffer LastDirBackup
Browser: backup copy of the current directory.
static const struct Mapping FolderHelp[]
Help Bar for the File/Dir/Mailbox browser dialog.
int examine_mailboxes(struct Mailbox *m, struct Menu *menu, struct BrowserState *state)
Get list of mailboxes/subscribed newsgroups.
EmailSortType
Methods for sorting Emails.
Definition sort.h:53
bool OptNews
(pseudo) used to change reader mode
Definition globals.c:64
char * CurrentFolder
Currently selected mailbox.
Definition globals.c:39
static int folder_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format a Folder for the Menu - Implements Menu::make_entry() -.
static int select_file_search(struct Menu *menu, regex_t *rx, int line)
Menu search callback for matching files - Implements Menu::search() -.
static int file_tag(struct Menu *menu, int sel, int act)
Tag an entry in the menu - Implements Menu::tag() -.
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox?
Definition imap.c:2349
static int browser_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
static int browser_mailbox_observer(struct NotifyCallback *nc)
Notification that a Mailbox has changed - Implements observer_t -.
static int browser_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
void browser_private_data_free(struct BrowserPrivateData **ptr)
Free Private Browser Data - Implements MuttWindow::wdata_free() -.
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
Definition path.c:476
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:660
@ WT_DLG_BROWSER
Browser Dialog, dlg_browser()
Definition mutt_window.h:81
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Definition muttlib.c:314
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition mx.c:1326
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition nntp.c:76
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:49
void * adata
Private data (for Mailbox backends)
Definition account.h:42
Private state data for the Browser.
char *** files
Array of selected files.
bool folder
Select folders.
int * numfiles
Number of selected files.
struct Mailbox * mailbox
Mailbox.
struct BrowserState state
State containing list of files/dir/mailboxes.
struct Buffer * file
Buffer for the result.
bool multiple
Allow multiple selections.
bool is_mailbox_list
Viewing mailboxes.
Definition lib.h:148
void * mdata
Driver specific data.
Definition mailbox.h:132
Mapping between user-readable string and a constant.
Definition mapping.h:33
int(* search)(struct Menu *menu, regex_t *rx, int line)
Definition lib.h:119
struct Notify * notify
Notifications handler.
Definition neomutt.h:44
NNTP-specific Account data -.
Definition adata.h:36
struct NntpMboxData ** groups_list
Definition adata.h:60
NNTP-specific Mailbox data -.
Definition mdata.h:34
struct NntpAccountData * adata
Definition mdata.h:48
@ MENU_BROWSER
General file/mailbox browser.
Definition type.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_compose()

int dlg_compose ( struct Email * e,
struct Buffer * fcc,
uint8_t flags,
struct ConfigSubset * sub )

Allow the user to edit the message envelope -.

Parameters
eEmail to fill
fccBuffer to save FCC
flagsFlags, e.g. MUTT_COMPOSE_NOFREEHEADER
subConfigSubset
Return values
1Message should be postponed
0Normal exit
-1Abort message

The Compose Dialog allows the user to edit the email envelope before sending.

Definition at line 403 of file dlg_compose.c.

404{
405 struct MuttWindow *dlg = compose_dlg_init(sub, e, fcc);
406 struct ComposeSharedData *shared = dlg->wdata;
407 shared->mailbox = get_current_mailbox();
408 shared->email = e;
409 shared->sub = sub;
410 shared->fcc = fcc;
411 shared->fcc_set = false;
412 shared->flags = flags;
413 shared->rc = -1;
414
418
419 if (OptNewsSend)
421 else
422 dlg->help_data = ComposeHelp;
423 dlg->help_menu = MENU_COMPOSE;
424
425 struct Menu *menu = shared->adata->menu;
426 update_menu(shared->adata->actx, menu, true);
428
429 struct MuttWindow *win_env = window_find_child(dlg, WT_CUSTOM);
430
431 dialog_push(dlg);
432 struct MuttWindow *old_focus = window_set_focus(menu->win);
433 // ---------------------------------------------------------------------------
434 // Event Loop
435 int rc = 0;
436 int op = OP_NULL;
437 do
438 {
439 OptNews = false; /* for any case */
440 menu_tagging_dispatcher(menu->win, op);
441 window_redraw(NULL);
442
444 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
445 if (op < 0)
446 continue;
447 if (op == OP_NULL)
448 {
450 continue;
451 }
453
454 rc = compose_function_dispatcher(dlg, op);
455 if (rc == FR_UNKNOWN)
456 rc = env_function_dispatcher(win_env, op);
457 if (rc == FR_UNKNOWN)
459 if (rc == FR_UNKNOWN)
460 rc = menu_function_dispatcher(menu->win, op);
461 if (rc == FR_UNKNOWN)
462 rc = global_function_dispatcher(NULL, op);
463 } while (rc != FR_DONE);
464 // ---------------------------------------------------------------------------
465
466#ifdef USE_AUTOCRYPT
467 /* This is a fail-safe to make sure the bit isn't somehow turned
468 * on. The user could have disabled the option after setting SEC_AUTOCRYPT,
469 * or perhaps resuming or replying to an autocrypt message. */
470 const bool c_autocrypt = cs_subset_bool(sub, "autocrypt");
471 if (!c_autocrypt)
473#endif
474
475 if (shared->adata->actx->idxlen)
476 e->body = shared->adata->actx->idx[0]->body;
477 else
478 e->body = NULL;
479
480 rc = shared->rc;
481
482 window_set_focus(old_focus);
483 dialog_pop();
484 mutt_window_free(&dlg);
485
486 return rc;
487}
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 update_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Redraw the compose window.
static const struct Mapping ComposeHelp[]
Help Bar for the Compose dialog.
Definition dlg_compose.c:93
static const struct Mapping ComposeNewsHelp[]
Help Bar for the News Compose dialog.
static struct MuttWindow * compose_dlg_init(struct ConfigSubset *sub, struct Email *e, struct Buffer *fcc)
Allocate the Windows for Compose.
@ NT_EMAIL_CHANGE
Email has changed.
Definition email.h:186
bool OptNewsSend
(pseudo) used to change behavior when posting
Definition globals.c:65
int preview_function_dispatcher(struct MuttWindow *win, int op)
Perform a preview function - Implements function_dispatcher_t -.
Definition preview.c:407
int env_function_dispatcher(struct MuttWindow *win, int op)
Perform an Envelope function - Implements function_dispatcher_t -.
Definition functions.c:530
int compose_function_dispatcher(struct MuttWindow *win, int op)
Perform a Compose function - Implements function_dispatcher_t -.
Definition functions.c:2141
static int compose_email_observer(struct NotifyCallback *nc)
Notification that an Email has changed - Implements observer_t -.
static int compose_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
static int compose_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
Definition index.c:721
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
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
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
Definition lib.h:93
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition notify_type.h:44
@ NT_ENVELOPE
Envelope has changed, NotifyEnvelope.
Definition notify_type.h:45
struct AttachPtr ** idx
Array of attachments.
Definition attach.h:67
short idxlen
Number of attachmentes.
Definition attach.h:68
struct Body * body
Attachment.
Definition attach.h:36
struct Menu * menu
Menu displaying the attachments.
Definition attach_data.h:35
struct AttachCtx * actx
Set of attachments.
Definition attach_data.h:34
Shared Compose Data.
Definition shared_data.h:36
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:37
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:38
int flags
Flags, e.g. MUTT_COMPOSE_NOFREEHEADER.
Definition shared_data.h:46
struct MuttWindow * win_preview
Message preview window.
Definition shared_data.h:42
bool fcc_set
User has edited the Fcc: field.
Definition shared_data.h:47
int rc
Return code to leave compose.
Definition shared_data.h:48
struct ComposeAttachData * adata
Attachments.
Definition shared_data.h:40
struct Email * email
Email being composed.
Definition shared_data.h:39
struct Buffer * fcc
Buffer to save FCC.
Definition shared_data.h:45
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition email.h:43
struct Body * body
List of MIME parts.
Definition email.h:69
struct Notify * notify
Notifications: NotifyEmail, EventEmail.
Definition email.h:73
const struct Mapping * help_data
Data for the Help Bar.
void * wdata
Private data.
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
@ MENU_COMPOSE
Compose an email.
Definition type.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_certificate()

int dlg_certificate ( const char * title,
struct StringArray * carr,
bool allow_always,
bool allow_skip )

Ask the user to validate the certificate -.

Parameters
titleMenu title
carrCertificate text to display
allow_alwaysIf true, allow the user to always accept the certificate
allow_skipIf true, allow the user to skip the verification
Return values
1Reject certificate (or menu aborted)
2Accept certificate once
3Accept certificate always/skip (see notes)
4Accept certificate skip

The Verify Certificate Dialog shows a list of signatures for a domain certificate. They can choose whether to accept or reject it.

The possible retvals will depend on the parameters. The options are given in the order: Reject, Once, Always, Skip. The retval represents the chosen option.

Definition at line 168 of file dlg_verifycert.c.

169{
171
172 struct CertMenuData mdata = { carr };
173
174 struct Menu *menu = sdw.menu;
175 menu->mdata = &mdata;
176 menu->mdata_free = NULL; // Menu doesn't own the data
178 menu->max = ARRAY_SIZE(carr);
179
180 sbar_set_title(sdw.sbar, title);
181
182 if (allow_always)
183 {
184 if (allow_skip)
185 {
186 mdata.prompt = _("(r)eject, accept (o)nce, (a)ccept always, (s)kip");
187 /* L10N: The letters correspond to the choices in the string:
188 "(r)eject, accept (o)nce, (a)ccept always, (s)kip"
189 This is an interactive certificate confirmation prompt for an SSL connection. */
190 mdata.keys = _("roas");
191 }
192 else
193 {
194 mdata.prompt = _("(r)eject, accept (o)nce, (a)ccept always");
195 /* L10N: The letters correspond to the choices in the string:
196 "(r)eject, accept (o)nce, (a)ccept always"
197 This is an interactive certificate confirmation prompt for an SSL connection. */
198 mdata.keys = _("roa");
199 }
200 }
201 else
202 {
203 if (allow_skip)
204 {
205 mdata.prompt = _("(r)eject, accept (o)nce, (s)kip");
206 /* L10N: The letters correspond to the choices in the string:
207 "(r)eject, accept (o)nce, (s)kip"
208 This is an interactive certificate confirmation prompt for an SSL connection. */
209 mdata.keys = _("ros");
210 }
211 else
212 {
213 mdata.prompt = _("(r)eject, accept (o)nce");
214 /* L10N: The letters correspond to the choices in the string:
215 "(r)eject, accept (o)nce"
216 This is an interactive certificate confirmation prompt for an SSL connection. */
217 mdata.keys = _("ro");
218 }
219 }
221
222 struct MuttWindow *old_focus = window_set_focus(menu->win);
223 // ---------------------------------------------------------------------------
224 // Event Loop
225 int choice = 0;
226 int op = OP_NULL;
227 do
228 {
229 window_redraw(NULL);
231
232 // Try to catch dialog keys before ops
233 if (menu_dialog_dokey(menu, &op) != 0)
234 {
236 }
237
238 if (op == OP_TIMEOUT)
239 continue;
240
241 // Convert menubar movement to scrolling
243
244 if (op <= OP_MAX)
245 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
246 else
247 mutt_debug(LL_DEBUG1, "Got choice %d\n", op - OP_MAX);
248
249 switch (op)
250 {
251 case OP_ABORT: // Abort: Ctrl-G
252 case OP_QUIT: // Q)uit
253 case OP_MAX + 1: // R)eject
254 choice = 1;
255 break;
256 case OP_MAX + 2: // O)nce
257 choice = 2;
258 break;
259 case OP_MAX + 3: // A)lways / S)kip
260 choice = 3;
261 break;
262 case OP_MAX + 4: // S)kip
263 choice = 4;
264 break;
265
266 case OP_JUMP:
267 case OP_JUMP_1:
268 case OP_JUMP_2:
269 case OP_JUMP_3:
270 case OP_JUMP_4:
271 case OP_JUMP_5:
272 case OP_JUMP_6:
273 case OP_JUMP_7:
274 case OP_JUMP_8:
275 case OP_JUMP_9:
276 mutt_error(_("Jumping is not implemented for dialogs"));
277 continue;
278
279 case OP_SEARCH:
280 case OP_SEARCH_NEXT:
281 case OP_SEARCH_OPPOSITE:
282 case OP_SEARCH_REVERSE:
283 mutt_error(_("Search is not implemented for this menu"));
284 continue;
285 }
286
287 (void) menu_function_dispatcher(menu->win, op);
288 } while (choice == 0);
289 // ---------------------------------------------------------------------------
290
291 window_set_focus(old_focus);
293
294 return choice;
295}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
@ MT_COLOR_PROMPT
Question/user input.
Definition color.h:57
static int menu_dialog_dokey(struct Menu *menu, int *id)
Check if there are any menu key events to process.
static int menu_dialog_translate_op(int op)
Convert menubar movement to scrolling.
static const struct Mapping VerifyHelp[]
Help Bar for the Certificate Verification dialog.
#define mutt_error(...)
Definition logging2.h:93
static int cert_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Create a Certificate for the Menu - Implements Menu::make_entry() -.
#define GETCH_IGNORE_MACRO
Don't use MacroEvents.
Definition lib.h:54
void msgwin_set_text(struct MuttWindow *win, const char *text, enum ColorId color)
Set the text for the Message Window.
Definition msgwin.c:483
@ WT_DLG_CERTIFICATE
Certificate Dialog, dlg_certificate()
Definition mutt_window.h:82
#define OP_TIMEOUT
1 second with no events
Definition opcodes.h:35
#define OP_ABORT
$abort_key pressed (Ctrl-G)
Definition opcodes.h:36
@ OP_MAX
Definition opcodes.h:1003
Certificate data to use in the Menu.
Definition ssl.h:37
char * prompt
Prompt for user, similar to mw_multi_choice.
Definition ssl.h:39
struct StringArray * carr
Lines of the Certificate.
Definition ssl.h:38
int max
Number of entries in the menu.
Definition lib.h:81
@ MENU_DIALOG
Simple Dialog.
Definition type.h:43
@ MENU_GENERIC
Generic selection list.
Definition type.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_history()

void dlg_history ( struct Buffer * buf,
struct StringArray * matches )

Select an item from a history list -.

Parameters
[in]bufBuffer in which to save string
[out]matchesItems to choose from

The History Dialog lets the user select from the history of commands, functions or files.

Definition at line 119 of file dlg_history.c.

120{
122 struct Menu *menu = sdw.menu;
123
124 struct HistoryData hd = { false, false, buf, menu, matches };
125
126 char title[256] = { 0 };
127 snprintf(title, sizeof(title), _("History '%s'"), buf_string(buf));
128 sbar_set_title(sdw.sbar, title);
129
132 menu->mdata = &hd;
133 menu->mdata_free = NULL; // Menu doesn't own the data
134
135 struct MuttWindow *old_focus = window_set_focus(menu->win);
136 // ---------------------------------------------------------------------------
137 // Event Loop
138 int op = OP_NULL;
139 do
140 {
141 menu_tagging_dispatcher(menu->win, op);
142 window_redraw(NULL);
143
145 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
146 if (op < 0)
147 continue;
148 if (op == OP_NULL)
149 {
151 continue;
152 }
154
155 int rc = history_function_dispatcher(sdw.dlg, op);
156 if (rc == FR_UNKNOWN)
157 rc = menu_function_dispatcher(menu->win, op);
158 if (rc == FR_UNKNOWN)
159 rc = global_function_dispatcher(NULL, op);
160 } while (!hd.done);
161 // ---------------------------------------------------------------------------
162
163 window_set_focus(old_focus);
165}
static const struct Mapping HistoryHelp[]
Help Bar for the History Selection dialog.
Definition dlg_history.c:75
int history_function_dispatcher(struct MuttWindow *win, int op)
Perform a History function - Implements function_dispatcher_t -.
Definition functions.c:79
static int history_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format a History Item for the Menu - Implements Menu::make_entry() -.
Definition dlg_history.c:88
@ WT_DLG_HISTORY
History Dialog, dlg_history()
Definition mutt_window.h:86
Data to pass to the History Functions.
Definition functions.h:34
struct Menu * menu
History Menu.
Definition functions.h:38
struct Buffer * buf
Buffer for the results.
Definition functions.h:37
struct StringArray * matches
History entries.
Definition functions.h:39
bool done
Should we close the Dialog?
Definition functions.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_index()

struct Mailbox * dlg_index ( struct MuttWindow * dlg,
struct Mailbox * m_init )

Display a list of emails -.

Parameters
dlgDialog containing Windows to draw on
m_initInitial mailbox
Return values
ptrMailbox open in the index

The Index Dialog is the heart of NeoMutt. From here, the user can read and reply to emails, organise them into folders, set labels, etc.

Definition at line 1099 of file dlg_index.c.

1100{
1101 /* Make sure use_threads/sort/sort_aux are coherent */
1103
1104 struct IndexSharedData *shared = dlg->wdata;
1106
1107 struct MuttWindow *panel_index = window_find_child(dlg, WT_INDEX);
1108
1109 struct IndexPrivateData *priv = panel_index->wdata;
1110 priv->win_index = window_find_child(panel_index, WT_MENU);
1111
1112 int op = OP_NULL;
1113
1114 if (shared->mailbox && (shared->mailbox->type == MUTT_NNTP))
1115 dlg->help_data = IndexNewsHelp;
1116 else
1117 dlg->help_data = IndexHelp;
1118 dlg->help_menu = MENU_INDEX;
1119
1120 priv->menu = priv->win_index->wdata;
1122 priv->menu->color = index_color;
1123 priv->menu->max = shared->mailbox ? shared->mailbox->vcount : 0;
1125
1126 struct MuttWindow *old_focus = window_set_focus(priv->menu->win);
1127 mutt_window_reflow(NULL);
1128
1129 if (!shared->attach_msg)
1130 {
1131 /* force the mailbox check after we enter the folder */
1133 }
1134#ifdef USE_INOTIFY
1135 mutt_monitor_add(NULL);
1136#endif
1137
1138 const bool c_collapse_all = cs_subset_bool(shared->sub, "collapse_all");
1139 if (mutt_using_threads() && c_collapse_all)
1140 {
1141 collapse_all(shared->mailbox_view, priv->menu, 0);
1143 }
1144
1145 int rc = 0;
1146 do
1147 {
1148 /* Clear the tag prefix unless we just started it.
1149 * Don't clear the prefix on a timeout, but do clear on an abort */
1150 if (priv->tag_prefix && (op != OP_TAG_PREFIX) &&
1151 (op != OP_TAG_PREFIX_COND) && (op != OP_TIMEOUT))
1152 {
1153 priv->tag_prefix = false;
1154 }
1155
1156 /* check if we need to resort the index because just about
1157 * any 'op' below could do mutt_enter_command(), either here or
1158 * from any new priv->menu launched, and change $sort/$sort_aux */
1159 if (OptNeedResort && shared->mailbox && (shared->mailbox->msg_count != 0) &&
1160 (menu_get_index(priv->menu) >= 0))
1161 {
1162 resort_index(shared->mailbox_view, priv->menu);
1163 }
1164
1165 priv->menu->max = shared->mailbox ? shared->mailbox->vcount : 0;
1166 priv->oldcount = shared->mailbox ? shared->mailbox->msg_count : 0;
1167
1168 if (shared->mailbox && shared->mailbox_view)
1169 {
1171
1172 shared->mailbox_view->menu = priv->menu;
1173 /* check for new mail in the mailbox. If nonzero, then something has
1174 * changed about the file (either we got new mail or the file was
1175 * modified underneath us.) */
1176 enum MxStatus check = mx_mbox_check(shared->mailbox);
1177
1178 if (check == MX_STATUS_ERROR)
1179 {
1180 if (buf_is_empty(&shared->mailbox->pathbuf))
1181 {
1182 /* fatal error occurred */
1183 mview_free(&shared->mailbox_view);
1185 }
1186
1188 }
1189 else if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED) ||
1190 (check == MX_STATUS_FLAGS))
1191 {
1192 /* notify the user of new mail */
1193 if (check == MX_STATUS_REOPENED)
1194 {
1195 mutt_error(_("Mailbox was externally modified. Flags may be wrong."));
1196 }
1197 else if (check == MX_STATUS_NEW_MAIL)
1198 {
1199 for (size_t i = 0; i < shared->mailbox->msg_count; i++)
1200 {
1201 const struct Email *e = shared->mailbox->emails[i];
1202 if (e && !e->read && !e->old)
1203 {
1204 mutt_message(_("New mail in this mailbox"));
1205 const bool c_beep_new = cs_subset_bool(shared->sub, "beep_new");
1206 if (c_beep_new)
1207 mutt_beep(true);
1208 const struct Expando *c_new_mail_command =
1209 cs_subset_expando(shared->sub, "new_mail_command");
1210 if (c_new_mail_command)
1211 {
1212 struct Buffer *cmd = buf_pool_get();
1213 menu_status_line(cmd, shared, NULL, -1, c_new_mail_command);
1214 if (mutt_system(buf_string(cmd)) != 0)
1215 mutt_error(_("Error running \"%s\""), buf_string(cmd));
1216 buf_pool_release(&cmd);
1217 }
1218 break;
1219 }
1220 }
1221 }
1222 else if (check == MX_STATUS_FLAGS)
1223 {
1224 mutt_message(_("Mailbox was externally modified"));
1225 }
1226
1227 /* avoid the message being overwritten by mailbox */
1228 priv->do_mailbox_notify = false;
1229
1230 bool verbose = shared->mailbox->verbose;
1231 shared->mailbox->verbose = false;
1232 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
1233 shared->mailbox->verbose = verbose;
1234 priv->menu->max = shared->mailbox->vcount;
1237 }
1238
1240 menu_get_index(priv->menu)));
1241 }
1242
1243 if (!shared->attach_msg)
1244 {
1245 /* check for new mail in the incoming folders */
1247 if (priv->do_mailbox_notify)
1248 {
1249 if (mutt_mailbox_notify(shared->mailbox))
1250 {
1251 const bool c_beep_new = cs_subset_bool(shared->sub, "beep_new");
1252 if (c_beep_new)
1253 mutt_beep(true);
1254 const struct Expando *c_new_mail_command = cs_subset_expando(shared->sub, "new_mail_command");
1255 if (c_new_mail_command)
1256 {
1257 struct Buffer *cmd = buf_pool_get();
1258 menu_status_line(cmd, shared, priv->menu, -1, c_new_mail_command);
1259 if (mutt_system(buf_string(cmd)) != 0)
1260 mutt_error(_("Error running \"%s\""), buf_string(cmd));
1261 buf_pool_release(&cmd);
1262 }
1263 }
1264 }
1265 else
1266 {
1267 priv->do_mailbox_notify = true;
1268 }
1269 }
1270
1271 window_redraw(NULL);
1272
1273 /* give visual indication that the next command is a tag- command */
1274 if (priv->tag_prefix)
1275 {
1276 msgwin_set_text(NULL, "tag-", MT_COLOR_NORMAL);
1277 }
1278
1279 const bool c_arrow_cursor = cs_subset_bool(shared->sub, "arrow_cursor");
1280 const bool c_braille_friendly = cs_subset_bool(shared->sub, "braille_friendly");
1281 const int index = menu_get_index(priv->menu);
1282 if (c_arrow_cursor)
1283 {
1284 const char *const c_arrow_string = cs_subset_string(shared->sub, "arrow_string");
1285 const int arrow_width = mutt_strwidth(c_arrow_string);
1286 mutt_window_move(priv->menu->win, index - priv->menu->top, arrow_width);
1287 }
1288 else if (c_braille_friendly)
1289 {
1290 mutt_window_move(priv->menu->win, index - priv->menu->top, 0);
1291 }
1292 else
1293 {
1294 mutt_window_move(priv->menu->win, index - priv->menu->top,
1295 priv->menu->win->state.cols - 1);
1296 }
1297 mutt_refresh();
1298
1299 window_redraw(NULL);
1301
1302 if (op == OP_REPAINT)
1303 {
1304 /* force a real complete redraw. clrtobot() doesn't seem to be able
1305 * to handle every case without this. */
1306 msgwin_clear_text(NULL);
1307 mutt_refresh();
1308 continue;
1309 }
1310
1311 /* either user abort or timeout */
1312 if (op < OP_NULL)
1313 {
1314 if (priv->tag_prefix)
1315 msgwin_clear_text(NULL);
1316 continue;
1317 }
1318
1319 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
1320
1321 /* special handling for the priv->tag-prefix function */
1322 const bool c_auto_tag = cs_subset_bool(shared->sub, "auto_tag");
1323 if ((op == OP_TAG_PREFIX) || (op == OP_TAG_PREFIX_COND))
1324 {
1325 /* A second priv->tag-prefix command aborts */
1326 if (priv->tag_prefix)
1327 {
1328 priv->tag_prefix = false;
1329 msgwin_clear_text(NULL);
1330 continue;
1331 }
1332
1333 if (!shared->mailbox)
1334 {
1335 mutt_error(_("No mailbox is open"));
1336 continue;
1337 }
1338
1339 if (shared->mailbox->msg_tagged == 0)
1340 {
1341 if (op == OP_TAG_PREFIX)
1342 {
1343 mutt_error(_("No tagged messages"));
1344 }
1345 else if (op == OP_TAG_PREFIX_COND)
1346 {
1348 mutt_message(_("Nothing to do"));
1349 }
1350 continue;
1351 }
1352
1353 /* get the real command */
1354 priv->tag_prefix = true;
1355 continue;
1356 }
1357 else if (c_auto_tag && shared->mailbox && (shared->mailbox->msg_tagged != 0))
1358 {
1359 priv->tag_prefix = true;
1360 }
1361
1363
1364 OptNews = false; /* for any case */
1365
1366#ifdef USE_NOTMUCH
1367 nm_db_debug_check(shared->mailbox);
1368#endif
1369
1370 rc = index_function_dispatcher(priv->win_index, op);
1371
1372 if (rc == FR_UNKNOWN)
1373 rc = menu_function_dispatcher(priv->win_index, op);
1374
1375 if (rc == FR_UNKNOWN)
1376 {
1377 struct MuttWindow *win_sidebar = window_find_child(dlg, WT_SIDEBAR);
1378 rc = sb_function_dispatcher(win_sidebar, op);
1379 }
1380 if (rc == FR_UNKNOWN)
1381 rc = global_function_dispatcher(NULL, op);
1382
1383 if (rc == FR_UNKNOWN)
1385
1386#ifdef USE_NOTMUCH
1387 nm_db_debug_check(shared->mailbox);
1388#endif
1389 } while (rc != FR_DONE);
1390
1391 mview_free(&shared->mailbox_view);
1392 window_set_focus(old_focus);
1393
1394 return shared->mailbox;
1395}
@ MT_COLOR_NORMAL
Plain text.
Definition color.h:54
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition compile.c:774
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
void mailbox_gc_run(void)
Run the garbage-collection.
Definition mailbox.c:312
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition mailbox.h:49
void mutt_refresh(void)
Force a refresh of the screen.
Definition curs_lib.c:79
void mutt_beep(bool force)
Irritate the user.
Definition curs_lib.c:69
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition curs_lib.c:445
const struct Mapping IndexNewsHelp[]
Help Bar for the News Index dialog.
Definition dlg_index.c:116
void update_index(struct Menu *menu, struct MailboxView *mv, enum MxStatus check, int oldcount, const struct IndexSharedData *shared)
Update the index.
Definition dlg_index.c:541
int find_first_message(struct MailboxView *mv)
Get index of first new message.
Definition dlg_index.c:308
static const struct Mapping IndexHelp[]
Help Bar for the Index dialog.
Definition dlg_index.c:101
void resort_index(struct MailboxView *mv, struct Menu *menu)
Resort the index.
Definition dlg_index.c:368
void collapse_all(struct MailboxView *mv, struct Menu *menu, int toggle)
Collapse/uncollapse all threads.
Definition dlg_index.c:164
bool OptNeedResort
(pseudo) used to force a re-sort
Definition globals.c:63
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition get.c:166
int sb_function_dispatcher(struct MuttWindow *win, int op)
Perform a Sidebar function - Implements function_dispatcher_t -.
Definition functions.c:375
int index_function_dispatcher(struct MuttWindow *win, int op)
Perform an Index function - Implements function_dispatcher_t -.
Definition functions.c:3265
#define mutt_message(...)
Definition logging2.h:92
const struct AttrColor * index_color(struct Menu *menu, int line)
Calculate the colour for a line of the index - Implements Menu::color() -.
Definition dlg_index.c:926
int index_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Email for the Menu - Implements Menu::make_entry() -.
Definition dlg_index.c:825
void index_shared_data_set_email(struct IndexSharedData *shared, struct Email *e)
Set the current Email for the Index and friends.
void index_shared_data_set_mview(struct IndexSharedData *shared, struct MailboxView *mv)
Set the MailboxView for the Index and friends.
void index_adjust_sort_threads(const struct ConfigSubset *sub)
Adjust use_threads/sort/sort_aux.
Definition index.c:184
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:59
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:184
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:160
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:174
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition monitor.c:484
void msgwin_clear_text(struct MuttWindow *win)
Clear the text in the Message Window.
Definition msgwin.c:518
int mutt_mailbox_check(struct Mailbox *m_cur, CheckStatsFlags flags)
Check all all Mailboxes for new mail.
bool mutt_mailbox_notify(struct Mailbox *m_cur)
Notify the user if there's new mail.
#define mutt_using_threads()
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
@ WT_INDEX
A panel containing the Index Window.
Definition mutt_window.h:97
@ WT_SIDEBAR
Side panel containing Accounts or groups of data.
@ WT_MENU
An Window containing a Menu.
Definition mutt_window.h:98
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition mview.c:417
void mview_free(struct MailboxView **ptr)
Free a MailboxView.
Definition mview.c:49
struct MailboxView * mview_new(struct Mailbox *m, struct Notify *parent)
Create a new MailboxView.
Definition mview.c:90
enum MxStatus mx_mbox_check(struct Mailbox *m)
Check for new mail - Wrapper for MxOps::mbox_check()
Definition mx.c:1110
#define MUTT_MAILBOX_CHECK_NO_FLAGS
No flags are set.
Definition mxapi.h:50
#define MUTT_MAILBOX_CHECK_POSTPONED
Make sure the number of postponed messages is updated.
Definition mxapi.h:51
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close()
Definition mxapi.h:60
@ MX_STATUS_ERROR
An error occurred.
Definition mxapi.h:61
@ MX_STATUS_FLAGS
Nondestructive flags change (IMAP)
Definition mxapi.h:66
@ MX_STATUS_REOPENED
Mailbox was reopened.
Definition mxapi.h:65
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition mxapi.h:63
void nm_db_debug_check(struct Mailbox *m)
Check if the database is open.
Definition db.c:397
#define OP_REPAINT
Repaint is needed.
Definition opcodes.h:34
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
void menu_status_line(struct Buffer *buf, struct IndexSharedData *shared, struct Menu *menu, int max_cols, const struct Expando *exp)
Create the status line.
Definition status.c:51
String manipulation buffer.
Definition buffer.h:36
The envelope/body of an email.
Definition email.h:39
bool read
Email is read.
Definition email.h:50
bool old
Email is seen, but unread.
Definition email.h:49
Parsed Expando trees.
Definition expando.h:41
Private state data for the Index.
struct MuttWindow * win_index
Window for the Index.
struct IndexSharedData * shared
Shared Index data.
bool tag_prefix
tag-prefix has been pressed
bool do_mailbox_notify
Do we need to notify the user of new mail?
struct Menu * menu
Menu controlling the index.
int oldcount
Old count of mails in the mailbox.
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:41
bool attach_msg
Are we in "attach message" mode?
Definition shared_data.h:46
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:38
struct MailboxView * mailbox_view
Current Mailbox view.
Definition shared_data.h:40
struct SearchState * search_state
State of the current search.
Definition shared_data.h:45
struct Menu * menu
Needed for pattern compilation.
Definition mview.h:47
int vcount
The number of virtual messages.
Definition mailbox.h:99
int msg_count
Total number of messages.
Definition mailbox.h:88
enum MailboxType type
Mailbox type.
Definition mailbox.h:102
struct Email ** emails
Array of Emails.
Definition mailbox.h:96
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:80
int msg_tagged
How many messages are tagged?
Definition mailbox.h:94
bool verbose
Display status messages?
Definition mailbox.h:117
const struct AttrColor *(* color)(struct Menu *menu, int line)
Definition lib.h:143
int top
Entry that is the top of the current page.
Definition lib.h:90
struct WindowState state
Current state of the Window.
struct PatternList * pattern
compiled search pattern
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
@ MENU_INDEX
Index panel (list of emails)
Definition type.h:46
+ Here is the caller graph for this function:

◆ dlg_gpgme()

struct CryptKeyInfo * dlg_gpgme ( struct CryptKeyInfo * keys,
struct Address * p,
const char * s,
unsigned int app,
bool * forced_valid )

Get the user to select a key -.

Parameters
[in]keysList of keys to select from
[in]pAddress to match
[in]sReal name to display
[in]appFlags, e.g. APPLICATION_PGP
[out]forced_validSet to true if user overrode key's validity
Return values
ptrKey selected by user

The Select GPGME Key Dialog lets the user select a PGP Key to use.

Definition at line 194 of file dlg_gpgme.c.

196{
197 /* build the key table */
198 struct CryptKeyInfoArray ckia = ARRAY_HEAD_INITIALIZER;
199 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
200 bool unusable = false;
201 for (struct CryptKeyInfo *k = keys; k; k = k->next)
202 {
203 if (!c_pgp_show_unusable && (k->flags & KEYFLAG_CANTUSE))
204 {
205 unusable = true;
206 continue;
207 }
208
209 ARRAY_ADD(&ckia, k);
210 }
211
212 if ((ARRAY_SIZE(&ckia) == 0) && unusable)
213 {
214 mutt_error(_("All matching keys are marked expired/revoked"));
215 return NULL;
216 }
217
218 gpgme_sort_keys(&ckia);
219
220 enum MenuType menu_to_use = MENU_GENERIC;
221 if (app & APPLICATION_PGP)
222 menu_to_use = MENU_PGP;
223 else if (app & APPLICATION_SMIME)
224 menu_to_use = MENU_SMIME;
225
227
228 struct Menu *menu = sdw.menu;
229 struct GpgmeData gd = { false, menu, &ckia, NULL, forced_valid };
230
231 menu->max = ARRAY_SIZE(&ckia);
233 menu->mdata = &gd;
234 menu->mdata_free = NULL; // Menu doesn't own the data
235
236 // NT_COLOR is handled by the SimpleDialog
239
240 const char *ts = NULL;
241
242 if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
243 ts = _("PGP and S/MIME keys matching");
244 else if ((app & APPLICATION_PGP))
245 ts = _("PGP keys matching");
246 else if ((app & APPLICATION_SMIME))
247 ts = _("S/MIME keys matching");
248 else
249 ts = _("keys matching");
250
251 char buf[1024] = { 0 };
252 if (p)
253 {
254 /* L10N: 1$s is one of the previous four entries.
255 %2$s is an address.
256 e.g. "S/MIME keys matching <john.doe@example.com>" */
257 snprintf(buf, sizeof(buf), _("%s <%s>"), ts, buf_string(p->mailbox));
258 }
259 else
260 {
261 /* L10N: e.g. 'S/MIME keys matching "John Doe".' */
262 snprintf(buf, sizeof(buf), _("%s \"%s\""), ts, s);
263 }
264
265 sbar_set_title(sdw.sbar, buf);
266
268
269 struct MuttWindow *old_focus = window_set_focus(menu->win);
270 // ---------------------------------------------------------------------------
271 // Event Loop
272 int op = OP_NULL;
273 do
274 {
275 menu_tagging_dispatcher(menu->win, op);
276 window_redraw(NULL);
277
278 op = km_dokey(menu_to_use, GETCH_NO_FLAGS);
279 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
280 if (op < 0)
281 continue;
282 if (op == OP_NULL)
283 {
284 km_error_key(menu_to_use);
285 continue;
286 }
288
289 int rc = gpgme_function_dispatcher(sdw.dlg, op);
290
291 if (rc == FR_UNKNOWN)
292 rc = menu_function_dispatcher(menu->win, op);
293 if (rc == FR_UNKNOWN)
294 rc = global_function_dispatcher(NULL, op);
295 } while (!gd.done);
296 // ---------------------------------------------------------------------------
297
298 ARRAY_FREE(&ckia);
299 window_set_focus(old_focus);
301 return gd.key;
302}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:156
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:204
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
static const struct Mapping GpgmeHelp[]
Help Bar for the GPGME key selection dialog.
Definition dlg_gpgme.c:91
int gpgme_function_dispatcher(struct MuttWindow *win, int op)
Perform a Gpgme function - Implements function_dispatcher_t -.
static int crypt_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format a PGP Key for the Menu - Implements Menu::make_entry() -.
Definition dlg_gpgme.c:106
static int gpgme_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition dlg_gpgme.c:131
static int gpgme_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition dlg_gpgme.c:160
@ WT_DLG_GPGME
GPGME Dialog, dlg_gpgme()
Definition mutt_window.h:84
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:96
#define KEYFLAG_CANTUSE
Definition lib.h:145
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition lib.h:97
void gpgme_sort_keys(struct CryptKeyInfoArray *ckia)
Sort an array of GPGME keys.
Definition sort_gpgme.c:175
struct Buffer * mailbox
Mailbox and host address.
Definition address.h:37
A stored PGP key.
Definition crypt_gpgme.h:44
struct CryptKeyInfo * next
Linked list.
Definition crypt_gpgme.h:45
Data to pass to the Gpgme Functions.
bool * forced_valid
User insists on out-of-date key.
struct CryptKeyInfo * key
Selected Key.
bool done
Should we close the Dialog?
struct Menu * menu
Gpgme Menu.
MenuType
Types of GUI selections.
Definition type.h:35
@ MENU_PGP
PGP encryption menu.
Definition type.h:48
@ MENU_SMIME
SMIME encryption menu.
Definition type.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_pgp()

struct PgpKeyInfo * dlg_pgp ( struct PgpKeyInfo * keys,
struct Address * p,
const char * s )

Let the user select a key to use -.

Parameters
keysList of PGP keys
pAddress to match
sString to match
Return values
ptrSelected PGP key

The Select PGP Key Dialog lets the user select an PGP Key to use.

Definition at line 191 of file dlg_pgp.c.

192{
193 struct Menu *menu = NULL;
194 char buf[1024] = { 0 };
195 bool unusable = false;
196 struct PgpUidArray pua = ARRAY_HEAD_INITIALIZER;
197
198 const bool c_pgp_show_unusable = cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
199 for (struct PgpKeyInfo *kp = keys; kp; kp = kp->next)
200 {
201 if (!c_pgp_show_unusable && (kp->flags & KEYFLAG_CANTUSE))
202 {
203 unusable = true;
204 continue;
205 }
206
207 for (struct PgpUid *a = kp->address; a; a = a->next)
208 {
209 if (!c_pgp_show_unusable && (a->flags & KEYFLAG_CANTUSE))
210 {
211 unusable = true;
212 continue;
213 }
214
215 ARRAY_ADD(&pua, a);
216 }
217 }
218
219 if ((ARRAY_SIZE(&pua) == 0) && unusable)
220 {
221 mutt_error(_("All matching keys are expired, revoked, or disabled"));
222 return NULL;
223 }
224
225 pgp_sort_keys(&pua);
226
228 menu = sdw.menu;
229 struct PgpData pd = { false, menu, &pua, NULL };
230
231 menu->max = ARRAY_SIZE(&pua);
233 menu->mdata = &pd;
234 menu->mdata_free = NULL; // Menu doesn't own the data
235
236 // NT_COLOR is handled by the SimpleDialog
239
240 if (p)
241 snprintf(buf, sizeof(buf), _("PGP keys matching <%s>"), buf_string(p->mailbox));
242 else
243 snprintf(buf, sizeof(buf), _("PGP keys matching \"%s\""), s);
244
245 sbar_set_title(sdw.sbar, buf);
246
248
249 struct MuttWindow *old_focus = window_set_focus(menu->win);
250 // ---------------------------------------------------------------------------
251 // Event Loop
252 int op = OP_NULL;
253 do
254 {
255 menu_tagging_dispatcher(menu->win, op);
256 window_redraw(NULL);
257
259 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
260 if (op < 0)
261 continue;
262 if (op == OP_NULL)
263 {
265 continue;
266 }
268
269 int rc = pgp_function_dispatcher(sdw.dlg, op);
270
271 if (rc == FR_UNKNOWN)
272 rc = menu_function_dispatcher(menu->win, op);
273 if (rc == FR_UNKNOWN)
274 rc = global_function_dispatcher(NULL, op);
275 } while (!pd.done);
276 // ---------------------------------------------------------------------------
277
278 ARRAY_FREE(&pua);
279 window_set_focus(old_focus);
281 return pd.key;
282}
static const struct Mapping PgpHelp[]
Help Bar for the PGP key selection dialog.
Definition dlg_pgp.c:90
int pgp_function_dispatcher(struct MuttWindow *win, int op)
Perform a Pgp function - Implements function_dispatcher_t -.
static int pgp_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format a PGP Key for the Menu - Implements Menu::make_entry() -.
Definition dlg_pgp.c:105
static int pgp_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition dlg_pgp.c:159
static int pgp_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition dlg_pgp.c:130
@ WT_DLG_PGP
Pgp Dialog, dlg_pgp()
Definition mutt_window.h:89
void pgp_sort_keys(struct PgpUidArray *pua)
Sort an array of PGP keys.
Definition sort_pgp.c:142
Data to pass to the Pgp Functions.
struct Menu * menu
Pgp Menu.
bool done
Should we close the Dialog?
struct PgpKeyInfo * key
Selected Key.
Information about a PGP key.
Definition pgplib.h:49
struct PgpKeyInfo * next
Definition pgplib.h:59
PGP User ID.
Definition pgplib.h:36
struct PgpUid * next
Linked list.
Definition pgplib.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_smime()

struct SmimeKey * dlg_smime ( struct SmimeKey * keys,
const char * query )

Get the user to select a key -.

Parameters
keysList of keys to select from
queryString to match
Return values
ptrKey selected by user

The Select SMIME Key Dialog lets the user select an SMIME Key to use.

Definition at line 194 of file dlg_smime.c.

195{
196 struct SmimeKeyArray ska = ARRAY_HEAD_INITIALIZER;
197 for (struct SmimeKey *key = keys; key; key = key->next)
198 {
199 ARRAY_ADD(&ska, key);
200 }
201 /* sorting keys might be done later - TODO */
202
204 struct Menu *menu = sdw.menu;
205
206 struct SmimeData sd = { false, menu, &ska, NULL };
207
208 menu->max = ARRAY_SIZE(&ska);
210 menu->mdata = &sd;
211 menu->mdata_free = NULL; // Menu doesn't own the data
212
213 char title[256] = { 0 };
214 snprintf(title, sizeof(title), _("S/MIME certificates matching \"%s\""), query);
215 sbar_set_title(sdw.sbar, title);
216
218
219 struct MuttWindow *old_focus = window_set_focus(menu->win);
220 // ---------------------------------------------------------------------------
221 // Event Loop
222 int op = OP_NULL;
223 do
224 {
225 menu_tagging_dispatcher(menu->win, op);
226 window_redraw(NULL);
227
229 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
230 if (op < 0)
231 continue;
232 if (op == OP_NULL)
233 {
235 continue;
236 }
238
239 int rc = smime_function_dispatcher(sdw.dlg, op);
240
241 if (rc == FR_UNKNOWN)
242 rc = menu_function_dispatcher(menu->win, op);
243 if (rc == FR_UNKNOWN)
244 rc = global_function_dispatcher(NULL, op);
245 } while (!sd.done);
246
247 window_set_focus(old_focus);
249 return sd.key;
250}
static const struct Mapping SmimeHelp[]
Help Bar for the Smime key selection dialog.
Definition dlg_smime.c:72
int smime_function_dispatcher(struct MuttWindow *win, int op)
Perform a Smime function - Implements function_dispatcher_t -.
static int smime_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an S/MIME Key for the Menu - Implements Menu::make_entry() -.
Definition dlg_smime.c:110
@ WT_DLG_SMIME
Smime Dialog, dlg_smime()
Definition mutt_window.h:92
Data to pass to the Smime Functions.
struct SmimeKey * key
Selected Key.
bool done
Should we close the Dialog?
struct Menu * menu
Smime Menu.
struct SmimeKeyArray * ska
Array of Keys.
An SIME key.
Definition smime.h:43
struct SmimeKey * next
Definition smime.h:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_pager()

int dlg_pager ( struct PagerView * pview)

Display an email, attachment, or help, in a window -.

Parameters
pviewPager view settings
Return values
0Success
-1Error

The Pager Dialog displays an Email to the user.

They can navigate through the Email, search through it and user color commands to highlight it.

From the Pager, the user can also use some Index functions, such as <next-entry> or <delete>.

This pager is actually not so simple as it once was. But it will be again. Currently it operates in 3 modes:

  • viewing messages. (PAGER_MODE_EMAIL)
  • viewing attachments. (PAGER_MODE_ATTACH)
  • viewing other stuff (e.g. help). (PAGER_MODE_OTHER) These can be distinguished by PagerMode in PagerView. Data is not yet polymorphic and is fused into a single struct (PagerData). Different elements of PagerData are expected to be present depending on the mode:
  • PAGER_MODE_EMAIL expects data->email and not expects data->body
  • PAGER_MODE_ATTACH expects data->email and data->body special sub-case of this mode is viewing attached email message it is recognized by presence of data->fp and data->body->email
  • PAGER_MODE_OTHER does not expect data->email or data->body

Definition at line 218 of file dlg_pager.c.

219{
220 //===========================================================================
221 // ACT 1 - Ensure sanity of the caller and determine the mode
222 //===========================================================================
223 ASSERT(pview);
224 ASSERT((pview->mode > PAGER_MODE_UNKNOWN) && (pview->mode < PAGER_MODE_MAX));
225 ASSERT(pview->pdata); // view can't exist in a vacuum
226 ASSERT(pview->win_pager);
227 ASSERT(pview->win_pbar);
228
229 struct MuttWindow *dlg = dialog_find(pview->win_pager);
230 struct IndexSharedData *shared = dlg->wdata;
231 struct MuttWindow *win_sidebar = window_find_child(dlg, WT_SIDEBAR);
232
233 switch (pview->mode)
234 {
235 case PAGER_MODE_EMAIL:
236 // This case was previously identified by IsEmail macro
237 // we expect data to contain email and not contain body
238 // We also expect email to always belong to some mailbox
239 ASSERT(shared->mailbox_view);
240 ASSERT(shared->mailbox);
241 ASSERT(shared->email);
242 ASSERT(!pview->pdata->body);
243 break;
244
246 // this case was previously identified by IsAttach and IsMsgAttach
247 // macros, we expect data to contain:
248 // - body (viewing regular attachment)
249 // - fp and body->email in special case of viewing an attached email.
250 ASSERT(pview->pdata->body);
251 if (pview->pdata->fp && pview->pdata->body->email)
252 {
253 // Special case: attachment is a full-blown email message.
254 // Yes, emails can contain other emails.
255 pview->mode = PAGER_MODE_ATTACH_E;
256 }
257 break;
258
259 case PAGER_MODE_HELP:
260 case PAGER_MODE_OTHER:
261 ASSERT(!shared->mailbox_view);
262 ASSERT(!shared->email);
263 ASSERT(!pview->pdata->body);
264 break;
265
267 case PAGER_MODE_MAX:
268 default:
269 // Unexpected mode. Catch fire and explode.
270 // This *should* happen if mode is PAGER_MODE_ATTACH_E, since
271 // we do not expect any caller to pass it to us.
272 ASSERT(false);
273 break;
274 }
275
276 //===========================================================================
277 // ACT 2 - Declare, initialize local variables, read config, etc.
278 //===========================================================================
279
280 //---------- local variables ------------------------------------------------
281 int op = 0;
282 enum MailboxType mailbox_type = shared->mailbox ? shared->mailbox->type : MUTT_UNKNOWN;
283 struct PagerPrivateData *priv = pview->win_pager->parent->wdata;
284 priv->rc = -1;
285 priv->searchctx = 0;
286 priv->first = true;
287 priv->wrapped = false;
288 priv->delay_read_timestamp = 0;
289 priv->pager_redraw = false;
290
291 // Wipe any previous state info
292 struct Notify *notify = priv->notify;
293 int prc = priv->rc;
294 memset(priv, 0, sizeof(*priv));
295 priv->rc = prc;
296 priv->notify = notify;
297 TAILQ_INIT(&priv->ansi_list);
298
299 //---------- setup flags ----------------------------------------------------
300 if (!(pview->flags & MUTT_SHOWCOLOR))
301 pview->flags |= MUTT_SHOWFLAT;
302
303 if ((pview->mode == PAGER_MODE_EMAIL) && !shared->email->read)
304 {
305 if (shared->mailbox_view)
306 shared->mailbox_view->msg_in_pager = shared->email->msgno;
307 const short c_pager_read_delay = cs_subset_number(NeoMutt->sub, "pager_read_delay");
308 if (c_pager_read_delay == 0)
309 {
310 mutt_set_flag(shared->mailbox, shared->email, MUTT_READ, true, true);
311 }
312 else
313 {
314 priv->delay_read_timestamp = mutt_date_now_ms() + (1000 * c_pager_read_delay);
315 }
316 }
317 //---------- setup help menu ------------------------------------------------
318 pview->win_pager->help_data = pager_resolve_help_mapping(pview->mode, mailbox_type);
320
321 //---------- initialize redraw pdata -----------------------------------------
323 priv->lines_max = LINES; // number of lines on screen, from curses
324 priv->lines = MUTT_MEM_CALLOC(priv->lines_max, struct Line);
325 priv->fp = mutt_file_fopen(pview->pdata->fname, "r");
326 priv->has_types = ((pview->mode == PAGER_MODE_EMAIL) || (pview->flags & MUTT_SHOWCOLOR)) ?
327 MUTT_TYPES :
328 0; // main message or rfc822 attachment
329
330 for (size_t i = 0; i < priv->lines_max; i++)
331 {
332 priv->lines[i].cid = -1;
333 priv->lines[i].search_arr_size = -1;
334 priv->lines[i].syntax = MUTT_MEM_CALLOC(1, struct TextSyntax);
335 (priv->lines[i].syntax)[0].first = -1;
336 (priv->lines[i].syntax)[0].last = -1;
337 }
338
339 // ---------- try to open the pdata file -------------------------------------
340 if (!priv->fp)
341 {
342 mutt_perror("%s", pview->pdata->fname);
343 return -1;
344 }
345
346 if (stat(pview->pdata->fname, &priv->st) != 0)
347 {
348 mutt_perror("%s", pview->pdata->fname);
349 mutt_file_fclose(&priv->fp);
350 return -1;
351 }
352 unlink(pview->pdata->fname);
353 priv->pview = pview;
354
355 //---------- show windows, set focus and visibility --------------------------
356 window_set_visible(pview->win_pager->parent, true);
359
360 struct MuttWindow *old_focus = window_set_focus(pview->win_pager);
361
362 //---------- jump to the bottom if requested ------------------------------
363 if (pview->flags & MUTT_PAGER_BOTTOM)
364 {
365 jump_to_bottom(priv, pview);
366 }
367
368 //-------------------------------------------------------------------------
369 // ACT 3: Read user input and decide what to do with it
370 // ...but also do a whole lot of other things.
371 //-------------------------------------------------------------------------
372
373 // Force an initial paint, which will populate priv->lines
375 window_redraw(NULL);
376
378 do
379 {
380 window_redraw(NULL);
381
382 const bool c_braille_friendly = cs_subset_bool(NeoMutt->sub, "braille_friendly");
383 if (c_braille_friendly)
384 {
385 if (BrailleRow != -1)
386 {
388 BrailleRow = -1;
389 }
390 }
391 else
392 {
393 mutt_window_move(priv->pview->win_pbar, 0, priv->pview->win_pager->state.cols - 1);
394 }
395
396 // force redraw of the screen at every iteration of the event loop
397 mutt_refresh();
398
399 //-------------------------------------------------------------------------
400 // Check if information in the status bar needs an update
401 // This is done because pager is a single-threaded application, which
402 // tries to emulate concurrency.
403 //-------------------------------------------------------------------------
404 bool do_new_mail = false;
405 if (shared->mailbox && !shared->attach_msg)
406 {
407 int oldcount = shared->mailbox->msg_count;
408 /* check for new mail */
409 enum MxStatus check = mx_mbox_check(shared->mailbox);
410 if (check == MX_STATUS_ERROR)
411 {
412 if (!shared->mailbox || buf_is_empty(&shared->mailbox->pathbuf))
413 {
414 /* fatal error occurred */
416 break;
417 }
418 }
419 else if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED) ||
420 (check == MX_STATUS_FLAGS))
421 {
422 /* notify user of newly arrived mail */
423 if (check == MX_STATUS_NEW_MAIL)
424 {
425 for (size_t i = oldcount; i < shared->mailbox->msg_count; i++)
426 {
427 struct Email *e = shared->mailbox->emails[i];
428
429 if (e && !e->read)
430 {
431 mutt_message(_("New mail in this mailbox"));
432 do_new_mail = true;
433 break;
434 }
435 }
436 }
437
438 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
439 {
442 }
443 }
444
445 if (mutt_mailbox_notify(shared->mailbox) || do_new_mail)
446 {
447 const bool c_beep_new = cs_subset_bool(NeoMutt->sub, "beep_new");
448 if (c_beep_new)
449 mutt_beep(true);
450 const struct Expando *c_new_mail_command = cs_subset_expando(NeoMutt->sub, "new_mail_command");
451 if (c_new_mail_command)
452 {
453 struct Buffer *cmd = buf_pool_get();
454 menu_status_line(cmd, shared, NULL, -1, c_new_mail_command);
455 if (mutt_system(buf_string(cmd)) != 0)
456 mutt_error(_("Error running \"%s\""), buf_string(cmd));
457 buf_pool_release(&cmd);
458 }
459 }
460 }
461 //-------------------------------------------------------------------------
462
463 if (priv->pager_redraw)
464 {
465 priv->pager_redraw = false;
467 clearok(stdscr, true); /* force complete redraw */
468 msgwin_clear_text(NULL);
469
471
472 /* note: mutt_resize_screen() -> mutt_window_reflow() sets
473 * PAGER_REDRAW_PAGER and PAGER_REDRAW_FLOW */
474 continue;
475 }
476
477 dump_pager(priv);
478
479 //-------------------------------------------------------------------------
480 // Finally, read user's key press
481 //-------------------------------------------------------------------------
482 // km_dokey() reads not only user's key strokes, but also a MacroBuffer
483 // MacroBuffer may contain OP codes of the operations.
484 // MacroBuffer is global
485 // OP codes inserted into the MacroBuffer by various functions.
486 // One of such functions is `mutt_enter_command()`
487 // Some OP codes are not handled by pager, they cause pager to quit returning
488 // OP code to index. Index handles the operation and then restarts pager
490
491 // km_dokey() can block, so recheck the timer.
492 // Note: This check must occur before handling the operations of the index
493 // as those can change the currently selected message/entry yielding to
494 // marking the wrong message as read.
496 {
497 mutt_set_flag(shared->mailbox, shared->email, MUTT_READ, true, true);
498 }
499
500 if (SigWinch)
501 priv->pager_redraw = true;
502
503 if (op >= OP_NULL)
505
506 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
507
508 if (op < OP_NULL)
509 continue;
510
511 if (op == OP_NULL)
512 {
514 continue;
515 }
516
517 int rc = pager_function_dispatcher(priv->pview->win_pager, op);
518
519 if (pview->mode == PAGER_MODE_EMAIL)
520 {
521 if ((rc == FR_UNKNOWN) && priv->pview->win_index)
523 if (rc == FR_UNKNOWN)
524 rc = sb_function_dispatcher(win_sidebar, op);
525 }
526 if (rc == FR_UNKNOWN)
527 rc = global_function_dispatcher(NULL, op);
528
529 if ((rc == FR_UNKNOWN) &&
530 ((pview->mode == PAGER_MODE_ATTACH) || (pview->mode == PAGER_MODE_ATTACH_E)))
531 {
532 // Some attachment functions still need to be delegated
533 priv->rc = op;
534 break;
535 }
536
537 if ((pview->mode != PAGER_MODE_EMAIL) && (rc == FR_UNKNOWN))
539
540 } while (priv->loop == PAGER_LOOP_CONTINUE);
541 window_set_focus(old_focus);
542
543 //-------------------------------------------------------------------------
544 // END OF ACT 3: Read user input loop - while (op != OP_ABORT)
545 //-------------------------------------------------------------------------
546
547 mutt_file_fclose(&priv->fp);
548 if (pview->mode == PAGER_MODE_EMAIL)
549 {
550 if (shared->mailbox_view)
551 shared->mailbox_view->msg_in_pager = -1;
552 }
553
555
556 for (size_t i = 0; i < priv->lines_max; i++)
557 {
558 FREE(&(priv->lines[i].syntax));
559 if (priv->search_compiled && priv->lines[i].search)
560 FREE(&(priv->lines[i].search));
561 }
562 if (priv->search_compiled)
563 {
564 regfree(&priv->search_re);
565 priv->search_compiled = false;
566 }
567 FREE(&priv->lines);
569 {
570 struct AttrColor *ac = NULL;
571 int count = 0;
572 TAILQ_FOREACH(ac, &priv->ansi_list, entries)
573 {
574 count++;
575 }
576 color_debug(LL_DEBUG5, "AnsiColors %d\n", count);
577 }
578
579 priv->pview = NULL;
580
581 if (priv->loop == PAGER_LOOP_RELOAD)
582 return PAGER_LOOP_RELOAD;
583
584 return (priv->rc != -1) ? priv->rc : 0;
585}
void attr_color_list_clear(struct AttrColorList *acl)
Free the contents of an AttrColorList.
Definition attr.c:116
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition helpers.c:143
MailboxType
Supported mailbox formats.
Definition mailbox.h:41
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:44
static void dump_pager(struct PagerPrivateData *priv)
Definition lib.h:148
static int color_debug(enum LogLevel level, const char *format,...)
Definition debug.h:52
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition dialog.c:89
int BrailleRow
Braille display: row to leave the cursor.
Definition dlg_pager.c:68
int BrailleCol
Braille display: column to leave the cursor.
Definition dlg_pager.c:70
static bool check_read_delay(uint64_t *timestamp)
Is it time to mark the message read?
Definition dlg_pager.c:179
void pager_queue_redraw(struct PagerPrivateData *priv, PagerRedrawFlags redraw)
Queue a request for a redraw.
Definition dlg_pager.c:128
static const struct Mapping * pager_resolve_help_mapping(enum PagerMode mode, enum MailboxType type)
Determine help mapping based on pager mode and mailbox type.
Definition dlg_pager.c:142
#define mutt_file_fclose(FP)
Definition file.h:139
#define mutt_file_fopen(PATH, MODE)
Definition file.h:138
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:56
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition get.c:58
int pager_function_dispatcher(struct MuttWindow *win, int op)
Perform a Pager function - Implements function_dispatcher_t -.
Definition functions.c:1130
#define mutt_perror(...)
Definition logging2.h:94
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:48
#define FREE(x)
Definition memory.h:62
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:47
uint64_t mutt_date_now_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition date.c:464
@ MUTT_READ
Messages that have been read.
Definition mutt.h:73
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition resize.c:76
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
void window_invalidate_all(void)
Mark all windows as in need of repaint.
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:49
bool jump_to_bottom(struct PagerPrivateData *priv, struct PagerView *pview)
Make sure the bottom line is displayed.
Definition functions.c:375
@ PAGER_LOOP_RELOAD
Reload the Pager from scratch.
Definition lib.h:152
@ PAGER_LOOP_CONTINUE
Stay in the Pager Event Loop.
Definition lib.h:150
#define MUTT_TYPES
Compute line's type.
Definition lib.h:65
#define MUTT_SHOWCOLOR
Show characters in color otherwise don't show characters.
Definition lib.h:62
#define PAGER_REDRAW_FLOW
Reflow the pager.
Definition lib.h:190
#define MUTT_PAGER_BOTTOM
Start at the bottom.
Definition lib.h:73
@ 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
#define PAGER_REDRAW_PAGER
Redraw the pager.
Definition lib.h:189
#define MUTT_SHOWFLAT
Show characters (used for displaying help)
Definition lib.h:61
void qstyle_free_tree(struct QuoteStyle **quote_list)
Free an entire tree of QuoteStyle.
Definition qstyle.c:58
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:782
#define TAILQ_INIT(head)
Definition queue.h:822
#define ASSERT(COND)
Definition signal2.h:60
volatile sig_atomic_t SigWinch
true after SIGWINCH is received
Definition signal.c:69
A curses colour and its attributes.
Definition attr.h:66
struct Email * email
header information for message/rfc822
Definition body.h:74
int msgno
Number displayed to the user.
Definition email.h:111
struct Email * email
Currently selected Email.
Definition shared_data.h:42
A line of text in the pager.
Definition display.h:50
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
short cid
Default line colour, e.g. MT_COLOR_SIGNATURE.
Definition display.h:52
struct TextSyntax * syntax
Array of coloured text in the line.
Definition display.h:57
int msg_in_pager
Message currently shown in the pager.
Definition mview.h:45
struct MuttWindow * parent
Parent Window.
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Notification API.
Definition notify.c:53
const char * fname
Name of the file to read.
Definition lib.h:163
FILE * fp
Source stream.
Definition lib.h:161
struct Body * body
Current attachment.
Definition lib.h:160
Private state data for the Pager.
int rc
Return code from functions.
bool wrapped
Has the search/next wrapped around?
bool pager_redraw
Force a complete redraw.
int lines_max
Capacity of lines array (total entries)
uint64_t delay_read_timestamp
Time that email was first shown.
enum PagerLoopMode loop
What the Event Loop should do next, e.g. PAGER_LOOP_CONTINUE.
struct Line * lines
Array of text lines in pager.
int has_types
Set to MUTT_TYPES for PAGER_MODE_EMAIL or MUTT_SHOWCOLOR.
struct Notify * notify
Notifications: NotifyPager, PagerPrivateData.
struct stat st
Stats about Email file.
bool first
First time flag for toggle-new.
struct QuoteStyle * quote_list
Tree of quoting levels.
struct PagerView * pview
Object to view in the pager.
struct AttrColorList ansi_list
List of ANSI colours used in the Pager.
int searchctx
Space to show around search matches.
regex_t search_re
Compiled search string.
FILE * fp
File containing decrypted/decoded/weeded Email.
bool search_compiled
Search regex is in use.
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
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:173
struct MuttWindow * win_pbar
Pager Bar Window.
Definition lib.h:177
struct MuttWindow * win_pager
Pager Window.
Definition lib.h:178
Highlighting for a piece of text.
Definition display.h:39
@ MENU_PAGER
Pager pager (email viewer)
Definition type.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_pattern()

bool dlg_pattern ( struct Buffer * buf)

Show menu to select a Pattern -.

Parameters
bufBuffer for the selected Pattern
Return values
trueA selection was made

The Select Pattern Dialog shows the user a help page of Patterns. They can select one to auto-complete some functions, e.g. <limit>

Definition at line 282 of file dlg_pattern.c.

283{
284 struct PatternData *pd = pattern_data_new();
285
288
289 struct Menu *menu = sdw.menu;
290 pd->menu = menu;
291 pd->buf = buf;
292
293 menu->mdata = pd;
296 menu->max = ARRAY_SIZE(&pd->entries);
297
298 // L10N: Pattern completion menu title
299 sbar_set_title(sdw.sbar, _("Patterns"));
300
301 // NT_COLOR is handled by the SimpleDialog
304
305 struct MuttWindow *old_focus = window_set_focus(menu->win);
306 // ---------------------------------------------------------------------------
307 // Event Loop
308 int op = OP_NULL;
309 do
310 {
311 menu_tagging_dispatcher(menu->win, op);
312 window_redraw(NULL);
313
315 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
316 if (op < 0)
317 continue;
318 if (op == OP_NULL)
319 {
321 continue;
322 }
324
325 int rc = pattern_function_dispatcher(sdw.dlg, op);
326 if (rc == FR_UNKNOWN)
327 rc = menu_function_dispatcher(menu->win, op);
328 if (rc == FR_UNKNOWN)
329 rc = global_function_dispatcher(NULL, op);
330 } while (!pd->done);
331 // ---------------------------------------------------------------------------
332
333 bool rc = pd->selection;
334
335 window_set_focus(old_focus);
337
338 return rc;
339}
static const struct Mapping PatternHelp[]
Help Bar for the Pattern selection dialog.
Definition dlg_pattern.c:88
static void create_pattern_entries(struct PatternEntryArray *pea)
Create the Pattern Entries.
int pattern_function_dispatcher(struct MuttWindow *win, int op)
Perform a Pattern function - Implements function_dispatcher_t -.
Definition functions.c:81
static int pattern_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Create a Pattern for the Menu - Implements Menu::make_entry() -.
void pattern_data_free(struct Menu *menu, void **ptr)
Free Pattern Data - Implements Menu::mdata_free() -.
static int pattern_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
static int pattern_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
@ WT_DLG_PATTERN
Pattern Dialog, dlg_pattern()
Definition mutt_window.h:88
struct PatternData * pattern_data_new(void)
Create new Pattern Data.
Data to pass to the Pattern Functions.
struct Menu * menu
Pattern Menu.
struct PatternEntryArray entries
Patterns for the Menu.
bool done
Should we close the Dialog?
struct Buffer * buf
Buffer for the results.
bool selection
Was a selection made?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_postponed()

struct Email * dlg_postponed ( struct Mailbox * m)

Create a Menu to select a postponed message -.

Parameters
mMailbox
Return values
ptrEmail

The Select Postponed Email Dialog shows the user a list of draft emails. They can select one to use in the Compose Dialog.

This dialog is only shown if there are two or more postponed emails.

Definition at line 210 of file dlg_postpone.c.

211{
214 // Required to number the emails
215 struct MailboxView *mv = mview_new(m, NeoMutt->notify);
216
217 struct Menu *menu = sdw.menu;
219 menu->color = post_color;
220 menu->max = m->msg_count;
221
222 struct PostponeData pd = { mv, menu, NULL, false, search_state_new() };
223 menu->mdata = &pd;
224 menu->mdata_free = NULL; // Menu doesn't own the data
225
226 // NT_COLOR is handled by the SimpleDialog
229
230 sbar_set_title(sdw.sbar, _("Postponed Messages"));
231
232 /* The postponed mailbox is setup to have sorting disabled, but the global
233 * `$sort` variable may indicate something different. Sorting has to be
234 * disabled while the postpone menu is being displayed. */
235 const enum EmailSortType c_sort = cs_subset_sort(NeoMutt->sub, "sort");
237
238 struct MuttWindow *old_focus = window_set_focus(menu->win);
239 // ---------------------------------------------------------------------------
240 // Event Loop
241 int op = OP_NULL;
242 do
243 {
244 menu_tagging_dispatcher(menu->win, op);
245 window_redraw(NULL);
246
248 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
249 if (op < 0)
250 continue;
251 if (op == OP_NULL)
252 {
254 continue;
255 }
257
258 int rc = postpone_function_dispatcher(sdw.dlg, op);
259
260 if (rc == FR_UNKNOWN)
261 rc = menu_function_dispatcher(menu->win, op);
262 if (rc == FR_UNKNOWN)
263 rc = global_function_dispatcher(NULL, op);
264 } while (!pd.done);
265 // ---------------------------------------------------------------------------
266
267 mview_free(&mv);
268 cs_subset_str_native_set(NeoMutt->sub, "sort", c_sort, NULL);
270 window_set_focus(old_focus);
272
273 return pd.email;
274}
static const struct Mapping PostponedHelp[]
Help Bar for the Postponed email selection dialog.
@ EMAIL_SORT_UNSORTED
Sort by the order the messages appear in the mailbox.
Definition sort.h:64
int postpone_function_dispatcher(struct MuttWindow *win, int op)
Perform a Postpone function - Implements function_dispatcher_t -.
Definition functions.c:177
static const struct AttrColor * post_color(struct Menu *menu, int line)
Calculate the colour for a line of the postpone index - Implements Menu::color() -.
static int post_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Email for the Menu - Implements Menu::make_entry() -.
static int postponed_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
static int postponed_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
@ WT_DLG_POSTPONED
Postponed Dialog, dlg_postponed()
Definition mutt_window.h:90
void search_state_free(struct SearchState **ptr)
Free a SearchState.
struct SearchState * search_state_new(void)
Create a new SearchState.
View of a Mailbox.
Definition mview.h:40
Data to pass to the Postpone Functions.
Definition functions.h:34
struct Email * email
Selected Email.
Definition functions.h:37
struct SearchState * search_state
State of the current search.
Definition functions.h:39
bool done
Should we close the Dialog?
Definition functions.h:38
struct Menu * menu
Postponed Menu.
Definition functions.h:36
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:303
@ MENU_POSTPONED
Select a postponed email.
Definition type.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function: