NeoMutt  2023-11-03-107-g582dc1
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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 "editor/lib.h"
86#include "history/lib.h"
87#include "key/lib.h"
88#include "menu/lib.h"
89#include "pattern/lib.h"
90#include "send/lib.h"
91#include "alias.h"
92#include "format_flags.h"
93#include "functions.h"
94#include "globals.h"
95#include "gui.h"
96#include "mutt_logging.h"
97#include "muttlib.h"
98
100static const struct Mapping QueryHelp[] = {
101 // clang-format off
102 { N_("Exit"), OP_EXIT },
103 { N_("Mail"), OP_MAIL },
104 { N_("New Query"), OP_QUERY },
105 { N_("Make Alias"), OP_CREATE_ALIAS },
106 { N_("Sort"), OP_SORT },
107 { N_("Rev-Sort"), OP_SORT_REVERSE },
108 { N_("Search"), OP_SEARCH },
109 { N_("Help"), OP_HELP },
110 { NULL, 0 },
111 // clang-format on
112};
113
120bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
121{
122 if (!al || !TAILQ_EMPTY(al) || !alias)
123 return false;
124
125 mutt_addrlist_copy(al, &alias->addr, false);
126 if (!TAILQ_EMPTY(al))
127 {
128 struct Address *first = TAILQ_FIRST(al);
129 struct Address *second = TAILQ_NEXT(first, entries);
130 if (!second && !first->personal)
131 {
132 first->personal = buf_new(alias->name);
133 }
134
135 mutt_addrlist_to_intl(al, NULL);
136 }
137
138 return true;
139}
140
152static const char *query_format_str(char *buf, size_t buflen, size_t col, int cols,
153 char op, const char *src, const char *prec,
154 const char *if_str, const char *else_str,
155 intptr_t data, MuttFormatFlags flags)
156{
157 struct AliasView *av = (struct AliasView *) data;
158 struct Alias *alias = av->alias;
159 char fmt[128] = { 0 };
160 bool optional = (flags & MUTT_FORMAT_OPTIONAL);
161
162 switch (op)
163 {
164 case 'a':
165 {
166 struct Buffer *tmpbuf = buf_pool_get();
167 char tmp[256] = { 0 };
168 tmp[0] = '<';
169 mutt_addrlist_write(&alias->addr, tmpbuf, true);
170 mutt_str_copy(tmp + 1, buf_string(tmpbuf), sizeof(tmp) - 1);
171 buf_pool_release(&tmpbuf);
172 const size_t len = strlen(tmp);
173 if (len < (sizeof(tmp) - 1))
174 {
175 tmp[len] = '>';
176 tmp[len + 1] = '\0';
177 }
178 mutt_format_s(buf, buflen, prec, tmp);
179 break;
180 }
181 case 'c':
182 snprintf(fmt, sizeof(fmt), "%%%sd", prec);
183 snprintf(buf, buflen, fmt, av->num + 1);
184 break;
185 case 'e':
186 if (!optional)
187 mutt_format_s(buf, buflen, prec, NONULL(alias->comment));
188 else if (!alias->comment || (*alias->comment == '\0'))
189 optional = false;
190 break;
191 case 'n':
192 mutt_format_s(buf, buflen, prec, NONULL(alias->name));
193 break;
194 case 't':
195 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
196 snprintf(buf, buflen, fmt, av->is_tagged ? '*' : ' ');
197 break;
198 default:
199 snprintf(fmt, sizeof(fmt), "%%%sc", prec);
200 snprintf(buf, buflen, fmt, op);
201 break;
202 }
203
204 if (optional)
205 {
206 mutt_expando_format(buf, buflen, col, cols, if_str, query_format_str, data,
208 }
209 else if (flags & MUTT_FORMAT_OPTIONAL)
210 {
211 mutt_expando_format(buf, buflen, col, cols, else_str, query_format_str,
213 }
214
215 /* We return the format string, unchanged */
216 return src;
217}
218
224static void query_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
225{
226 const struct AliasMenuData *mdata = menu->mdata;
227 const struct AliasViewArray *ava = &mdata->ava;
228 struct AliasView *av = ARRAY_GET(ava, line);
229
230 const char *const c_query_format = cs_subset_string(mdata->sub, "query_format");
231
232 mutt_expando_format(buf, buflen, 0, menu->win->state.cols, NONULL(c_query_format),
234}
235
239static int query_tag(struct Menu *menu, int sel, int act)
240{
241 const struct AliasMenuData *mdata = menu->mdata;
242 const struct AliasViewArray *ava = &mdata->ava;
243 struct AliasView *av = ARRAY_GET(ava, sel);
244
245 bool ot = av->is_tagged;
246
247 av->is_tagged = ((act >= 0) ? act : !av->is_tagged);
248 return av->is_tagged - ot;
249}
250
260int query_run(const char *s, bool verbose, struct AliasList *al, const struct ConfigSubset *sub)
261{
262 FILE *fp = NULL;
263 char *buf = NULL;
264 size_t buflen;
265 char *msg = NULL;
266 size_t msglen = 0;
267 char *p = NULL;
268 struct Buffer *cmd = buf_pool_get();
269
270 const char *const c_query_command = cs_subset_string(sub, "query_command");
271 buf_file_expand_fmt_quote(cmd, c_query_command, s);
272
273 pid_t pid = filter_create(buf_string(cmd), NULL, &fp, NULL, EnvList);
274 if (pid < 0)
275 {
276 mutt_debug(LL_DEBUG1, "unable to fork command: %s\n", buf_string(cmd));
277 buf_pool_release(&cmd);
278 return -1;
279 }
280 buf_pool_release(&cmd);
281
282 if (verbose)
283 mutt_message(_("Waiting for response..."));
284
285 /* The query protocol first reads one NL-terminated line. If an error
286 * occurs, this is assumed to be an error message. Otherwise it's ignored. */
287 msg = mutt_file_read_line(msg, &msglen, fp, NULL, MUTT_RL_NO_FLAGS);
288 while ((buf = mutt_file_read_line(buf, &buflen, fp, NULL, MUTT_RL_NO_FLAGS)))
289 {
290 p = strtok(buf, "\t\n");
291 if (p)
292 {
293 struct Alias *alias = alias_new();
294
295 mutt_addrlist_parse(&alias->addr, p);
296 p = strtok(NULL, "\t\n");
297 if (p)
298 {
299 alias->name = mutt_str_dup(p);
300 p = strtok(NULL, "\t\n");
301 alias->comment = mutt_str_dup(p);
302 }
303 TAILQ_INSERT_TAIL(al, alias, entries);
304 }
305 }
306 FREE(&buf);
307 mutt_file_fclose(&fp);
308 if (filter_wait(pid))
309 {
310 mutt_debug(LL_DEBUG1, "Error: %s\n", msg);
311 if (verbose)
312 mutt_error("%s", msg);
313 }
314 else
315 {
316 if (verbose)
317 mutt_message("%s", msg);
318 }
319 FREE(&msg);
320
321 return 0;
322}
323
328{
329 if (nc->event_type != NT_WINDOW)
330 return 0;
331 if (!nc->global_data || !nc->event_data)
332 return -1;
334 return 0;
335
336 struct MuttWindow *win_menu = nc->global_data;
337 struct EventWindow *ev_w = nc->event_data;
338 if (ev_w->win != win_menu)
339 return 0;
340
341 struct Menu *menu = win_menu->wdata;
342
345
346 mutt_debug(LL_DEBUG5, "window delete done\n");
347 return 0;
348}
349
356static struct MuttWindow *query_dialog_new(struct AliasMenuData *mdata, const char *query)
357{
359
360 struct Menu *menu = dlg->wdata;
361
363 menu->tag = query_tag;
364 menu->max = ARRAY_SIZE(&mdata->ava);
365 mdata->title = mutt_str_dup(_("Query"));
366 menu->mdata = mdata;
367 menu->mdata_free = NULL; // Menu doesn't own the data
368
369 struct MuttWindow *win_menu = menu->win;
370
371 // Override the Simple Dialog's recalc()
372 win_menu->recalc = alias_recalc;
373
374 char title[256] = { 0 };
375 snprintf(title, sizeof(title), "%s: %s", mdata->title, query);
376 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
377 sbar_set_title(sbar, title);
378
379 // NT_COLOR is handled by the SimpleDialog
382
383 return dlg;
384}
385
397static bool dlg_query(struct Buffer *buf, struct AliasMenuData *mdata)
398{
399 struct MuttWindow *dlg = query_dialog_new(mdata, buf_string(buf));
400 struct Menu *menu = dlg->wdata;
401 struct MuttWindow *win_sbar = window_find_child(dlg, WT_STATUS_BAR);
402 struct MuttWindow *win_menu = window_find_child(dlg, WT_MENU);
403 mdata->menu = menu;
404 mdata->sbar = win_sbar;
405 mdata->query = buf;
406
407 alias_array_sort(&mdata->ava, mdata->sub);
408
409 struct AliasView *avp = NULL;
410 ARRAY_FOREACH(avp, &mdata->ava)
411 {
412 avp->num = ARRAY_FOREACH_IDX;
413 }
414
415 struct MuttWindow *old_focus = window_set_focus(menu->win);
416 // ---------------------------------------------------------------------------
417 // Event Loop
418 int rc = 0;
419 int op = OP_NULL;
420 do
421 {
422 menu_tagging_dispatcher(menu->win, op);
423 window_redraw(NULL);
424
426 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
427 if (op < 0)
428 continue;
429 if (op == OP_NULL)
430 {
432 continue;
433 }
435
436 rc = alias_function_dispatcher(dlg, op);
437 if (rc == FR_UNKNOWN)
438 rc = menu_function_dispatcher(win_menu, op);
439 if (rc == FR_UNKNOWN)
440 rc = global_function_dispatcher(NULL, op);
441 } while ((rc != FR_DONE) && (rc != FR_CONTINUE));
442 // ---------------------------------------------------------------------------
443
444 window_set_focus(old_focus);
445 simple_dialog_free(&dlg);
446 window_redraw(NULL);
447 return (rc == FR_CONTINUE); // Was a selection made?
448}
449
456int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
457{
458 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
459 mdata.search_state = search_state_new();
460
461 struct AliasList al = TAILQ_HEAD_INITIALIZER(al);
462 const char *const c_query_command = cs_subset_string(sub, "query_command");
463 if (!c_query_command)
464 {
465 mutt_warning(_("Query command not defined"));
466 goto done;
467 }
468
469 query_run(buf_string(buf), true, &al, sub);
470 if (TAILQ_EMPTY(&al))
471 goto done;
472
473 mdata.al = &al;
474
475 struct Alias *a_first = TAILQ_FIRST(&al);
476 if (!TAILQ_NEXT(a_first, entries)) // only one response?
477 {
478 struct AddressList addr = TAILQ_HEAD_INITIALIZER(addr);
479 if (alias_to_addrlist(&addr, a_first))
480 {
482 buf_reset(buf);
483 mutt_addrlist_write(&addr, buf, false);
484 mutt_addrlist_clear(&addr);
486 }
487 goto done;
488 }
489
490 struct Alias *np = NULL;
491 TAILQ_FOREACH(np, mdata.al, entries)
492 {
493 alias_array_alias_add(&mdata.ava, np);
494 }
495
496 /* multiple results, choose from query menu */
497 if (!dlg_query(buf, &mdata))
498 goto done;
499
500 buf_reset(buf);
501 buf_alloc(buf, 8192);
502 bool first = true;
503 struct AliasView *avp = NULL;
504 ARRAY_FOREACH(avp, &mdata.ava)
505 {
506 if (!avp->is_tagged)
507 continue;
508
509 if (!first)
510 {
511 buf_addstr(buf, ", ");
512 }
513
514 first = false;
515 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
516 if (alias_to_addrlist(&al_copy, avp->alias))
517 {
518 mutt_addrlist_to_local(&al_copy);
519 mutt_addrlist_write(&al_copy, buf, false);
520 mutt_addrlist_clear(&al_copy);
521 }
522 }
523
524done:
525 ARRAY_FREE(&mdata.ava);
526 FREE(&mdata.title);
527 FREE(&mdata.limit);
529 aliaslist_clear(&al);
530 return 0;
531}
532
538void query_index(struct Mailbox *m, struct ConfigSubset *sub)
539{
540 const char *const c_query_command = cs_subset_string(sub, "query_command");
541 if (!c_query_command)
542 {
543 mutt_warning(_("Query command not defined"));
544 return;
545 }
546
547 struct AliasList al = TAILQ_HEAD_INITIALIZER(al);
548 struct AliasMenuData mdata = { ARRAY_HEAD_INITIALIZER, NULL, sub };
549 mdata.al = &al;
550 mdata.search_state = search_state_new();
551
552 struct Buffer *buf = buf_pool_get();
553 if ((mw_get_field(_("Query: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0) ||
554 buf_is_empty(buf))
555 {
556 goto done;
557 }
558
559 query_run(buf_string(buf), false, &al, sub);
560 if (TAILQ_EMPTY(&al))
561 goto done;
562
563 struct Alias *np = NULL;
564 TAILQ_FOREACH(np, mdata.al, entries)
565 {
566 alias_array_alias_add(&mdata.ava, np);
567 }
568
569 if (!dlg_query(buf, &mdata))
570 goto done;
571
572 // Prepare the "To:" field of a new email
573 struct Email *e = email_new();
574 e->env = mutt_env_new();
575
576 struct AliasView *avp = NULL;
577 ARRAY_FOREACH(avp, &mdata.ava)
578 {
579 if (!avp->is_tagged)
580 continue;
581
582 struct AddressList al_copy = TAILQ_HEAD_INITIALIZER(al_copy);
583 if (alias_to_addrlist(&al_copy, avp->alias))
584 {
585 mutt_addrlist_copy(&e->env->to, &al_copy, false);
586 mutt_addrlist_clear(&al_copy);
587 }
588 }
589
590 mutt_send_message(SEND_REVIEW_TO, e, NULL, m, NULL, sub);
591
592done:
593 ARRAY_FREE(&mdata.ava);
594 FREE(&mdata.title);
595 FREE(&mdata.limit);
597 aliaslist_clear(&al);
598 buf_pool_release(&buf);
599}
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:762
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1461
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition: address.c:1379
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
Definition: address.c:1207
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:478
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1294
Email Address Handling.
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition: sort.c:166
struct Alias * alias_new(void)
Create a new Alias.
Definition: alias.c:630
void aliaslist_clear(struct AliasList *al)
Empty a List of Aliases.
Definition: alias.c:664
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 buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:88
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:303
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:316
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:238
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:349
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
@ 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:100
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:260
bool alias_to_addrlist(struct AddressList *al, struct Alias *alias)
Turn an Alias into an AddressList.
Definition: dlg_query.c:120
int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
Perform auto-complete using an Address Query.
Definition: dlg_query.c:456
static struct MuttWindow * query_dialog_new(struct AliasMenuData *mdata, const char *query)
Create an Query Selection Dialog.
Definition: dlg_query.c:356
void query_index(struct Mailbox *m, struct ConfigSubset *sub)
Perform an Alias Query and display the results.
Definition: dlg_query.c:538
Edit a string.
struct Email * email_new(void)
Create a new Email.
Definition: email.c:78
Structs that make up an email.
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:763
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
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:1497
#define MUTT_RL_NO_FLAGS
No flags are set.
Definition: file.h:39
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:218
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:207
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
Definition: format.c:215
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 km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:463
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: get.c:293
char ** EnvList
Private copy of the environment variables.
Definition: globals.c:83
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:169
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:317
int alias_function_dispatcher(struct MuttWindow *win, int op)
Perform a Alias function - Implements function_dispatcher_t -.
Definition: functions.c:417
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:152
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:739
static bool dlg_query(struct Buffer *buf, struct AliasMenuData *mdata)
Get the user to enter an Address Query -.
Definition: dlg_query.c:397
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:275
#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 void query_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format an Alias for the Menu - Implements Menu::make_entry() -.
Definition: dlg_query.c:224
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:239
static int query_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_query.c:327
int alias_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: gui.c:43
int alias_recalc(struct MuttWindow *win)
Recalculate the display of the Alias Window - Implements MuttWindow::recalc() -.
Definition: gui.c:89
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:132
Shared code for the Alias and Query Dialogs.
Read/write command history from/to a file.
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:56
Manage keymappings.
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:52
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
#define FREE(x)
Definition: memory.h:45
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: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:251
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:653
Many unsorted constants and some structs.
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:55
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:73
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:634
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:684
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:533
@ WT_DLG_QUERY
Query Dialog, dlg_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:229
Some miscellaneous functions.
@ 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
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:50
struct SearchState * search_state_new(void)
Create a new SearchState.
Definition: search_state.c:38
Convenience wrapper for the send headers.
int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Mailbox *m, struct EmailArray *ea, struct ConfigSubset *sub)
Send an email.
Definition: send.c:2099
#define SEND_REVIEW_TO
Allow the user to edit the To field.
Definition: send.h:54
Sidebar functions.
Key value store.
#define NONULL(x)
Definition: string2.h:37
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:52
char * limit
Limit being used.
Definition: gui.h:58
struct AliasViewArray ava
All Aliases/Queries.
Definition: gui.h:53
struct SearchState * search_state
State of the current search.
Definition: gui.h:61
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
char * data
Pointer to data.
Definition: buffer.h:35
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: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:239
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:240
A mailbox.
Definition: mailbox.h:79
Mapping between user-readable string and a constant.
Definition: mapping.h:32
Definition: lib.h:70
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
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:151
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:72
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:173
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
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:58