NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_query.c
Go to the documentation of this file.
1
72#include "config.h"
73#include <stdbool.h>
74#include <stdio.h>
75#include <string.h>
76#include <sys/types.h>
77#include "mutt/lib.h"
78#include "address/lib.h"
79#include "config/lib.h"
80#include "email/lib.h"
81#include "core/lib.h"
82#include "gui/lib.h"
83#include "mutt.h"
84#include "lib.h"
85#include "editor/lib.h"
86#include "expando/lib.h"
87#include "history/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 "globals.h"
95#include "gui.h"
96#include "mutt_logging.h"
97
99
101static const struct Mapping QueryHelp[] = {
102 // clang-format off
103 { N_("Exit"), OP_EXIT },
104 { N_("Mail"), OP_MAIL },
105 { N_("New Query"), OP_QUERY },
106 { N_("Make Alias"), OP_CREATE_ALIAS },
107 { N_("Sort"), OP_SORT },
108 { N_("Rev-Sort"), OP_SORT_REVERSE },
109 { N_("Search"), OP_SEARCH },
110 { N_("Help"), OP_HELP },
111 { NULL, 0 },
112 // clang-format on
113};
114
121bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
122{
123 if (!al || !TAILQ_EMPTY(al) || !alias)
124 return false;
125
126 mutt_addrlist_copy(al, &alias->addr, false);
127 if (!TAILQ_EMPTY(al))
128 {
129 struct Address *first = TAILQ_FIRST(al);
130 struct Address *second = TAILQ_NEXT(first, entries);
131 if (!second && !first->personal)
132 {
133 first->personal = buf_new(alias->name);
134 }
135
136 mutt_addrlist_to_intl(al, NULL);
137 }
138
139 return true;
140}
141
145void query_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
146 struct Buffer *buf)
147{
148 const struct AliasView *av = data;
149 const struct Alias *alias = av->alias;
150
151 struct Buffer *addrs = buf_pool_get();
152 mutt_addrlist_write(&alias->addr, addrs, true);
153
154 buf_printf(buf, "<%s>", buf_string(addrs));
155 buf_pool_release(&addrs);
156}
157
161long query_c_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
162{
163 const struct AliasView *av = data;
164
165 return av->num + 1;
166}
167
171void query_e(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
172 struct Buffer *buf)
173{
174 const struct AliasView *av = data;
175 const struct Alias *alias = av->alias;
176
177 const char *s = alias->comment;
178 buf_strcpy(buf, s);
179}
180
184void query_n(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
185 struct Buffer *buf)
186{
187 const struct AliasView *av = data;
188 const struct Alias *alias = av->alias;
189
190 const char *s = alias->name;
191 buf_strcpy(buf, s);
192}
193
197long query_t_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
198{
199 const struct AliasView *av = data;
200 return av->is_tagged;
201}
202
206void query_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
207 struct Buffer *buf)
208{
209 const struct AliasView *av = data;
210
211 // NOTE(g0mb4): use $flag_chars?
212 const char *s = av->is_tagged ? "*" : " ";
213 buf_strcpy(buf, s);
214}
215
219void query_Y(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
220 struct Buffer *buf)
221{
222 const struct AliasView *av = data;
223
224 alias_tags_to_buffer(&av->alias->tags, buf);
225}
226
232static int query_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
233{
234 const struct AliasMenuData *mdata = menu->mdata;
235 const struct AliasViewArray *ava = &mdata->ava;
236 struct AliasView *av = ARRAY_GET(ava, line);
237
238 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
239 if (c_arrow_cursor)
240 {
241 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
242 if (max_cols > 0)
243 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
244 }
245
246 const struct Expando *c_query_format = cs_subset_expando(mdata->sub, "query_format");
247 return expando_filter(c_query_format, QueryRenderData, av,
248 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
249}
250
254static int query_tag(struct Menu *menu, int sel, int act)
255{
256 const struct AliasMenuData *mdata = menu->mdata;
257 const struct AliasViewArray *ava = &mdata->ava;
258 struct AliasView *av = ARRAY_GET(ava, sel);
259
260 bool ot = av->is_tagged;
261
262 av->is_tagged = ((act >= 0) ? act : !av->is_tagged);
263 return av->is_tagged - ot;
264}
265
275int query_run(const char *s, bool verbose, struct AliasList *al, const struct ConfigSubset *sub)
276{
277 FILE *fp = NULL;
278 char *buf = NULL;
279 size_t buflen;
280 char *msg = NULL;
281 size_t msglen = 0;
282 char *tok = NULL;
283 char *next_tok = NULL;
284 struct Buffer *cmd = buf_pool_get();
285
286 const char *const c_query_command = cs_subset_string(sub, "query_command");
287 buf_file_expand_fmt_quote(cmd, c_query_command, s);
288
289 pid_t pid = filter_create(buf_string(cmd), NULL, &fp, NULL, EnvList);
290 if (pid < 0)
291 {
292 mutt_debug(LL_DEBUG1, "unable to fork command: %s\n", buf_string(cmd));
293 buf_pool_release(&cmd);
294 return -1;
295 }
296 buf_pool_release(&cmd);
297
298 if (verbose)
299 mutt_message(_("Waiting for response..."));
300
301 /* The query protocol first reads one NL-terminated line. If an error
302 * occurs, this is assumed to be an error message. Otherwise it's ignored. */
303 msg = mutt_file_read_line(msg, &msglen, fp, NULL, MUTT_RL_NO_FLAGS);
304 while ((buf = mutt_file_read_line(buf, &buflen, fp, NULL, MUTT_RL_NO_FLAGS)))
305 {
306 tok = buf;
307 next_tok = strchr(tok, '\t');
308 if (next_tok)
309 *next_tok++ = '\0';
310
311 if (*tok == '\0')
312 continue;
313
314 struct Alias *alias = alias_new();
315
316 mutt_addrlist_parse(&alias->addr, tok);
317
318 if (next_tok)
319 {
320 tok = next_tok;
321 next_tok = strchr(tok, '\t');
322 if (next_tok)
323 *next_tok++ = '\0';
324
325 alias->name = mutt_str_dup(tok);
326 parse_alias_comments(alias, next_tok);
327 }
328
329 TAILQ_INSERT_TAIL(al, alias, entries);
330 }
331
332 FREE(&buf);
333 mutt_file_fclose(&fp);
334 if (filter_wait(pid))
335 {
336 mutt_debug(LL_DEBUG1, "Error: %s\n", msg);
337 if (verbose)
338 mutt_error("%s", msg);
339 }
340 else
341 {
342 if (verbose)
343 mutt_message("%s", msg);
344 }
345 FREE(&msg);
346
347 return 0;
348}
349
354{
355 if (nc->event_type != NT_WINDOW)
356 return 0;
357 if (!nc->global_data || !nc->event_data)
358 return -1;
360 return 0;
361
362 struct MuttWindow *win_menu = nc->global_data;
363 struct EventWindow *ev_w = nc->event_data;
364 if (ev_w->win != win_menu)
365 return 0;
366
367 struct Menu *menu = win_menu->wdata;
368
371
372 mutt_debug(LL_DEBUG5, "window delete done\n");
373 return 0;
374}
375
383 const char *query)
384{
386
387 struct Menu *menu = sdw.menu;
388
390 menu->tag = query_tag;
391 menu->max = ARRAY_SIZE(&mdata->ava);
392 mdata->title = mutt_str_dup(_("Query"));
393 menu->mdata = mdata;
394 menu->mdata_free = NULL; // Menu doesn't own the data
395
396 struct MuttWindow *win_menu = menu->win;
397
398 // Override the Simple Dialog's recalc()
399 win_menu->recalc = alias_recalc;
400
401 char title[256] = { 0 };
402 snprintf(title, sizeof(title), "%s: %s", mdata->title, query);
403 sbar_set_title(sdw.sbar, title);
404
405 // NT_COLOR is handled by the SimpleDialog
408
409 return sdw;
410}
411
423static bool dlg_query(struct Buffer *buf, struct AliasMenuData *mdata)
424{
425 struct SimpleDialogWindows sdw = query_dialog_new(mdata, buf_string(buf));
426 struct Menu *menu = sdw.menu;
427 mdata->menu = menu;
428 mdata->sbar = sdw.sbar;
429 mdata->query = buf;
430
431 alias_array_sort(&mdata->ava, mdata->sub);
432
433 struct AliasView *avp = NULL;
434 ARRAY_FOREACH(avp, &mdata->ava)
435 {
436 avp->num = ARRAY_FOREACH_IDX;
437 }
438
439 struct MuttWindow *old_focus = window_set_focus(menu->win);
440 // ---------------------------------------------------------------------------
441 // Event Loop
442 int rc = 0;
443 int op = OP_NULL;
444 do
445 {
446 menu_tagging_dispatcher(menu->win, op);
447 window_redraw(NULL);
448
450 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
451 if (op < 0)
452 continue;
453 if (op == OP_NULL)
454 {
456 continue;
457 }
459
460 rc = alias_function_dispatcher(sdw.dlg, op);
461 if (rc == FR_UNKNOWN)
462 rc = menu_function_dispatcher(menu->win, op);
463 if (rc == FR_UNKNOWN)
464 rc = global_function_dispatcher(NULL, op);
465 } while ((rc != FR_DONE) && (rc != FR_CONTINUE));
466 // ---------------------------------------------------------------------------
467
468 window_set_focus(old_focus);
470 window_redraw(NULL);
471 return (rc == FR_CONTINUE); // Was a selection made?
472}
473
480int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
481{
482 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
483 mdata.search_state = search_state_new();
484
485 struct AliasList al = TAILQ_HEAD_INITIALIZER(al);
486 const char *const c_query_command = cs_subset_string(sub, "query_command");
487 if (!c_query_command)
488 {
489 mutt_warning(_("Query command not defined"));
490 goto done;
491 }
492
493 query_run(buf_string(buf), true, &al, sub);
494 if (TAILQ_EMPTY(&al))
495 goto done;
496
497 mdata.al = &al;
498
499 struct Alias *a_first = TAILQ_FIRST(&al);
500 if (!TAILQ_NEXT(a_first, entries)) // only one response?
501 {
502 struct AddressList addr = TAILQ_HEAD_INITIALIZER(addr);
503 if (alias_to_addrlist(&addr, a_first))
504 {
506 buf_reset(buf);
507 mutt_addrlist_write(&addr, buf, false);
508 mutt_addrlist_clear(&addr);
510 }
511 goto done;
512 }
513
514 struct Alias *np = NULL;
515 TAILQ_FOREACH(np, mdata.al, entries)
516 {
517 alias_array_alias_add(&mdata.ava, np);
518 }
519
520 /* multiple results, choose from query menu */
521 if (!dlg_query(buf, &mdata))
522 goto done;
523
524 buf_reset(buf);
525 buf_alloc(buf, 8192);
526 struct AliasView *avp = NULL;
527 ARRAY_FOREACH(avp, &mdata.ava)
528 {
529 if (!avp->is_tagged)
530 continue;
531
532 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
533 if (alias_to_addrlist(&al_copy, avp->alias))
534 {
535 mutt_addrlist_to_local(&al_copy);
536 mutt_addrlist_write(&al_copy, buf, false);
537 mutt_addrlist_clear(&al_copy);
538 }
539 buf_addstr(buf, ", ");
540 }
541
542done:
543 ARRAY_FREE(&mdata.ava);
544 FREE(&mdata.title);
545 FREE(&mdata.limit);
547 aliaslist_clear(&al);
548 return 0;
549}
550
556void query_index(struct Mailbox *m, struct ConfigSubset *sub)
557{
558 const char *const c_query_command = cs_subset_string(sub, "query_command");
559 if (!c_query_command)
560 {
561 mutt_warning(_("Query command not defined"));
562 return;
563 }
564
565 struct AliasList al = TAILQ_HEAD_INITIALIZER(al);
566 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
567 mdata.al = &al;
568 mdata.search_state = search_state_new();
569
570 struct Buffer *buf = buf_pool_get();
571 if ((mw_get_field(_("Query: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0) ||
572 buf_is_empty(buf))
573 {
574 goto done;
575 }
576
577 query_run(buf_string(buf), false, &al, sub);
578 if (TAILQ_EMPTY(&al))
579 goto done;
580
581 struct Alias *np = NULL;
582 TAILQ_FOREACH(np, mdata.al, entries)
583 {
584 alias_array_alias_add(&mdata.ava, np);
585 }
586
587 if (!dlg_query(buf, &mdata))
588 goto done;
589
590 // Prepare the "To:" field of a new email
591 struct Email *e = email_new();
592 e->env = mutt_env_new();
593
594 struct AliasView *avp = NULL;
595 ARRAY_FOREACH(avp, &mdata.ava)
596 {
597 if (!avp->is_tagged)
598 continue;
599
600 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
601 if (alias_to_addrlist(&al_copy, avp->alias))
602 {
603 mutt_addrlist_copy(&e->env->to, &al_copy, false);
604 mutt_addrlist_clear(&al_copy);
605 }
606 }
607
608 mutt_send_message(SEND_REVIEW_TO, e, NULL, m, NULL, sub);
609
610done:
611 ARRAY_FREE(&mdata.ava);
612 FREE(&mdata.title);
613 FREE(&mdata.limit);
615 aliaslist_clear(&al);
616 buf_pool_release(&buf);
617}
618
624const struct ExpandoRenderData QueryRenderData[] = {
625 // clang-format off
626 { ED_ALIAS, ED_ALI_ADDRESS, query_a, NULL },
628 { ED_ALIAS, ED_ALI_COMMENT, query_e, NULL },
629 { ED_ALIAS, ED_ALI_NAME, query_n, NULL },
631 { ED_ALIAS, ED_ALI_TAGS, query_Y, NULL },
632 { -1, -1, NULL, NULL },
633 // clang-format on
634};
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
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition: address.c:1378
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
Definition: address.c:1206
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:480
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1293
Email Address Handling.
void parse_alias_comments(struct Alias *alias, const char *com)
Parse the alias/query comment field.
Definition: commands.c:95
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
struct Alias * alias_new(void)
Create a new Alias.
Definition: alias.c:660
void aliaslist_clear(struct AliasList *al)
Empty a List of Aliases.
Definition: alias.c:697
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_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#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
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
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
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:304
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
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:337
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
static const struct Mapping QueryHelp[]
Help Bar for the Address Query dialog.
Definition: dlg_query.c:101
int query_run(const char *s, bool verbose, struct AliasList *al, const struct ConfigSubset *sub)
Run an external program to find Addresses.
Definition: dlg_query.c:275
static struct SimpleDialogWindows query_dialog_new(struct AliasMenuData *mdata, const char *query)
Create an Query Selection Dialog.
Definition: dlg_query.c:382
bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
Turn an Alias into an AddressList.
Definition: dlg_query.c:121
int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
Perform auto-complete using an Address Query.
Definition: dlg_query.c:480
const struct ExpandoRenderData QueryRenderData[]
Callbacks for Query Expandos.
Definition: dlg_query.c:98
void query_index(struct Mailbox *m, struct ConfigSubset *sub)
Perform an Alias Query and display the results.
Definition: dlg_query.c:556
@ ED_ALIAS
Alias ED_ALI_ ExpandoDataAlias.
Definition: domain.h:35
Edit a string.
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.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
Definition: file.c:808
void buf_file_expand_fmt_quote(struct Buffer *dest, const char *fmt, const char *src)
Replace s in a string with a filename.
Definition: file.c:1456
#define mutt_file_fclose(FP)
Definition: file.h:138
#define MUTT_RL_NO_FLAGS
No flags are set.
Definition: file.h:40
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
char ** EnvList
Private copy of the environment variables.
Definition: globals.c:75
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:462
long query_t_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Query: Tagged char - Implements ExpandoRenderData::get_number() -.
Definition: dlg_query.c:197
long query_c_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Query: Index number - Implements ExpandoRenderData::get_number() -.
Definition: dlg_query.c:161
void query_n(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Query: Name - Implements ExpandoRenderData::get_string() -.
Definition: dlg_query.c:184
void query_e(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Query: Extra information - Implements ExpandoRenderData::get_string() -.
Definition: dlg_query.c:171
void query_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Query: Tagged char - Implements ExpandoRenderData::get_string() -.
Definition: dlg_query.c:206
void query_Y(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Query: Tags - Implements ExpandoRenderData::get_string() -.
Definition: dlg_query.c:219
void query_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Query: Address - Implements ExpandoRenderData::get_string() -.
Definition: dlg_query.c:145
static bool dlg_query(struct Buffer *buf, struct AliasMenuData *mdata)
Get the user to enter an Address Query -.
Definition: dlg_query.c:423
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:274
#define mutt_warning(...)
Definition: logging2.h:90
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_message(...)
Definition: logging2.h:91
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int query_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_query.c:232
static int query_tag(struct Menu *menu, int sel, int act)
Tag an entry in the Query Menu - Implements Menu::tag() -.
Definition: dlg_query.c:254
static int query_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_query.c:353
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:92
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
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
Shared code for the Alias and Query Dialogs.
@ 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
Read/write command history from/to a file.
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:59
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:55
GUI present the user with a selectable list.
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:220
pid_t filter_create(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, char **envlist)
Set up filter program.
Definition: filter.c:209
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
Many unsorted constants and some structs.
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56
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
@ WT_DLG_QUERY
Query Dialog, dlg_query()
Definition: mutt_window.h:90
@ 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
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:48
Match patterns to emails.
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_INSERT_TAIL(head, elm, field)
Definition: queue.h:809
#define TAILQ_FIRST(head)
Definition: queue.h:723
#define TAILQ_NEXT(elm, field)
Definition: queue.h:832
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:637
#define TAILQ_EMPTY(head)
Definition: queue.h:721
#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 sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:227
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:2102
#define SEND_REVIEW_TO
Allow the user to edit the To field.
Definition: send.h:56
Sidebar functions.
Key value store.
An email address.
Definition: address.h:36
struct Buffer * personal
Real name of address.
Definition: address.h:37
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 Menu * menu
Menu.
Definition: gui.h:58
char * title
Title for the status bar.
Definition: gui.h:62
struct AliasList * al
Alias data.
Definition: gui.h:56
struct ConfigSubset * sub
Config items.
Definition: gui.h:57
GUI data wrapping an Alias.
Definition: gui.h:38
struct Alias * alias
Alias.
Definition: gui.h:46
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
char * data
Pointer to data.
Definition: buffer.h:37
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 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 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
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_QUERY
Select from results of external query.
Definition: type.h:55