NeoMutt  2025-12-11-911-gd8d604
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() -.
 

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 56 of file private.h.

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

◆ 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 79 of file private.h.

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

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 99 of file sidebar.c.

100{
101 if (!m)
102 return;
103
104 struct SbEntry **sbep = NULL;
105 ARRAY_FOREACH(sbep, &wdata->entries)
106 {
107 if ((*sbep)->mailbox == m)
108 return;
109 }
110
111 /* Any new/deleted mailboxes will cause a refresh. As long as
112 * they're valid, our pointers will be updated in prepare_sidebar() */
113
114 struct IndexSharedData *shared = wdata->shared;
115 struct SbEntry *entry = MUTT_MEM_CALLOC(1, struct SbEntry);
116 entry->mailbox = m;
117 entry->score = -1;
118
119 if (wdata->top_index < 0)
120 wdata->top_index = ARRAY_SIZE(&wdata->entries);
121 if (wdata->bot_index < 0)
122 wdata->bot_index = ARRAY_SIZE(&wdata->entries);
123 if ((wdata->opn_index < 0) && shared->mailbox &&
125 {
126 wdata->opn_index = ARRAY_SIZE(&wdata->entries);
127 }
128
129 ARRAY_ADD(&wdata->entries, entry);
130}
#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:83
Info about folders in the sidebar.
Definition private.h:40
int score
Fuzzy-match score.
Definition private.h:47
struct Mailbox * mailbox
Mailbox this represents.
Definition private.h:44
int top_index
First mailbox visible in sidebar.
Definition private.h:94
int bot_index
Last mailbox visible in sidebar.
Definition private.h:97
struct IndexSharedData * shared
Shared Index Data.
Definition private.h:91
int opn_index
Current (open) mailbox.
Definition private.h:95
struct SbEntryArray entries
Items to display in the sidebar.
Definition private.h:92
+ 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 137 of file sidebar.c.

138{
139 struct SbEntry **sbep = NULL;
140 ARRAY_FOREACH(sbep, &wdata->entries)
141 {
142 if ((*sbep)->mailbox != m)
143 continue;
144
145 struct SbEntry *sbe_remove = *sbep;
146 ARRAY_REMOVE(&wdata->entries, sbep);
147 FREE(&sbe_remove);
148
149 if (wdata->opn_index == ARRAY_FOREACH_IDX_sbep)
150 {
151 // Open item was deleted
152 wdata->opn_index = -1;
153 }
154 else if ((wdata->opn_index > 0) && (wdata->opn_index > ARRAY_FOREACH_IDX_sbep))
155 {
156 // Open item is still visible, so adjust the index
157 wdata->opn_index--;
158 }
159
160 if (wdata->hil_index == ARRAY_FOREACH_IDX_sbep)
161 {
162 // If possible, keep the highlight where it is
163 struct SbEntry **sbep_cur = ARRAY_GET(&wdata->entries, ARRAY_FOREACH_IDX_sbep);
164 if (!sbep_cur)
165 {
166 // The last entry was deleted, so backtrack
167 sb_prev(wdata);
168 }
169 else if ((*sbep_cur)->is_hidden)
170 {
171 // Find the next unhidden entry, or the previous
172 if (!sb_next(wdata) && !sb_prev(wdata))
173 wdata->hil_index = -1;
174 }
175 }
176 else if ((wdata->hil_index > 0) && (wdata->hil_index > ARRAY_FOREACH_IDX_sbep))
177 {
178 // Highlighted item is still visible, so adjust the index
179 wdata->hil_index--;
180 }
181 break;
182 }
183}
#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:194
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
Definition functions.c:119
int hil_index
Highlighted mailbox.
Definition private.h:96
+ 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 190 of file sidebar.c.

191{
192 wdata->opn_index = -1;
193
194 struct SbEntry **sbep = NULL;
195 ARRAY_FOREACH(sbep, &wdata->entries)
196 {
197 if (m && m->visible)
198 {
199 if (mutt_str_equal((*sbep)->mailbox->realpath, m->realpath))
200 {
201 wdata->opn_index = ARRAY_FOREACH_IDX_sbep;
202 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
203 break;
204 }
205 }
206 (*sbep)->is_hidden = !(*sbep)->mailbox->visible;
207 }
208}
bool visible
True if a result of "mailboxes".
Definition mailbox.h:132
bool is_hidden
Don't show, e.g. $sidebar_new_mail_only.
Definition private.h:45
+ 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 74 of file sidebar.c.

75{
76 const bool c_sidebar_visible = cs_subset_bool(NeoMutt->sub, "sidebar_visible");
77 if (!c_sidebar_visible)
78 return NULL;
79
81 if (!wdata || (wdata->hil_index < 0))
82 return NULL;
83
84 struct SbEntry **sbep = ARRAY_GET(&wdata->entries, wdata->hil_index);
85 if (!sbep)
86 return NULL;
87
88 return (*sbep)->mailbox;
89}
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:89
struct MuttWindow * win
Sidebar Window.
Definition private.h:90
+ 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 119 of file functions.c.

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}
#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 194 of file functions.c.

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}
#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:62
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:58
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:50
@ 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 306 of file window.c.

307{
308 const char *path = mailbox_path(entry->mailbox);
309
310 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
311 // Try to abbreviate the full path
312 const char *abbr = abbrev_folder(path, c_folder, entry->mailbox->type);
313 if (!abbr)
314 abbr = abbrev_url(path, entry->mailbox->type);
315 const char *short_path = abbr ? abbr : path;
316
317 /* Compute the depth */
318 const char *last_part = abbr;
319 const char *const c_sidebar_delim_chars = cs_subset_string(NeoMutt->sub, "sidebar_delim_chars");
320 entry->depth = calc_path_depth(abbr, c_sidebar_delim_chars, &last_part);
321
322 const bool short_path_is_abbr = (short_path == abbr);
323 const bool c_sidebar_short_path = cs_subset_bool(NeoMutt->sub, "sidebar_short_path");
324 if (c_sidebar_short_path)
325 {
326 short_path = last_part;
327 }
328
329 // Don't indent if we were unable to create an abbreviation.
330 // Otherwise, the full path will be indent, and it looks unusual.
331 const bool c_sidebar_folder_indent = cs_subset_bool(NeoMutt->sub, "sidebar_folder_indent");
332 if (c_sidebar_folder_indent && short_path_is_abbr)
333 {
334 const short c_sidebar_component_depth = cs_subset_number(NeoMutt->sub, "sidebar_component_depth");
335 if (c_sidebar_component_depth > 0)
336 entry->depth -= c_sidebar_component_depth;
337 }
338 else if (!c_sidebar_folder_indent)
339 {
340 entry->depth = 0;
341 }
342
343 mutt_str_copy(entry->box, short_path, sizeof(entry->box));
344}
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:216
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:193
static const char * abbrev_folder(const char *mbox, const char *folder, enum MailboxType type)
Abbreviate a Mailbox path using a folder.
Definition window.c:129
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:285
enum MailboxType type
Mailbox type.
Definition mailbox.h:104
int depth
Indentation depth.
Definition private.h:43
char box[256]
Mailbox path (possibly abbreviated)
Definition private.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function: