NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
private.h File Reference

GUI display the mailboxes in a side panel. More...

#include <stdbool.h>
#include "mutt/lib.h"
#include "email/lib.h"
#include "core/lib.h"
+ Include dependency graph for private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SbEntry
 Info about folders in the sidebar. More...
 
struct  SidebarWindowData
 Sidebar private Window data -. More...
 

Enumerations

enum  ExpandoDataSidebar {
  ED_SID_DELETED_COUNT = 1 , ED_SID_DESCRIPTION , ED_SID_FLAGGED , ED_SID_FLAGGED_COUNT ,
  ED_SID_LIMITED_COUNT , ED_SID_MESSAGE_COUNT , ED_SID_NAME , ED_SID_FUZZY_SCORE ,
  ED_SID_NEW_MAIL , ED_SID_NOTIFY , ED_SID_OLD_COUNT , ED_SID_POLL ,
  ED_SID_READ_COUNT , ED_SID_TAGGED_COUNT , ED_SID_UNREAD_COUNT , ED_SID_UNSEEN_COUNT
}
 Expando UIDs for the Sidebar. More...
 
enum  DivType { SB_DIV_USER , SB_DIV_ASCII }
 Source of the sidebar divider character. More...
 

Functions

 ARRAY_HEAD (SbEntryArray, struct SbEntry *)
 
void sb_add_mailbox (struct SidebarWindowData *wdata, struct Mailbox *m)
 Add a Mailbox to the Sidebar.
 
void sb_remove_mailbox (struct SidebarWindowData *wdata, const struct Mailbox *m)
 Remove a Mailbox from the Sidebar.
 
void sb_set_current_mailbox (struct SidebarWindowData *wdata, struct Mailbox *m)
 Set the current Mailbox.
 
struct Mailboxsb_get_highlight (struct MuttWindow *win)
 Get the Mailbox that's highlighted in the sidebar.
 
enum CommandResult parse_sidebar_unpin (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'sidebar-unpin' command - Implements Command::parse() -.
 
enum CommandResult parse_sidebar_pin (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'sidebar-pin' command - Implements Command::parse() -.
 
bool sb_next (struct SidebarWindowData *wdata)
 Find the next unhidden Mailbox.
 
bool sb_prev (struct SidebarWindowData *wdata)
 Find the previous unhidden Mailbox.
 
int sb_insertion_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
void sb_win_add_observers (struct MuttWindow *win)
 Add Observers to the Sidebar Window.
 
void sb_sort_entries (struct SidebarWindowData *wdata, enum EmailSortType sort)
 Sort the Sidebar entries.
 
void sb_wdata_free (struct MuttWindow *win, void **ptr)
 Free Sidebar Window data - Implements MuttWindow::wdata_free() -.
 
struct SidebarWindowDatasb_wdata_get (struct MuttWindow *win)
 Get the Sidebar data for this window.
 
struct SidebarWindowDatasb_wdata_new (struct MuttWindow *win, struct IndexSharedData *shared)
 Create new Window data for the Sidebar.
 
void sb_entry_set_display_name (struct SbEntry *entry)
 Set the display name for an SbEntry.
 
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() -.
 

Variables

struct ListHead SidebarPinned
 List of mailboxes to always display in the sidebar.
 

Detailed Description

GUI display the mailboxes in a side panel.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file private.h.

Enumeration Type Documentation

◆ ExpandoDataSidebar

Expando UIDs for the Sidebar.

See also
ED_SIDEBAR, ExpandoDomain
Enumerator
ED_SID_DELETED_COUNT 

Mailbox.msg_deleted.

ED_SID_DESCRIPTION 

Mailbox.name.

ED_SID_FLAGGED 

Mailbox.msg_flagged.

ED_SID_FLAGGED_COUNT 

Mailbox.msg_flagged.

ED_SID_LIMITED_COUNT 

Mailbox.vcount.

ED_SID_MESSAGE_COUNT 

Mailbox.msg_count.

ED_SID_NAME 

SbEntry.box.

ED_SID_FUZZY_SCORE 

SbEntry.score.

ED_SID_NEW_MAIL 

Mailbox.has_new.

ED_SID_NOTIFY 

Mailbox.notify_user.

ED_SID_OLD_COUNT 

Mailbox.msg_unread, Mailbox.msg_new.

ED_SID_POLL 

Mailbox.poll_new_mail.

ED_SID_READ_COUNT 

Mailbox.msg_count, Mailbox.msg_unread.

ED_SID_TAGGED_COUNT 

Mailbox.msg_tagged.

ED_SID_UNREAD_COUNT 

Mailbox.msg_unread.

ED_SID_UNSEEN_COUNT 

Mailbox.msg_new.

Definition at line 58 of file private.h.

59{
76};
@ ED_SID_FLAGGED_COUNT
Mailbox.msg_flagged.
Definition private.h:63
@ ED_SID_FUZZY_SCORE
SbEntry.score.
Definition private.h:67
@ ED_SID_READ_COUNT
Mailbox.msg_count, Mailbox.msg_unread.
Definition private.h:72
@ ED_SID_DESCRIPTION
Mailbox.name.
Definition private.h:61
@ ED_SID_NEW_MAIL
Mailbox.has_new.
Definition private.h:68
@ ED_SID_UNSEEN_COUNT
Mailbox.msg_new.
Definition private.h:75
@ ED_SID_POLL
Mailbox.poll_new_mail.
Definition private.h:71
@ ED_SID_OLD_COUNT
Mailbox.msg_unread, Mailbox.msg_new.
Definition private.h:70
@ ED_SID_MESSAGE_COUNT
Mailbox.msg_count.
Definition private.h:65
@ ED_SID_LIMITED_COUNT
Mailbox.vcount.
Definition private.h:64
@ ED_SID_UNREAD_COUNT
Mailbox.msg_unread.
Definition private.h:74
@ ED_SID_TAGGED_COUNT
Mailbox.msg_tagged.
Definition private.h:73
@ ED_SID_NOTIFY
Mailbox.notify_user.
Definition private.h:69
@ ED_SID_NAME
SbEntry.box.
Definition private.h:66
@ ED_SID_DELETED_COUNT
Mailbox.msg_deleted.
Definition private.h:60
@ ED_SID_FLAGGED
Mailbox.msg_flagged.
Definition private.h:62

◆ DivType

enum DivType

Source of the sidebar divider character.

Enumerator
SB_DIV_USER 

User configured using $sidebar_divider_char.

SB_DIV_ASCII 

An ASCII vertical bar (pipe)

Definition at line 81 of file private.h.

82{
85};
@ SB_DIV_ASCII
An ASCII vertical bar (pipe)
Definition private.h:84
@ SB_DIV_USER
User configured using $sidebar_divider_char.
Definition private.h:83

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( SbEntryArray ,
struct SbEntry *  )

◆ sb_add_mailbox()

void sb_add_mailbox ( struct SidebarWindowData * wdata,
struct Mailbox * m )

Add a Mailbox to the Sidebar.

Parameters
wdataSidebar data
mMailbox to add

The Sidebar will be re-sorted, and the indices updated, when sb_recalc() is called.

Definition at line 100 of file sidebar.c.

101{
102 if (!m)
103 return;
104
105 struct SbEntry **sbep = NULL;
106 ARRAY_FOREACH(sbep, &wdata->entries)
107 {
108 if ((*sbep)->mailbox == m)
109 return;
110 }
111
112 /* Any new/deleted mailboxes will cause a refresh. As long as
113 * they're valid, our pointers will be updated in prepare_sidebar() */
114
115 struct IndexSharedData *shared = wdata->shared;
116 struct SbEntry *entry = MUTT_MEM_CALLOC(1, struct SbEntry);
117 entry->mailbox = m;
118 entry->score = -1;
119
120 if (wdata->top_index < 0)
121 wdata->top_index = ARRAY_SIZE(&wdata->entries);
122 if (wdata->bot_index < 0)
123 wdata->bot_index = ARRAY_SIZE(&wdata->entries);
124 if ((wdata->opn_index < 0) && shared->mailbox &&
126 {
127 wdata->opn_index = ARRAY_SIZE(&wdata->entries);
128 }
129
130 ARRAY_ADD(&wdata->entries, entry);
131}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:41
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition mailbox.h:80
Info about folders in the sidebar.
Definition private.h:42
int score
Fuzzy-match score.
Definition private.h:49
struct Mailbox * mailbox
Mailbox this represents.
Definition private.h:46
int top_index
First mailbox visible in sidebar.
Definition private.h:96
int bot_index
Last mailbox visible in sidebar.
Definition private.h:99
struct IndexSharedData * shared
Shared Index Data.
Definition private.h:93
int opn_index
Current (open) mailbox.
Definition private.h:97
struct SbEntryArray entries
Items to display in the sidebar.
Definition private.h:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_remove_mailbox()

void sb_remove_mailbox ( struct SidebarWindowData * wdata,
const struct Mailbox * m )

Remove a Mailbox from the Sidebar.

Parameters
wdataSidebar data
mMailbox to remove

Definition at line 138 of file sidebar.c.

139{
140 struct SbEntry **sbep = NULL;
141 ARRAY_FOREACH(sbep, &wdata->entries)
142 {
143 if ((*sbep)->mailbox != m)
144 continue;
145
146 struct SbEntry *sbe_remove = *sbep;
147 ARRAY_REMOVE(&wdata->entries, sbep);
148 FREE(&sbe_remove);
149
150 if (wdata->opn_index == ARRAY_FOREACH_IDX_sbep)
151 {
152 // Open item was deleted
153 wdata->opn_index = -1;
154 }
155 else if ((wdata->opn_index > 0) && (wdata->opn_index > ARRAY_FOREACH_IDX_sbep))
156 {
157 // Open item is still visible, so adjust the index
158 wdata->opn_index--;
159 }
160
161 if (wdata->hil_index == ARRAY_FOREACH_IDX_sbep)
162 {
163 // If possible, keep the highlight where it is
164 struct SbEntry **sbep_cur = ARRAY_GET(&wdata->entries, ARRAY_FOREACH_IDX_sbep);
165 if (!sbep_cur)
166 {
167 // The last entry was deleted, so backtrack
168 sb_prev(wdata);
169 }
170 else if ((*sbep_cur)->is_hidden)
171 {
172 // Find the next unhidden entry, or the previous
173 if (!sb_next(wdata) && !sb_prev(wdata))
174 wdata->hil_index = -1;
175 }
176 }
177 else if ((wdata->hil_index > 0) && (wdata->hil_index > ARRAY_FOREACH_IDX_sbep))
178 {
179 // Highlighted item is still visible, so adjust the index
180 wdata->hil_index--;
181 }
182 break;
183 }
184}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
bool sb_prev(struct SidebarWindowData *wdata)
Find the previous unhidden Mailbox.
Definition functions.c:155
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
Definition functions.c:116
int hil_index
Highlighted mailbox.
Definition private.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_set_current_mailbox()

void sb_set_current_mailbox ( struct SidebarWindowData * wdata,
struct Mailbox * m )

Set the current Mailbox.

Parameters
wdataSidebar data
mMailbox

Definition at line 191 of file sidebar.c.

192{
193 wdata->opn_index = -1;
194
195 struct SbEntry **sbep = NULL;
196 ARRAY_FOREACH(sbep, &wdata->entries)
197 {
198 if (m && m->visible)
199 {
200 if (mutt_str_equal((*sbep)->mailbox->realpath, m->realpath))
201 {
202 wdata->opn_index = ARRAY_FOREACH_IDX_sbep;
203 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
204 break;
205 }
206 }
207 (*sbep)->is_hidden = !(*sbep)->mailbox->visible;
208 }
209}
bool visible
True if a result of "mailboxes".
Definition mailbox.h:129
bool is_hidden
Don't show, e.g. $sidebar_new_mail_only.
Definition private.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_get_highlight()

struct Mailbox * sb_get_highlight ( struct MuttWindow * win)

Get the Mailbox that's highlighted in the sidebar.

Parameters
winSidebar Window
Return values
ptrMailbox

Definition at line 75 of file sidebar.c.

76{
77 const bool c_sidebar_visible = cs_subset_bool(NeoMutt->sub, "sidebar_visible");
78 if (!c_sidebar_visible)
79 return NULL;
80
82 if (!wdata || (wdata->hil_index < 0))
83 return NULL;
84
85 struct SbEntry **sbep = ARRAY_GET(&wdata->entries, wdata->hil_index);
86 if (!sbep)
87 return NULL;
88
89 return (*sbep)->mailbox;
90}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
struct SidebarWindowData * sb_wdata_get(struct MuttWindow *win)
Get the Sidebar data for this window.
Definition wdata.c:77
void * wdata
Private data.
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Sidebar private Window data -.
Definition private.h:91
struct MuttWindow * win
Sidebar Window.
Definition private.h:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_next()

bool sb_next ( struct SidebarWindowData * wdata)

Find the next unhidden Mailbox.

Parameters
wdataSidebar data
Return values
trueMailbox found

Definition at line 116 of file functions.c.

117{
118 struct SbEntry **sbep = NULL;
119 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->hil_index + 1)
120 {
121 if (!(*sbep)->is_hidden)
122 {
123 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
124 return true;
125 }
126 }
127
128 return false;
129}
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition array.h:235
+ Here is the caller graph for this function:

◆ sb_prev()

bool sb_prev ( struct SidebarWindowData * wdata)

Find the previous unhidden Mailbox.

Parameters
wdataSidebar data
Return values
trueMailbox found

Definition at line 155 of file functions.c.

156{
157 struct SbEntry **sbep = NULL, **prev = NULL;
158 ARRAY_FOREACH_TO(sbep, &wdata->entries, wdata->hil_index)
159 {
160 if (!(*sbep)->is_hidden)
161 prev = sbep;
162 }
163
164 if (prev)
165 {
166 wdata->hil_index = ARRAY_IDX(&wdata->entries, prev);
167 return true;
168 }
169
170 return false;
171}
#define ARRAY_IDX(head, elem)
Return the index of an element of the array.
Definition array.h:324
#define ARRAY_FOREACH_TO(elem, head, to)
Iterate from the beginning to an index.
Definition array.h:247
+ Here is the caller graph for this function:

◆ sb_win_add_observers()

void sb_win_add_observers ( struct MuttWindow * win)

Add Observers to the Sidebar Window.

Parameters
winSidebar Window

Definition at line 442 of file observer.c.

443{
444 if (!win || !NeoMutt)
445 return;
446
447 struct MuttWindow *dlg = window_find_parent(win, WT_DLG_INDEX);
448 if (!dlg)
449 return;
450
458}
void mutt_color_observer_add(observer_t callback, void *global_data)
Add an observer.
Definition notify.c:61
static int sb_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition observer.c:413
static int sb_mailbox_observer(struct NotifyCallback *nc)
Notification that a Mailbox has changed - Implements observer_t -.
Definition observer.c:384
static int sb_account_observer(struct NotifyCallback *nc)
Notification that an Account has changed - Implements observer_t -.
Definition observer.c:177
static int sb_command_observer(struct NotifyCallback *nc)
Notification that a Command has occurred - Implements observer_t -.
Definition observer.c:250
static int sb_color_observer(struct NotifyCallback *nc)
Notification that a Color has changed - Implements observer_t -.
Definition observer.c:204
static int sb_index_observer(struct NotifyCallback *nc)
Notification that the Index has changed - Implements observer_t -.
Definition observer.c:360
static int sb_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition observer.c:271
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
struct MuttWindow * window_find_parent(struct MuttWindow *win, enum WindowType type)
Find a (grand-)parent of a Window by type.
@ WT_DLG_INDEX
Index Dialog, dlg_index()
Definition mutt_window.h:86
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:49
@ NT_COMMAND
A Command has been executed, Command.
Definition notify_type.h:42
@ NT_ACCOUNT
Account has changed, NotifyAccount, EventAccount.
Definition notify_type.h:36
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition notify_type.h:48
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_sort_entries()

void sb_sort_entries ( struct SidebarWindowData * wdata,
enum EmailSortType sort )

Sort the Sidebar entries.

Parameters
wdataSidebar data
sortSort order, e.g. SB_SORT_PATH

Sort the wdata->entries array according to the current sort config option $sidebar_sort. This calls qsort to do the work which calls our callback function "cb_qsort_sbe".

Once sorted, the prev/next links will be reconstructed.

Definition at line 161 of file sort.c.

162{
163 sort_t fn = NULL;
164
165 switch (sort & SORT_MASK)
166 {
167 case SB_SORT_COUNT:
168 fn = sb_sort_count;
169 break;
170 case SB_SORT_DESC:
171 fn = sb_sort_desc;
172 break;
173 case SB_SORT_FLAGGED:
174 fn = sb_sort_flagged;
175 break;
176 case SB_SORT_PATH:
177 fn = sb_sort_path;
178 break;
179 case SB_SORT_UNREAD:
180 fn = sb_sort_unread;
181 break;
182 case SB_SORT_UNSORTED:
183 default:
184 fn = sb_sort_unsorted;
185 break;
186 }
187
188 bool sort_reverse = (sort & SORT_REVERSE);
189 ARRAY_SORT(&wdata->entries, fn, &sort_reverse);
190}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition array.h:373
#define SORT_MASK
Mask for the sort id.
Definition sort.h:39
#define SORT_REVERSE
Reverse the order of the sort.
Definition sort.h:40
static int sb_sort_desc(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by description - Implements sort_t -.
Definition sort.c:64
static int sb_sort_unread(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by unread - Implements sort_t -.
Definition sort.c:118
static int sb_sort_flagged(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by flagged - Implements sort_t -.
Definition sort.c:79
static int sb_sort_unsorted(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by order of creation - Implements sort_t -.
Definition sort.c:138
static int sb_sort_path(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by path - Implements sort_t -.
Definition sort.c:99
static int sb_sort_count(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by count - Implements sort_t -.
Definition sort.c:44
int(* sort_t)(const void *a, const void *b, void *sdata)
Definition qsort_r.h:41
@ SB_SORT_FLAGGED
Sort by count of flagged messages.
Definition sort.h:33
@ SB_SORT_COUNT
Sort by total message count.
Definition sort.h:31
@ SB_SORT_DESC
Sort by mailbox description.
Definition sort.h:32
@ SB_SORT_PATH
Sort by mailbox path (alphabetically)
Definition sort.h:34
@ SB_SORT_UNREAD
Sort by count of unread messages.
Definition sort.h:35
@ SB_SORT_UNSORTED
Sort into the order the mailboxes were configured.
Definition sort.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_wdata_get()

struct SidebarWindowData * sb_wdata_get ( struct MuttWindow * win)

Get the Sidebar data for this window.

Parameters
winWindow

Definition at line 77 of file wdata.c.

78{
79 if (!win || (win->type != WT_SIDEBAR))
80 return NULL;
81
82 return win->wdata;
83}
@ WT_SIDEBAR
Side panel containing Accounts or groups of data.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
+ Here is the caller graph for this function:

◆ sb_wdata_new()

struct SidebarWindowData * sb_wdata_new ( struct MuttWindow * win,
struct IndexSharedData * shared )

Create new Window data for the Sidebar.

Parameters
winSidebar Window
sharedIndex shared data
Return values
ptrNew Window data

Definition at line 44 of file wdata.c.

45{
47 wdata->win = win;
48 wdata->shared = shared;
49 ARRAY_INIT(&wdata->entries);
50 return wdata;
51}
#define ARRAY_INIT(head)
Initialize an array.
Definition array.h:65
+ Here is the caller graph for this function:

◆ sb_entry_set_display_name()

void sb_entry_set_display_name ( struct SbEntry * entry)

Set the display name for an SbEntry.

Parameters
entrySbEntry to update

Definition at line 305 of file window.c.

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}
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
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:213
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:586
static const char * abbrev_url(const char *mbox, enum MailboxType type)
Abbreviate a url-style Mailbox path.
Definition window.c:192
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
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
enum MailboxType type
Mailbox type.
Definition mailbox.h:101
int depth
Indentation depth.
Definition private.h:45
char box[256]
Mailbox path (possibly abbreviated)
Definition private.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ SidebarPinned

struct ListHead SidebarPinned
extern

List of mailboxes to always display in the sidebar.

Definition at line 44 of file sidebar.c.