NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c
Go to the documentation of this file.
1
23
29
30#include "config.h"
31#include <stdbool.h>
32#include <stdio.h>
33#include "mutt/lib.h"
34#include "address/lib.h"
35#include "config/lib.h"
36#include "core/lib.h"
37#include "gui/lib.h"
38#include "functions.h"
39#include "lib.h"
40#include "editor/lib.h"
41#include "history/lib.h"
42#include "key/lib.h"
43#include "menu/lib.h"
44#include "pattern/lib.h"
45#include "question/lib.h"
46#include "alias.h"
47#include "gui.h"
48#include "module_data.h"
49#include "sort.h"
50
51// clang-format off
55static const struct MenuFuncOp OpAlias[] = { /* map: alias */
56 { "delete-entry", OP_DELETE },
57 { "exit", OP_EXIT },
58 { "limit", OP_MAIN_LIMIT },
59 { "mail", OP_MAIL },
60 { "sort-alias", OP_SORT },
61 { "sort-alias-reverse", OP_SORT_REVERSE },
62 { "tag-pattern", OP_MAIN_TAG_PATTERN },
63 { "undelete-entry", OP_UNDELETE },
64 { "untag-pattern", OP_MAIN_UNTAG_PATTERN },
65 { NULL, 0 },
66};
67
71const struct MenuFuncOp OpQuery[] = { /* map: query */
72 { "create-alias", OP_CREATE_ALIAS },
73 { "exit", OP_EXIT },
74 { "limit", OP_MAIN_LIMIT },
75 { "mail", OP_MAIL },
76 { "query", OP_QUERY },
77 { "query-append", OP_QUERY_APPEND },
78 { "sort", OP_SORT },
79 { "sort-reverse", OP_SORT_REVERSE },
80 { "tag-pattern", OP_MAIN_TAG_PATTERN },
81 { "untag-pattern", OP_MAIN_UNTAG_PATTERN },
82 { NULL, 0 },
83};
84
88static const struct MenuOpSeq AliasDefaultBindings[] = { /* map: alias */
89 { OP_DELETE, "d" },
90 { OP_EXIT, "q" },
91 { OP_MAIL, "m" },
92 { OP_MAIN_LIMIT, "l" },
93 { OP_MAIN_TAG_PATTERN, "T" },
94 { OP_MAIN_UNTAG_PATTERN, "\024" }, // <Ctrl-T>
95 { OP_SORT, "o" },
96 { OP_SORT_REVERSE, "O" },
97 { OP_TAG, "<space>" },
98 { OP_UNDELETE, "u" },
99 { 0, NULL },
100};
101
105static const struct MenuOpSeq QueryDefaultBindings[] = { /* map: query */
106 { OP_CREATE_ALIAS, "a" },
107 { OP_EXIT, "q" },
108 { OP_MAIL, "m" },
109 { OP_MAIN_LIMIT, "l" },
110 { OP_MAIN_TAG_PATTERN, "T" },
111 { OP_MAIN_UNTAG_PATTERN, "\024" }, // <Ctrl-T>
112 { OP_QUERY, "Q" },
113 { OP_QUERY_APPEND, "A" },
114 { OP_SORT, "o" },
115 { OP_SORT_REVERSE, "O" },
116 { OP_TAG, "<space>" },
117 { 0, NULL },
118};
119// clang-format on
120
124void alias_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
125{
127 ASSERT(mod_data);
128
129 struct MenuDefinition *md = NULL;
130 struct SubMenu *sm = NULL;
131
133 md = km_register_menu(MENU_ALIAS, "alias");
134 km_menu_add_submenu(md, sm);
135 km_menu_add_submenu(md, sm_generic);
137
138 mod_data->menu_alias = md;
139
141 md = km_register_menu(MENU_QUERY, "query");
142 km_menu_add_submenu(md, sm);
143 km_menu_add_submenu(md, sm_generic);
145
146 mod_data->menu_query = md;
147}
148
152static int op_create_alias(struct AliasFunctionData *fdata, const struct KeyEvent *event)
153{
154 struct AliasMenuData *mdata = fdata->wdata;
155 struct Menu *menu = mdata->menu;
156
157 if (menu->tag_prefix)
158 {
159 struct AddressList naddr = TAILQ_HEAD_INITIALIZER(naddr);
160
161 struct AliasView *avp = NULL;
162 ARRAY_FOREACH(avp, &mdata->ava)
163 {
164 if (!avp->is_tagged)
165 continue;
166
167 struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
168 if (alias_to_addrlist(&al, avp->alias))
169 {
170 mutt_addrlist_copy(&naddr, &al, false);
172 }
173 }
174
175 alias_create(&naddr, mdata->sub);
176 mutt_addrlist_clear(&naddr);
177 }
178 else
179 {
180 struct AliasView *av = ARRAY_GET(&mdata->ava, menu_get_index(menu));
181 if (!av)
182 return FR_NO_ACTION;
183
184 struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
185 if (alias_to_addrlist(&al, av->alias))
186 {
187 alias_create(&al, mdata->sub);
189 }
190 }
191 return FR_SUCCESS;
192}
193
209static int alias_add_selection(struct AliasViewPtrArray *avpa,
210 struct AliasMenuData *mdata, bool tagged, int count)
211{
212 if (!avpa || !mdata)
213 return 0;
214
215 if (tagged)
216 {
217 struct AliasView *avp = NULL;
218 ARRAY_FOREACH(avp, &mdata->ava)
219 {
220 if (avp->is_tagged)
221 ARRAY_ADD(avpa, avp);
222 }
223 }
224 else
225 {
226 struct Menu *menu = mdata->menu;
227 const int index = menu_get_index(menu);
228 if ((index < 0) || (index >= menu->max))
229 return 0;
230
231 int n = (count > 1) ? count : 1;
232 if ((index + n) > menu->max)
233 n = menu->max - index;
234
235 for (int i = 0; i < n; i++)
236 {
237 struct AliasView *av = ARRAY_GET(&mdata->ava, index + i);
238 if (av)
239 ARRAY_ADD(avpa, av);
240 }
241 }
242
243 return ARRAY_SIZE(avpa);
244}
245
251static void alias_apply_set_deleted(struct AliasViewPtrArray *avpa, bool deleted)
252{
253 if (!avpa)
254 return;
255
256 struct AliasView **avpp = NULL;
257 ARRAY_FOREACH(avpp, avpa)
258 {
259 if (*avpp)
260 (*avpp)->is_deleted = deleted;
261 }
262}
263
274static int op_delete(struct AliasFunctionData *fdata, const struct KeyEvent *event)
275{
276 struct AliasMenuData *mdata = fdata->wdata;
277 struct Menu *menu = mdata->menu;
278 const bool deleted = (event->op == OP_DELETE);
279
280 struct AliasViewPtrArray avpa = ARRAY_HEAD_INITIALIZER;
281 alias_add_selection(&avpa, mdata, menu->tag_prefix, event->count);
282 if (ARRAY_EMPTY(&avpa))
283 {
284 ARRAY_FREE(&avpa);
285 return FR_NO_ACTION;
286 }
287 alias_apply_set_deleted(&avpa, deleted);
288 const int num = ARRAY_SIZE(&avpa);
289 ARRAY_FREE(&avpa);
290
291 if (menu->tag_prefix)
292 {
294 }
295 else
296 {
297 const int index = menu_get_index(menu);
299 const bool c_resolve = cs_subset_bool(mdata->sub, "resolve");
300 if (c_resolve && ((index + num) < menu->max))
301 {
302 menu_set_index(menu, index + num);
304 }
305 }
306 return FR_SUCCESS;
307}
308
312static int op_exit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
313{
314 return FR_DONE;
315}
316
320static int op_jump(struct AliasFunctionData *fdata, const struct KeyEvent *event)
321{
322 int num = event->count;
323
324 if (num == 0)
325 return FR_NO_ACTION;
326
327 struct AliasMenuData *mdata = fdata->wdata;
328 struct Menu *menu = mdata->menu;
329
330 if ((num < 1) || (num > menu->max))
331 {
332 mutt_warning(_("Invalid message number"));
333 return FR_ERROR;
334 }
335
336 menu_set_index(menu, num - 1); // Num is 1-based
337 return FR_SUCCESS;
338}
339
347static int alias_select_entries(struct AliasMenuData *mdata, int count)
348{
349 struct Menu *menu = mdata->menu;
350 if (menu->tag_prefix)
351 {
352 // Untag any non-visible aliases
353 struct AliasView *avp = NULL;
354 ARRAY_FOREACH(avp, &mdata->ava)
355 {
356 if (avp->is_tagged && !avp->is_visible)
357 avp->is_tagged = false;
358 }
359 }
360 else
361 {
362 struct AliasViewPtrArray avpa = ARRAY_HEAD_INITIALIZER;
363 alias_add_selection(&avpa, mdata, false, count);
364 if (ARRAY_EMPTY(&avpa))
365 {
366 ARRAY_FREE(&avpa);
367 return FR_NO_ACTION;
368 }
369
370 // Untag all but the selected alias(es)
371 struct AliasView *avp = NULL;
372 ARRAY_FOREACH(avp, &mdata->ava)
373 {
374 avp->is_tagged = false;
375 }
376
377 struct AliasView **avpp = NULL;
378 ARRAY_FOREACH(avpp, &avpa)
379 {
380 if (*avpp)
381 (*avpp)->is_tagged = true;
382 }
383 ARRAY_FREE(&avpa);
384 }
385
386 return FR_CONTINUE;
387}
388
392static int op_generic_select_entry(struct AliasFunctionData *fdata, const struct KeyEvent *event)
393{
394 if (event->count > 0)
395 return op_jump(fdata, event);
396
397 return alias_select_entries(fdata->wdata, 0);
398}
399
403static int op_mail(struct AliasFunctionData *fdata, const struct KeyEvent *event)
404{
405 return alias_select_entries(fdata->wdata, event->count);
406}
407
411static int op_main_limit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
412{
413 struct AliasMenuData *mdata = fdata->wdata;
414 struct Menu *menu = mdata->menu;
415 int rc = mutt_pattern_alias_func(_("Limit to addresses matching: "), mdata,
416 PAA_VISIBLE, menu);
417 if (rc != 0)
418 return FR_NO_ACTION;
419
420 alias_array_sort(&mdata->ava, mdata->sub);
421 alias_set_title(mdata->sbar, mdata->title, mdata->limit);
423 window_redraw(NULL);
424
425 return FR_SUCCESS;
426}
427
431static int op_main_tag_pattern(struct AliasFunctionData *fdata, const struct KeyEvent *event)
432{
433 struct AliasMenuData *mdata = fdata->wdata;
434 struct Menu *menu = mdata->menu;
435 int rc = mutt_pattern_alias_func(_("Tag addresses matching: "), mdata, PAA_TAG, menu);
436 if (rc != 0)
437 return FR_NO_ACTION;
438
440 window_redraw(NULL);
441
442 return FR_SUCCESS;
443}
444
448static int op_main_untag_pattern(struct AliasFunctionData *fdata, const struct KeyEvent *event)
449{
450 struct AliasMenuData *mdata = fdata->wdata;
451 struct Menu *menu = mdata->menu;
452 int rc = mutt_pattern_alias_func(_("Untag addresses matching: "), mdata, PAA_UNTAG, menu);
453 if (rc != 0)
454 return FR_NO_ACTION;
455
457 window_redraw(NULL);
458
459 return FR_SUCCESS;
460}
461
469static int op_query(struct AliasFunctionData *fdata, const struct KeyEvent *event)
470{
471 struct AliasMenuData *mdata = fdata->wdata;
472 struct Buffer *buf = mdata->query;
473 if ((mw_get_field(_("Query: "), buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0) ||
474 buf_is_empty(buf))
475 {
476 return FR_NO_ACTION;
477 }
478
479 const int op = event->op;
480 if (op == OP_QUERY)
481 {
482 ARRAY_FREE(&mdata->ava);
483 aliaslist_clear(mdata->aa);
484 }
485
486 struct Menu *menu = mdata->menu;
487 struct AliasArray aa = ARRAY_HEAD_INITIALIZER;
488
489 query_run(buf_string(buf), true, &aa, mdata->sub);
491 char title[256] = { 0 };
492 snprintf(title, sizeof(title), "%s%s", _("Query: "), buf_string(buf));
493 sbar_set_title(mdata->sbar, title);
494
495 if (ARRAY_EMPTY(&aa))
496 {
497 if (op == OP_QUERY)
498 menu->max = 0;
499 return FR_NO_ACTION;
500 }
501
502 struct Alias **ap = NULL;
503 ARRAY_FOREACH(ap, &aa)
504 {
505 alias_array_alias_add(&mdata->ava, *ap);
506 ARRAY_ADD(mdata->aa, *ap); // Transfer
507 }
508 ARRAY_FREE(&aa); // Free the array structure but not the aliases
509 alias_array_sort(&mdata->ava, mdata->sub);
510 menu->max = ARRAY_SIZE(&mdata->ava);
511 return FR_SUCCESS;
512}
513
523static int op_search(struct AliasFunctionData *fdata, const struct KeyEvent *event)
524{
525 struct AliasMenuData *mdata = fdata->wdata;
526 SearchFlags flags = SEARCH_NONE;
527 switch (event->op)
528 {
529 case OP_SEARCH:
530 flags |= SEARCH_PROMPT;
531 mdata->search_state->reverse = false;
532 break;
533 case OP_SEARCH_REVERSE:
534 flags |= SEARCH_PROMPT;
535 mdata->search_state->reverse = true;
536 break;
537 case OP_SEARCH_NEXT:
538 break;
539 case OP_SEARCH_OPPOSITE:
540 flags |= SEARCH_OPPOSITE;
541 break;
542 }
543
544 struct Menu *menu = mdata->menu;
545 int index = menu_get_index(menu);
546 index = mutt_search_alias_command(menu, index, mdata->search_state, flags);
547 if (index == -1)
548 return FR_NO_ACTION;
549
550 menu_set_index(menu, index);
551 return FR_SUCCESS;
552}
553
561static int op_sort(struct AliasFunctionData *fdata, const struct KeyEvent *event)
562{
563 struct AliasMenuData *mdata = fdata->wdata;
564 int sort = cs_subset_sort(mdata->sub, "alias_sort");
565 bool resort = true;
566 const int op = event->op;
567 bool reverse = (op == OP_SORT_REVERSE);
568
569 switch (mw_multi_choice(reverse ?
570 /* L10N: The highlighted letters must match the "Sort" options */
571 _("Rev-Sort (a)lias, (n)ame, (e)mail or (u)nsorted?") :
572 /* L10N: The highlighted letters must match the "Rev-Sort" options */
573 _("Sort (a)lias, (n)ame, (e)mail or (u)nsorted?"),
574 /* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
575 _("aneu")))
576 {
577 case -1: /* abort */
578 resort = false;
579 break;
580
581 case 1: /* (a)lias */
582 sort = ALIAS_SORT_ALIAS;
583 break;
584
585 case 2: /* (n)ame */
586 sort = ALIAS_SORT_NAME;
587 break;
588
589 case 3: /* (e)mail */
590 sort = ALIAS_SORT_EMAIL;
591 break;
592
593 case 4: /* (u)nsorted */
594 sort = ALIAS_SORT_UNSORTED;
595 break;
596 }
597
598 if (resort)
599 {
600 sort |= reverse ? SORT_REVERSE : 0;
601
602 // This will trigger a WA_RECALC
603 cs_subset_str_native_set(mdata->sub, "alias_sort", sort, NULL);
604 }
605
606 return FR_SUCCESS;
607}
608
609// -----------------------------------------------------------------------------
610
614static const struct AliasFunction AliasFunctions[] = {
615 // clang-format off
616 { OP_CREATE_ALIAS, op_create_alias },
617 { OP_DELETE, op_delete },
618 { OP_EXIT, op_exit },
619 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
620 { OP_MAIL, op_mail },
621 { OP_MAIN_LIMIT, op_main_limit },
622 { OP_MAIN_TAG_PATTERN, op_main_tag_pattern },
623 { OP_MAIN_UNTAG_PATTERN, op_main_untag_pattern },
624 { OP_QUERY, op_query },
625 { OP_QUERY_APPEND, op_query },
626 { OP_SEARCH, op_search },
627 { OP_SEARCH_NEXT, op_search },
628 { OP_SEARCH_OPPOSITE, op_search },
629 { OP_SEARCH_REVERSE, op_search },
630 { OP_SORT, op_sort },
631 { OP_SORT_REVERSE, op_sort },
632 { OP_UNDELETE, op_delete },
633 { 0, NULL },
634 // clang-format on
635};
636
640int alias_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
641{
642 // The Dispatcher may be called on any Window in the Dialog
643 struct MuttWindow *dlg = dialog_find(win);
644 if (!event || !dlg || !dlg->wdata)
645 return FR_ERROR;
646
647 struct Menu *menu = dlg->wdata;
648 struct AliasMenuData *mdata = menu->mdata;
649 if (!mdata)
650 return FR_ERROR;
651
652 const int op = event->op;
653
654 struct AliasFunctionData fdata = {
655 .n = NeoMutt,
656 .wdata = mdata,
657 };
658
659 int rc = FR_UNKNOWN;
660 for (size_t i = 0; AliasFunctions[i].op != OP_NULL; i++)
661 {
662 const struct AliasFunction *fn = &AliasFunctions[i];
663 if (fn->op == op)
664 {
665 rc = fn->function(&fdata, event);
666 break;
667 }
668 }
669
670 if (rc == FR_UNKNOWN) // Not our function
671 return rc;
672
673 const char *result = dispatcher_get_retval_name(rc);
674 mutt_debug(LL_DEBUG1, "Handled %s (%d) -> %s\n", opcodes_get_name(op), op, NONULL(result));
675
677 return rc;
678}
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition address.c:774
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition address.c:1469
Email Address Handling.
const struct MenuFuncOp OpQuery[]
Functions for the external Query Menu.
Definition functions.c:71
static const struct MenuOpSeq QueryDefaultBindings[]
Key bindings for the external Query Menu.
Definition functions.c:105
static const struct MenuOpSeq AliasDefaultBindings[]
Key bindings for the Alias Menu.
Definition functions.c:88
static int alias_add_selection(struct AliasViewPtrArray *avpa, struct AliasMenuData *mdata, bool tagged, int count)
Build a working set of AliasView pointers for an action.
Definition functions.c:209
static const struct AliasFunction AliasFunctions[]
All the NeoMutt functions that the Alias supports.
Definition functions.c:614
static void alias_apply_set_deleted(struct AliasViewPtrArray *avpa, bool deleted)
Apply the deleted flag to a working set of AliasViews.
Definition functions.c:251
void alias_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
Initialise the Alias Keybindings - Implements ::init_keys_api.
Definition functions.c:124
static int alias_select_entries(struct AliasMenuData *mdata, int count)
Select entries to return from the Alias Dialog.
Definition functions.c:347
static const struct MenuFuncOp OpAlias[]
Functions for the Alias Menu.
Definition functions.c:55
Alias functions.
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition sort.c:235
Email Aliases.
Alias private Module data.
Address book sorting functions.
@ ALIAS_SORT_UNSORTED
Sort by the order the Aliases were configured.
Definition sort.h:34
@ ALIAS_SORT_NAME
Sort by Real Name.
Definition sort.h:33
@ ALIAS_SORT_EMAIL
Sort by Email Address.
Definition sort.h:32
@ ALIAS_SORT_ALIAS
Sort by Alias short name.
Definition sort.h:31
void aliaslist_clear(struct AliasArray *aa)
Empty a List of Aliases.
Definition alias.c:698
void alias_create(struct AddressList *al, const struct ConfigSubset *sub)
Create a new Alias from an Address.
Definition alias.c:368
Representation of a single alias to an email address.
int alias_array_alias_add(struct AliasViewArray *ava, struct Alias *alias)
Add an Alias to the AliasViewArray.
Definition array.c:47
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#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:209
#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
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition helpers.c:266
Convenience wrapper for the config headers.
#define SORT_REVERSE
Reverse the order of the sort.
Definition sort.h:40
Convenience wrapper for the core headers.
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition dialog.c:89
const char * dispatcher_get_retval_name(int rv)
Get the name of a return value.
Definition dispatcher.c:55
void dispatcher_flush_on_error(int rv)
Flush pending keys after a dispatch error.
Definition dispatcher.c:65
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:36
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:34
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
@ FR_CONTINUE
Remain in the Dialog.
Definition dispatcher.h:35
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
int query_run(const char *s, bool verbose, struct AliasArray *aa, const struct ConfigSubset *sub)
Run an external program to find Addresses.
Definition dlg_query.c:188
bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
Turn an Alias into an AddressList.
Definition dlg_query.c:119
Edit a string.
@ MUTT_COMP_NONE
No flags are set.
Definition wdata.h:46
static int op_main_limit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
show only messages matching a pattern - Implements alias_function_t -
Definition functions.c:411
static int op_query(struct AliasFunctionData *fdata, const struct KeyEvent *event)
query external program for addresses - Implements alias_function_t -
Definition functions.c:469
static int op_create_alias(struct AliasFunctionData *fdata, const struct KeyEvent *event)
create an alias from a message sender - Implements alias_function_t -
Definition functions.c:152
static int op_jump(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Jump to an index number - Implements alias_function_t -.
Definition functions.c:320
static int op_main_untag_pattern(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Untag messages matching a pattern - Implements alias_function_t -.
Definition functions.c:448
static int op_main_tag_pattern(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Tag messages matching a pattern - Implements alias_function_t -.
Definition functions.c:431
static int op_exit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
exit this menu - Implements alias_function_t -
Definition functions.c:312
static int op_mail(struct AliasFunctionData *fdata, const struct KeyEvent *event)
mail the selected entries - Implements alias_function_t -
Definition functions.c:403
static int op_delete(struct AliasFunctionData *fdata, const struct KeyEvent *event)
delete the current entry - Implements alias_function_t -
Definition functions.c:274
static int op_search(struct AliasFunctionData *fdata, const struct KeyEvent *event)
search for a regular expression - Implements alias_function_t -
Definition functions.c:523
static int op_generic_select_entry(struct AliasFunctionData *fdata, const struct KeyEvent *event)
select the current entry - Implements alias_function_t -
Definition functions.c:392
static int op_sort(struct AliasFunctionData *fdata, const struct KeyEvent *event)
sort aliases - Implements alias_function_t -
Definition functions.c:561
int alias_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
Perform a Alias function - Implements function_dispatcher_t -.
Definition functions.c:640
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition window.c:502
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
Definition question.c:62
#define mutt_warning(...)
Definition logging2.h:92
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
Convenience wrapper for the gui headers.
void alias_set_title(struct MuttWindow *sbar, char *menu_name, char *limit)
Create a title string for the Menu.
Definition gui.c:72
Shared code for the Alias and Query Dialogs.
Read/write command history from/to a file.
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:61
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:121
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:87
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:104
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:134
Manage keymappings.
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
GUI present the user with a selectable list.
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:179
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:155
@ MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:61
@ MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:64
@ MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition lib.h:63
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:169
@ MODULE_ID_ALIAS
ModuleAlias, Alias
Definition module_api.h:48
Convenience wrapper for the library headers.
#define _(a)
Definition message.h:28
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition opcodes.c:48
Match patterns to emails.
@ PAA_VISIBLE
Set AliasView.is_visible and hide the rest.
Definition lib.h:203
@ PAA_TAG
Set AliasView.is_tagged, but don't touch the others.
Definition lib.h:201
@ PAA_UNTAG
Unset AliasView.is_tagged, but don't touch the others.
Definition lib.h:202
int mutt_pattern_alias_func(char *prompt, struct AliasMenuData *mdata, enum PatternAlias action, struct Menu *menu)
Perform some Pattern matching for Alias.
Definition pattern.c:170
int mutt_search_alias_command(struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags)
Perform a search.
Definition pattern.c:619
Ask the user a question.
#define TAILQ_HEAD_INITIALIZER(head)
Definition queue.h:694
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition sbar.c:227
uint8_t SearchFlags
@ SEARCH_NONE
No flags are set.
@ SEARCH_PROMPT
Ask for search input.
@ SEARCH_OPPOSITE
Search in the opposite direction.
#define ASSERT(COND)
Definition signal2.h:59
#define NONULL(x)
Definition string2.h:44
Data passed to Alias worker functions.
Definition functions.h:40
struct AliasMenuData * wdata
Alias menu data.
Definition functions.h:42
A NeoMutt function.
Definition functions.h:64
int op
Op code, e.g. OP_SEARCH.
Definition functions.h:65
alias_function_t function
Function to call.
Definition functions.h:66
AliasView array wrapper with Pattern information -.
Definition gui.h:55
struct AliasViewArray ava
All Aliases/Queries.
Definition gui.h:56
struct AliasArray * aa
Alias data.
Definition gui.h:57
struct MuttWindow * sbar
Status Bar.
Definition gui.h:62
struct Menu * menu
Menu.
Definition gui.h:59
struct Buffer * query
Query string.
Definition gui.h:60
struct ConfigSubset * sub
Config items.
Definition gui.h:58
Alias private Module data.
Definition module_data.h:33
struct MenuDefinition * menu_query
Query menu definition.
Definition module_data.h:43
struct MenuDefinition * menu_alias
Alias menu definition.
Definition module_data.h:42
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
A shortcut for an email address or addresses.
Definition alias.h:35
String manipulation buffer.
Definition buffer.h:36
An event such as a keypress.
Definition get.h:75
int count
Optional count prefix, e.g. 3 for 3j
Definition get.h:78
int op
Function opcode, e.g. OP_HELP.
Definition get.h:77
Functions for a Dialog or Window.
Definition menu.h:77
Mapping between a function and an operation.
Definition menu.h:35
Mapping between an operation and a key sequence.
Definition menu.h:45
Definition lib.h:86
void * mdata
Private data.
Definition lib.h:155
bool tag_prefix
User has pressed <tag-prefix>
Definition lib.h:92
int max
Number of entries in the menu.
Definition lib.h:88
void * wdata
Private data.
Container for Accounts, Notifications.
Definition neomutt.h:41
Collection of related functions.
Definition menu.h:65
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_QUERY
Select from results of external query.
Definition type.h:49
@ MENU_ALIAS
Select an email address by its alias.
Definition type.h:34