NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
window.c
Go to the documentation of this file.
1
27
68
69#include "config.h"
70#include <stdbool.h>
71#include <string.h>
72#include "private.h"
73#include "mutt/lib.h"
74#include "config/lib.h"
75#include "email/lib.h"
76#include "core/lib.h"
77#include "gui/lib.h"
78#include "color/lib.h"
79#include "expando/lib.h"
80#include "index/lib.h"
81#include "expando.h"
82
89static int imap_is_prefix(const char *folder, const char *mbox)
90{
91 int plen = 0;
92
93 struct Url *url_m = url_parse(mbox);
94 struct Url *url_f = url_parse(folder);
95 if (!url_m || !url_f)
96 goto done;
97
98 if (!mutt_istr_equal(url_m->host, url_f->host))
99 goto done;
100
101 if (url_m->user && url_f->user && !mutt_istr_equal(url_m->user, url_f->user))
102 goto done;
103
104 size_t mlen = mutt_str_len(url_m->path);
105 size_t flen = mutt_str_len(url_f->path);
106 if (flen > mlen)
107 goto done;
108
109 if (!mutt_strn_equal(url_m->path, url_f->path, flen))
110 goto done;
111
112 plen = strlen(mbox) - mlen + flen;
113
114done:
115 url_free(&url_m);
116 url_free(&url_f);
117
118 return plen;
119}
120
128static const char *abbrev_folder(const char *mbox, const char *folder, enum MailboxType type)
129{
130 if (!mbox || !folder)
131 return NULL;
132
133 if (type == MUTT_IMAP)
134 {
135 int prefix = imap_is_prefix(folder, mbox);
136 if (prefix == 0)
137 return NULL;
138 return mbox + prefix;
139 }
140
141 const char *const c_sidebar_delim_chars = cs_subset_string(NeoMutt->sub, "sidebar_delim_chars");
142 if (!c_sidebar_delim_chars)
143 return NULL;
144
145 size_t flen = mutt_str_len(folder);
146 if (flen == 0)
147 return NULL;
148 if (strchr(c_sidebar_delim_chars, folder[flen - 1])) // folder ends with a delimiter
149 flen--;
150
151 size_t mlen = mutt_str_len(mbox);
152 if (mlen < flen)
153 return NULL;
154
155 if (!mutt_strn_equal(folder, mbox, flen))
156 return NULL;
157
158 // After the match, check that mbox has a delimiter
159 if (!strchr(c_sidebar_delim_chars, mbox[flen]))
160 return NULL;
161
162 if (mlen > flen)
163 {
164 return mbox + flen + 1;
165 }
166
167 // mbox and folder are equal, use the chunk after the last delimiter
168 while (mlen--)
169 {
170 if (strchr(c_sidebar_delim_chars, mbox[mlen]))
171 {
172 return mbox + mlen + 1;
173 }
174 }
175
176 return NULL;
177}
178
192static const char *abbrev_url(const char *mbox, enum MailboxType type)
193{
194 /* This is large enough to skip `notmuch://`,
195 * but not so large that it will go past the host part. */
196 const int scheme_len = 10;
197
198 size_t len = mutt_str_len(mbox);
199 if ((len < scheme_len) || ((type != MUTT_NNTP) && (type != MUTT_IMAP) &&
200 (type != MUTT_NOTMUCH) && (type != MUTT_POP)))
201 {
202 return mbox;
203 }
204
205 const char split = (type == MUTT_NOTMUCH) ? '?' : '/';
206
207 // Skip over the scheme, e.g. `imaps://`, `notmuch://`
208 const char *last = strchr(mbox + scheme_len, split);
209 if (last)
210 mbox = last + 1;
211 return mbox;
212}
213
221static const struct AttrColor *calc_color(const struct Mailbox *m, bool current, bool highlight)
222{
223 const struct AttrColor *ac = NULL;
224
225 const char *const c_spool_file = cs_subset_string(NeoMutt->sub, "spool_file");
227 mutt_str_equal(mailbox_path(m), c_spool_file))
228 {
230 }
231
233 {
235 }
236
238 {
240 }
241
243 {
245 }
246
248 {
250 }
251
252 const struct AttrColor *ac_bg = simple_color_get(MT_COLOR_NORMAL);
254 ac = merged_color_overlay(ac_bg, ac);
255
256 if (current || highlight)
257 {
258 int color;
259 if (current)
260 {
263 else
264 color = MT_COLOR_INDICATOR;
265 }
266 else
267 {
269 }
270
271 ac = merged_color_overlay(ac, simple_color_get(color));
272 }
273
274 return ac;
275}
276
284static int calc_path_depth(const char *mbox, const char *delims, const char **last_part)
285{
286 if (!mbox || !delims || !last_part)
287 return 0;
288
289 int depth = 0;
290 const char *match = NULL;
291 while ((match = strpbrk(mbox, delims)))
292 {
293 depth++;
294 mbox = match + 1;
295 }
296
297 *last_part = mbox;
298 return depth;
299}
300
306{
307 const char *path = mailbox_path(entry->mailbox);
308
309 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
310 // Try to abbreviate the full path
311 const char *abbr = abbrev_folder(path, c_folder, entry->mailbox->type);
312 if (!abbr)
313 abbr = abbrev_url(path, entry->mailbox->type);
314 const char *short_path = abbr ? abbr : path;
315
316 /* Compute the depth */
317 const char *last_part = abbr;
318 const char *const c_sidebar_delim_chars = cs_subset_string(NeoMutt->sub, "sidebar_delim_chars");
319 entry->depth = calc_path_depth(abbr, c_sidebar_delim_chars, &last_part);
320
321 const bool short_path_is_abbr = (short_path == abbr);
322 const bool c_sidebar_short_path = cs_subset_bool(NeoMutt->sub, "sidebar_short_path");
323 if (c_sidebar_short_path)
324 {
325 short_path = last_part;
326 }
327
328 // Don't indent if we were unable to create an abbreviation.
329 // Otherwise, the full path will be indent, and it looks unusual.
330 const bool c_sidebar_folder_indent = cs_subset_bool(NeoMutt->sub, "sidebar_folder_indent");
331 if (c_sidebar_folder_indent && short_path_is_abbr)
332 {
333 const short c_sidebar_component_depth = cs_subset_number(NeoMutt->sub, "sidebar_component_depth");
334 if (c_sidebar_component_depth > 0)
335 entry->depth -= c_sidebar_component_depth;
336 }
337 else if (!c_sidebar_folder_indent)
338 {
339 entry->depth = 0;
340 }
341
342 mutt_str_copy(entry->box, short_path, sizeof(entry->box));
343}
344
358static void make_sidebar_entry(char *buf, size_t buflen, int width,
359 struct SbEntry *sbe, struct IndexSharedData *shared)
360{
361 struct SidebarData sdata = { sbe, shared };
362
363 struct Buffer *tmp = buf_pool_get();
364 const struct Expando *c_sidebar_format = cs_subset_expando(NeoMutt->sub, "sidebar_format");
365 expando_filter(c_sidebar_format, SidebarRenderCallbacks, &sdata,
366 MUTT_FORMAT_NO_FLAGS, width, NeoMutt->env, tmp);
367 mutt_str_copy(buf, buf_string(tmp), buflen);
368 buf_pool_release(&tmp);
369
370 /* Force string to be exactly the right width */
371 int w = mutt_strwidth(buf);
372 int s = mutt_str_len(buf);
373 width = MIN(buflen, width);
374 if (w < width)
375 {
376 /* Pad with spaces, capping to available buffer space */
377 int pad = width - w;
378 if ((s + pad) >= (int) buflen)
379 pad = (int) buflen - s - 1;
380 if (pad > 0)
381 {
382 memset(buf + s, ' ', pad);
383 buf[s + pad] = '\0';
384 }
385 }
386 else if (w > width)
387 {
388 /* Truncate to fit */
389 size_t len = mutt_wstr_trunc(buf, buflen, width, NULL);
390 buf[len] = '\0';
391 }
392}
393
407{
408 /* Aliases for readability */
409 const bool c_sidebar_new_mail_only = cs_subset_bool(NeoMutt->sub, "sidebar_new_mail_only");
410 const bool c_sidebar_non_empty_mailbox_only = cs_subset_bool(NeoMutt->sub, "sidebar_non_empty_mailbox_only");
411 struct SbEntry *sbe = NULL;
412
413 struct IndexSharedData *shared = wdata->shared;
414 struct SbEntry **sbep = NULL;
415 ARRAY_FOREACH(sbep, &wdata->entries)
416 {
417 int i = ARRAY_FOREACH_IDX_sbep;
418 sbe = *sbep;
419
420 sbe->is_hidden = false;
421
422 if (!sbe->mailbox->visible)
423 {
424 sbe->is_hidden = true;
425 continue;
426 }
427
428 if (shared->mailbox &&
430 {
431 /* Spool directories are always visible */
432 continue;
433 }
434
437 {
438 /* Explicitly asked to be visible */
439 continue;
440 }
441
442 if (c_sidebar_non_empty_mailbox_only && (i != wdata->opn_index) &&
443 (sbe->mailbox->msg_count == 0))
444 {
445 sbe->is_hidden = true;
446 }
447
448 if (c_sidebar_new_mail_only && (i != wdata->opn_index) &&
449 (sbe->mailbox->msg_unread == 0) && (sbe->mailbox->msg_flagged == 0) &&
450 !sbe->mailbox->has_new)
451 {
452 sbe->is_hidden = true;
453 }
454 }
455}
456
470static bool prepare_sidebar(struct SidebarWindowData *wdata, int page_size)
471{
472 if (ARRAY_EMPTY(&wdata->entries) || (page_size <= 0))
473 return false;
474
475 struct SbEntry **sbep = NULL;
476 const bool c_sidebar_new_mail_only = cs_subset_bool(NeoMutt->sub, "sidebar_new_mail_only");
477 const bool c_sidebar_non_empty_mailbox_only = cs_subset_bool(NeoMutt->sub, "sidebar_non_empty_mailbox_only");
478
479 sbep = (wdata->opn_index >= 0) ? ARRAY_GET(&wdata->entries, wdata->opn_index) : NULL;
480 const struct SbEntry *opn_entry = sbep ? *sbep : NULL;
481 sbep = (wdata->hil_index >= 0) ? ARRAY_GET(&wdata->entries, wdata->hil_index) : NULL;
482 const struct SbEntry *hil_entry = sbep ? *sbep : NULL;
483
485 const enum EmailSortType c_sidebar_sort = cs_subset_sort(NeoMutt->sub, "sidebar_sort");
486 sb_sort_entries(wdata, c_sidebar_sort);
487
488 if (opn_entry || hil_entry)
489 {
490 ARRAY_FOREACH(sbep, &wdata->entries)
491 {
492 if ((opn_entry == *sbep) && (*sbep)->mailbox->visible)
493 wdata->opn_index = ARRAY_FOREACH_IDX_sbep;
494 if ((hil_entry == *sbep) && (*sbep)->mailbox->visible)
495 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
496 }
497 }
498
499 if ((wdata->hil_index < 0) || (hil_entry && hil_entry->is_hidden) ||
500 (c_sidebar_sort != wdata->previous_sort))
501 {
502 if (wdata->opn_index >= 0)
503 {
504 wdata->hil_index = wdata->opn_index;
505 }
506 else
507 {
508 wdata->hil_index = 0;
509 /* Note is_hidden will only be set when `$sidebar_new_mail_only` */
510 if ((*ARRAY_GET(&wdata->entries, 0))->is_hidden && !sb_next(wdata))
511 wdata->hil_index = -1;
512 }
513 }
514
515 /* Set the Top and Bottom to frame the wdata->hil_index in groups of page_size */
516
517 /* If `$sidebar_new_mail_only` or `$sidebar_non_empty_mailbox_only` is set,
518 * some entries may be hidden so we need to scan for the framing interval */
519 if (c_sidebar_new_mail_only || c_sidebar_non_empty_mailbox_only)
520 {
521 wdata->top_index = -1;
522 wdata->bot_index = -1;
523 while (wdata->bot_index < wdata->hil_index)
524 {
525 wdata->top_index = wdata->bot_index + 1;
526 int page_entries = 0;
527 while (page_entries < page_size)
528 {
529 wdata->bot_index++;
530 if (wdata->bot_index >= ARRAY_SIZE(&wdata->entries))
531 break;
532 if (!(*ARRAY_GET(&wdata->entries, wdata->bot_index))->is_hidden)
533 page_entries++;
534 }
535 }
536 }
537 else
538 {
539 /* Otherwise we can just calculate the interval */
540 wdata->top_index = (wdata->hil_index / page_size) * page_size;
541 wdata->bot_index = wdata->top_index + page_size - 1;
542 }
543
544 if (wdata->bot_index > (ARRAY_SIZE(&wdata->entries) - 1))
545 wdata->bot_index = ARRAY_SIZE(&wdata->entries) - 1;
546
547 wdata->previous_sort = c_sidebar_sort;
548
549 return (wdata->hil_index >= 0);
550}
551
555int sb_recalc(struct MuttWindow *win)
556{
558 struct IndexSharedData *shared = wdata->shared;
559
560 if (ARRAY_EMPTY(&wdata->entries))
561 {
562 struct MailboxArray ma = neomutt_mailboxes_get(NeoMutt, MUTT_MAILBOX_ANY);
563 struct Mailbox **mp = NULL;
564 ARRAY_FOREACH(mp, &ma)
565 {
566 struct Mailbox *m = *mp;
567
568 if (m->visible)
569 sb_add_mailbox(wdata, m);
570 }
571 ARRAY_FREE(&ma); // Clean up the ARRAY, but not the Mailboxes
572 }
573
574 if (!prepare_sidebar(wdata, win->state.rows))
575 {
576 win->actions |= WA_REPAINT;
577 return 0;
578 }
579
580 int num_rows = win->state.rows;
581 int num_cols = win->state.cols;
582
583 if (ARRAY_EMPTY(&wdata->entries) || (num_rows <= 0))
584 return 0;
585
586 if (wdata->top_index < 0)
587 return 0;
588
589 int width = num_cols - wdata->divider_width;
590 int row = 0;
591 struct Mailbox *m_cur = shared->mailbox;
592 struct SbEntry **sbep = NULL;
593 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->top_index)
594 {
595 if (row >= num_rows)
596 break;
597
598 if ((*sbep)->is_hidden)
599 continue;
600
601 struct SbEntry *entry = (*sbep);
602 struct Mailbox *m = entry->mailbox;
603
604 const int entryidx = ARRAY_FOREACH_IDX_sbep;
605 entry->color = calc_color(m, (entryidx == wdata->opn_index),
606 (entryidx == wdata->hil_index));
607
608 if (m_cur && (m_cur->realpath[0] != '\0') &&
609 mutt_str_equal(m->realpath, m_cur->realpath))
610 {
611 m->msg_unread = m_cur->msg_unread;
612 m->msg_count = m_cur->msg_count;
613 m->msg_flagged = m_cur->msg_flagged;
614 }
615
617 make_sidebar_entry(entry->display, sizeof(entry->display), width, entry, shared);
618 row++;
619 }
620
621 win->actions |= WA_REPAINT;
622 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
623 return 0;
624}
625
642static int draw_divider(struct SidebarWindowData *wdata, struct MuttWindow *win,
643 int num_rows, int num_cols)
644{
645 if ((num_rows < 1) || (num_cols < 1) || (wdata->divider_width > num_cols) ||
646 (wdata->divider_width == 0))
647 {
648 return 0;
649 }
650
651 const int width = wdata->divider_width;
652 const char *const c_sidebar_divider_char = cs_subset_string(NeoMutt->sub, "sidebar_divider_char");
653
654 const struct AttrColor *ac = simple_color_get(MT_COLOR_NORMAL);
658
659 const bool c_sidebar_on_right = cs_subset_bool(NeoMutt->sub, "sidebar_on_right");
660 const int col = c_sidebar_on_right ? 0 : (num_cols - width);
661
662 for (int i = 0; i < num_rows; i++)
663 {
664 mutt_window_move(win, i, col);
665
666 if (wdata->divider_type == SB_DIV_USER)
667 mutt_window_addstr(win, NONULL(c_sidebar_divider_char));
668 else
669 mutt_window_addch(win, '|');
670 }
671
673 return width;
674}
675
686static void fill_empty_space(struct MuttWindow *win, int first_row,
687 int num_rows, int div_width, int num_cols)
688{
689 /* Fill the remaining rows with blank space */
690 const struct AttrColor *ac = simple_color_get(MT_COLOR_NORMAL);
693
694 const bool c_sidebar_on_right = cs_subset_bool(NeoMutt->sub, "sidebar_on_right");
695 if (!c_sidebar_on_right)
696 div_width = 0;
697 for (int r = 0; r < num_rows; r++)
698 {
699 mutt_window_move(win, first_row + r, div_width);
701
702 for (int i = 0; i < num_cols; i++)
703 mutt_window_addch(win, ' ');
704 }
705}
706
710int sb_repaint(struct MuttWindow *win)
711{
713 const bool c_sidebar_on_right = cs_subset_bool(NeoMutt->sub, "sidebar_on_right");
714
715 int row = 0;
716 int num_rows = win->state.rows;
717 int num_cols = win->state.cols;
718
719 if (wdata->top_index >= 0)
720 {
721 int col = 0;
722 if (c_sidebar_on_right)
723 col = wdata->divider_width;
724
725 struct SbEntry **sbep = NULL;
726 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->top_index)
727 {
728 if (row >= num_rows)
729 break;
730
731 if ((*sbep)->is_hidden)
732 continue;
733
734 struct SbEntry *entry = (*sbep);
735 mutt_window_move(win, row, col);
737 mutt_window_printf(win, "%s", entry->display);
738 mutt_refresh();
739 row++;
740 }
741 }
742
743 fill_empty_space(win, row, num_rows - row, wdata->divider_width,
744 num_cols - wdata->divider_width);
745 draw_divider(wdata, win, num_rows, num_cols);
746
747 mutt_debug(LL_DEBUG5, "repaint done\n");
748 return 0;
749}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_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
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
Color and attribute parsing.
bool simple_color_is_set(enum ColorId cid)
Is the object coloured?
Definition simple.c:116
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition simple.c:95
@ MT_COLOR_SIDEBAR_DIVIDER
Line dividing sidebar from the index/pager.
Definition color.h:69
@ MT_COLOR_SIDEBAR_NEW
Mailbox with new mail.
Definition color.h:73
@ MT_COLOR_SIDEBAR_UNREAD
Mailbox with unread mail.
Definition color.h:76
@ MT_COLOR_INDICATOR
Selected item in list.
Definition color.h:49
@ MT_COLOR_SIDEBAR_SPOOLFILE
$spool_file (Spool mailbox)
Definition color.h:75
@ MT_COLOR_SIDEBAR_ORDINARY
Mailbox with no new or flagged messages.
Definition color.h:74
@ MT_COLOR_SIDEBAR_BACKGROUND
Background colour for the Sidebar.
Definition color.h:68
@ MT_COLOR_NORMAL
Plain text.
Definition color.h:53
@ MT_COLOR_SIDEBAR_INDICATOR
Current open mailbox.
Definition color.h:72
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
Definition color.h:71
@ MT_COLOR_SIDEBAR_FLAGGED
Mailbox with flagged messages.
Definition color.h:70
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition helpers.c:143
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition helpers.c:266
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:213
MailboxType
Supported mailbox formats.
Definition mailbox.h:40
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
@ MUTT_POP
'POP3' Mailbox type
Definition mailbox.h:51
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition mailbox.h:48
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:49
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition mailbox.h:41
size_t mutt_wstr_trunc(const char *src, size_t maxlen, size_t maxwid, size_t *width)
Work out how to truncate a widechar string.
Definition curs_lib.c:384
void mutt_refresh(void)
Force a refresh of the screen.
Definition curs_lib.c:78
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition curs_lib.c:444
Structs that make up an email.
EmailSortType
Methods for sorting Emails.
Definition sort.h:53
int expando_filter(const struct Expando *exp, const struct ExpandoRenderCallback *erc, void *data, MuttFormatFlags flags, int max_cols, char **env_list, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition filter.c:139
Parse Expando string.
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
int sb_recalc(struct MuttWindow *win)
Recalculate the Sidebar display - Implements MuttWindow::recalc() -.
Definition window.c:555
int sb_repaint(struct MuttWindow *win)
Repaint the Sidebar display - Implements MuttWindow::repaint() -.
Definition window.c:710
Convenience wrapper for the gui headers.
GUI manage the main index (list of emails)
struct ListNode * mutt_list_find(const struct ListHead *h, const char *data)
Find a string in a List.
Definition list.c:103
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:49
#define MIN(a, b)
Return the minimum of two values.
Definition memory.h:40
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
Definition merged.c:107
Convenience wrapper for the library headers.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition string.c:674
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:662
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
Definition string.c:429
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition string.c:500
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:583
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the Colour ID.
Definition mutt_curses.c:79
void mutt_curses_set_color(const struct AttrColor *ac)
Set the colour and attributes for text.
Definition mutt_curses.c:38
int mutt_window_printf(struct MuttWindow *win, const char *fmt,...)
Write a formatted string to a Window.
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
#define WA_REPAINT
Redraw the contents of the Window.
struct MailboxArray neomutt_mailboxes_get(struct NeoMutt *n, enum MailboxType type)
Get an Array of matching Mailboxes.
Definition neomutt.c:526
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
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition render.h:33
const struct ExpandoRenderCallback SidebarRenderCallbacks[]
Callbacks for Sidebar Expandos.
Definition expando.c:290
Sidebar Expando definitions.
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
Definition functions.c:100
GUI display the mailboxes in a side panel.
@ SB_DIV_USER
User configured using $sidebar_divider_char.
Definition private.h:81
void sb_sort_entries(struct SidebarWindowData *wdata, enum EmailSortType sort)
Sort the Sidebar entries.
Definition sort.c:161
struct ListHead SidebarPinned
List of mailboxes to always display in the sidebar.
Definition sidebar.c:44
void sb_add_mailbox(struct SidebarWindowData *wdata, struct Mailbox *m)
Add a Mailbox to the Sidebar.
Definition sidebar.c:100
struct SidebarWindowData * sb_wdata_get(struct MuttWindow *win)
Get the Sidebar data for this window.
Definition wdata.c:77
static const char * abbrev_url(const char *mbox, enum MailboxType type)
Abbreviate a url-style Mailbox path.
Definition window.c:192
static void fill_empty_space(struct MuttWindow *win, int first_row, int num_rows, int div_width, int num_cols)
Wipe the remaining Sidebar space.
Definition window.c:686
static void update_entries_visibility(struct SidebarWindowData *wdata)
Should a SbEntry be displayed in the sidebar?
Definition window.c:406
static const struct AttrColor * calc_color(const struct Mailbox *m, bool current, bool highlight)
Calculate the colour of a Sidebar row.
Definition window.c:221
static const char * abbrev_folder(const char *mbox, const char *folder, enum MailboxType type)
Abbreviate a Mailbox path using a folder.
Definition window.c:128
void sb_entry_set_display_name(struct SbEntry *entry)
Set the display name for an SbEntry.
Definition window.c:305
static int calc_path_depth(const char *mbox, const char *delims, const char **last_part)
Calculate the depth of a Mailbox path.
Definition window.c:284
static bool prepare_sidebar(struct SidebarWindowData *wdata, int page_size)
Prepare the list of SbEntry's for the sidebar display.
Definition window.c:470
static int imap_is_prefix(const char *folder, const char *mbox)
Check if folder matches the beginning of mbox.
Definition window.c:89
static int draw_divider(struct SidebarWindowData *wdata, struct MuttWindow *win, int num_rows, int num_cols)
Draw a line between the sidebar and the rest of neomutt.
Definition window.c:642
static void make_sidebar_entry(char *buf, size_t buflen, int width, struct SbEntry *sbe, struct IndexSharedData *shared)
Turn mailbox data into a sidebar string.
Definition window.c:358
#define NONULL(x)
Definition string2.h:44
A curses colour and its attributes.
Definition attr.h:65
String manipulation buffer.
Definition buffer.h:36
Parsed Expando trees.
Definition expando.h:41
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:41
A mailbox.
Definition mailbox.h:78
bool has_new
Mailbox has new mail.
Definition mailbox.h:84
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition mailbox.h:80
int msg_count
Total number of messages.
Definition mailbox.h:87
enum MailboxType type
Mailbox type.
Definition mailbox.h:101
char * name
A short name for the Mailbox.
Definition mailbox.h:81
bool visible
True if a result of "mailboxes".
Definition mailbox.h:129
int msg_flagged
Number of flagged messages.
Definition mailbox.h:89
int msg_unread
Number of unread messages.
Definition mailbox.h:88
struct WindowState state
Current state of the Window.
void * wdata
Private data.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Container for Accounts, Notifications.
Definition neomutt.h:41
char ** env
Private copy of the environment variables.
Definition neomutt.h:58
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Info about folders in the sidebar.
Definition private.h:42
const struct AttrColor * color
Colour to use.
Definition private.h:48
int depth
Indentation depth.
Definition private.h:45
char display[256]
Formatted string to display.
Definition private.h:44
struct Mailbox * mailbox
Mailbox this represents.
Definition private.h:46
bool is_hidden
Don't show, e.g. $sidebar_new_mail_only.
Definition private.h:47
char box[256]
Mailbox path (possibly abbreviated)
Definition private.h:43
Data passed to sidebar_format_str()
Definition expando.h:34
struct IndexSharedData * shared
Shared Index Data.
Definition expando.h:36
Sidebar private Window data -.
Definition private.h:89
short previous_sort
Old $sidebar_sort
Definition private.h:99
int top_index
First mailbox visible in sidebar.
Definition private.h:94
short divider_width
Width of the divider in screen columns.
Definition private.h:101
int bot_index
Last mailbox visible in sidebar.
Definition private.h:97
int hil_index
Highlighted mailbox.
Definition private.h:96
enum DivType divider_type
Type of divider to use, e.g. SB_DIV_ASCII.
Definition private.h:100
struct IndexSharedData * shared
Shared Index Data.
Definition private.h:91
int opn_index
Current (open) mailbox.
Definition private.h:95
struct MuttWindow * win
Sidebar Window.
Definition private.h:90
struct SbEntryArray entries
Items to display in the sidebar.
Definition private.h:92
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition url.h:69
char * user
Username.
Definition url.h:71
char * host
Host.
Definition url.h:73
char * path
Path.
Definition url.h:75
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:60
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
struct Url * url_parse(const char *src)
Fill in Url.
Definition url.c:239
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition url.c:124