NeoMutt
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
recalc()

Recalculate the Window data. More...

+ Collaboration diagram for recalc():

Functions

int alias_recalc (struct MuttWindow *win)
 Recalculate the display of the Alias Window - Implements MuttWindow::recalc() -.
 
static int cbar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int enter_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int env_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int msgwin_recalc (struct MuttWindow *win)
 Recalculate the display of the Message Window - Implements MuttWindow::recalc() -.
 
static int sbar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int helpbar_recalc (struct MuttWindow *win)
 Recalculate the display of the Help Bar - Implements MuttWindow::recalc() -.
 
static int ibar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int index_recalc (struct MuttWindow *win)
 Recalculate the Index display - Implements MuttWindow::recalc() -.
 
static int menu_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int win_chain_recalc (struct MuttWindow *win)
 Recalculate the Chain list - Implements MuttWindow::recalc() -.
 
static int pager_recalc (struct MuttWindow *win)
 Recalculate the Pager display - Implements MuttWindow::recalc() -.
 
static int pbar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int progress_window_recalc (struct MuttWindow *win)
 Recalculate the Progress Bar - Implements MuttWindow::recalc() -.
 
int sb_recalc (struct MuttWindow *win)
 Recalculate the Sidebar display - Implements MuttWindow::recalc() -.
 

Detailed Description

Recalculate the Window data.

Parameters
winWindow
Return values
0Success
-1Error
Precondition
win is not NULL
win is visible

Function Documentation

◆ alias_recalc()

int alias_recalc ( struct MuttWindow win)

Recalculate the display of the Alias Window - Implements MuttWindow::recalc() -.

Definition at line 89 of file gui.c.

90{
91 struct Menu *menu = win->wdata;
92 struct AliasMenuData *mdata = menu->mdata;
93
94 alias_array_sort(&mdata->ava, mdata->sub);
95
97 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
98 return 0;
99}
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition: sort.c:166
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
AliasView array wrapper with Pattern information -.
Definition: gui.h:52
struct Menu * menu
Menu.
Definition: gui.h:56
Definition: lib.h:70
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
void * mdata
Private data.
Definition: lib.h:137
void * wdata
Private data.
Definition: mutt_window.h:145
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cbar_recalc()

static int cbar_recalc ( struct MuttWindow win)
static

Recalculate the Window data - Implements MuttWindow::recalc() -.

See also
$compose_format, compose_format_str()

Definition at line 161 of file cbar.c.

162{
163 char buf[1024] = { 0 };
164 struct ComposeSharedData *shared = win->parent->wdata;
165
166 const char *const c_compose_format = cs_subset_string(shared->sub, "compose_format");
167 mutt_expando_format(buf, sizeof(buf), 0, win->state.cols, NONULL(c_compose_format),
168 compose_format_str, (intptr_t) shared, MUTT_FORMAT_NO_FLAGS);
169
170 struct ComposeBarData *cbar_data = win->wdata;
171 if (!mutt_str_equal(buf, cbar_data->compose_format))
172 {
173 mutt_str_replace(&cbar_data->compose_format, buf);
174 win->actions |= WA_REPAINT;
175 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
176 }
177
178 return 0;
179}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
static const char * compose_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Create the status bar string for compose mode - Implements format_t -.
Definition: cbar.c:104
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string -.
Definition: muttlib.c:745
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:327
#define NONULL(x)
Definition: string2.h:37
Data to fill the Compose Bar Window.
Definition: cbar_data.h:34
char * compose_format
Cached status string.
Definition: cbar_data.h:35
Shared Compose Data.
Definition: shared_data.h:33
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:34
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enter_recalc()

static int enter_recalc ( struct MuttWindow win)
static

Recalculate the Window data - Implements MuttWindow::recalc() -.

See also
$compose_format, compose_format_str()

Definition at line 176 of file window.c.

177{
178 win->actions |= WA_REPAINT;
179 mutt_debug(LL_DEBUG1, "recalc done, request WA_REPAINT\n");
180
181 return 0;
182}
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
+ Here is the caller graph for this function:

◆ env_recalc()

static int env_recalc ( struct MuttWindow win)
static

Recalculate the Window data - Implements MuttWindow::recalc() -.

Definition at line 775 of file window.c.

776{
777 struct EnvelopeWindowData *wdata = win->wdata;
778
779 const int cur_rows = win->state.rows;
780 const int new_rows = calc_envelope(win, wdata);
781
782 if (new_rows != cur_rows)
783 {
784 win->req_rows = new_rows;
786 }
787
788 win->actions |= WA_REPAINT;
789 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
790 return 0;
791}
static int calc_envelope(struct MuttWindow *win, struct EnvelopeWindowData *wdata)
Calculate how many rows the envelope will need.
Definition: window.c:309
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:344
Data to fill the Envelope Window.
Definition: wdata.h:38
short req_rows
Number of rows required.
Definition: mutt_window.h:125
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgwin_recalc()

static int msgwin_recalc ( struct MuttWindow win)
static

Recalculate the display of the Message Window - Implements MuttWindow::recalc() -.

Definition at line 163 of file msgwin.c.

164{
165 win->actions |= WA_REPAINT;
166 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
167 return 0;
168}
+ Here is the caller graph for this function:

◆ sbar_recalc()

static int sbar_recalc ( struct MuttWindow win)
static

Recalculate the Window data - Implements MuttWindow::recalc() -.

Definition at line 82 of file sbar.c.

83{
84 if (!win)
85 return -1;
86
87 win->actions |= WA_REPAINT;
88 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
89 return 0;
90}
+ Here is the caller graph for this function:

◆ helpbar_recalc()

static int helpbar_recalc ( struct MuttWindow win)
static

Recalculate the display of the Help Bar - Implements MuttWindow::recalc() -.

Generate the help string from data on the focused Window. The Help Bar isn't drawn, yet.

Definition at line 142 of file helpbar.c.

143{
145 if (!wdata)
146 return 0;
147
148 FREE(&wdata->help_str);
149
150 struct MuttWindow *win_focus = window_get_focus();
151 if (!win_focus)
152 return 0;
153
154 // Ascend the Window tree until we find help_data
155 while (win_focus && !win_focus->help_data)
156 win_focus = win_focus->parent;
157
158 if (!win_focus)
159 return 0;
160
161 char helpstr[1024] = { 0 };
162 compile_help(helpstr, sizeof(helpstr), win_focus->help_menu, win_focus->help_data);
163
164 wdata->help_menu = win_focus->help_menu;
165 wdata->help_data = win_focus->help_data;
166 wdata->help_str = mutt_str_dup(helpstr);
167
168 win->actions |= WA_REPAINT;
169 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
170 return 0;
171}
struct HelpbarWindowData * helpbar_wdata_get(struct MuttWindow *win)
Get the Helpbar data for this window.
Definition: wdata.c:64
static char * compile_help(char *buf, size_t buflen, enum MenuType menu, const struct Mapping *items)
Create the text for the help menu.
Definition: helpbar.c:115
#define FREE(x)
Definition: memory.h:45
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:251
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
Definition: mutt_window.c:668
Help Bar Window data -.
Definition: private.h:34
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ibar_recalc()

static int ibar_recalc ( struct MuttWindow win)
static

Recalculate the Window data - Implements MuttWindow::recalc() -.

Definition at line 89 of file ibar.c.

90{
91 char buf[1024] = { 0 };
92
93 struct IBarPrivateData *ibar_data = win->wdata;
94 struct IndexSharedData *shared = ibar_data->shared;
95 struct IndexPrivateData *priv = ibar_data->priv;
96
97 const char *c_status_format = cs_subset_string(shared->sub, "status_format");
98 menu_status_line(buf, sizeof(buf), shared, priv->menu, win->state.cols,
99 NONULL(c_status_format));
100
101 if (!mutt_str_equal(buf, ibar_data->status_format))
102 {
103 mutt_str_replace(&ibar_data->status_format, buf);
104 win->actions |= WA_REPAINT;
105 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
106 }
107
108 const bool c_ts_enabled = cs_subset_bool(shared->sub, "ts_enabled");
109 if (c_ts_enabled && TsSupported)
110 {
111 const char *c_ts_status_format = cs_subset_string(shared->sub, "ts_status_format");
112 menu_status_line(buf, sizeof(buf), shared, priv->menu, sizeof(buf),
113 NONULL(c_ts_status_format));
114 if (!mutt_str_equal(buf, ibar_data->ts_status_format))
115 {
116 mutt_str_replace(&ibar_data->ts_status_format, buf);
117 win->actions |= WA_REPAINT;
118 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
119 }
120
121 const char *c_ts_icon_format = cs_subset_string(shared->sub, "ts_icon_format");
122 menu_status_line(buf, sizeof(buf), shared, priv->menu, sizeof(buf),
123 NONULL(c_ts_icon_format));
124 if (!mutt_str_equal(buf, ibar_data->ts_icon_format))
125 {
126 mutt_str_replace(&ibar_data->ts_icon_format, buf);
127 win->actions |= WA_REPAINT;
128 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
129 }
130 }
131
132 return 0;
133}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
void menu_status_line(char *buf, size_t buflen, struct IndexSharedData *shared, struct Menu *menu, int cols, const char *fmt)
Create the status line.
Definition: status.c:479
Data to draw the Index Bar.
Definition: ibar.c:78
char * ts_icon_format
Cached terminal icon string.
Definition: ibar.c:83
struct IndexSharedData * shared
Shared Index data.
Definition: ibar.c:79
char * ts_status_format
Cached terminal status string.
Definition: ibar.c:82
char * status_format
Cached screen status string.
Definition: ibar.c:81
struct IndexPrivateData * priv
Private Index data.
Definition: ibar.c:80
Private state data for the Index.
Definition: private_data.h:35
struct IndexSharedData * shared
Shared Index data.
Definition: private_data.h:41
struct Menu * menu
Menu controlling the index.
Definition: private_data.h:42
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:37
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:38
bool TsSupported
Terminal Setting is supported.
Definition: terminal.c:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index_recalc()

static int index_recalc ( struct MuttWindow win)
static

Recalculate the Index display - Implements MuttWindow::recalc() -.

Definition at line 534 of file index.c.

535{
536 win->actions |= WA_REPAINT;
537 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
538 return 0;
539}
+ Here is the caller graph for this function:

◆ menu_recalc()

static int menu_recalc ( struct MuttWindow win)
static

Recalculate the Window data - Implements MuttWindow::recalc() -.

Definition at line 80 of file window.c.

81{
82 if (win->type != WT_MENU)
83 return 0;
84
85 win->actions |= WA_REPAINT;
86 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
87 return 0;
88}
@ WT_MENU
An Window containing a Menu.
Definition: mutt_window.h:98
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
+ Here is the caller graph for this function:

◆ win_chain_recalc()

static int win_chain_recalc ( struct MuttWindow win)
static

Recalculate the Chain list - Implements MuttWindow::recalc() -.

Definition at line 106 of file win_chain.c.

107{
108 const int wrap_indent = 2;
109
110 if (!win || !win->wdata)
111 return 0;
112
113 struct ChainData *cd = win->wdata;
114 cbar_update(cd);
115
116 win->actions |= WA_REPAINT;
117 if (cd->chain_len == 0)
118 return 0;
119
120 short col = 0, row = 0;
121 for (int i = 0; i < cd->chain_len; i++)
122 {
123 short old_col = col;
124 int index = cd->chain[i];
125 struct Remailer **rp = ARRAY_GET(cd->ra, index);
126 col += strlen((*rp)->shortname) + 2;
127
128 if (col >= win->state.cols)
129 {
130 old_col = wrap_indent;
131 col = wrap_indent;
132 row++;
133 }
134
135 cd->coords[i].col = old_col;
136 cd->coords[i].row = row;
137 }
138
139 return 0;
140}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:108
An ordered set of Remailer hosts.
Definition: chain_data.h:46
int chain_len
Length of chain.
Definition: chain_data.h:48
struct RemailerArray * ra
Array of all Remailer hosts.
Definition: chain_data.h:51
int chain[MAX_MIXES]
Indexes of chain hosts.
Definition: chain_data.h:49
struct Coord coords[MAX_MIXES]
Screen coordinates of each entry.
Definition: chain_data.h:50
short col
Column.
Definition: chain_data.h:37
short row
Row.
Definition: chain_data.h:36
A Mixmaster remailer.
Definition: remailer.h:40
static void cbar_update(struct ChainData *cd)
Update the Chain bar (status bar)
Definition: win_chain.c:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pager_recalc()

static int pager_recalc ( struct MuttWindow win)
static

Recalculate the Pager display - Implements MuttWindow::recalc() -.

Definition at line 120 of file pager.c.

121{
122 win->actions |= WA_REPAINT;
123 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
124 return 0;
125}
+ Here is the caller graph for this function:

◆ pbar_recalc()

static int pbar_recalc ( struct MuttWindow win)
static

Recalculate the Window data - Implements MuttWindow::recalc() -.

Definition at line 93 of file pbar.c.

94{
95 char buf[1024] = { 0 };
96
97 struct PBarPrivateData *pbar_data = win->wdata;
98 struct IndexSharedData *shared = pbar_data->shared;
99 struct PagerPrivateData *priv = pbar_data->priv;
100 if (!priv || !priv->pview)
101 return 0;
102
103 char pager_progress_str[65] = { 0 }; /* Lots of space for translations */
104
105 long offset;
106 if (priv->lines && (priv->cur_line <= priv->lines_used))
107 offset = priv->lines[priv->cur_line].offset;
108 else
109 offset = priv->bytes_read;
110
111 if (offset < (priv->st.st_size - 1))
112 {
113 const long percent = (100 * offset) / priv->st.st_size;
114 /* L10N: Pager position percentage.
115 `%ld` is the number, `%%` is the percent symbol.
116 They may be reordered, or space inserted, if you wish. */
117 snprintf(pager_progress_str, sizeof(pager_progress_str), _("%ld%%"), percent);
118 }
119 else
120 {
121 const char *msg = (priv->top_line == 0) ?
122 /* L10N: Status bar message: the entire email is visible in the pager */
123 _("all") :
124 /* L10N: Status bar message: the end of the email is visible in the pager */
125 _("end");
126 mutt_str_copy(pager_progress_str, msg, sizeof(pager_progress_str));
127 }
128
129 if ((priv->pview->mode == PAGER_MODE_EMAIL) || (priv->pview->mode == PAGER_MODE_ATTACH_E))
130 {
131 int msg_in_pager = shared->mailbox_view ? shared->mailbox_view->msg_in_pager : -1;
132
133 const char *c_pager_format = cs_subset_string(shared->sub, "pager_format");
134 mutt_make_string(buf, sizeof(buf), win->state.cols, NONULL(c_pager_format),
135 shared->mailbox, msg_in_pager, shared->email,
136 MUTT_FORMAT_NO_FLAGS, pager_progress_str);
137 }
138 else
139 {
140 snprintf(buf, sizeof(buf), "%s (%s)", priv->pview->banner, pager_progress_str);
141 }
142
143 if (!mutt_str_equal(buf, pbar_data->pager_format))
144 {
145 mutt_str_replace(&pbar_data->pager_format, buf);
146 win->actions |= WA_REPAINT;
147 }
148
149 return 0;
150}
void mutt_make_string(char *buf, size_t buflen, int cols, const char *s, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
Definition: hdrline.c:1426
#define _(a)
Definition: message.h:28
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:653
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:137
@ PAGER_MODE_ATTACH_E
A special case of PAGER_MODE_ATTACH - attachment is a full-blown email message.
Definition: lib.h:139
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
struct MailboxView * mailbox_view
Current Mailbox view.
Definition: shared_data.h:40
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
Definition: display.h:52
int msg_in_pager
Message currently shown in the pager.
Definition: mview.h:44
Data to draw the Pager Bar.
Definition: pbar.c:84
struct PagerPrivateData * priv
Private Pager data.
Definition: pbar.c:86
char * pager_format
Cached status string.
Definition: pbar.c:87
struct IndexSharedData * shared
Shared Index data.
Definition: pbar.c:85
Private state data for the Pager.
Definition: private_data.h:41
int cur_line
Current line (last line visible on screen)
Definition: private_data.h:51
int lines_used
Size of lines array (used entries)
Definition: private_data.h:49
struct Line * lines
Array of text lines in pager.
Definition: private_data.h:48
LOFF_T bytes_read
Number of bytes read from file.
Definition: private_data.h:46
int top_line
First visible line on screen.
Definition: private_data.h:55
struct stat st
Stats about Email file.
Definition: private_data.h:45
struct PagerView * pview
Object to view in the pager.
Definition: private_data.h:42
enum PagerMode mode
Pager mode.
Definition: lib.h:173
const char * banner
Title to display in status bar.
Definition: lib.h:175
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ progress_window_recalc()

static int progress_window_recalc ( struct MuttWindow win)
static

Recalculate the Progress Bar - Implements MuttWindow::recalc() -.

Definition at line 133 of file window.c.

134{
135 if (!win || !win->wdata)
136 return -1;
137
138 struct ProgressWindowData *wdata = win->wdata;
139 wdata->display_pos = wdata->update_pos;
140 wdata->display_time = wdata->update_time;
141
142 if (wdata->is_bytes)
143 mutt_str_pretty_size(wdata->pretty_pos, sizeof(wdata->pretty_pos), wdata->display_pos);
144
145 if (wdata->update_percent < 0)
146 wdata->display_percent = 100.0 * wdata->display_pos / wdata->size;
147 else
148 wdata->display_percent = wdata->update_percent;
149
151 return 0;
152}
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Definition: muttlib.c:1651
Progress Bar Window Data.
Definition: wdata.h:36
int update_percent
Updated percentage complete.
Definition: wdata.h:55
size_t size
Total expected size.
Definition: wdata.h:42
char pretty_pos[24]
Pretty string for the position.
Definition: wdata.h:51
uint64_t update_time
Time of last update.
Definition: wdata.h:56
int display_percent
Displayed percentage complete.
Definition: wdata.h:49
size_t display_pos
Displayed position.
Definition: wdata.h:48
bool is_bytes
true if measuring bytes
Definition: wdata.h:45
size_t update_pos
Updated position.
Definition: wdata.h:54
struct MuttWindow * win
Window to draw on.
Definition: wdata.h:37
uint64_t display_time
Time of last display.
Definition: wdata.h:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_recalc()

int sb_recalc ( struct MuttWindow win)

Recalculate the Sidebar display - Implements MuttWindow::recalc() -.

Definition at line 770 of file window.c.

771{
773 struct IndexSharedData *shared = wdata->shared;
774
775 if (ARRAY_EMPTY(&wdata->entries))
776 {
777 struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
779 struct MailboxNode *np = NULL;
780 STAILQ_FOREACH(np, &ml, entries)
781 {
782 if (np->mailbox->visible)
783 sb_add_mailbox(wdata, np->mailbox);
784 }
786 }
787
788 if (!prepare_sidebar(wdata, win->state.rows))
789 {
790 win->actions |= WA_REPAINT;
791 return 0;
792 }
793
794 int num_rows = win->state.rows;
795 int num_cols = win->state.cols;
796
797 if (ARRAY_EMPTY(&wdata->entries) || (num_rows <= 0))
798 return 0;
799
800 if (wdata->top_index < 0)
801 return 0;
802
803 int width = num_cols - wdata->divider_width;
804 int row = 0;
805 struct Mailbox *m_cur = shared->mailbox;
806 struct SbEntry **sbep = NULL;
807 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->top_index)
808 {
809 if (row >= num_rows)
810 break;
811
812 if ((*sbep)->is_hidden)
813 continue;
814
815 struct SbEntry *entry = (*sbep);
816 struct Mailbox *m = entry->mailbox;
817
818 const int entryidx = ARRAY_FOREACH_IDX;
819 entry->color = calc_color(m, (entryidx == wdata->opn_index),
820 (entryidx == wdata->hil_index));
821
822 if (m_cur && (m_cur->realpath[0] != '\0') &&
823 mutt_str_equal(m->realpath, m_cur->realpath))
824 {
825 m->msg_unread = m_cur->msg_unread;
826 m->msg_count = m_cur->msg_count;
827 m->msg_flagged = m_cur->msg_flagged;
828 }
829
830 const char *path = mailbox_path(m);
831
832 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
833 // Try to abbreviate the full path
834 const char *abbr = abbrev_folder(path, c_folder, m->type);
835 if (!abbr)
836 abbr = abbrev_url(path, m->type);
837 const char *short_path = abbr ? abbr : path;
838
839 /* Compute the depth */
840 const char *last_part = abbr;
841 const char *const c_sidebar_delim_chars = cs_subset_string(NeoMutt->sub, "sidebar_delim_chars");
842 entry->depth = calc_path_depth(abbr, c_sidebar_delim_chars, &last_part);
843
844 const bool short_path_is_abbr = (short_path == abbr);
845 const bool c_sidebar_short_path = cs_subset_bool(NeoMutt->sub, "sidebar_short_path");
846 if (c_sidebar_short_path)
847 {
848 short_path = last_part;
849 }
850
851 // Don't indent if we were unable to create an abbreviation.
852 // Otherwise, the full path will be indent, and it looks unusual.
853 const bool c_sidebar_folder_indent = cs_subset_bool(NeoMutt->sub, "sidebar_folder_indent");
854 if (c_sidebar_folder_indent && short_path_is_abbr)
855 {
856 const short c_sidebar_component_depth = cs_subset_number(NeoMutt->sub, "sidebar_component_depth");
857 if (c_sidebar_component_depth > 0)
858 entry->depth -= c_sidebar_component_depth;
859 }
860 else if (!c_sidebar_folder_indent)
861 {
862 entry->depth = 0;
863 }
864
865 mutt_str_copy(entry->box, short_path, sizeof(entry->box));
866 make_sidebar_entry(entry->display, sizeof(entry->display), width, entry, shared);
867 row++;
868 }
869
870 win->actions |= WA_REPAINT;
871 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
872 return 0;
873}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:73
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition: array.h:222
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:144
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:210
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition: mailbox.h:42
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:162
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:185
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:324
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
void sb_add_mailbox(struct SidebarWindowData *wdata, struct Mailbox *m)
Add a Mailbox to the Sidebar.
Definition: sidebar.c:88
struct SidebarWindowData * sb_wdata_get(struct MuttWindow *win)
Get the Sidebar data for this window.
Definition: wdata.c:76
static const char * abbrev_url(const char *mbox, enum MailboxType type)
Abbreviate a url-style Mailbox path.
Definition: window.c:202
static const struct AttrColor * calc_color(const struct Mailbox *m, bool current, bool highlight)
Calculate the colour of a Sidebar row.
Definition: window.c:249
static const char * abbrev_folder(const char *mbox, const char *folder, enum MailboxType type)
Abbreviate a Mailbox path using a folder.
Definition: window.c:138
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:312
static bool prepare_sidebar(struct SidebarWindowData *wdata, int page_size)
Prepare the list of SbEntry's for the sidebar display.
Definition: window.c:685
static void make_sidebar_entry(char *buf, size_t buflen, int width, struct SbEntry *sbe, struct IndexSharedData *shared)
Turn mailbox data into a sidebar string.
Definition: window.c:582
List of Mailboxes.
Definition: mailbox.h:153
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:154
A mailbox.
Definition: mailbox.h:79
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:81
int msg_count
Total number of messages.
Definition: mailbox.h:88
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
bool visible
True if a result of "mailboxes".
Definition: mailbox.h:131
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:90
int msg_unread
Number of unread messages.
Definition: mailbox.h:89
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
Info about folders in the sidebar.
Definition: private.h:41
const struct AttrColor * color
Colour to use.
Definition: private.h:47
int depth
Indentation depth.
Definition: private.h:44
char display[256]
Formatted string to display.
Definition: private.h:43
struct Mailbox * mailbox
Mailbox this represents.
Definition: private.h:45
char box[256]
Mailbox path (possibly abbreviated)
Definition: private.h:42
Sidebar private Window data -.
Definition: private.h:64
int top_index
First mailbox visible in sidebar.
Definition: private.h:69
short divider_width
Width of the divider in screen columns.
Definition: private.h:76
int hil_index
Highlighted mailbox.
Definition: private.h:71
struct IndexSharedData * shared
Shared Index Data.
Definition: private.h:66
int opn_index
Current (open) mailbox.
Definition: private.h:70
struct MuttWindow * win
Sidebar Window.
Definition: private.h:65
struct SbEntryArray entries
Items to display in the sidebar.
Definition: private.h:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function: