NeoMutt  2022-04-29-247-gc6aae8
Teaching an old dog new tricks
DOXYGEN
dlg_query.c
Go to the documentation of this file.
1
71#include "config.h"
72#include <stdbool.h>
73#include <stdint.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 "enter/lib.h"
86#include "menu/lib.h"
87#include "send/lib.h"
88#include "alias.h"
89#include "format_flags.h"
90#include "functions.h"
91#include "gui.h"
92#include "keymap.h"
93#include "mutt_logging.h"
94#include "muttlib.h"
95#include "opcodes.h"
96
98static const struct Mapping QueryHelp[] = {
99 // clang-format off
100 { N_("Exit"), OP_EXIT },
101 { N_("Mail"), OP_MAIL },
102 { N_("New Query"), OP_QUERY },
103 { N_("Make Alias"), OP_CREATE_ALIAS },
104 { N_("Sort"), OP_SORT },
105 { N_("Rev-Sort"), OP_SORT_REVERSE },
106 { N_("Search"), OP_SEARCH },
107 { N_("Help"), OP_HELP },
108 { NULL, 0 },
109 // clang-format on
110};
111
118bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
119{
120 if (!al || !TAILQ_EMPTY(al) || !alias)
121 return false;
122
123 mutt_addrlist_copy(al, &alias->addr, false);
124 if (!TAILQ_EMPTY(al))
125 {
126 struct Address *first = TAILQ_FIRST(al);
127 struct Address *second = TAILQ_NEXT(first, entries);
128 if (!second && !first->personal)
129 first->personal = mutt_str_dup(alias->name);
130
131 mutt_addrlist_to_intl(al, NULL);
132 }
133
134 return true;
135}
136
148static const char *query_format_str(char *buf, size_t buflen, size_t col, int cols,
149 char op, const char *src, const char *prec,
150 const char *if_str, const char *else_str,
151 intptr_t data, MuttFormatFlags flags)
152{
153 struct AliasView *av = (struct AliasView *) data;
154 struct Alias *alias = av->alias;
155 char fmt[128] = { 0 };
156 char tmp[256] = { 0 };
157 bool optional = (flags & MUTT_FORMAT_OPTIONAL);
158
159 switch (op)
160 {
161 case 'a':
162 tmp[0] = '<';
163 mutt_addrlist_write(&alias->addr, tmp + 1, sizeof(tmp) - 1, true);
164 const size_t len = strlen(tmp);
165 if (len < (sizeof(tmp) - 1))
166 {
167 tmp[len] = '>';
168 tmp[len + 1] = '\0';
169 }
170 mutt_format_s(buf, buflen, prec, tmp);
171 break;
172 case 'c':
173 snprintf(fmt, sizeof(fmt), "%%%sd", prec);
174 snprintf(buf, buflen, fmt, av->num + 1);
175 break;
176 case 'e':
177 if (!optional)
178 mutt_format_s(buf, buflen, prec, NONULL(alias->comment));
179 else if (!alias->comment || (*alias->comment == '\0'))
180 optional = false;
181 break;
182 case 'n':
183 mutt_format_s(buf, buflen, prec, NONULL(alias->name));
184 break;
185 case 't':
186 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
187 snprintf(buf, buflen, fmt, av->is_tagged ? '*' : ' ');
188 break;
189 default:
190 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
191 snprintf(buf, buflen, fmt, op);
192 break;
193 }
194
195 if (optional)
196 {
197 mutt_expando_format(buf, buflen, col, cols, if_str, query_format_str, data,
199 }
200 else if (flags & MUTT_FORMAT_OPTIONAL)
201 {
202 mutt_expando_format(buf, buflen, col, cols, else_str, query_format_str,
204 }
205
206 /* We return the format string, unchanged */
207 return src;
208}
209
215static void query_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
216{
217 const struct AliasMenuData *mdata = menu->mdata;
218 const struct AliasViewArray *ava = &mdata->ava;
219 struct AliasView *av = ARRAY_GET(ava, line);
220
221 const char *const query_format = cs_subset_string(mdata->sub, "query_format");
222
223 mutt_expando_format(buf, buflen, 0, menu->win->state.cols, NONULL(query_format),
225}
226
230static int query_tag(struct Menu *menu, int sel, int act)
231{
232 const struct AliasMenuData *mdata = menu->mdata;
233 const struct AliasViewArray *ava = &mdata->ava;
234 struct AliasView *av = ARRAY_GET(ava, sel);
235
236 bool ot = av->is_tagged;
237
238 av->is_tagged = ((act >= 0) ? act : !av->is_tagged);
239 return av->is_tagged - ot;
240}
241
251int query_run(const char *s, bool verbose, struct AliasList *al, const struct ConfigSubset *sub)
252{
253 FILE *fp = NULL;
254 char *buf = NULL;
255 size_t buflen;
256 char *msg = NULL;
257 size_t msglen = 0;
258 char *p = NULL;
259 struct Buffer *cmd = mutt_buffer_pool_get();
260
261 const char *const query_command = cs_subset_string(sub, "query_command");
262 mutt_buffer_file_expand_fmt_quote(cmd, query_command, s);
263
264 pid_t pid = filter_create(mutt_buffer_string(cmd), NULL, &fp, NULL);
265 if (pid < 0)
266 {
267 mutt_debug(LL_DEBUG1, "unable to fork command: %s\n", mutt_buffer_string(cmd));
269 return -1;
270 }
272
273 if (verbose)
274 mutt_message(_("Waiting for response..."));
275
276 /* The query protocol first reads one NL-terminated line. If an error
277 * occurs, this is assumed to be an error message. Otherwise it's ignored. */
278 msg = mutt_file_read_line(msg, &msglen, fp, NULL, MUTT_RL_NO_FLAGS);
279 while ((buf = mutt_file_read_line(buf, &buflen, fp, NULL, MUTT_RL_NO_FLAGS)))
280 {
281 p = strtok(buf, "\t\n");
282 if (p)
283 {
284 struct Alias *alias = alias_new();
285
286 mutt_addrlist_parse(&alias->addr, p);
287 p = strtok(NULL, "\t\n");
288 if (p)
289 {
290 alias->name = mutt_str_dup(p);
291 p = strtok(NULL, "\t\n");
292 alias->comment = mutt_str_dup(p);
293 }
294 TAILQ_INSERT_TAIL(al, alias, entries);
295 }
296 }
297 FREE(&buf);
298 mutt_file_fclose(&fp);
299 if (filter_wait(pid))
300 {
301 mutt_debug(LL_DEBUG1, "Error: %s\n", msg);
302 if (verbose)
303 mutt_error("%s", msg);
304 }
305 else
306 {
307 if (verbose)
308 mutt_message("%s", msg);
309 }
310 FREE(&msg);
311
312 return 0;
313}
314
319{
320 if (nc->event_type != NT_WINDOW)
321 return 0;
322 if (!nc->global_data || !nc->event_data)
323 return -1;
325 return 0;
326
327 struct MuttWindow *win_menu = nc->global_data;
328 struct EventWindow *ev_w = nc->event_data;
329 if (ev_w->win != win_menu)
330 return 0;
331
332 struct Menu *menu = win_menu->wdata;
333
336
337 mutt_debug(LL_DEBUG5, "window delete done\n");
338 return 0;
339}
340
347static struct MuttWindow *query_dialog_new(struct AliasMenuData *mdata, const char *query)
348{
350
351 struct Menu *menu = dlg->wdata;
352
354 menu->custom_search = true;
355 menu->tag = query_tag;
356 menu->max = ARRAY_SIZE(&mdata->ava);
357 mdata->title = mutt_str_dup(_("Query"));
358 menu->mdata = mdata;
359 menu->mdata_free = NULL; // Menu doesn't own the data
360
361 struct MuttWindow *win_menu = menu->win;
362
363 // Override the Simple Dialog's recalc()
364 win_menu->recalc = alias_recalc;
365
366 char title[256] = { 0 };
367 snprintf(title, sizeof(title), "%s: %s", mdata->title, query);
368 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
369 sbar_set_title(sbar, title);
370
371 // NT_COLOR is handled by the SimpleDialog
374
375 return dlg;
376}
377
384static bool dlg_select_query(struct Buffer *buf, struct AliasMenuData *mdata)
385{
386 struct MuttWindow *dlg = query_dialog_new(mdata, mutt_buffer_string(buf));
387 struct Menu *menu = dlg->wdata;
388 struct MuttWindow *win_sbar = window_find_child(dlg, WT_STATUS_BAR);
389 struct MuttWindow *win_menu = window_find_child(dlg, WT_MENU);
390 mdata->menu = menu;
391 mdata->sbar = win_sbar;
392 mdata->query = buf;
393
394 alias_array_sort(&mdata->ava, mdata->sub);
395
396 struct AliasView *avp = NULL;
397 ARRAY_FOREACH(avp, &mdata->ava)
398 {
399 avp->num = ARRAY_FOREACH_IDX;
400 }
401
402 // ---------------------------------------------------------------------------
403 // Event Loop
404 int rc = 0;
405 int op = OP_NULL;
406 do
407 {
408 menu_tagging_dispatcher(menu->win, op);
409 window_redraw(NULL);
410
411 op = km_dokey(MENU_QUERY);
412 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
413 if (op < 0)
414 continue;
415 if (op == OP_NULL)
416 {
418 continue;
419 }
421
422 rc = alias_function_dispatcher(dlg, op);
423 if (rc == FR_UNKNOWN)
424 rc = menu_function_dispatcher(win_menu, op);
425 if (rc == FR_UNKNOWN)
426 rc = global_function_dispatcher(NULL, op);
427 } while ((rc != FR_DONE) && (rc != FR_CONTINUE));
428 // ---------------------------------------------------------------------------
429
430 simple_dialog_free(&dlg);
431 window_redraw(NULL);
432 return (rc == FR_CONTINUE); // Was a selection made?
433}
434
441int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
442{
443 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
444
445 struct AliasList al = TAILQ_HEAD_INITIALIZER(al);
446 const char *const query_command = cs_subset_string(sub, "query_command");
447 if (!query_command)
448 {
449 mutt_warning(_("Query command not defined"));
450 goto done;
451 }
452
453 query_run(mutt_buffer_string(buf), true, &al, sub);
454 if (TAILQ_EMPTY(&al))
455 goto done;
456
457 mdata.al = &al;
458
459 struct Alias *a_first = TAILQ_FIRST(&al);
460 if (!TAILQ_NEXT(a_first, entries)) // only one response?
461 {
462 struct AddressList addr = TAILQ_HEAD_INITIALIZER(addr);
463 if (alias_to_addrlist(&addr, a_first))
464 {
467 mutt_addrlist_write(&addr, buf->data, buf->dsize, false);
468 mutt_addrlist_clear(&addr);
470 }
471 goto done;
472 }
473
474 struct Alias *np = NULL;
475 TAILQ_FOREACH(np, mdata.al, entries)
476 {
477 alias_array_alias_add(&mdata.ava, np);
478 }
479
480 /* multiple results, choose from query menu */
481 if (!dlg_select_query(buf, &mdata))
482 goto done;
483
485 mutt_buffer_alloc(buf, 8192);
486 size_t curpos = 0;
487
488 struct AliasView *avp = NULL;
489 ARRAY_FOREACH(avp, &mdata.ava)
490 {
491 if (!avp->is_tagged)
492 continue;
493
494 if (curpos == 0)
495 {
496 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
497 if (alias_to_addrlist(&al_copy, avp->alias))
498 {
499 mutt_addrlist_to_local(&al_copy);
500 mutt_addrlist_write(&al_copy, buf->data, buf->dsize, false);
501 curpos = mutt_buffer_len(buf);
502 mutt_addrlist_clear(&al_copy);
503 }
504 }
505 else if ((curpos + 2) < buf->dsize)
506 {
507 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
508 if (alias_to_addrlist(&al_copy, avp->alias))
509 {
510 mutt_addrlist_to_local(&al_copy);
511 mutt_buffer_addstr(buf, ", ");
512 mutt_addrlist_write(&al_copy, buf->data + curpos + 2, buf->dsize - curpos - 2, false);
513 curpos = mutt_buffer_len(buf);
514 mutt_addrlist_clear(&al_copy);
515 }
516 }
517 }
518
519done:
520 ARRAY_FREE(&mdata.ava);
521 FREE(&mdata.title);
522 FREE(&mdata.limit);
523 aliaslist_free(&al);
524 return 0;
525}
526
532void query_index(struct Mailbox *m, struct ConfigSubset *sub)
533{
534 const char *const query_command = cs_subset_string(sub, "query_command");
535 if (!query_command)
536 {
537 mutt_warning(_("Query command not defined"));
538 return;
539 }
540
541 struct AliasList al = TAILQ_HEAD_INITIALIZER(al);
542 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
543 mdata.al = &al;
544
545 struct Buffer *buf = mutt_buffer_pool_get();
546 if ((mutt_buffer_get_field(_("Query: "), buf, MUTT_COMP_NO_FLAGS, false, NULL,
547 NULL, NULL) != 0) ||
549 {
550 goto done;
551 }
552
553 query_run(mutt_buffer_string(buf), false, &al, sub);
554 if (TAILQ_EMPTY(&al))
555 goto done;
556
557 struct Alias *np = NULL;
558 TAILQ_FOREACH(np, mdata.al, entries)
559 {
560 alias_array_alias_add(&mdata.ava, np);
561 }
562
563 if (!dlg_select_query(buf, &mdata))
564 goto done;
565
566 // Prepare the "To:" field of a new email
567 struct Email *e = email_new();
568 e->env = mutt_env_new();
569
570 struct AliasView *avp = NULL;
571 ARRAY_FOREACH(avp, &mdata.ava)
572 {
573 if (!avp->is_tagged)
574 continue;
575
576 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
577 if (alias_to_addrlist(&al_copy, avp->alias))
578 {
579 mutt_addrlist_copy(&e->env->to, &al_copy, false);
580 mutt_addrlist_clear(&al_copy);
581 }
582 }
583
584 mutt_send_message(SEND_REVIEW_TO, e, NULL, m, NULL, sub);
585
586done:
587 ARRAY_FREE(&mdata.ava);
588 FREE(&mdata.title);
589 FREE(&mdata.limit);
590 aliaslist_free(&al);
592}
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:737
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1470
size_t mutt_addrlist_write(const struct AddressList *al, char *buf, size_t buflen, bool display)
Write an Address to a buffer.
Definition: address.c:1150
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition: address.c:1388
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:458
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1305
Email Address Handling.
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition: sort.c:156
struct Alias * alias_new(void)
Create a new Alias.
Definition: alias.c:630
void aliaslist_free(struct AliasList *al)
Free a List of Aliases.
Definition: alias.c:662
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:211
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:86
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:203
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:108
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition: array.h:57
void mutt_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:275
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:260
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:371
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:233
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:85
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
Definition: curs_lib.c:793
@ 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:98
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:251
static bool dlg_select_query(struct Buffer *buf, struct AliasMenuData *mdata)
Get the user to enter an Address Query.
Definition: dlg_query.c:384
bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
Turn an Alias into an AddressList.
Definition: dlg_query.c:118
int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
Perform auto-complete using an Address Query.
Definition: dlg_query.c:441
static struct MuttWindow * query_dialog_new(struct AliasMenuData *mdata, const char *query)
Create an Query Selection Dialog.
Definition: dlg_query.c:347
void query_index(struct Mailbox *m, struct ConfigSubset *sub)
Perform an Alias Query and display the results.
Definition: dlg_query.c:532
struct Email * email_new(void)
Create a new Email.
Definition: email.c:78
Structs that make up an email.
Enter a string.
int mutt_buffer_get_field(const char *field, struct Buffer *buf, CompletionFlags complete, bool multiple, struct Mailbox *m, char ***files, int *numfiles)
Ask the user for a string.
Definition: window.c:180
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:43
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:720
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
void mutt_buffer_file_expand_fmt_quote(struct Buffer *dest, const char *fmt, const char *src)
Replace s in a string with a filename.
Definition: file.c:1488
#define MUTT_RL_NO_FLAGS
No flags are set.
Definition: file.h:38
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
pid_t filter_create(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:206
Flags to control mutt_expando_format()
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
#define MUTT_FORMAT_OPTIONAL
Allow optional field processing.
Definition: format_flags.h:33
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: format_flags.h:35
uint8_t MuttFormatFlags
Flags for mutt_expando_format(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: format_flags.h:29
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
int alias_function_dispatcher(struct MuttWindow *win, int op)
Perform a Alias function - Implements function_dispatcher_t -.
Definition: functions.c:333
static const char * query_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Format a string for the query menu - Implements format_t -.
Definition: dlg_query.c:148
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string -.
Definition: muttlib.c:777
#define mutt_warning(...)
Definition: logging.h:85
#define mutt_error(...)
Definition: logging.h:87
#define mutt_message(...)
Definition: logging.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static void query_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the query list - Implements Menu::make_entry() -.
Definition: dlg_query.c:215
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:230
static int query_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_query.c:318
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:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
Shared code for the Alias and Query Dialogs.
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
Manage keymappings.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
#define FREE(x)
Definition: memory.h:43
GUI present the user with a selectable list.
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:228
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:189
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
Many unsorted constants and some structs.
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:52
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:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
@ WT_DLG_QUERY
Query Dialog, dlg_select_query()
Definition: mutt_window.h:90
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
@ WT_MENU
An Window containing a Menu.
Definition: mutt_window.h:98
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:206
Some miscellaneous functions.
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
@ 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:46
All user-callable functions.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#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
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
Convenience wrapper for the send headers.
int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Mailbox *m, struct EmailList *el, struct ConfigSubset *sub)
Send an email.
Definition: send.c:2126
#define SEND_REVIEW_TO
Allow the user to edit the To field.
Definition: send.h:54
Sidebar functions.
Key value store.
#define NONULL(x)
Definition: string2.h:37
An email address.
Definition: address.h:36
char * personal
Real name of address.
Definition: address.h:37
AliasView array wrapper with Pattern information -.
Definition: gui.h:52
char * limit
Limit being used.
Definition: gui.h:58
struct AliasViewArray ava
All Aliases/Queries.
Definition: gui.h:53
struct MuttWindow * sbar
Status Bar.
Definition: gui.h:59
struct Menu * menu
Menu.
Definition: gui.h:56
struct Buffer * query
Query string.
Definition: gui.h:57
char * title
Title for the status bar.
Definition: gui.h:60
struct AliasList * al
Alias data.
Definition: gui.h:54
struct ConfigSubset * sub
Config items.
Definition: gui.h:55
GUI data wrapping an Alias.
Definition: gui.h:36
struct Alias * alias
Alias.
Definition: gui.h:44
bool is_tagged
Is it tagged?
Definition: gui.h:41
int num
Index number in list.
Definition: gui.h:37
A shortcut for an email address or addresses.
Definition: alias.h:34
char * comment
Free-form comment string.
Definition: alias.h:37
char * name
Short name.
Definition: alias.h:35
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:36
String manipulation buffer.
Definition: buffer.h:34
size_t dsize
Length of data.
Definition: buffer.h:37
char * data
Pointer to data.
Definition: buffer.h:35
A set of inherited config items.
Definition: subset.h:47
The envelope/body of an email.
Definition: email.h:37
struct Envelope * env
Envelope information.
Definition: email.h:66
struct AddressList to
Email's 'To' list.
Definition: envelope.h:60
An Event that happened to a Window.
Definition: mutt_window.h:216
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
A mailbox.
Definition: mailbox.h:79
Mapping between user-readable string and a constant.
Definition: mapping.h:32
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:121
void * mdata
Private data.
Definition: lib.h:137
int max
Number of entries in the menu.
Definition: lib.h:71
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:84
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:171
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
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
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
@ MENU_QUERY
Select from results of external query.
Definition: type.h:57