NeoMutt  2025-12-11-980-ge38c27
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 { "limit", OP_MAIN_LIMIT },
58 { "mail", OP_MAIL },
59 { "sort-alias", OP_SORT },
60 { "sort-alias-reverse", OP_SORT_REVERSE },
61 { "tag-pattern", OP_MAIN_TAG_PATTERN },
62 { "undelete-entry", OP_UNDELETE },
63 { "untag-pattern", OP_MAIN_UNTAG_PATTERN },
64 { NULL, 0 },
65};
66
70const struct MenuFuncOp OpQuery[] = { /* map: query */
71 { "create-alias", OP_CREATE_ALIAS },
72 { "limit", OP_MAIN_LIMIT },
73 { "mail", OP_MAIL },
74 { "query", OP_QUERY },
75 { "query-append", OP_QUERY_APPEND },
76 { "sort", OP_SORT },
77 { "sort-reverse", OP_SORT_REVERSE },
78 { "tag-pattern", OP_MAIN_TAG_PATTERN },
79 { "untag-pattern", OP_MAIN_UNTAG_PATTERN },
80 { NULL, 0 },
81};
82
86static const struct MenuOpSeq AliasDefaultBindings[] = { /* map: alias */
87 { OP_DELETE, "d" },
88 { OP_MAIL, "m" },
89 { OP_MAIN_LIMIT, "l" },
90 { OP_MAIN_TAG_PATTERN, "T" },
91 { OP_MAIN_UNTAG_PATTERN, "\024" }, // <Ctrl-T>
92 { OP_SORT, "o" },
93 { OP_SORT_REVERSE, "O" },
94 { OP_TAG, "<space>" },
95 { OP_UNDELETE, "u" },
96 { 0, NULL },
97};
98
102static const struct MenuOpSeq QueryDefaultBindings[] = { /* map: query */
103 { OP_CREATE_ALIAS, "a" },
104 { OP_MAIL, "m" },
105 { OP_MAIN_LIMIT, "l" },
106 { OP_MAIN_TAG_PATTERN, "T" },
107 { OP_MAIN_UNTAG_PATTERN, "\024" }, // <Ctrl-T>
108 { OP_QUERY, "Q" },
109 { OP_QUERY_APPEND, "A" },
110 { OP_SORT, "o" },
111 { OP_SORT_REVERSE, "O" },
112 { OP_TAG, "<space>" },
113 { 0, NULL },
114};
115// clang-format on
116
120void alias_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
121{
123 ASSERT(mod_data);
124
125 struct MenuDefinition *md = NULL;
126 struct SubMenu *sm = NULL;
127
129 md = km_register_menu(MENU_ALIAS, "alias");
130 km_menu_add_submenu(md, sm);
131 km_menu_add_submenu(md, sm_generic);
133
134 mod_data->menu_alias = md;
135
137 md = km_register_menu(MENU_QUERY, "query");
138 km_menu_add_submenu(md, sm);
139 km_menu_add_submenu(md, sm_generic);
141
142 mod_data->menu_query = md;
143}
144
148static int op_create_alias(struct AliasFunctionData *fdata, const struct KeyEvent *event)
149{
150 struct AliasMenuData *mdata = fdata->wdata;
151 struct Menu *menu = mdata->menu;
152
153 if (menu->tag_prefix)
154 {
155 struct AddressList naddr = TAILQ_HEAD_INITIALIZER(naddr);
156
157 struct AliasView *avp = NULL;
158 ARRAY_FOREACH(avp, &mdata->ava)
159 {
160 if (!avp->is_tagged)
161 continue;
162
163 struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
164 if (alias_to_addrlist(&al, avp->alias))
165 {
166 mutt_addrlist_copy(&naddr, &al, false);
168 }
169 }
170
171 alias_create(&naddr, mdata->sub);
172 mutt_addrlist_clear(&naddr);
173 }
174 else
175 {
176 struct AliasView *av = ARRAY_GET(&mdata->ava, menu_get_index(menu));
177 if (!av)
178 return FR_NO_ACTION;
179
180 struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
181 if (alias_to_addrlist(&al, av->alias))
182 {
183 alias_create(&al, mdata->sub);
185 }
186 }
187 return FR_SUCCESS;
188}
189
205static int alias_add_selection(struct AliasViewPtrArray *avpa,
206 struct AliasMenuData *mdata, bool tagged, int count)
207{
208 if (!avpa || !mdata)
209 return 0;
210
211 if (tagged)
212 {
213 struct AliasView *avp = NULL;
214 ARRAY_FOREACH(avp, &mdata->ava)
215 {
216 if (avp->is_tagged)
217 ARRAY_ADD(avpa, avp);
218 }
219 }
220 else
221 {
222 struct Menu *menu = mdata->menu;
223 const int index = menu_get_index(menu);
224 if ((index < 0) || (index >= menu->max))
225 return 0;
226
227 int n = (count > 1) ? count : 1;
228 if ((index + n) > menu->max)
229 n = menu->max - index;
230
231 for (int i = 0; i < n; i++)
232 {
233 struct AliasView *av = ARRAY_GET(&mdata->ava, index + i);
234 if (av)
235 ARRAY_ADD(avpa, av);
236 }
237 }
238
239 return ARRAY_SIZE(avpa);
240}
241
247static void alias_apply_set_deleted(struct AliasViewPtrArray *avpa, bool deleted)
248{
249 if (!avpa)
250 return;
251
252 struct AliasView **avpp = NULL;
253 ARRAY_FOREACH(avpp, avpa)
254 {
255 if (*avpp)
256 (*avpp)->is_deleted = deleted;
257 }
258}
259
270static int op_delete(struct AliasFunctionData *fdata, const struct KeyEvent *event)
271{
272 struct AliasMenuData *mdata = fdata->wdata;
273 struct Menu *menu = mdata->menu;
274 const bool deleted = (event->op == OP_DELETE);
275
276 struct AliasViewPtrArray avpa = ARRAY_HEAD_INITIALIZER;
277 alias_add_selection(&avpa, mdata, menu->tag_prefix, event->count);
278 if (ARRAY_EMPTY(&avpa))
279 {
280 ARRAY_FREE(&avpa);
281 return FR_NO_ACTION;
282 }
283 alias_apply_set_deleted(&avpa, deleted);
284 const int num = ARRAY_SIZE(&avpa);
285 ARRAY_FREE(&avpa);
286
287 if (menu->tag_prefix)
288 {
290 }
291 else
292 {
293 const int index = menu_get_index(menu);
295 const bool c_resolve = cs_subset_bool(mdata->sub, "resolve");
296 if (c_resolve && ((index + num) < menu->max))
297 {
298 menu_set_index(menu, index + num);
300 }
301 }
302 return FR_SUCCESS;
303}
304
308static int op_quit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
309{
310 return FR_DONE;
311}
312
316static int op_jump(struct AliasFunctionData *fdata, const struct KeyEvent *event)
317{
318 int num = event->count;
319
320 if (num == 0)
321 return FR_NO_ACTION;
322
323 struct AliasMenuData *mdata = fdata->wdata;
324 struct Menu *menu = mdata->menu;
325
326 if ((num < 1) || (num > menu->max))
327 {
328 mutt_warning(_("Invalid message number"));
329 return FR_ERROR;
330 }
331
332 menu_set_index(menu, num - 1); // Num is 1-based
333 return FR_SUCCESS;
334}
335
343static int alias_select_entries(struct AliasMenuData *mdata, int count)
344{
345 struct Menu *menu = mdata->menu;
346 if (menu->tag_prefix)
347 {
348 // Untag any non-visible aliases
349 struct AliasView *avp = NULL;
350 ARRAY_FOREACH(avp, &mdata->ava)
351 {
352 if (avp->is_tagged && !avp->is_visible)
353 avp->is_tagged = false;
354 }
355 }
356 else
357 {
358 struct AliasViewPtrArray avpa = ARRAY_HEAD_INITIALIZER;
359 alias_add_selection(&avpa, mdata, false, count);
360 if (ARRAY_EMPTY(&avpa))
361 {
362 ARRAY_FREE(&avpa);
363 return FR_NO_ACTION;
364 }
365
366 // Untag all but the selected alias(es)
367 struct AliasView *avp = NULL;
368 ARRAY_FOREACH(avp, &mdata->ava)
369 {
370 avp->is_tagged = false;
371 }
372
373 struct AliasView **avpp = NULL;
374 ARRAY_FOREACH(avpp, &avpa)
375 {
376 if (*avpp)
377 (*avpp)->is_tagged = true;
378 }
379 ARRAY_FREE(&avpa);
380 }
381
382 return FR_CONTINUE;
383}
384
388static int op_generic_select_entry(struct AliasFunctionData *fdata, const struct KeyEvent *event)
389{
390 if (event->count > 0)
391 return op_jump(fdata, event);
392
393 return alias_select_entries(fdata->wdata, 0);
394}
395
399static int op_mail(struct AliasFunctionData *fdata, const struct KeyEvent *event)
400{
401 return alias_select_entries(fdata->wdata, event->count);
402}
403
407static int op_main_limit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
408{
409 struct AliasMenuData *mdata = fdata->wdata;
410 struct Menu *menu = mdata->menu;
411 int rc = mutt_pattern_alias_func(_("Limit to addresses matching: "), mdata,
412 PAA_VISIBLE, menu);
413 if (rc != 0)
414 return FR_NO_ACTION;
415
416 alias_array_sort(&mdata->ava, mdata->sub);
417 alias_set_title(mdata->sbar, mdata->title, mdata->limit);
419 window_redraw(NULL);
420
421 return FR_SUCCESS;
422}
423
427static int op_main_tag_pattern(struct AliasFunctionData *fdata, const struct KeyEvent *event)
428{
429 struct AliasMenuData *mdata = fdata->wdata;
430 struct Menu *menu = mdata->menu;
431 int rc = mutt_pattern_alias_func(_("Tag addresses matching: "), mdata, PAA_TAG, menu);
432 if (rc != 0)
433 return FR_NO_ACTION;
434
436 window_redraw(NULL);
437
438 return FR_SUCCESS;
439}
440
444static int op_main_untag_pattern(struct AliasFunctionData *fdata, const struct KeyEvent *event)
445{
446 struct AliasMenuData *mdata = fdata->wdata;
447 struct Menu *menu = mdata->menu;
448 int rc = mutt_pattern_alias_func(_("Untag addresses matching: "), mdata, PAA_UNTAG, menu);
449 if (rc != 0)
450 return FR_NO_ACTION;
451
453 window_redraw(NULL);
454
455 return FR_SUCCESS;
456}
457
465static int op_query(struct AliasFunctionData *fdata, const struct KeyEvent *event)
466{
467 struct AliasMenuData *mdata = fdata->wdata;
468 struct Buffer *buf = mdata->query;
469 if ((mw_get_field(_("Query: "), buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0) ||
470 buf_is_empty(buf))
471 {
472 return FR_NO_ACTION;
473 }
474
475 const int op = event->op;
476 if (op == OP_QUERY)
477 {
478 ARRAY_FREE(&mdata->ava);
479 aliaslist_clear(mdata->aa);
480 }
481
482 struct Menu *menu = mdata->menu;
483 struct AliasArray aa = ARRAY_HEAD_INITIALIZER;
484
485 query_run(buf_string(buf), true, &aa, mdata->sub);
487 char title[256] = { 0 };
488 snprintf(title, sizeof(title), "%s%s", _("Query: "), buf_string(buf));
489 sbar_set_title(mdata->sbar, title);
490
491 if (ARRAY_EMPTY(&aa))
492 {
493 if (op == OP_QUERY)
494 menu->max = 0;
495 return FR_NO_ACTION;
496 }
497
498 struct Alias **ap = NULL;
499 ARRAY_FOREACH(ap, &aa)
500 {
501 alias_array_alias_add(&mdata->ava, *ap);
502 ARRAY_ADD(mdata->aa, *ap); // Transfer
503 }
504 ARRAY_FREE(&aa); // Free the array structure but not the aliases
505 alias_array_sort(&mdata->ava, mdata->sub);
506 menu->max = ARRAY_SIZE(&mdata->ava);
507 return FR_SUCCESS;
508}
509
519static int op_search(struct AliasFunctionData *fdata, const struct KeyEvent *event)
520{
521 struct AliasMenuData *mdata = fdata->wdata;
522 SearchFlags flags = SEARCH_NONE;
523 switch (event->op)
524 {
525 case OP_SEARCH:
526 flags |= SEARCH_PROMPT;
527 mdata->search_state->reverse = false;
528 break;
529 case OP_SEARCH_REVERSE:
530 flags |= SEARCH_PROMPT;
531 mdata->search_state->reverse = true;
532 break;
533 case OP_SEARCH_NEXT:
534 break;
535 case OP_SEARCH_OPPOSITE:
536 flags |= SEARCH_OPPOSITE;
537 break;
538 }
539
540 struct Menu *menu = mdata->menu;
541 int index = menu_get_index(menu);
542 index = mutt_search_alias_command(menu, index, mdata->search_state, flags);
543 if (index == -1)
544 return FR_NO_ACTION;
545
546 menu_set_index(menu, index);
547 return FR_SUCCESS;
548}
549
557static int op_sort(struct AliasFunctionData *fdata, const struct KeyEvent *event)
558{
559 struct AliasMenuData *mdata = fdata->wdata;
560 int sort = cs_subset_sort(mdata->sub, "alias_sort");
561 bool resort = true;
562 const int op = event->op;
563 bool reverse = (op == OP_SORT_REVERSE);
564
565 switch (mw_multi_choice(reverse ?
566 /* L10N: The highlighted letters must match the "Sort" options */
567 _("Rev-Sort (a)lias, (n)ame, (e)mail or (u)nsorted?") :
568 /* L10N: The highlighted letters must match the "Rev-Sort" options */
569 _("Sort (a)lias, (n)ame, (e)mail or (u)nsorted?"),
570 /* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
571 _("aneu")))
572 {
573 case -1: /* abort */
574 resort = false;
575 break;
576
577 case 1: /* (a)lias */
578 sort = ALIAS_SORT_ALIAS;
579 break;
580
581 case 2: /* (n)ame */
582 sort = ALIAS_SORT_NAME;
583 break;
584
585 case 3: /* (e)mail */
586 sort = ALIAS_SORT_EMAIL;
587 break;
588
589 case 4: /* (u)nsorted */
590 sort = ALIAS_SORT_UNSORTED;
591 break;
592 }
593
594 if (resort)
595 {
596 sort |= reverse ? SORT_REVERSE : 0;
597
598 // This will trigger a WA_RECALC
599 cs_subset_str_native_set(mdata->sub, "alias_sort", sort, NULL);
600 }
601
602 return FR_SUCCESS;
603}
604
605// -----------------------------------------------------------------------------
606
610static const struct AliasFunction AliasFunctions[] = {
611 // clang-format off
612 { OP_CREATE_ALIAS, op_create_alias },
613 { OP_DELETE, op_delete },
614 { OP_EXIT, op_quit },
615 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
616 { OP_MAIL, op_mail },
617 { OP_MAIN_LIMIT, op_main_limit },
618 { OP_MAIN_TAG_PATTERN, op_main_tag_pattern },
619 { OP_MAIN_UNTAG_PATTERN, op_main_untag_pattern },
620 { OP_QUERY, op_query },
621 { OP_QUERY_APPEND, op_query },
622 { OP_QUIT, op_quit },
623 { OP_SEARCH, op_search },
624 { OP_SEARCH_NEXT, op_search },
625 { OP_SEARCH_OPPOSITE, op_search },
626 { OP_SEARCH_REVERSE, op_search },
627 { OP_SORT, op_sort },
628 { OP_SORT_REVERSE, op_sort },
629 { OP_UNDELETE, op_delete },
630 { 0, NULL },
631 // clang-format on
632};
633
637int alias_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
638{
639 // The Dispatcher may be called on any Window in the Dialog
640 struct MuttWindow *dlg = dialog_find(win);
641 if (!event || !dlg || !dlg->wdata)
642 return FR_ERROR;
643
644 struct Menu *menu = dlg->wdata;
645 struct AliasMenuData *mdata = menu->mdata;
646 if (!mdata)
647 return FR_ERROR;
648
649 const int op = event->op;
650
651 struct AliasFunctionData fdata = {
652 .n = NeoMutt,
653 .wdata = mdata,
654 };
655
656 int rc = FR_UNKNOWN;
657 for (size_t i = 0; AliasFunctions[i].op != OP_NULL; i++)
658 {
659 const struct AliasFunction *fn = &AliasFunctions[i];
660 if (fn->op == op)
661 {
662 rc = fn->function(&fdata, event);
663 break;
664 }
665 }
666
667 if (rc == FR_UNKNOWN) // Not our function
668 return rc;
669
670 const char *result = dispatcher_get_retval_name(rc);
671 mutt_debug(LL_DEBUG1, "Handled %s (%d) -> %s\n", opcodes_get_name(op), op, NONULL(result));
672
674 return rc;
675}
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition address.c:776
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition address.c:1475
Email Address Handling.
const struct MenuFuncOp OpQuery[]
Functions for the external Query Menu.
Definition functions.c:70
static const struct MenuOpSeq QueryDefaultBindings[]
Key bindings for the external Query Menu.
Definition functions.c:102
static const struct MenuOpSeq AliasDefaultBindings[]
Key bindings for the Alias Menu.
Definition functions.c:86
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:205
static const struct AliasFunction AliasFunctions[]
All the NeoMutt functions that the Alias supports.
Definition functions.c:610
static void alias_apply_set_deleted(struct AliasViewPtrArray *avpa, bool deleted)
Apply the deleted flag to a working set of AliasViews.
Definition functions.c:247
void alias_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
Initialise the Alias Keybindings - Implements ::init_keys_api.
Definition functions.c:120
static int alias_select_entries(struct AliasMenuData *mdata, int count)
Select entries to return from the Alias Dialog.
Definition functions.c:343
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:699
void alias_create(struct AddressList *al, const struct ConfigSubset *sub)
Create a new Alias from an Address.
Definition alias.c:369
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:298
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_quit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Save changes and exit this dialog - Implements alias_function_t -.
Definition functions.c:308
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:407
static int op_query(struct AliasFunctionData *fdata, const struct KeyEvent *event)
query external program for addresses - Implements alias_function_t -
Definition functions.c:465
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:148
static int op_jump(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Jump to an index number - Implements alias_function_t -.
Definition functions.c:316
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:444
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:427
static int op_mail(struct AliasFunctionData *fdata, const struct KeyEvent *event)
mail the selected entries - Implements alias_function_t -
Definition functions.c:399
static int op_delete(struct AliasFunctionData *fdata, const struct KeyEvent *event)
delete the current entry - Implements alias_function_t -
Definition functions.c:270
static int op_search(struct AliasFunctionData *fdata, const struct KeyEvent *event)
search for a regular expression - Implements alias_function_t -
Definition functions.c:519
static int op_generic_select_entry(struct AliasFunctionData *fdata, const struct KeyEvent *event)
select the current entry - Implements alias_function_t -
Definition functions.c:388
static int op_sort(struct AliasFunctionData *fdata, const struct KeyEvent *event)
sort aliases - Implements alias_function_t -
Definition functions.c:557
int alias_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
Perform a Alias function - Implements function_dispatcher_t -.
Definition functions.c:637
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:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:88
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:105
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
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:177
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:153
@ 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:167
@ 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:666
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 menudef.h:44
Mapping between a function and an operation.
Definition menu.h:37
Mapping between an operation and a key sequence.
Definition menu.h:47
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 menudef.h:33
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:50
@ MENU_ALIAS
Select an email address by its alias.
Definition type.h:34