NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_alias.c
Go to the documentation of this file.
1
77#include "config.h"
78#include <stdbool.h>
79#include <stdio.h>
80#include "mutt/lib.h"
81#include "address/lib.h"
82#include "config/lib.h"
83#include "email/lib.h"
84#include "core/lib.h"
85#include "gui/lib.h"
86#include "lib.h"
87#include "expando/lib.h"
88#include "key/lib.h"
89#include "menu/lib.h"
90#include "pattern/lib.h"
91#include "send/lib.h"
92#include "alias.h"
93#include "functions.h"
94#include "gui.h"
95#include "mutt_logging.h"
96
98
100static const struct Mapping AliasHelp[] = {
101 // clang-format off
102 { N_("Exit"), OP_EXIT },
103 { N_("Del"), OP_DELETE },
104 { N_("Undel"), OP_UNDELETE },
105 { N_("Sort"), OP_SORT },
106 { N_("Rev-Sort"), OP_SORT_REVERSE },
107 { N_("Select"), OP_GENERIC_SELECT_ENTRY },
108 { N_("Help"), OP_HELP },
109 { NULL, 0 },
110 // clang-format on
111};
112
116void alias_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
117 struct Buffer *buf)
118{
119 const struct AliasView *av = data;
120 const struct Alias *alias = av->alias;
121
122 const char *s = alias->name;
123 buf_strcpy(buf, s);
124}
125
129void alias_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
130 struct Buffer *buf)
131{
132 const struct AliasView *av = data;
133 const struct Alias *alias = av->alias;
134
135 const char *s = alias->comment;
136 buf_strcpy(buf, s);
137}
138
142long alias_f_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
143{
144 const struct AliasView *av = data;
145 return av->is_deleted;
146}
147
151void alias_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
152 struct Buffer *buf)
153{
154 const struct AliasView *av = data;
155
156 // NOTE(g0mb4): use $flag_chars?
157 const char *s = av->is_deleted ? "D" : " ";
158 buf_strcpy(buf, s);
159}
160
164long alias_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
165{
166 const struct AliasView *av = data;
167
168 return av->num + 1;
169}
170
174void alias_r(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
175 struct Buffer *buf)
176{
177 const struct AliasView *av = data;
178 const struct Alias *alias = av->alias;
179
180 mutt_addrlist_write(&alias->addr, buf, true);
181}
182
186long alias_t_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
187{
188 const struct AliasView *av = data;
189 return av->is_tagged;
190}
191
195void alias_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
196 struct Buffer *buf)
197{
198 const struct AliasView *av = data;
199
200 // NOTE(g0mb4): use $flag_chars?
201 const char *s = av->is_tagged ? "*" : " ";
202 buf_strcpy(buf, s);
203}
204
208void alias_Y(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
209 struct Buffer *buf)
210{
211 const struct AliasView *av = data;
212
213 alias_tags_to_buffer(&av->alias->tags, buf);
214}
215
221static int alias_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
222{
223 const struct AliasMenuData *mdata = menu->mdata;
224 const struct AliasViewArray *ava = &mdata->ava;
225 struct AliasView *av = ARRAY_GET(ava, line);
226
227 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
228 if (c_arrow_cursor)
229 {
230 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
231 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
232 }
233
234 const struct Expando *c_alias_format = cs_subset_expando(mdata->sub, "alias_format");
235 return expando_filter(c_alias_format, AliasRenderData, av,
236 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
237}
238
242static int alias_tag(struct Menu *menu, int sel, int act)
243{
244 const struct AliasMenuData *mdata = menu->mdata;
245 const struct AliasViewArray *ava = &mdata->ava;
246 struct AliasView *av = ARRAY_GET(ava, sel);
247
248 bool ot = av->is_tagged;
249
250 av->is_tagged = ((act >= 0) ? act : !av->is_tagged);
251
252 return av->is_tagged - ot;
253}
254
259{
260 if (nc->event_type != NT_ALIAS)
261 return 0;
262 if (!nc->global_data || !nc->event_data)
263 return -1;
264
265 struct EventAlias *ev_a = nc->event_data;
266 struct Menu *menu = nc->global_data;
267 struct AliasMenuData *mdata = menu->mdata;
268 struct Alias *alias = ev_a->alias;
269
270 if (nc->event_subtype == NT_ALIAS_ADD)
271 {
272 alias_array_alias_add(&mdata->ava, alias);
273
274 if (alias_array_count_visible(&mdata->ava) != ARRAY_SIZE(&mdata->ava))
275 {
276 mutt_pattern_alias_func(NULL, mdata, menu);
277 }
278 }
279 else if (nc->event_subtype == NT_ALIAS_DELETE)
280 {
281 alias_array_alias_delete(&mdata->ava, alias);
282
283 int vcount = alias_array_count_visible(&mdata->ava);
284 int index = menu_get_index(menu);
285 if ((index > (vcount - 1)) && (index > 0))
286 menu_set_index(menu, index - 1);
287 }
288
289 alias_array_sort(&mdata->ava, mdata->sub);
290
291 menu->max = alias_array_count_visible(&mdata->ava);
293 mutt_debug(LL_DEBUG5, "alias done, request WA_RECALC, MENU_REDRAW_FULL\n");
294
295 return 0;
296}
297
306{
307 if (nc->event_type != NT_WINDOW)
308 return 0;
309 if (!nc->global_data || !nc->event_data)
310 return -1;
312 return 0;
313
314 struct MuttWindow *win_menu = nc->global_data;
315 struct EventWindow *ev_w = nc->event_data;
316 if (ev_w->win != win_menu)
317 return 0;
318
319 struct Menu *menu = win_menu->wdata;
320
324
325 mutt_debug(LL_DEBUG5, "window delete done\n");
326 return 0;
327}
328
334static struct MuttWindow *alias_dialog_new(struct AliasMenuData *mdata)
335{
337
338 struct Menu *menu = dlg->wdata;
339
341 menu->tag = alias_tag;
342 menu->max = alias_array_count_visible(&mdata->ava);
343 menu->mdata = mdata;
344 menu->mdata_free = NULL; // Menu doesn't own the data
345
346 struct MuttWindow *win_menu = menu->win;
347
348 // Override the Simple Dialog's recalc()
349 win_menu->recalc = alias_recalc;
350
351 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
352 alias_set_title(sbar, mdata->title, mdata->limit);
353
354 // NT_COLOR is handled by the SimpleDialog
358
359 return dlg;
360}
361
371static bool dlg_alias(struct Buffer *buf, struct AliasMenuData *mdata)
372{
373 if (ARRAY_EMPTY(&mdata->ava))
374 {
375 mutt_warning(_("You have no aliases"));
376 return false;
377 }
378
379 mdata->query = buf;
380 mdata->title = mutt_str_dup(_("Aliases"));
381
382 struct MuttWindow *dlg = alias_dialog_new(mdata);
383 struct Menu *menu = dlg->wdata;
384 struct MuttWindow *win_sbar = window_find_child(dlg, WT_STATUS_BAR);
385 mdata->menu = menu;
386 mdata->sbar = win_sbar;
387
388 alias_array_sort(&mdata->ava, mdata->sub);
389
390 struct AliasView *avp = NULL;
391 ARRAY_FOREACH(avp, &mdata->ava)
392 {
393 avp->num = ARRAY_FOREACH_IDX;
394 }
395
396 struct MuttWindow *old_focus = window_set_focus(menu->win);
397 // ---------------------------------------------------------------------------
398 // Event Loop
399 int rc = 0;
400 int op = OP_NULL;
401 do
402 {
403 menu_tagging_dispatcher(menu->win, op);
404 window_redraw(NULL);
405
407 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
408 if (op < 0)
409 continue;
410 if (op == OP_NULL)
411 {
413 continue;
414 }
416
417 rc = alias_function_dispatcher(dlg, op);
418 if (rc == FR_UNKNOWN)
419 rc = menu_function_dispatcher(menu->win, op);
420 if (rc == FR_UNKNOWN)
421 rc = global_function_dispatcher(NULL, op);
422 } while ((rc != FR_DONE) && (rc != FR_CONTINUE));
423 // ---------------------------------------------------------------------------
424
425 window_set_focus(old_focus);
426 simple_dialog_free(&dlg);
427 window_redraw(NULL);
428 return (rc == FR_CONTINUE); // Was a selection made?
429}
430
442int alias_complete(struct Buffer *buf, struct ConfigSubset *sub)
443{
444 struct Alias *np = NULL;
445 char bestname[8192] = { 0 };
446
447 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
448 mdata.limit = buf_strdup(buf);
449 mdata.search_state = search_state_new();
450
451 if (buf_at(buf, 0) != '\0')
452 {
453 TAILQ_FOREACH(np, &Aliases, entries)
454 {
455 if (np->name && mutt_strn_equal(np->name, buf_string(buf), buf_len(buf)))
456 {
457 if (bestname[0] == '\0') /* init */
458 {
459 mutt_str_copy(bestname, np->name,
460 MIN(mutt_str_len(np->name) + 1, sizeof(bestname)));
461 }
462 else
463 {
464 int i;
465 for (i = 0; np->name[i] && (np->name[i] == bestname[i]); i++)
466 ; // do nothing
467
468 bestname[i] = '\0';
469 }
470 }
471 }
472
473 if (bestname[0] == '\0')
474 {
475 // Create a View Array of all the Aliases
476 FREE(&mdata.limit);
477 TAILQ_FOREACH(np, &Aliases, entries)
478 {
480 }
481 }
482 else
483 {
484 /* fake the pattern for menu title */
485 char *mtitle = NULL;
486 mutt_str_asprintf(&mtitle, "~f ^%s", buf_string(buf));
487 FREE(&mdata.limit);
488 mdata.limit = mtitle;
489
490 if (!mutt_str_equal(bestname, buf_string(buf)))
491 {
492 /* we are adding something to the completion */
493 buf_strcpy_n(buf, bestname, mutt_str_len(bestname) + 1);
494 FREE(&mdata.limit);
495 search_state_free(&mdata.search_state);
496 return 1;
497 }
498
499 /* build alias list and show it */
500 TAILQ_FOREACH(np, &Aliases, entries)
501 {
502 int aasize = alias_array_alias_add(&mdata.ava, np);
503
504 struct AliasView *av = ARRAY_GET(&mdata.ava, aasize - 1);
505
506 if (np->name && !mutt_strn_equal(np->name, buf_string(buf), buf_len(buf)))
507 {
508 av->is_visible = false;
509 }
510 }
511 }
512 }
513
514 if (ARRAY_EMPTY(&mdata.ava))
515 {
516 TAILQ_FOREACH(np, &Aliases, entries)
517 {
518 alias_array_alias_add(&mdata.ava, np);
519 }
520
521 mutt_pattern_alias_func(NULL, &mdata, NULL);
522 }
523
524 if (!dlg_alias(NULL, &mdata))
525 goto done;
526
527 buf_reset(buf);
528
529 // Extract the selected aliases
530 struct Buffer *tmpbuf = buf_pool_get();
531 struct AliasView *avp = NULL;
532 ARRAY_FOREACH(avp, &mdata.ava)
533 {
534 if (!avp->is_tagged)
535 continue;
536
537 mutt_addrlist_write(&avp->alias->addr, tmpbuf, true);
538 buf_addstr(tmpbuf, ", ");
539 }
540 buf_copy(buf, tmpbuf);
541 buf_pool_release(&tmpbuf);
542
543done:
544 // Process any deleted aliases
545 ARRAY_FOREACH(avp, &mdata.ava)
546 {
547 if (!avp->is_deleted)
548 continue;
549
550 TAILQ_REMOVE(&Aliases, avp->alias, entries);
551 alias_free(&avp->alias);
552 }
553
554 ARRAY_FREE(&mdata.ava);
555 FREE(&mdata.limit);
556 FREE(&mdata.title);
558
559 return 0;
560}
561
567void alias_dialog(struct Mailbox *m, struct ConfigSubset *sub)
568{
569 struct Alias *np = NULL;
570
571 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
572 mdata.search_state = search_state_new();
573
574 // Create a View Array of all the Aliases
575 TAILQ_FOREACH(np, &Aliases, entries)
576 {
578 }
579
580 if (!dlg_alias(NULL, &mdata))
581 goto done;
582
583 // Prepare the "To:" field of a new email
584 struct Email *e = email_new();
585 e->env = mutt_env_new();
586
587 struct AliasView *avp = NULL;
588 ARRAY_FOREACH(avp, &mdata.ava)
589 {
590 if (!avp->is_tagged)
591 continue;
592
593 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
594 if (alias_to_addrlist(&al_copy, avp->alias))
595 {
596 mutt_addrlist_copy(&e->env->to, &al_copy, false);
597 mutt_addrlist_clear(&al_copy);
598 }
599 }
600
601 mutt_send_message(SEND_REVIEW_TO, e, NULL, m, NULL, sub);
602
603done:
604 // Process any deleted aliases
605 ARRAY_FOREACH(avp, &mdata.ava)
606 {
607 if (avp->is_deleted)
608 {
609 TAILQ_REMOVE(&Aliases, avp->alias, entries);
610 alias_free(&avp->alias);
611 }
612 }
613
614 ARRAY_FREE(&mdata.ava);
615 FREE(&mdata.limit);
616 FREE(&mdata.title);
618}
619
625const struct ExpandoRenderData AliasRenderData[] = {
626 // clang-format off
627 { ED_ALIAS, ED_ALI_NAME, alias_a, NULL },
628 { ED_ALIAS, ED_ALI_COMMENT, alias_c, NULL },
631 { ED_ALIAS, ED_ALI_ADDRESS, alias_r, NULL },
633 { ED_ALIAS, ED_ALI_TAGS, alias_Y, NULL },
634 { -1, -1, NULL, NULL },
635 // clang-format on
636};
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:765
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1460
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
Definition: address.c:1206
Email Address Handling.
void alias_tags_to_buffer(struct TagList *tl, struct Buffer *buf)
Write a comma-separated list of tags to a Buffer.
Definition: commands.c:49
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition: sort.c:168
void alias_free(struct Alias **ptr)
Free an Alias.
Definition: alias.c:672
struct AliasList Aliases
List of all the user's email aliases.
Definition: alias.c:62
Representation of a single alias to an email address.
@ NT_ALIAS_ADD
Alias has been added.
Definition: alias.h:56
@ NT_ALIAS_DELETE
Alias is about to be deleted.
Definition: alias.h:57
int alias_array_count_visible(struct AliasViewArray *ava)
Count number of visible Aliases.
Definition: array.c:95
int alias_array_alias_delete(struct AliasViewArray *ava, const struct Alias *alias)
Delete an Alias from the AliasViewArray.
Definition: array.c:73
int alias_array_alias_add(struct AliasViewArray *ava, struct Alias *alias)
Add an Alias to the AliasViewArray.
Definition: array.c:47
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:74
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:109
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition: array.h:58
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
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
Definition: buffer.c:670
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_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:226
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
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:571
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Definition: config_type.c:357
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition: curs_lib.c:443
@ 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
int alias_complete(struct Buffer *buf, struct ConfigSubset *sub)
Alias completion routine.
Definition: dlg_alias.c:442
static const struct Mapping AliasHelp[]
Help Bar for the Alias dialog (address book)
Definition: dlg_alias.c:100
void alias_dialog(struct Mailbox *m, struct ConfigSubset *sub)
Open the aliases dialog.
Definition: dlg_alias.c:567
const struct ExpandoRenderData AliasRenderData[]
Callbacks for Alias Expandos.
Definition: dlg_alias.c:97
static struct MuttWindow * alias_dialog_new(struct AliasMenuData *mdata)
Create an Alias Selection Dialog.
Definition: dlg_alias.c:334
bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
Turn an Alias into an AddressList.
Definition: dlg_query.c:121
@ ED_ALIAS
Alias ED_ALI_ ExpandoDataAlias.
Definition: domain.h:35
struct Email * email_new(void)
Create a new Email.
Definition: email.c:77
Structs that make up an email.
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:46
int expando_filter(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition: filter.c:138
Parse Expando string.
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:464
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:172
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:318
int alias_function_dispatcher(struct MuttWindow *win, int op)
Perform a Alias function - Implements function_dispatcher_t -.
Definition: functions.c:418
long alias_t_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Alias: Tagged char - Implements ExpandoRenderData::get_number() -.
Definition: dlg_alias.c:186
long alias_f_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Alias: Flags - Implements ExpandoRenderData::get_number() -.
Definition: dlg_alias.c:142
long alias_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Alias: Index number - Implements ExpandoRenderData::get_number() -.
Definition: dlg_alias.c:164
void alias_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Alias: Tagged char - Implements ExpandoRenderData::get_string() -.
Definition: dlg_alias.c:195
void alias_Y(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Alias: Tags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_alias.c:208
void alias_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Alias: Comment - Implements ExpandoRenderData::get_string() -.
Definition: dlg_alias.c:129
void alias_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Alias: Alias name - Implements ExpandoRenderData::get_string() -.
Definition: dlg_alias.c:116
void alias_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Alias: Flags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_alias.c:151
void alias_r(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Alias: Address - Implements ExpandoRenderData::get_string() -.
Definition: dlg_alias.c:174
static bool dlg_alias(struct Buffer *buf, struct AliasMenuData *mdata)
Display a menu of Aliases -.
Definition: dlg_alias.c:371
#define mutt_warning(...)
Definition: logging2.h:90
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int alias_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Alias for the Menu - Implements Menu::make_entry() -.
Definition: dlg_alias.c:221
static int alias_tag(struct Menu *menu, int sel, int act)
Tag some aliases - Implements Menu::tag() -.
Definition: dlg_alias.c:242
static int alias_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_alias.c:305
static int alias_alias_observer(struct NotifyCallback *nc)
Notification that an Alias has changed - Implements observer_t -.
Definition: dlg_alias.c:258
int alias_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: gui.c:43
int alias_recalc(struct MuttWindow *win)
Recalculate the display of the Alias Window - Implements MuttWindow::recalc() -.
Definition: gui.c:89
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:132
void alias_set_title(struct MuttWindow *sbar, char *menu_name, char *limit)
Create a title string for the Menu.
Definition: gui.c:69
Shared code for the Alias and Query Dialogs.
@ ED_ALI_FLAGS
Alias.flags.
Definition: gui.h:75
@ ED_ALI_NUMBER
AliasView.num.
Definition: gui.h:77
@ ED_ALI_NAME
Alias.name.
Definition: gui.h:76
@ ED_ALI_ADDRESS
Alias.addr.
Definition: gui.h:73
@ ED_ALI_COMMENT
Alias.comment.
Definition: gui.h:74
@ ED_ALI_TAGGED
AliasView.tagged.
Definition: gui.h:78
@ ED_ALI_TAGS
Alias.tags.
Definition: gui.h:79
Manage keymappings.
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:51
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
#define FREE(x)
Definition: memory.h:45
#define MIN(a, b)
Definition: memory.h:32
GUI present the user with a selectable list.
#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
Convenience wrapper for the library headers.
#define N_(a)
Definition: message.h:32
#define _(a)
Definition: message.h:28
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
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
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:253
int mutt_str_asprintf(char **strp, const char *fmt,...)
Definition: string.c:803
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
Definition: string.c:425
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:496
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:581
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:633
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:683
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:532
@ WT_DLG_ALIAS
Alias Dialog, dlg_alias()
Definition: mutt_window.h:77
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:101
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:228
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
@ NT_ALIAS
Alias has changed, NotifyAlias, EventAlias.
Definition: notify_type.h:37
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:48
Match patterns to emails.
int mutt_pattern_alias_func(char *prompt, struct AliasMenuData *mdata, struct Menu *menu)
Perform some Pattern matching for Alias.
Definition: pattern.c:190
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:841
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:637
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: render.h:37
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: render.h:32
void search_state_free(struct SearchState **ptr)
Free a SearchState.
Definition: search_state.c:51
struct SearchState * search_state_new(void)
Create a new SearchState.
Definition: search_state.c:39
Convenience wrapper for the send headers.
int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Mailbox *m, struct EmailArray *ea, struct ConfigSubset *sub)
Send an email.
Definition: send.c:2099
#define SEND_REVIEW_TO
Allow the user to edit the To field.
Definition: send.h:56
Sidebar functions.
Key value store.
AliasView array wrapper with Pattern information -.
Definition: gui.h:54
char * limit
Limit being used.
Definition: gui.h:60
struct AliasViewArray ava
All Aliases/Queries.
Definition: gui.h:55
struct SearchState * search_state
State of the current search.
Definition: gui.h:63
struct MuttWindow * sbar
Status Bar.
Definition: gui.h:61
struct Menu * menu
Menu.
Definition: gui.h:58
struct Buffer * query
Query string.
Definition: gui.h:59
char * title
Title for the status bar.
Definition: gui.h:62
struct ConfigSubset * sub
Config items.
Definition: gui.h:57
GUI data wrapping an Alias.
Definition: gui.h:38
bool is_visible
Is visible?
Definition: gui.h:45
struct Alias * alias
Alias.
Definition: gui.h:46
bool is_deleted
Is it deleted?
Definition: gui.h:44
bool is_tagged
Is it tagged?
Definition: gui.h:43
int num
Index number in list.
Definition: gui.h:39
A shortcut for an email address or addresses.
Definition: alias.h:35
struct TagList tags
Tags.
Definition: alias.h:39
char * comment
Free-form comment string.
Definition: alias.h:38
char * name
Short name.
Definition: alias.h:36
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:37
String manipulation buffer.
Definition: buffer.h:36
A set of inherited config items.
Definition: subset.h:47
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
The envelope/body of an email.
Definition: email.h:39
struct Envelope * env
Envelope information.
Definition: email.h:68
struct AddressList to
Email's 'To' list.
Definition: envelope.h:60
An alias-change event.
Definition: alias.h:66
struct Alias * alias
Alias that changed.
Definition: alias.h:67
An Event that happened to a Window.
Definition: mutt_window.h:238
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:239
Basic Expando Node.
Definition: node.h:67
Parsed Expando trees.
Definition: expando.h:41
A mailbox.
Definition: mailbox.h:79
Mapping between user-readable string and a constant.
Definition: mapping.h:33
Definition: lib.h:79
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:86
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 ConfigSubset * sub
Inherited config items.
Definition: lib.h:87
void * mdata
Private data.
Definition: lib.h:147
int max
Number of entries in the menu.
Definition: lib.h:81
void * wdata
Private data.
Definition: mutt_window.h:144
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:137
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:172
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct Notify * notify
Notifications handler.
Definition: neomutt.h:43
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
Data passed to a notification function.
Definition: observer.h:34
void * event_data
Data from notify_send()
Definition: observer.h:38
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:37
void * global_data
Data from notify_observer_add()
Definition: observer.h:39
@ MENU_ALIAS
Select an email address by its alias.
Definition: type.h:37