NeoMutt  2018-07-16 +952-a2da0a
Teaching an old dog new tricks
DOXYGEN
sidebar.c File Reference

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

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "sidebar.h"
#include "context.h"
#include "curs_lib.h"
#include "format_flags.h"
#include "globals.h"
#include "mailbox.h"
#include "menu.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "muttlib.h"
#include "mx.h"
#include "opcodes.h"
#include "sort.h"
+ Include dependency graph for sidebar.c:

Go to the source code of this file.

Data Structures

struct  SbEntry
 Info about folders in the sidebar. More...
 

Enumerations

enum  DivType { SB_DIV_USER, SB_DIV_ASCII, SB_DIV_UTF8 }
 Source of the sidebar divider character. More...
 

Functions

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, unsigned long data, enum FormatFlag flags)
 Format a string for the sidebar - Implements format_t. More...
 
static void make_sidebar_entry (char *buf, size_t buflen, int width, char *box, struct SbEntry *sbe)
 Turn mailbox data into a sidebar string. More...
 
static int cb_qsort_sbe (const void *a, const void *b)
 qsort callback to sort SbEntry's More...
 
static void update_entries_visibility (void)
 Should a sidebar_entry be displayed in the sidebar. More...
 
static void unsort_entries (void)
 Restore Entries array order to match Mailbox list order. More...
 
static void sort_entries (void)
 Sort Entries array. More...
 
static bool select_next (void)
 Selects the next unhidden mailbox. More...
 
static int select_next_new (void)
 Selects the next new mailbox. More...
 
static bool select_prev (void)
 Selects the previous unhidden mailbox. More...
 
static bool select_prev_new (void)
 Selects the previous new mailbox. More...
 
static int select_page_down (void)
 Selects the first entry in the next page of mailboxes. More...
 
static int select_page_up (void)
 Selects the last entry in the previous page of mailboxes. More...
 
static bool prepare_sidebar (int page_size)
 Prepare the list of SbEntry's for the sidebar display. More...
 
static int draw_divider (int num_rows, int num_cols)
 Draw a line between the sidebar and the rest of neomutt. More...
 
static void fill_empty_space (int first_row, int num_rows, int div_width, int num_cols)
 Wipe the remaining Sidebar space. More...
 
static void draw_sidebar (int num_rows, int num_cols, int div_width)
 Write out a list of mailboxes, in a panel. More...
 
void mutt_sb_draw (void)
 Completely redraw the sidebar. More...
 
void mutt_sb_change_mailbox (int op)
 Change the selected mailbox. More...
 
struct Mailboxmutt_sb_get_highlight (void)
 Get the Mailbox that's highlighted in the sidebar. More...
 
void mutt_sb_set_open_mailbox (void)
 Set the OpnMailbox based on the global Context. More...
 
void mutt_sb_notify_mailbox (struct Mailbox *m, bool created)
 The state of a Mailbox is about to change. More...
 

Variables

short SidebarComponentDepth
 Config: (sidebar) Strip leading path components from sidebar folders. More...
 
char * SidebarDelimChars
 Config: (sidebar) Characters that separate nested folders. More...
 
char * SidebarDividerChar
 Config: (sidebar) Character to draw between the sidebar and index. More...
 
bool SidebarFolderIndent
 Config: (sidebar) Indent nested folders. More...
 
char * SidebarFormat
 Config: (sidebar) printf-like format string for the sidebar panel. More...
 
char * SidebarIndentString
 Config: (sidebar) Indent nested folders using this string. More...
 
bool SidebarNewMailOnly
 Config: (sidebar) Only show folders with new/flagged mail. More...
 
bool SidebarNextNewWrap
 Config: (sidebar) Wrap around when searching for the next mailbox with new mail. More...
 
bool SidebarShortPath
 Config: (sidebar) Abbreviate the paths using the Folder variable. More...
 
short SidebarSortMethod
 Config: (sidebar) Method to sort the sidebar. More...
 
static short PreviousSort = SORT_ORDER
 
static int EntryCount = 0
 
static int EntryLen = 0
 
static struct SbEntry ** Entries = NULL
 
static int TopIndex = -1
 First mailbox visible in sidebar. More...
 
static int OpnIndex = -1
 Current (open) mailbox. More...
 
static int HilIndex = -1
 Highlighted mailbox. More...
 
static int BotIndex = -1
 Last mailbox visible in sidebar. More...
 

Detailed Description

GUI display the mailboxes in a side panel.

Authors
  • Justin Hibbits
  • Thomer M. Gil
  • Richard Russon
  • Kevin J. McCarthy

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 sidebar.c.

Enumeration Type Documentation

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)

SB_DIV_UTF8 

A unicode line-drawing character.

Definition at line 90 of file sidebar.c.

91 {
92  SB_DIV_USER,
93  SB_DIV_ASCII,
94  SB_DIV_UTF8,
95 };

Function Documentation

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,
unsigned long  data,
enum FormatFlag  flags 
)
static

Format a string for the sidebar - Implements format_t.

Expando Description
%B Name of the mailbox
%d Number of deleted messages
%D Description of the mailbox
%F Number of Flagged messages in the mailbox
%L Number of messages after limiting
%n N if mailbox has new mail, blank otherwise
%N Number of unread messages in the mailbox
%S Size of mailbox (total number of messages)
%t Number of tagged messages
%! 'n!' Flagged messages

Definition at line 113 of file sidebar.c.

117 {
118  struct SbEntry *sbe = (struct SbEntry *) data;
119  unsigned int optional;
120  char fmt[STRING];
121 
122  if (!sbe || !buf)
123  return src;
124 
125  buf[0] = 0; /* Just in case there's nothing to do */
126 
127  struct Mailbox *m = sbe->mailbox;
128  if (!m)
129  return src;
130 
131  int c = Context && (mutt_str_strcmp(Context->mailbox->realpath, m->realpath) == 0);
132 
133  optional = flags & MUTT_FORMAT_OPTIONAL;
134 
135  switch (op)
136  {
137  case 'B':
138  mutt_format_s(buf, buflen, prec, sbe->box);
139  break;
140 
141  case 'd':
142  if (!optional)
143  {
144  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
145  snprintf(buf, buflen, fmt, c ? Context->mailbox->msg_deleted : 0);
146  }
147  else if ((c && Context->mailbox->msg_deleted == 0) || !c)
148  optional = 0;
149  break;
150 
151  case 'D':
152  if (sbe->mailbox->desc)
153  mutt_format_s(buf, buflen, prec, sbe->mailbox->desc);
154  else
155  mutt_format_s(buf, buflen, prec, sbe->box);
156  break;
157 
158  case 'F':
159  if (!optional)
160  {
161  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
162  snprintf(buf, buflen, fmt, m->msg_flagged);
163  }
164  else if (m->msg_flagged == 0)
165  optional = 0;
166  break;
167 
168  case 'L':
169  if (!optional)
170  {
171  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
172  snprintf(buf, buflen, fmt, c ? Context->mailbox->vcount : m->msg_count);
173  }
174  else if ((c && Context->mailbox->vcount == m->msg_count) || !c)
175  optional = 0;
176  break;
177 
178  case 'N':
179  if (!optional)
180  {
181  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
182  snprintf(buf, buflen, fmt, m->msg_unread);
183  }
184  else if (m->msg_unread == 0)
185  optional = 0;
186  break;
187 
188  case 'n':
189  if (!optional)
190  {
191  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
192  snprintf(buf, buflen, fmt, m->has_new ? 'N' : ' ');
193  }
194  else if (m->has_new == false)
195  optional = 0;
196  break;
197 
198  case 'S':
199  if (!optional)
200  {
201  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
202  snprintf(buf, buflen, fmt, m->msg_count);
203  }
204  else if (m->msg_count == 0)
205  optional = 0;
206  break;
207 
208  case 't':
209  if (!optional)
210  {
211  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
212  snprintf(buf, buflen, fmt, c ? Context->mailbox->msg_tagged : 0);
213  }
214  else if ((c && Context->mailbox->msg_tagged == 0) || !c)
215  optional = 0;
216  break;
217 
218  case '!':
219  if (m->msg_flagged == 0)
220  mutt_format_s(buf, buflen, prec, "");
221  else if (m->msg_flagged == 1)
222  mutt_format_s(buf, buflen, prec, "!");
223  else if (m->msg_flagged == 2)
224  mutt_format_s(buf, buflen, prec, "!!");
225  else
226  {
227  snprintf(fmt, sizeof(fmt), "%d!", m->msg_flagged);
228  mutt_format_s(buf, buflen, prec, fmt);
229  }
230  break;
231  }
232 
233  if (optional)
234  {
235  mutt_expando_format(buf, buflen, col, SidebarWidth, if_str,
236  sidebar_format_str, (unsigned long) sbe, flags);
237  }
238  else if (flags & MUTT_FORMAT_OPTIONAL)
239  {
240  mutt_expando_format(buf, buflen, col, SidebarWidth, else_str,
241  sidebar_format_str, (unsigned long) sbe, flags);
242  }
243 
244  /* We return the format string, unchanged */
245  return src;
246 }
The "current" mailbox.
Definition: context.h:36
int msg_count
total number of messages
Definition: mailbox.h:86
int msg_deleted
number of deleted messages
Definition: mailbox.h:90
int msg_unread
number of unread messages
Definition: mailbox.h:87
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
char * desc
Definition: mailbox.h:81
Info about folders in the sidebar.
Definition: sidebar.c:71
int vcount
the number of virtual messages
Definition: mailbox.h:96
bool has_new
mailbox has new mail
Definition: mailbox.h:83
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74
struct Mailbox * mailbox
Definition: context.h:50
allow optional field processing
Definition: format_flags.h:36
int flags
e.g.
Definition: mailbox.h:128
WHERE short SidebarWidth
Config: (sidebar) Width of the sidebar.
Definition: globals.h:160
A mailbox.
Definition: mailbox.h:76
int msg_tagged
how many messages are tagged?
Definition: mailbox.h:91
#define STRING
Definition: string2.h:35
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
Definition: curs_lib.c:1061
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
char box[STRING]
formatted mailbox name
Definition: sidebar.c:73
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, enum FormatFlag flags)
Expand expandos (x) in a string.
Definition: muttlib.c:816

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void make_sidebar_entry ( char *  buf,
size_t  buflen,
int  width,
char *  box,
struct SbEntry sbe 
)
static

Turn mailbox data into a sidebar string.

Parameters
[out]bufBuffer in which to save string
[in]buflenBuffer length
[in]widthDesired width in screen cells
[in]boxMailbox name
[in]sbeMailbox object

Take all the relevant mailbox data and the desired screen width and then get mutt_expando_format to do the actual work. mutt_expando_format will callback to us using sidebar_format_str() for the sidebar specific formatting characters.

Definition at line 260 of file sidebar.c.

262 {
263  if (!buf || !box || !sbe)
264  return;
265 
266  mutt_str_strfcpy(sbe->box, box, sizeof(sbe->box));
267 
268  mutt_expando_format(buf, buflen, 0, width, NONULL(SidebarFormat),
269  sidebar_format_str, (unsigned long) sbe, 0);
270 
271  /* Force string to be exactly the right width */
272  int w = mutt_strwidth(buf);
273  int s = mutt_str_strlen(buf);
274  width = MIN(buflen, width);
275  if (w < width)
276  {
277  /* Pad with spaces */
278  memset(buf + s, ' ', width - w);
279  buf[s + width - w] = 0;
280  }
281  else if (w > width)
282  {
283  /* Truncate to fit */
284  size_t len = mutt_wstr_trunc(buf, buflen, width, NULL);
285  buf[len] = 0;
286  }
287 }
#define NONULL(x)
Definition: string2.h:39
#define MIN(a, b)
Definition: memory.h:31
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:663
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1176
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:1126
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
char box[STRING]
formatted mailbox name
Definition: sidebar.c:73
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, enum FormatFlag flags)
Expand expandos (x) in a string.
Definition: muttlib.c:816

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int cb_qsort_sbe ( const void *  a,
const void *  b 
)
static

qsort callback to sort SbEntry's

Parameters
aFirst SbEntry to compare
bSecond SbEntry to compare
Return values
-1a precedes b
0a and b are identical
1b precedes a

Definition at line 297 of file sidebar.c.

298 {
299  const struct SbEntry *sbe1 = *(const struct SbEntry **) a;
300  const struct SbEntry *sbe2 = *(const struct SbEntry **) b;
301  struct Mailbox *m1 = sbe1->mailbox;
302  struct Mailbox *m2 = sbe2->mailbox;
303 
304  int result = 0;
305 
306  switch ((SidebarSortMethod & SORT_MASK))
307  {
308  case SORT_COUNT:
309  if (m2->msg_count == m1->msg_count)
310  result = mutt_str_strcoll(m1->path, m2->path);
311  else
312  result = (m2->msg_count - m1->msg_count);
313  break;
314  case SORT_UNREAD:
315  if (m2->msg_unread == m1->msg_unread)
316  result = mutt_str_strcoll(m1->path, m2->path);
317  else
318  result = (m2->msg_unread - m1->msg_unread);
319  break;
320  case SORT_DESC:
321  result = mutt_str_strcmp(m1->desc, m2->desc);
322  break;
323  case SORT_FLAGGED:
324  if (m2->msg_flagged == m1->msg_flagged)
325  result = mutt_str_strcoll(m1->path, m2->path);
326  else
327  result = (m2->msg_flagged - m1->msg_flagged);
328  break;
329  case SORT_PATH:
330  {
331  result = mutt_inbox_cmp(m1->path, m2->path);
332  if (result == 0)
333  result = mutt_str_strcoll(m1->path, m2->path);
334  break;
335  }
336  }
337 
339  result = -result;
340 
341  return result;
342 }
#define SORT_COUNT
Sort by number of emails in a folder.
Definition: sort.h:60
int msg_count
total number of messages
Definition: mailbox.h:86
int msg_unread
number of unread messages
Definition: mailbox.h:87
#define SORT_UNREAD
Sort by the number of unread emails.
Definition: sort.h:61
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
char * desc
Definition: mailbox.h:81
Info about folders in the sidebar.
Definition: sidebar.c:71
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74
#define SORT_DESC
Sort by the folder&#39;s description.
Definition: sort.h:65
A mailbox.
Definition: mailbox.h:76
int mutt_inbox_cmp(const char *a, const char *b)
do two folders share the same path and one is an inbox
Definition: muttlib.c:1628
#define SORT_PATH
Sort by the folder&#39;s path.
Definition: sort.h:63
char path[PATH_MAX]
Definition: mailbox.h:78
#define SORT_FLAGGED
Sort by the number of flagged emails.
Definition: sort.h:62
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort.h:78
int mutt_str_strcoll(const char *a, const char *b)
Collate two strings (compare using locale), safely.
Definition: string.c:676
#define SORT_MASK
Mask for the sort id.
Definition: sort.h:77
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void update_entries_visibility ( void  )
static

Should a sidebar_entry be displayed in the sidebar.

For each SbEntry in the Entries array, check whether we should display it. This is determined by several criteria. If the Mailbox:

  • is the currently open mailbox
  • is the currently highlighted mailbox
  • has unread messages
  • has flagged messages
  • is whitelisted

Definition at line 355 of file sidebar.c.

356 {
357  short new_only = SidebarNewMailOnly;
358  struct SbEntry *sbe = NULL;
359  for (int i = 0; i < EntryCount; i++)
360  {
361  sbe = Entries[i];
362 
363  sbe->is_hidden = false;
364 
365  if (!new_only)
366  continue;
367 
368  if ((i == OpnIndex) || (sbe->mailbox->msg_unread > 0) ||
369  sbe->mailbox->has_new || (sbe->mailbox->msg_flagged > 0))
370  {
371  continue;
372  }
373 
375  {
376  /* Spool directory */
377  continue;
378  }
379 
380  if (mutt_list_find(&SidebarWhitelist, sbe->mailbox->path) ||
381  mutt_list_find(&SidebarWhitelist, sbe->mailbox->desc))
382  {
383  /* Explicitly asked to be visible */
384  continue;
385  }
386 
387  sbe->is_hidden = true;
388  }
389 }
The "current" mailbox.
Definition: context.h:36
int msg_unread
number of unread messages
Definition: mailbox.h:87
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
char * desc
Definition: mailbox.h:81
Info about folders in the sidebar.
Definition: sidebar.c:71
bool is_hidden
Don&#39;t show, e.g.
Definition: sidebar.c:75
bool has_new
mailbox has new mail
Definition: mailbox.h:83
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74
struct Mailbox * mailbox
Definition: context.h:50
struct ListNode * mutt_list_find(const struct ListHead *h, const char *data)
Find a string in a List.
Definition: list.c:88
char path[PATH_MAX]
Definition: mailbox.h:78
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unsort_entries ( void  )
static

Restore Entries array order to match Mailbox list order.

Definition at line 394 of file sidebar.c.

395 {
396  int i = 0;
397 
398  struct MailboxNode *np = NULL;
399  STAILQ_FOREACH(np, &AllMailboxes, entries)
400  {
401  if (i >= EntryCount)
402  break;
403 
404  int j = i;
405  while ((j < EntryCount) && (Entries[j]->mailbox != np->m))
406  j++;
407  if (j < EntryCount)
408  {
409  if (j != i)
410  {
411  struct SbEntry *tmp = Entries[i];
412  Entries[i] = Entries[j];
413  Entries[j] = tmp;
414  }
415  i++;
416  }
417  }
418 }
Info about folders in the sidebar.
Definition: sidebar.c:71
struct Mailbox * m
Definition: mailbox.h:139
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
struct MailboxList AllMailboxes
List of all Mailboxes.
Definition: mailbox.c:85
List of Mailboxes.
Definition: mailbox.h:137

+ Here is the caller graph for this function:

static void sort_entries ( void  )
static

Sort Entries array.

Sort the Entries array according to the current sort config option "sidebar_sort_method". 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 429 of file sidebar.c.

430 {
431  short ssm = (SidebarSortMethod & SORT_MASK);
432 
433  /* These are the only sort methods we understand */
434  if ((ssm == SORT_COUNT) || (ssm == SORT_UNREAD) || (ssm == SORT_FLAGGED) || (ssm == SORT_PATH))
435  qsort(Entries, EntryCount, sizeof(*Entries), cb_qsort_sbe);
436  else if ((ssm == SORT_ORDER) && (SidebarSortMethod != PreviousSort))
437  unsort_entries();
438 }
#define SORT_COUNT
Sort by number of emails in a folder.
Definition: sort.h:60
#define SORT_UNREAD
Sort by the number of unread emails.
Definition: sort.h:61
#define SORT_PATH
Sort by the folder&#39;s path.
Definition: sort.h:63
#define SORT_FLAGGED
Sort by the number of flagged emails.
Definition: sort.h:62
#define SORT_MASK
Mask for the sort id.
Definition: sort.h:77
#define SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool select_next ( void  )
static

Selects the next unhidden mailbox.

Return values
trueSuccess
falseFailure

Definition at line 445 of file sidebar.c.

446 {
447  int entry = HilIndex;
448 
449  if (!EntryCount || HilIndex < 0)
450  return false;
451 
452  do
453  {
454  entry++;
455  if (entry == EntryCount)
456  return false;
457  } while (Entries[entry]->is_hidden);
458 
459  HilIndex = entry;
460  return true;
461 }
bool is_hidden
Don&#39;t show, e.g.
Definition: sidebar.c:75

+ Here is the caller graph for this function:

static int select_next_new ( void  )
static

Selects the next new mailbox.

Return values
trueSuccess
falseFailure

Search down the list of mail folders for one containing new mail.

Definition at line 470 of file sidebar.c.

471 {
472  int entry = HilIndex;
473 
474  if (!EntryCount || HilIndex < 0)
475  return false;
476 
477  do
478  {
479  entry++;
480  if (entry == EntryCount)
481  {
482  if (SidebarNextNewWrap)
483  entry = 0;
484  else
485  return false;
486  }
487  if (entry == HilIndex)
488  return false;
489  } while (!Entries[entry]->mailbox->has_new && !Entries[entry]->mailbox->msg_unread);
490 
491  HilIndex = entry;
492  return true;
493 }
int msg_unread
number of unread messages
Definition: mailbox.h:87
bool has_new
mailbox has new mail
Definition: mailbox.h:83
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74

+ Here is the caller graph for this function:

static bool select_prev ( void  )
static

Selects the previous unhidden mailbox.

Return values
trueSuccess
falseFailure

Definition at line 500 of file sidebar.c.

501 {
502  int entry = HilIndex;
503 
504  if (!EntryCount || HilIndex < 0)
505  return false;
506 
507  do
508  {
509  entry--;
510  if (entry < 0)
511  return false;
512  } while (Entries[entry]->is_hidden);
513 
514  HilIndex = entry;
515  return true;
516 }
bool is_hidden
Don&#39;t show, e.g.
Definition: sidebar.c:75

+ Here is the caller graph for this function:

static bool select_prev_new ( void  )
static

Selects the previous new mailbox.

Return values
trueSuccess
falseFailure

Search up the list of mail folders for one containing new mail.

Definition at line 525 of file sidebar.c.

526 {
527  int entry = HilIndex;
528 
529  if (!EntryCount || HilIndex < 0)
530  return false;
531 
532  do
533  {
534  entry--;
535  if (entry < 0)
536  {
537  if (SidebarNextNewWrap)
538  entry = EntryCount - 1;
539  else
540  return false;
541  }
542  if (entry == HilIndex)
543  return false;
544  } while (!Entries[entry]->mailbox->has_new && !Entries[entry]->mailbox->msg_unread);
545 
546  HilIndex = entry;
547  return true;
548 }
int msg_unread
number of unread messages
Definition: mailbox.h:87
bool has_new
mailbox has new mail
Definition: mailbox.h:83
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74

+ Here is the caller graph for this function:

static int select_page_down ( void  )
static

Selects the first entry in the next page of mailboxes.

Return values
trueSuccess
falseFailure

Definition at line 555 of file sidebar.c.

556 {
557  int orig_hil_index = HilIndex;
558 
559  if (!EntryCount || BotIndex < 0)
560  return 0;
561 
562  HilIndex = BotIndex;
563  select_next();
564  /* If the rest of the entries are hidden, go up to the last unhidden one */
565  if (Entries[HilIndex]->is_hidden)
566  select_prev();
567 
568  return orig_hil_index != HilIndex;
569 }
bool is_hidden
Don&#39;t show, e.g.
Definition: sidebar.c:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int select_page_up ( void  )
static

Selects the last entry in the previous page of mailboxes.

Return values
trueSuccess
falseFailure

Definition at line 576 of file sidebar.c.

577 {
578  int orig_hil_index = HilIndex;
579 
580  if (!EntryCount || TopIndex < 0)
581  return 0;
582 
583  HilIndex = TopIndex;
584  select_prev();
585  /* If the rest of the entries are hidden, go down to the last unhidden one */
586  if (Entries[HilIndex]->is_hidden)
587  select_next();
588 
589  return orig_hil_index != HilIndex;
590 }
bool is_hidden
Don&#39;t show, e.g.
Definition: sidebar.c:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool prepare_sidebar ( int  page_size)
static

Prepare the list of SbEntry's for the sidebar display.

Parameters
page_sizeThe number of lines on a page
Return values
falseNo, don't draw the sidebar
trueYes, draw the sidebar

Before painting the sidebar, we determine which are visible, sort them and set up our page pointers.

This is a lot of work to do each refresh, but there are many things that can change outside of the sidebar that we don't hear about.

Definition at line 604 of file sidebar.c.

605 {
606  if (!EntryCount || (page_size <= 0))
607  return false;
608 
609  const struct SbEntry *opn_entry = (OpnIndex >= 0) ? Entries[OpnIndex] : NULL;
610  const struct SbEntry *hil_entry = (HilIndex >= 0) ? Entries[HilIndex] : NULL;
611 
613  sort_entries();
614 
615  for (int i = 0; i < EntryCount; i++)
616  {
617  if (opn_entry == Entries[i])
618  OpnIndex = i;
619  if (hil_entry == Entries[i])
620  HilIndex = i;
621  }
622 
624  {
625  if (OpnIndex >= 0)
626  HilIndex = OpnIndex;
627  else
628  {
629  HilIndex = 0;
630  if (Entries[HilIndex]->is_hidden)
631  select_next();
632  }
633  }
634 
635  /* Set the Top and Bottom to frame the HilIndex in groups of page_size */
636 
637  /* If SidebarNewMailOnly is set, some entries may be hidden so we
638  * need to scan for the framing interval */
639  if (SidebarNewMailOnly)
640  {
641  TopIndex = -1;
642  BotIndex = -1;
643  while (BotIndex < HilIndex)
644  {
645  TopIndex = BotIndex + 1;
646  int page_entries = 0;
647  while (page_entries < page_size)
648  {
649  BotIndex++;
650  if (BotIndex >= EntryCount)
651  break;
652  if (!Entries[BotIndex]->is_hidden)
653  page_entries++;
654  }
655  }
656  }
657  /* Otherwise we can just calculate the interval */
658  else
659  {
660  TopIndex = (HilIndex / page_size) * page_size;
661  BotIndex = TopIndex + page_size - 1;
662  }
663 
664  if (BotIndex > (EntryCount - 1))
665  BotIndex = EntryCount - 1;
666 
668  return true;
669 }
Info about folders in the sidebar.
Definition: sidebar.c:71
bool is_hidden
Don&#39;t show, e.g.
Definition: sidebar.c:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int draw_divider ( int  num_rows,
int  num_cols 
)
static

Draw a line between the sidebar and the rest of neomutt.

Parameters
num_rowsHeight of the Sidebar
num_colsWidth of the Sidebar
Return values
0Empty string
numCharacter occupies n screen columns

Draw a divider using characters from the config option "sidebar_divider_char". This can be an ASCII or Unicode character. We calculate these characters' width in screen columns.

If the user hasn't set $sidebar_divider_char we pick a character for them, respecting the value of $ascii_chars.

Definition at line 685 of file sidebar.c.

686 {
687  if ((num_rows < 1) || (num_cols < 1))
688  return 0;
689 
690  int delim_len;
691  enum DivType altchar = SB_DIV_UTF8;
692 
693  /* Calculate the width of the delimiter in screen cells */
694  delim_len = mutt_strwidth(SidebarDividerChar);
695  if (delim_len < 0)
696  {
697  delim_len = 1; /* Bad character */
698  }
699  else if (delim_len == 0)
700  {
701  if (SidebarDividerChar)
702  return 0; /* User has set empty string */
703 
704  delim_len = 1; /* Unset variable */
705  }
706  else
707  {
708  altchar = SB_DIV_USER; /* User config */
709  }
710 
711  if (AsciiChars && (altchar != SB_DIV_ASCII))
712  {
713  /* $ascii_chars overrides Unicode divider chars */
714  if (altchar == SB_DIV_UTF8)
715  {
716  altchar = SB_DIV_ASCII;
717  }
718  else if (SidebarDividerChar)
719  {
720  for (int i = 0; i < delim_len; i++)
721  {
722  if (SidebarDividerChar[i] & ~0x7F) /* high-bit is set */
723  {
724  altchar = SB_DIV_ASCII;
725  delim_len = 1;
726  break;
727  }
728  }
729  }
730  }
731 
732  if (delim_len > num_cols)
733  return 0;
734 
736 
737  int col = SidebarOnRight ? 0 : (SidebarWidth - delim_len);
738 
739  for (int i = 0; i < num_rows; i++)
740  {
742 
743  switch (altchar)
744  {
745  case SB_DIV_USER:
746  addstr(NONULL(SidebarDividerChar));
747  break;
748  case SB_DIV_ASCII:
749  addch('|');
750  break;
751  case SB_DIV_UTF8:
752  addch(ACS_VLINE);
753  break;
754  }
755  }
756 
757  return delim_len;
758 }
#define NONULL(x)
Definition: string2.h:39
WHERE bool SidebarOnRight
Config: (sidebar) Display the sidebar on the right.
Definition: globals.h:255
WHERE short SidebarWidth
Config: (sidebar) Width of the sidebar.
Definition: globals.h:160
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1176
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
#define SETCOLOR(X)
Definition: mutt_curses.h:220
struct MuttWindow * MuttSidebarWindow
Sidebar Window.
Definition: mutt_window.c:43
Line dividing sidebar from the index/pager.
Definition: mutt_curses.h:145
WHERE bool AsciiChars
Config: Use plain ASCII characters, when drawing email threads.
Definition: globals.h:200

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void fill_empty_space ( int  first_row,
int  num_rows,
int  div_width,
int  num_cols 
)
static

Wipe the remaining Sidebar space.

Parameters
first_rowWindow line to start (0-based)
num_rowsNumber of rows to fill
div_widthWidth in screen characters taken by the divider
num_colsNumber of columns to fill

Write spaces over the area the sidebar isn't using.

Definition at line 769 of file sidebar.c.

770 {
771  /* Fill the remaining rows with blank space */
772  NORMAL_COLOR;
773 
774  if (!SidebarOnRight)
775  div_width = 0;
776  for (int r = 0; r < num_rows; r++)
777  {
778  mutt_window_move(MuttSidebarWindow, first_row + r, div_width);
779 
780  for (int i = 0; i < num_cols; i++)
781  addch(' ');
782  }
783 }
#define NORMAL_COLOR
Definition: mutt_curses.h:235
WHERE bool SidebarOnRight
Config: (sidebar) Display the sidebar on the right.
Definition: globals.h:255
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
struct MuttWindow * MuttSidebarWindow
Sidebar Window.
Definition: mutt_window.c:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void draw_sidebar ( int  num_rows,
int  num_cols,
int  div_width 
)
static

Write out a list of mailboxes, in a panel.

Parameters
num_rowsHeight of the Sidebar
num_colsWidth of the Sidebar
div_widthWidth in screen characters taken by the divider

Display a list of mailboxes in a panel on the left. What's displayed will depend on our index markers: TopMailbox, OpnMailbox, HilMailbox, BotMailbox. On the first run they'll be NULL, so we display the top of NeoMutt's list (AllMailboxes).

  • TopMailbox - first visible mailbox
  • BotMailbox - last visible mailbox
  • OpnMailbox - mailbox shown in NeoMutt's Index Panel
  • HilMailbox - Unselected mailbox (the paging follows this)

The entries are formatted using "sidebar_format" and may be abbreviated: "sidebar_short_path", indented: "sidebar_folder_indent", "sidebar_indent_string" and sorted: "sidebar_sort_method". Finally, they're trimmed to fit the available space.

Definition at line 806 of file sidebar.c.

807 {
808  struct SbEntry *entry = NULL;
809  struct Mailbox *m = NULL;
810  if (TopIndex < 0)
811  return;
812 
813  int w = MIN(num_cols, (SidebarWidth - div_width));
814  int row = 0;
815  for (int entryidx = TopIndex; (entryidx < EntryCount) && (row < num_rows); entryidx++)
816  {
817  entry = Entries[entryidx];
818  if (entry->is_hidden)
819  continue;
820  m = entry->mailbox;
821 
822  if (entryidx == OpnIndex)
823  {
824  if ((ColorDefs[MT_COLOR_SB_INDICATOR] != 0))
826  else
828  }
829  else if (entryidx == HilIndex)
831  else if ((m->msg_unread > 0) || (m->has_new))
833  else if (m->msg_flagged > 0)
835  else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) &&
836  (mutt_str_strcmp(m->path, Spoolfile) == 0))
837  {
839  }
840  else
841  {
842  if (ColorDefs[MT_COLOR_ORDINARY] != 0)
844  else
845  NORMAL_COLOR;
846  }
847 
848  int col = 0;
849  if (SidebarOnRight)
850  col = div_width;
851 
853  if (Context && (Context->mailbox->realpath[0] != '\0') &&
855  {
859  }
860 
861  /* compute length of Folder without trailing separator */
862  size_t maildirlen = mutt_str_strlen(Folder);
863  if (maildirlen && SidebarDelimChars && strchr(SidebarDelimChars, Folder[maildirlen - 1]))
864  maildirlen--;
865 
866  /* check whether Folder is a prefix of the current folder's path */
867  bool maildir_is_prefix = false;
868  if ((mutt_str_strlen(m->path) > maildirlen) &&
869  (mutt_str_strncmp(Folder, m->path, maildirlen) == 0) &&
870  SidebarDelimChars && strchr(SidebarDelimChars, m->path[maildirlen]))
871  {
872  maildir_is_prefix = true;
873  }
874 
875  /* calculate depth of current folder and generate its display name with indented spaces */
876  int sidebar_folder_depth = 0;
877  char *sidebar_folder_name = NULL;
878  if (SidebarShortPath)
879  {
880  /* disregard a trailing separator, so strlen() - 2 */
881  sidebar_folder_name = m->path;
882  for (int i = mutt_str_strlen(sidebar_folder_name) - 2; i >= 0; i--)
883  {
884  if (SidebarDelimChars && strchr(SidebarDelimChars, sidebar_folder_name[i]))
885  {
886  sidebar_folder_name += (i + 1);
887  break;
888  }
889  }
890  }
891  else if ((SidebarComponentDepth > 0) && SidebarDelimChars)
892  {
893  sidebar_folder_name = m->path + maildir_is_prefix * (maildirlen + 1);
894  for (int i = 0; i < SidebarComponentDepth; i++)
895  {
896  char *chars_after_delim = strpbrk(sidebar_folder_name, SidebarDelimChars);
897  if (!chars_after_delim)
898  break;
899  else
900  sidebar_folder_name = chars_after_delim + 1;
901  }
902  }
903  else
904  sidebar_folder_name = m->path + maildir_is_prefix * (maildirlen + 1);
905 
906  if (m->desc)
907  {
908  sidebar_folder_name = m->desc;
909  }
910  else if (maildir_is_prefix && SidebarFolderIndent)
911  {
912  int lastsep = 0;
913  const char *tmp_folder_name = m->path + maildirlen + 1;
914  int tmplen = (int) mutt_str_strlen(tmp_folder_name) - 1;
915  for (int i = 0; i < tmplen; i++)
916  {
917  if (SidebarDelimChars && strchr(SidebarDelimChars, tmp_folder_name[i]))
918  {
919  sidebar_folder_depth++;
920  lastsep = i + 1;
921  }
922  }
923  if (sidebar_folder_depth > 0)
924  {
925  if (SidebarShortPath)
926  tmp_folder_name += lastsep; /* basename */
927  int sfn_len = mutt_str_strlen(tmp_folder_name) +
928  sidebar_folder_depth * mutt_str_strlen(SidebarIndentString) + 1;
929  sidebar_folder_name = mutt_mem_malloc(sfn_len);
930  sidebar_folder_name[0] = 0;
931  for (int i = 0; i < sidebar_folder_depth; i++)
932  mutt_str_strcat(sidebar_folder_name, sfn_len, NONULL(SidebarIndentString));
933  mutt_str_strcat(sidebar_folder_name, sfn_len, tmp_folder_name);
934  }
935  }
936  char str[STRING];
937  make_sidebar_entry(str, sizeof(str), w, sidebar_folder_name, entry);
938  printw("%s", str);
939  if (sidebar_folder_depth > 0)
940  FREE(&sidebar_folder_name);
941  row++;
942  }
943 
944  fill_empty_space(row, num_rows - row, div_width, w);
945 }
$spoolfile (Spool mailbox)
Definition: mutt_curses.h:151
The "current" mailbox.
Definition: context.h:36
#define NONULL(x)
Definition: string2.h:39
int msg_count
total number of messages
Definition: mailbox.h:86
#define MIN(a, b)
Definition: memory.h:31
int msg_unread
number of unread messages
Definition: mailbox.h:87
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
#define NORMAL_COLOR
Definition: mutt_curses.h:235
char * desc
Definition: mailbox.h:81
WHERE bool SidebarOnRight
Config: (sidebar) Display the sidebar on the right.
Definition: globals.h:255
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:663
Info about folders in the sidebar.
Definition: sidebar.c:71
bool is_hidden
Don&#39;t show, e.g.
Definition: sidebar.c:75
bool has_new
mailbox has new mail
Definition: mailbox.h:83
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74
struct Mailbox * mailbox
Definition: context.h:50
Current open mailbox.
Definition: mutt_curses.h:150
Select cursor.
Definition: mutt_curses.h:147
A folder/dir in the browser.
Definition: browser.h:47
WHERE short SidebarWidth
Config: (sidebar) Width of the sidebar.
Definition: globals.h:160
A mailbox.
Definition: mailbox.h:76
Mailbox with new mail.
Definition: mutt_curses.h:148
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:99
Mailbox with flagged messages.
Definition: mutt_curses.h:146
int ColorDefs[MT_COLOR_MAX]
Array of all fixed colours, see enum ColorId.
Definition: color.c:51
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
#define SETCOLOR(X)
Definition: mutt_curses.h:220
char path[PATH_MAX]
Definition: mailbox.h:78
char * mutt_str_strcat(char *buf, size_t buflen, const char *s)
Concatenate two strings.
Definition: string.c:402
struct MuttWindow * MuttSidebarWindow
Sidebar Window.
Definition: mutt_window.c:43
#define STRING
Definition: string2.h:35
int mutt_str_strncmp(const char *a, const char *b, size_t l)
Compare two strings (to a maximum), safely.
Definition: string.c:639
#define FREE(x)
Definition: memory.h:46
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
WHERE char * Spoolfile
Config: Inbox.
Definition: globals.h:147
Selected item in list.
Definition: mutt_curses.h:127
Mailbox with no new or flagged messages.
Definition: mutt_curses.h:149
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_sb_draw ( void  )

Completely redraw the sidebar.

Completely refresh the sidebar region. First draw the divider; then, for each Mailbox, call make_sidebar_entry; finally blank out any remaining space.

Definition at line 953 of file sidebar.c.

954 {
955  if (!SidebarVisible)
956  return;
957 
958 #ifdef USE_SLANG_CURSES
959  int x = SLsmg_get_column();
960  int y = SLsmg_get_row();
961 #else
962  int x = getcurx(stdscr);
963  int y = getcury(stdscr);
964 #endif
965 
966  int num_rows = MuttSidebarWindow->rows;
967  int num_cols = MuttSidebarWindow->cols;
968 
969  int div_width = draw_divider(num_rows, num_cols);
970 
971  if (!Entries)
972  {
973  struct MailboxNode *np = NULL;
974  STAILQ_FOREACH(np, &AllMailboxes, entries)
975  {
976  mutt_sb_notify_mailbox(np->m, true);
977  }
978  }
979 
980  if (!prepare_sidebar(num_rows))
981  {
982  fill_empty_space(0, num_rows, div_width, num_cols - div_width);
983  return;
984  }
985 
986  draw_sidebar(num_rows, num_cols, div_width);
987  move(y, x);
988 }
WHERE bool SidebarVisible
Config: (sidebar) Show the sidebar.
Definition: globals.h:254
struct Mailbox * m
Definition: mailbox.h:139
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
struct MailboxList AllMailboxes
List of all Mailboxes.
Definition: mailbox.c:85
struct MuttWindow * MuttSidebarWindow
Sidebar Window.
Definition: mutt_window.c:43
List of Mailboxes.
Definition: mailbox.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_sb_change_mailbox ( int  op)

Change the selected mailbox.

Parameters
opOperation code

Change the selected mailbox, e.g. "Next mailbox", "Previous Mailbox with new mail". The operations are listed in opcodes.h.

If the operation is successful, HilMailbox will be set to the new mailbox. This function only selects the mailbox, doesn't open it.

Allowed values are: OP_SIDEBAR_NEXT, OP_SIDEBAR_NEXT_NEW, OP_SIDEBAR_PAGE_DOWN, OP_SIDEBAR_PAGE_UP, OP_SIDEBAR_PREV, OP_SIDEBAR_PREV_NEW.

Definition at line 1004 of file sidebar.c.

1005 {
1006  if (!SidebarVisible)
1007  return;
1008 
1009  if (HilIndex < 0) /* It'll get reset on the next draw */
1010  return;
1011 
1012  switch (op)
1013  {
1014  case OP_SIDEBAR_NEXT:
1015  if (!select_next())
1016  return;
1017  break;
1018  case OP_SIDEBAR_NEXT_NEW:
1019  if (!select_next_new())
1020  return;
1021  break;
1022  case OP_SIDEBAR_PAGE_DOWN:
1023  if (!select_page_down())
1024  return;
1025  break;
1026  case OP_SIDEBAR_PAGE_UP:
1027  if (!select_page_up())
1028  return;
1029  break;
1030  case OP_SIDEBAR_PREV:
1031  if (!select_prev())
1032  return;
1033  break;
1034  case OP_SIDEBAR_PREV_NEW:
1035  if (!select_prev_new())
1036  return;
1037  break;
1038  default:
1039  return;
1040  }
1042 }
WHERE bool SidebarVisible
Config: (sidebar) Show the sidebar.
Definition: globals.h:254

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct Mailbox* mutt_sb_get_highlight ( void  )

Get the Mailbox that's highlighted in the sidebar.

Return values
ptrMailbox

Definition at line 1048 of file sidebar.c.

1049 {
1050  if (!SidebarVisible)
1051  return NULL;
1052 
1053  if (!EntryCount || (HilIndex < 0))
1054  return NULL;
1055 
1056  return Entries[HilIndex]->mailbox;
1057 }
WHERE bool SidebarVisible
Config: (sidebar) Show the sidebar.
Definition: globals.h:254
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74

+ Here is the caller graph for this function:

void mutt_sb_set_open_mailbox ( void  )

Set the OpnMailbox based on the global Context.

Search through the list of mailboxes. If a Mailbox has a matching path, set OpnMailbox to it.

Definition at line 1065 of file sidebar.c.

1066 {
1067  OpnIndex = -1;
1068 
1069  if (!Context)
1070  return;
1071 
1072  for (int entry = 0; entry < EntryCount; entry++)
1073  {
1074  if (mutt_str_strcmp(Entries[entry]->mailbox->realpath, Context->mailbox->realpath) == 0)
1075  {
1076  OpnIndex = entry;
1077  HilIndex = entry;
1078  break;
1079  }
1080  }
1081 }
The "current" mailbox.
Definition: context.h:36
struct Mailbox * mailbox
Definition: context.h:50
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_sb_notify_mailbox ( struct Mailbox m,
bool  created 
)

The state of a Mailbox is about to change.

Parameters
mFolder
createdTrue if folder created, false if deleted

We receive a notification:

Before a deletion, check that our pointers won't be invalidated.

Definition at line 1094 of file sidebar.c.

1095 {
1096  if (!m)
1097  return;
1098 
1099  /* Any new/deleted mailboxes will cause a refresh. As long as
1100  * they're valid, our pointers will be updated in prepare_sidebar() */
1101 
1102  if (created)
1103  {
1104  if (EntryCount >= EntryLen)
1105  {
1106  EntryLen += 10;
1107  mutt_mem_realloc(&Entries, EntryLen * sizeof(struct SbEntry *));
1108  }
1109  Entries[EntryCount] = mutt_mem_calloc(1, sizeof(struct SbEntry));
1111 
1112  if (TopIndex < 0)
1113  TopIndex = EntryCount;
1114  if (BotIndex < 0)
1115  BotIndex = EntryCount;
1116  if ((OpnIndex < 0) && Context &&
1118  OpnIndex = EntryCount;
1119 
1120  EntryCount++;
1121  }
1122  else
1123  {
1124  int del_index;
1125  for (del_index = 0; del_index < EntryCount; del_index++)
1126  if (Entries[del_index]->mailbox == m)
1127  break;
1128  if (del_index == EntryCount)
1129  return;
1130  FREE(&Entries[del_index]);
1131  EntryCount--;
1132 
1133  if (TopIndex > del_index || TopIndex == EntryCount)
1134  TopIndex--;
1135  if (OpnIndex == del_index)
1136  OpnIndex = -1;
1137  else if (OpnIndex > del_index)
1138  OpnIndex--;
1139  if (HilIndex > del_index || HilIndex == EntryCount)
1140  HilIndex--;
1141  if (BotIndex > del_index || BotIndex == EntryCount)
1142  BotIndex--;
1143 
1144  for (; del_index < EntryCount; del_index++)
1145  Entries[del_index] = Entries[del_index + 1];
1146  }
1147 
1149 }
The "current" mailbox.
Definition: context.h:36
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
Info about folders in the sidebar.
Definition: sidebar.c:71
struct Mailbox * m
Definition: mailbox.h:139
struct Mailbox * mailbox
Mailbox this represents.
Definition: sidebar.c:74
struct Mailbox * mailbox
Definition: context.h:50
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:124
#define FREE(x)
Definition: memory.h:46
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

short SidebarComponentDepth

Config: (sidebar) Strip leading path components from sidebar folders.

Definition at line 54 of file sidebar.c.

char* SidebarDelimChars

Config: (sidebar) Characters that separate nested folders.

Definition at line 55 of file sidebar.c.

char* SidebarDividerChar

Config: (sidebar) Character to draw between the sidebar and index.

Definition at line 56 of file sidebar.c.

bool SidebarFolderIndent

Config: (sidebar) Indent nested folders.

Definition at line 57 of file sidebar.c.

char* SidebarFormat

Config: (sidebar) printf-like format string for the sidebar panel.

Definition at line 58 of file sidebar.c.

char* SidebarIndentString

Config: (sidebar) Indent nested folders using this string.

Definition at line 59 of file sidebar.c.

bool SidebarNewMailOnly

Config: (sidebar) Only show folders with new/flagged mail.

Definition at line 60 of file sidebar.c.

bool SidebarNextNewWrap

Config: (sidebar) Wrap around when searching for the next mailbox with new mail.

Definition at line 61 of file sidebar.c.

bool SidebarShortPath

Config: (sidebar) Abbreviate the paths using the Folder variable.

Definition at line 62 of file sidebar.c.

short SidebarSortMethod

Config: (sidebar) Method to sort the sidebar.

Definition at line 63 of file sidebar.c.

short PreviousSort = SORT_ORDER
static

Definition at line 66 of file sidebar.c.

int EntryCount = 0
static

Definition at line 78 of file sidebar.c.

int EntryLen = 0
static

Definition at line 79 of file sidebar.c.

struct SbEntry** Entries = NULL
static

Definition at line 80 of file sidebar.c.

int TopIndex = -1
static

First mailbox visible in sidebar.

Definition at line 82 of file sidebar.c.

int OpnIndex = -1
static

Current (open) mailbox.

Definition at line 83 of file sidebar.c.

int HilIndex = -1
static

Highlighted mailbox.

Definition at line 84 of file sidebar.c.

int BotIndex = -1
static

Last mailbox visible in sidebar.

Definition at line 85 of file sidebar.c.