105 if (!url_m || !url_f)
122 plen = strlen(mbox) - mlen + flen;
140 if (!mbox || !folder)
148 return mbox + prefix;
152 if (!c_sidebar_delim_chars)
158 if (strchr(c_sidebar_delim_chars, folder[flen - 1]))
169 if (!strchr(c_sidebar_delim_chars, mbox[flen]))
174 return mbox + flen + 1;
180 if (strchr(c_sidebar_delim_chars, mbox[mlen]))
182 return mbox + mlen + 1;
206 const int scheme_len = 10;
218 const char *last = strchr(mbox + scheme_len, split);
235 for (
int i = 0; i < sbe->
depth; i++)
237 res +=
mutt_str_copy(buf + res, c_sidebar_indent_string, buflen - res);
284 if (current || highlight)
312static int calc_path_depth(
const char *mbox,
const char *delims,
const char **last_part)
314 if (!mbox || !delims || !last_part)
318 const char *match = NULL;
319 while ((match = strpbrk(mbox, delims)))
351 char op,
const char *src,
const char *prec,
352 const char *if_str,
const char *else_str,
358 char fmt[256] = { 0 };
360 if (!sbe || !shared || !buf)
380 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
393 char indented[256] = { 0 };
394 size_t ilen =
sizeof(indented);
396 snprintf(indented + off, ilen - off,
"%s",
405 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
406 snprintf(buf, buflen, fmt, c ? m_cur->
msg_deleted : 0);
417 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
429 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
441 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
453 snprintf(fmt,
sizeof(fmt),
"%%%sc", prec);
454 snprintf(buf, buflen, fmt, m->
has_new ?
'N' :
' ');
465 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
477 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
490 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
502 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
503 snprintf(buf, buflen, fmt, m->
msg_count);
514 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
515 snprintf(buf, buflen, fmt, c ? m_cur->
msg_tagged : 0);
517 else if ((c && (m_cur->
msg_tagged == 0)) || !c)
526 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
527 snprintf(buf, buflen, fmt, m->
msg_new);
529 else if ((c && (m_cur->
msg_new) == 0) || !c)
594 width =
MIN(buflen, width);
598 memset(buf + s,
' ', width - w);
599 buf[s + width - w] =
'\0';
632 int i = ARRAY_FOREACH_IDX;
657 if (c_sidebar_non_empty_mailbox_only && (i != wdata->
opn_index) &&
663 if (c_sidebar_new_mail_only && (i != wdata->
opn_index) &&
695 const struct SbEntry *opn_entry = sbep ? *sbep : NULL;
697 const struct SbEntry *hil_entry = sbep ? *sbep : NULL;
703 if (opn_entry || hil_entry)
707 if ((opn_entry == *sbep) && (*sbep)->mailbox->visible)
709 if ((hil_entry == *sbep) && (*sbep)->mailbox->visible)
734 if (c_sidebar_new_mail_only || c_sidebar_non_empty_mailbox_only)
741 int page_entries = 0;
742 while (page_entries < page_size)
812 if ((*sbep)->is_hidden)
815 struct SbEntry *entry = (*sbep);
818 const int entryidx = ARRAY_FOREACH_IDX;
822 if (m_cur && (m_cur->
realpath[0] !=
'\0') &&
837 const char *short_path = abbr ? abbr : path;
840 const char *last_part = abbr;
844 const bool short_path_is_abbr = (short_path == abbr);
846 if (c_sidebar_short_path)
848 short_path = last_part;
854 if (c_sidebar_folder_indent && short_path_is_abbr)
857 if (c_sidebar_component_depth > 0)
858 entry->
depth -= c_sidebar_component_depth;
860 else if (!c_sidebar_folder_indent)
892 int num_rows,
int num_cols)
894 if ((num_rows < 1) || (num_cols < 1) || (wdata->
divider_width > num_cols) ||
909 const int col = c_sidebar_on_right ? 0 : (num_cols - width);
911 for (
int i = 0; i < num_rows; i++)
936 int num_rows,
int div_width,
int num_cols)
944 if (!c_sidebar_on_right)
946 for (
int r = 0; r < num_rows; r++)
951 for (
int i = 0; i < num_cols; i++)
968 if (
wdata->top_index >= 0)
971 if (c_sidebar_on_right)
972 col =
wdata->divider_width;
980 if ((*sbep)->is_hidden)
983 struct SbEntry *entry = (*sbep);
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_EMPTY(head)
Check if an array is empty.
#define ARRAY_SIZE(head)
The number of elements stored.
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
#define ARRAY_GET(head, idx)
Return the element at index.
Color and attribute parsing.
bool simple_color_is_set(enum ColorId cid)
Is the object coloured?
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
@ MT_COLOR_SIDEBAR_DIVIDER
Line dividing sidebar from the index/pager.
@ MT_COLOR_SIDEBAR_NEW
Mailbox with new mail.
@ MT_COLOR_SIDEBAR_UNREAD
Mailbox with unread mail.
@ MT_COLOR_INDICATOR
Selected item in list.
@ MT_COLOR_SIDEBAR_SPOOLFILE
$spool_file (Spool mailbox)
@ MT_COLOR_SIDEBAR_ORDINARY
Mailbox with no new or flagged messages.
@ MT_COLOR_SIDEBAR_BACKGROUND
Background colour for the Sidebar.
@ MT_COLOR_NORMAL
Plain text.
@ MT_COLOR_SIDEBAR_INDICATOR
Current open mailbox.
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
@ MT_COLOR_SIDEBAR_FLAGGED
Mailbox with flagged messages.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
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.
void mutt_refresh(void)
Force a refresh of the screen.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Structs that make up an email.
static const char * sidebar_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 sidebar - Implements format_t -.
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 -.
#define mutt_debug(LEVEL,...)
int sb_recalc(struct MuttWindow *win)
Recalculate the Sidebar display - Implements MuttWindow::recalc() -.
int sb_repaint(struct MuttWindow *win)
Repaint the Sidebar display - Implements MuttWindow::repaint() -.
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.
@ LL_DEBUG5
Log at debug level 5.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
MailboxType
Supported mailbox formats.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
@ MUTT_POP
'POP3' Mailbox type
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
@ MUTT_IMAP
'IMAP' Mailbox type
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
Convenience wrapper for the library headers.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
void mutt_curses_set_color(const struct AttrColor *ac)
Set the colour and attributes for text.
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 col, int row)
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.
Some miscellaneous functions.
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
#define STAILQ_HEAD_INITIALIZER(head)
#define STAILQ_FOREACH(var, head, field)
A curses colour and its attributes.
Data shared between Index, Pager and Sidebar.
struct Mailbox * mailbox
Current Mailbox.
struct Mailbox * mailbox
Mailbox in the list.
int vcount
The number of virtual messages.
bool has_new
Mailbox has new mail.
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
int msg_new
Number of new messages.
int msg_count
Total number of messages.
enum MailboxType type
Mailbox type.
bool poll_new_mail
Check for new mail.
char * name
A short name for the Mailbox.
bool notify_user
Notify the user of new mail.
int msg_deleted
Number of deleted messages.
bool visible
True if a result of "mailboxes".
int msg_flagged
Number of flagged messages.
int msg_tagged
How many messages are tagged?
int msg_unread
Number of unread messages.
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.
struct ConfigSubset * sub
Inherited config items.
Info about folders in the sidebar.
const struct AttrColor * color
Colour to use.
int depth
Indentation depth.
char display[256]
Formatted string to display.
struct Mailbox * mailbox
Mailbox this represents.
bool is_hidden
Don't show, e.g. $sidebar_new_mail_only.
char box[256]
Mailbox path (possibly abbreviated)
A parsed URL proto://user:password@host:port/path?a=1&b=2
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
struct Url * url_parse(const char *src)
Fill in Url.
void url_free(struct Url **ptr)
Free the contents of a URL.