NeoMutt  2025-12-11-860-g80c9cc
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 <string.h>
33#include "private.h"
34#include "mutt/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 "fuzzy/lib.h"
42#include "history/lib.h"
43#include "index/lib.h"
44#include "key/lib.h"
45#include "menu/lib.h"
46#include "module_data.h"
47
48// clang-format off
52static const struct MenuFuncOp OpSidebar[] = { /* map: sidebar */
53 { "sidebar-first", OP_SIDEBAR_FIRST },
54 { "sidebar-last", OP_SIDEBAR_LAST },
55 { "sidebar-next", OP_SIDEBAR_NEXT },
56 { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW },
57 { "sidebar-open", OP_SIDEBAR_OPEN },
58 { "sidebar-page-down", OP_SIDEBAR_PAGE_DOWN },
59 { "sidebar-page-up", OP_SIDEBAR_PAGE_UP },
60 { "sidebar-prev", OP_SIDEBAR_PREV },
61 { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW },
62 { "sidebar-abort-search", OP_SIDEBAR_ABORT_SEARCH },
63 { "sidebar-start-search", OP_SIDEBAR_START_SEARCH },
64 { "sidebar-toggle-virtual", OP_SIDEBAR_TOGGLE_VIRTUAL },
65 { "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE },
66 { NULL, 0 },
67};
68
73 { OP_SIDEBAR_NEXT, "<down>" },
74 { OP_SIDEBAR_PREV, "<up>" },
75 { 0, NULL },
76};
77// clang-format on
78
82void sidebar_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
83{
85 ASSERT(mod_data);
86
87 struct MenuDefinition *md = NULL;
88 struct SubMenu *sm = NULL;
89 struct SubMenu *sm_editor = editor_get_submenu();
90 ASSERT(sm_editor);
91
93 md = km_register_menu(MENU_SIDEBAR, "sidebar");
94 km_menu_add_submenu(md, sm);
95 km_menu_add_submenu(md, sm_editor);
97
98 mod_data->md_sidebar = md;
99 mod_data->sm_sidebar = sm;
100}
101
107{
109 ASSERT(mod_data);
110
111 return mod_data->sm_sidebar;
112}
113
119bool sb_next(struct SidebarWindowData *wdata)
120{
121 struct SbEntry **sbep = NULL;
122 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->hil_index + 1)
123 {
124 if (!(*sbep)->is_hidden)
125 {
126 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
127 return true;
128 }
129 }
130
131 return false;
132}
133
141static bool sb_next_n(struct SidebarWindowData *wdata, int count)
142{
143 int orig = wdata->hil_index;
144 for (int i = 0; i < count; i++)
145 {
146 if (!sb_next(wdata))
147 break;
148 }
149 return (wdata->hil_index != orig);
150}
151
159static bool sb_prev_n(struct SidebarWindowData *wdata, int count)
160{
161 int orig = wdata->hil_index;
162 for (int i = 0; i < count; i++)
163 {
164 if (!sb_prev(wdata))
165 break;
166 }
167 return (wdata->hil_index != orig);
168}
169
178static struct SbEntry **sb_next_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
179{
180 struct SbEntry **sbep = NULL;
181 ARRAY_FOREACH_FROM_TO(sbep, &wdata->entries, begin, end)
182 {
183 if ((*sbep)->mailbox->has_new || ((*sbep)->mailbox->msg_unread != 0))
184 return sbep;
185 }
186 return NULL;
187}
188
194bool sb_prev(struct SidebarWindowData *wdata)
195{
196 struct SbEntry **sbep = NULL, **prev = NULL;
197 ARRAY_FOREACH_TO(sbep, &wdata->entries, wdata->hil_index)
198 {
199 if (!(*sbep)->is_hidden)
200 prev = sbep;
201 }
202
203 if (prev)
204 {
205 wdata->hil_index = ARRAY_IDX(&wdata->entries, prev);
206 return true;
207 }
208
209 return false;
210}
211
220static struct SbEntry **sb_prev_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
221{
222 struct SbEntry **sbep = NULL, **prev = NULL;
223 ARRAY_FOREACH_FROM_TO(sbep, &wdata->entries, begin, end)
224 {
225 if ((*sbep)->mailbox->has_new || ((*sbep)->mailbox->msg_unread != 0))
226 prev = sbep;
227 }
228
229 return prev;
230}
231
232// -----------------------------------------------------------------------------
233
237static int op_sidebar_first(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
238{
239 struct SidebarWindowData *wdata = fdata->wdata;
240 if (!mutt_window_is_visible(wdata->win))
241 return FR_NO_ACTION;
242
243 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
244 return FR_NO_ACTION;
245
246 int orig_hil_index = wdata->hil_index;
247
248 wdata->hil_index = 0;
249 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
250 if (!sb_next(wdata))
251 wdata->hil_index = orig_hil_index;
252
253 if (orig_hil_index == wdata->hil_index)
254 return FR_NO_ACTION;
255
256 wdata->win->actions |= WA_RECALC;
257 return FR_SUCCESS;
258}
259
263static int op_sidebar_last(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
264{
265 struct SidebarWindowData *wdata = fdata->wdata;
266 if (!mutt_window_is_visible(wdata->win))
267 return FR_NO_ACTION;
268
269 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
270 return FR_NO_ACTION;
271
272 int orig_hil_index = wdata->hil_index;
273
274 wdata->hil_index = ARRAY_SIZE(&wdata->entries);
275 if (!sb_prev(wdata))
276 wdata->hil_index = orig_hil_index;
277
278 if (orig_hil_index == wdata->hil_index)
279 return FR_NO_ACTION;
280
281 wdata->win->actions |= WA_RECALC;
282 return FR_SUCCESS;
283}
284
288static int op_sidebar_next(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
289{
290 struct SidebarWindowData *wdata = fdata->wdata;
291 if (!mutt_window_is_visible(wdata->win))
292 return FR_NO_ACTION;
293
294 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
295 return FR_NO_ACTION;
296
297 const int count = event->count;
298 if (count > 0)
299 {
300 if (!sb_next_n(wdata, count))
301 return FR_NO_ACTION;
302 }
303 else
304 {
305 if (!sb_next(wdata))
306 {
307 mutt_message(_("You are on the last entry"));
308 return FR_ERROR;
309 }
310 }
311
312 wdata->win->actions |= WA_RECALC;
313 return FR_SUCCESS;
314}
315
321static int op_sidebar_next_new(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
322{
323 struct SidebarWindowData *wdata = fdata->wdata;
324 if (!mutt_window_is_visible(wdata->win))
325 return FR_NO_ACTION;
326
327 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
328 if ((max_entries == 0) || (wdata->hil_index < 0))
329 return FR_NO_ACTION;
330
331 const int count = MAX(event->count, 1);
332 const bool c_sidebar_next_new_wrap = cs_subset_bool(fdata->n->sub, "sidebar_next_new_wrap");
333 int orig_hil_index = wdata->hil_index;
334
335 for (int i = 0; i < count; i++)
336 {
337 struct SbEntry **sbep = NULL;
338 if ((sbep = sb_next_new(wdata, wdata->hil_index + 1, max_entries)) ||
339 (c_sidebar_next_new_wrap && (sbep = sb_next_new(wdata, 0, wdata->hil_index))))
340 {
341 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
342 }
343 else
344 {
345 break;
346 }
347 }
348
349 if (wdata->hil_index == orig_hil_index)
350 return FR_NO_ACTION;
351
352 wdata->win->actions |= WA_RECALC;
353 return FR_SUCCESS;
354}
355
359static int op_sidebar_open(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
360{
361 struct SidebarWindowData *wdata = fdata->wdata;
362 struct MuttWindow *win_sidebar = wdata->win;
363 if (!mutt_window_is_visible(win_sidebar))
364 return FR_NO_ACTION;
365
366 struct MuttWindow *dlg = dialog_find(win_sidebar);
367 index_change_folder(dlg, sb_get_highlight(win_sidebar));
368 return FR_SUCCESS;
369}
370
374static int op_sidebar_page_down(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
375{
376 struct SidebarWindowData *wdata = fdata->wdata;
377 if (!mutt_window_is_visible(wdata->win))
378 return FR_NO_ACTION;
379
380 if (ARRAY_EMPTY(&wdata->entries) || (wdata->bot_index < 0))
381 return FR_NO_ACTION;
382
383 int orig_hil_index = wdata->hil_index;
384 const int page_size = wdata->win->state.rows;
385 const int count = MAX(event->count, 1);
386
387 if (!sb_next_n(wdata, count * page_size))
388 return FR_NO_ACTION;
389
390 /* If we landed on a hidden entry, go up to the last unhidden one */
391 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
392 sb_prev(wdata);
393
394 if (orig_hil_index == wdata->hil_index)
395 return FR_NO_ACTION;
396
397 wdata->repage = true;
398 wdata->win->actions |= WA_RECALC;
399 return FR_SUCCESS;
400}
401
405static int op_sidebar_page_up(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
406{
407 struct SidebarWindowData *wdata = fdata->wdata;
408 if (!mutt_window_is_visible(wdata->win))
409 return FR_NO_ACTION;
410
411 if (ARRAY_EMPTY(&wdata->entries) || (wdata->top_index < 0))
412 return FR_NO_ACTION;
413
414 int orig_hil_index = wdata->hil_index;
415 const int page_size = wdata->win->state.rows;
416 const int count = MAX(event->count, 1);
417
418 if (!sb_prev_n(wdata, count * page_size))
419 return FR_NO_ACTION;
420
421 /* If we landed on a hidden entry, go down to the last unhidden one */
422 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
423 sb_next(wdata);
424
425 if (orig_hil_index == wdata->hil_index)
426 return FR_NO_ACTION;
427
428 wdata->repage = true;
429 wdata->win->actions |= WA_RECALC;
430 return FR_SUCCESS;
431}
432
436static int op_sidebar_prev(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
437{
438 struct SidebarWindowData *wdata = fdata->wdata;
439 if (!mutt_window_is_visible(wdata->win))
440 return FR_NO_ACTION;
441
442 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
443 return FR_NO_ACTION;
444
445 const int count = event->count;
446 if (count > 0)
447 {
448 if (!sb_prev_n(wdata, count))
449 return FR_NO_ACTION;
450 }
451 else
452 {
453 if (!sb_prev(wdata))
454 {
455 mutt_message(_("You are on the first entry"));
456 return FR_ERROR;
457 }
458 }
459
460 wdata->win->actions |= WA_RECALC;
461 return FR_SUCCESS;
462}
463
469static int op_sidebar_prev_new(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
470{
471 struct SidebarWindowData *wdata = fdata->wdata;
472 if (!mutt_window_is_visible(wdata->win))
473 return FR_NO_ACTION;
474
475 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
476 if ((max_entries == 0) || (wdata->hil_index < 0))
477 return FR_NO_ACTION;
478
479 const int count = MAX(event->count, 1);
480 const bool c_sidebar_next_new_wrap = cs_subset_bool(fdata->n->sub, "sidebar_next_new_wrap");
481 int orig_hil_index = wdata->hil_index;
482
483 for (int i = 0; i < count; i++)
484 {
485 struct SbEntry **sbep = NULL;
486 if ((sbep = sb_prev_new(wdata, 0, wdata->hil_index)) ||
487 (c_sidebar_next_new_wrap &&
488 (sbep = sb_prev_new(wdata, wdata->hil_index + 1, max_entries))))
489 {
490 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
491 }
492 else
493 {
494 break;
495 }
496 }
497
498 if (wdata->hil_index == orig_hil_index)
499 return FR_NO_ACTION;
500
501 wdata->win->actions |= WA_RECALC;
502 return FR_SUCCESS;
503}
504
509 const struct KeyEvent *event)
510{
511 bool_str_toggle(fdata->n->sub, "sidebar_visible", NULL);
512 mutt_window_reflow(NULL);
513 return FR_SUCCESS;
514}
515
520 const struct KeyEvent *event)
521{
522 return FR_SUCCESS;
523}
524
528static void sidebar_matcher_cb(const char *text, void *data)
529{
530 struct MuttWindow *win = data;
531 struct SidebarWindowData *wdata = win->wdata;
532 wdata->hil_index = -1;
533 wdata->repage = true;
534
535 struct SbEntry **sbep = NULL;
536
537 if (text[0] == '\0')
538 {
539 ARRAY_FOREACH(sbep, &wdata->entries)
540 {
541 struct SbEntry *sbe = *sbep;
542 sbe->mailbox->visible = true;
543 sbe->score = -1;
544 if (wdata->hil_index == -1)
545 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
546 }
547 wdata->win->actions |= WA_RECALC;
548 return;
549 }
550
551 struct FuzzyOptions opts = { .smart_case = true };
552 struct FuzzyResult result = { 0 };
553 int best_score = -1;
554 int best_index = -1;
555 struct Buffer *buf = buf_pool_get();
556
557 ARRAY_FOREACH(sbep, &wdata->entries)
558 {
559 struct SbEntry *sbe = *sbep;
560 buf_printf(buf, "%s %s", sbe->box, sbe->display);
561 int score = fuzzy_match(text, buf_string(buf), FUZZY_ALGO_SUBSEQ, &opts, &result);
562 if (score > 0)
563 {
564 // Extra 2 points for new (unseen) mail
565 // 1 point for old (seen) mail
566 score += (2 * sbe->mailbox->msg_new);
567 score += (sbe->mailbox->msg_unread - sbe->mailbox->msg_new);
568 }
569 sbe->score = score;
570 if (score >= 0)
571 {
572 if ((best_score == -1) || (score > best_score))
573 {
574 best_score = score;
575 best_index = ARRAY_FOREACH_IDX_sbep;
576 }
577 sbe->mailbox->visible = true;
578 }
579 else
580 {
581 sbe->mailbox->visible = false;
582 }
583 }
584
585 if (best_index != -1)
586 wdata->hil_index = best_index;
587
588 wdata->win->actions |= WA_RECALC;
589 buf_pool_release(&buf);
590}
591
598 const struct KeyEvent *event)
599{
600 struct SidebarWindowData *wdata = fdata->wdata;
601 if (wdata->search_active)
602 return FR_DONE;
603 else
604 return FR_NO_ACTION;
605}
606
611 const struct KeyEvent *event)
612{
613 struct SidebarWindowData *wdata = fdata->wdata;
614 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
615 {
616 mutt_warning(_("There are no mailboxes"));
617 return FR_ERROR;
618 }
619
620 const bool was_visible = cs_subset_bool(fdata->n->sub, "sidebar_visible");
621 if (!was_visible)
622 {
623 cs_subset_str_native_set(fdata->n->sub, "sidebar_visible", true, NULL);
624 mutt_window_reflow(NULL);
625 }
626
627 struct Buffer *buf = buf_pool_get();
628 int orghlidx = wdata->hil_index;
629
630 struct SbEntry **sbep = NULL;
631 ARRAY_FOREACH(sbep, &wdata->entries)
632 {
633 struct SbEntry *sbe = *sbep;
634 if (sbe->box[0] == '\0')
636 }
637
638 int rc = FR_NO_ACTION;
639 wdata->search_active = true;
640
641 if (mw_get_field_notify(_("Sidebar search: "), buf, MUTT_COMP_UNBUFFERED,
642 HC_NONE, NULL, NULL, sidebar_matcher_cb, wdata->win,
644 {
645 wdata->hil_index = orghlidx;
646 goto done;
647 }
648
649 if (!buf || buf_is_empty(buf) || (wdata->hil_index == -1))
650 {
651 wdata->hil_index = orghlidx;
652 goto done;
653 }
654
655 ARRAY_FOREACH(sbep, &wdata->entries)
656 {
657 struct SbEntry *sbe = *sbep;
658 sbe->score = -1;
659 }
660 rc = FR_SUCCESS;
661
662done:
663 ARRAY_FOREACH(sbep, &wdata->entries)
664 {
665 (*sbep)->mailbox->visible = true;
666 }
667 wdata->search_active = false;
668 wdata->repage = false;
669 wdata->win->actions |= WA_RECALC;
670
671 if (rc == FR_SUCCESS)
672 {
673 struct MuttWindow *dlg = dialog_find(wdata->win);
675 }
676
677 if (!was_visible)
678 {
679 cs_subset_str_native_set(fdata->n->sub, "sidebar_visible", false, NULL);
680 mutt_window_reflow(NULL);
681 }
682
683 buf_pool_release(&buf);
684 return rc;
685}
686
687// -----------------------------------------------------------------------------
688
692static const struct SidebarFunction SidebarFunctions[] = {
693 // clang-format off
694 { OP_SIDEBAR_FIRST, op_sidebar_first },
695 { OP_SIDEBAR_LAST, op_sidebar_last },
696 { OP_SIDEBAR_NEXT, op_sidebar_next },
697 { OP_SIDEBAR_NEXT_NEW, op_sidebar_next_new },
698 { OP_SIDEBAR_OPEN, op_sidebar_open },
699 { OP_SIDEBAR_PAGE_DOWN, op_sidebar_page_down },
700 { OP_SIDEBAR_PAGE_UP, op_sidebar_page_up },
701 { OP_SIDEBAR_PREV, op_sidebar_prev },
702 { OP_SIDEBAR_PREV_NEW, op_sidebar_prev_new },
703 { OP_SIDEBAR_TOGGLE_VIRTUAL, op_sidebar_toggle_virtual },
704 { OP_SIDEBAR_TOGGLE_VISIBLE, op_sidebar_toggle_visible },
705 { OP_SIDEBAR_ABORT_SEARCH, op_sidebar_abort_search },
706 { OP_SIDEBAR_START_SEARCH, op_sidebar_start_search },
707 { 0, NULL },
708 // clang-format on
709};
710
714int sb_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
715{
716 if (!event || !win || !win->wdata)
717 return FR_UNKNOWN;
718
719 const int op = event->op;
720
722
723 struct SidebarFunctionData fdata = {
724 .n = NeoMutt,
725 .mod_data = mod_data,
726 .wdata = win->wdata,
727 };
728
729 int rc = FR_UNKNOWN;
730 for (size_t i = 0; SidebarFunctions[i].op != OP_NULL; i++)
731 {
732 const struct SidebarFunction *fn = &SidebarFunctions[i];
733 if (fn->op == op)
734 {
735 rc = fn->function(&fdata, event);
736 break;
737 }
738 }
739
740 if (rc == FR_UNKNOWN) // Not our function
741 return rc;
742
743 const char *result = dispatcher_get_retval_name(rc);
744 mutt_debug(LL_DEBUG1, "Handled %s (%d) -> %s\n", opcodes_get_name(op), op, NONULL(result));
745
747 return rc;
748}
#define ARRAY_IDX(head, elem)
Return the index of an element of the array.
Definition array.h:324
#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_FOREACH_TO(elem, head, to)
Iterate from the beginning to an index.
Definition array.h:247
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition array.h:235
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
#define ARRAY_FOREACH_FROM_TO(elem, head, from, to)
Iterate between two indexes.
Definition array.h:261
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition bool.c:231
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
Convenience wrapper for the config headers.
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_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
void index_change_folder(struct MuttWindow *dlg, struct Mailbox *m)
Change the current folder, cautiously.
Definition dlg_index.c:1490
struct SubMenu * editor_get_submenu(void)
Get the Editor SubMenu.
Definition functions.c:585
Edit a string.
int mw_get_field_notify(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata, get_field_callback_t callback, void *cb_data, const struct MenuDefinition *md, function_dispatcher_t fn_disp)
Ask the user for a string and call a notify function on keypress.
Definition window.c:266
#define MUTT_COMP_UNBUFFERED
Ignore macro buffer.
Definition wdata.h:45
Fuzzy matching library.
@ FUZZY_ALGO_SUBSEQ
Subsequence matching algorithm.
Definition lib.h:77
int fuzzy_match(const char *pattern, const char *candidate, enum FuzzyAlgo algo, const struct FuzzyOptions *opts, struct FuzzyResult *out)
Perform fuzzy matching.
Definition fuzzy.c:58
int sb_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
Perform a Sidebar function - Implements function_dispatcher_t -.
Definition functions.c:714
#define mutt_warning(...)
Definition logging2.h:92
#define mutt_message(...)
Definition logging2.h:93
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
static int op_sidebar_next(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the next unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:288
static int op_sidebar_start_search(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the last unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:610
static int op_sidebar_toggle_visible(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Make the sidebar (in)visible - Implements sidebar_function_t -.
Definition functions.c:508
static int op_sidebar_page_up(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.
Definition functions.c:405
static int op_sidebar_toggle_virtual(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Deprecated - Implements sidebar_function_t -.
Definition functions.c:519
static int op_sidebar_abort_search(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Close the Sidebar Search - Implements sidebar_function_t -.
Definition functions.c:597
static int op_sidebar_prev(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the previous unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:436
static int op_sidebar_page_down(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.
Definition functions.c:374
static int op_sidebar_last(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the last unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:263
static int op_sidebar_first(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the first unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:237
static int op_sidebar_open(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Open highlighted mailbox - Implements sidebar_function_t -.
Definition functions.c:359
static int op_sidebar_next_new(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the next new mailbox - Implements sidebar_function_t -.
Definition functions.c:321
static int op_sidebar_prev_new(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the previous new mailbox - Implements sidebar_function_t -.
Definition functions.c:469
Convenience wrapper for the gui headers.
Read/write command history from/to a file.
@ HC_NONE
No History.
Definition lib.h:64
GUI manage the main index (list of emails)
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:121
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:87
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:104
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:134
Manage keymappings.
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
#define MAX(a, b)
Return the maximum of two values.
Definition memory.h:38
GUI present the user with a selectable list.
@ MODULE_ID_SIDEBAR
ModuleSidebar, Sidebar
Definition module_api.h:91
Convenience wrapper for the library headers.
#define _(a)
Definition message.h:28
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
#define WA_RECALC
Recalculate the contents of the Window.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition opcodes.c:48
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
static const struct SidebarFunction SidebarFunctions[]
All the NeoMutt functions that the Sidebar supports.
Definition functions.c:692
const struct MenuOpSeq SidebarDefaultBindings[]
Key bindings for the Sidebar Window.
Definition functions.c:72
bool sb_prev(struct SidebarWindowData *wdata)
Find the previous unhidden Mailbox.
Definition functions.c:194
static void sidebar_matcher_cb(const char *text, void *data)
React to keys as they are entered - Implements get_field_callback_t.
Definition functions.c:528
void sidebar_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
Initialise the Sidebar Keybindings - Implements ::init_keys_api.
Definition functions.c:82
static struct SbEntry ** sb_prev_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
Return the previous mailbox with new messages.
Definition functions.c:220
struct SubMenu * sidebar_get_submenu(void)
Get the Sidebar SubMenu.
Definition functions.c:106
static bool sb_next_n(struct SidebarWindowData *wdata, int count)
Move down N unhidden Mailboxes, capping at the last.
Definition functions.c:141
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
Definition functions.c:119
static bool sb_prev_n(struct SidebarWindowData *wdata, int count)
Move up N unhidden Mailboxes, capping at the first.
Definition functions.c:159
static const struct MenuFuncOp OpSidebar[]
Functions for the Sidebar Window.
Definition functions.c:52
static struct SbEntry ** sb_next_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
Return the next mailbox with new messages.
Definition functions.c:178
Sidebar functions.
GUI display the mailboxes in a side panel.
Sidebar private Module data.
GUI display the mailboxes in a side panel.
void sb_entry_set_display_name(struct SbEntry *entry)
Set the display name for an SbEntry.
Definition window.c:306
struct Mailbox * sb_get_highlight(struct MuttWindow *win)
Get the Mailbox that's highlighted in the sidebar.
Definition sidebar.c:74
#define ASSERT(COND)
Definition signal2.h:59
#define NONULL(x)
Definition string2.h:44
String manipulation buffer.
Definition buffer.h:36
Options for fuzzy matching.
Definition lib.h:87
Result of a fuzzy match.
Definition lib.h:98
An event such as a keypress.
Definition get.h:57
int count
Optional count prefix, e.g. 3 for 3j
Definition get.h:60
int msg_new
Number of new messages.
Definition mailbox.h:91
bool visible
True if a result of "mailboxes".
Definition mailbox.h:129
int msg_unread
Number of unread messages.
Definition mailbox.h:88
Functions for a Dialog or Window.
Definition menu.h:77
Mapping between a function and an operation.
Definition menu.h:35
Mapping between an operation and a key sequence.
Definition menu.h:45
void * wdata
Private data.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Info about folders in the sidebar.
Definition private.h:40
int score
Fuzzy-match score.
Definition private.h:47
char display[256]
Formatted string to display.
Definition private.h:42
struct Mailbox * mailbox
Mailbox this represents.
Definition private.h:44
char box[256]
Mailbox path (possibly abbreviated)
Definition private.h:41
Data passed to Sidebar worker functions.
Definition functions.h:32
struct SidebarWindowData * wdata
Sidebar window data.
Definition functions.h:35
struct NeoMutt * n
NeoMutt application data.
Definition functions.h:33
struct SidebarModuleData * mod_data
Sidebar module data.
Definition functions.h:34
A NeoMutt function.
Definition functions.h:57
int op
Op code, e.g. OP_SIDEBAR_NEXT.
Definition functions.h:58
sidebar_function_t function
Function to call.
Definition functions.h:59
Sidebar private Module data.
Definition module_data.h:32
struct MenuDefinition * md_sidebar
Sidebar Menu Definition.
Definition module_data.h:34
struct SubMenu * sm_sidebar
Sidebar functions.
Definition module_data.h:35
Sidebar private Window data -.
Definition private.h:89
int hil_index
Highlighted mailbox.
Definition private.h:96
bool search_active
Sidebar Search is running.
Definition private.h:99
struct MuttWindow * win
Sidebar Window.
Definition private.h:90
struct SbEntryArray entries
Items to display in the sidebar.
Definition private.h:92
bool repage
Force RECALC to recompute the paging used for the overlays.
Definition private.h:98
Collection of related functions.
Definition menu.h:65
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition subset.c:303
@ MENU_SIDEBAR
Sidebar menu.
Definition type.h:49