NeoMutt  2025-12-11-911-gd8d604
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 attach_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int cbar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int compose_recalc (struct MuttWindow *dlg)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int preview_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 utilwin_recalc (struct MuttWindow *win)
 Recalculate the Utility Window - 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 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 96 of file gui.c.

97{
98 struct Menu *menu = win->wdata;
99 struct AliasMenuData *mdata = menu->mdata;
100
101 alias_array_sort(&mdata->ava, mdata->sub);
102
104 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
105 return 0;
106}
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition sort.c:235
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:49
@ WA_REPAINT
Redraw the contents of the Window.
AliasView array wrapper with Pattern information -.
Definition gui.h:55
struct Menu * menu
Menu.
Definition gui.h:59
Definition lib.h:86
struct MuttWindow * win
Window holding the Menu.
Definition lib.h:94
void * mdata
Private data.
Definition lib.h:155
void * wdata
Private data.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attach_recalc()

static int attach_recalc ( struct MuttWindow * win)
static

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

Definition at line 244 of file attach.c.

245{
246 struct Menu *menu = win->wdata;
247 struct ComposeAttachData *adata = menu->mdata;
248
249 const int cur_rows = win->state.rows;
250 const int new_rows = adata->actx->idxlen;
251
252 if (new_rows != cur_rows)
253 {
254 win->req_rows = new_rows;
257 }
258
259 win->actions |= WA_REPAINT;
260 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
261 return 0;
262}
void menu_adjust(struct Menu *menu)
Reapply the config to the Menu.
Definition move.c:325
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
short idxlen
Number of attachmentes.
Definition attach.h:70
Data to fill the Compose Attach Window.
Definition attach_data.h:33
struct Menu * menu
Menu displaying the attachments.
Definition attach_data.h:35
struct AttachCtx * actx
Set of attachments.
Definition attach_data.h:34
struct WindowState state
Current state of the Window.
short req_rows
Number of rows required.
struct MuttWindow * parent
Parent Window.
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:

◆ cbar_recalc()

static int cbar_recalc ( struct MuttWindow * win)
static

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

See also
$compose_format

Definition at line 81 of file cbar.c.

82{
83 struct Buffer *buf = buf_pool_get();
84 struct ComposeSharedData *shared = win->parent->wdata;
85
86 const struct Expando *c_compose_format = cs_subset_expando(shared->sub, "compose_format");
87 expando_filter(c_compose_format, ComposeRenderCallbacks, shared,
89
90 struct ComposeBarData *cbar_data = win->wdata;
91 if (!mutt_str_equal(buf_string(buf), cbar_data->compose_format))
92 {
94 win->actions |= WA_REPAINT;
95 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
96 }
97 buf_pool_release(&buf);
98
99 return 0;
100}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
const struct ExpandoRenderCallback ComposeRenderCallbacks[]
Callbacks for Compose Expandos.
Definition expando.c:103
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
int expando_filter(const struct Expando *exp, const struct ExpandoRenderCallback *erc, void *data, MuttFormatFlags flags, int max_cols, char **env_list, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition filter.c:139
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
@ MUTT_FORMAT_NONE
No flags are set.
Definition render.h:37
String manipulation buffer.
Definition buffer.h:36
Data to fill the Compose Bar Window.
Definition cbar_data.h:33
char * compose_format
Cached status string.
Definition cbar_data.h:34
Shared Compose Data.
Definition shared_data.h:35
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:36
Parsed Expando trees.
Definition expando.h:41
Container for Accounts, Notifications.
Definition neomutt.h:41
char ** env
Private copy of the environment variables.
Definition neomutt.h:57
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:

◆ compose_recalc()

static int compose_recalc ( struct MuttWindow * dlg)
static

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

Definition at line 128 of file dlg_compose.c.

129{
130 if (!dlg)
131 return -1;
132
133 struct ComposeSharedData *shared = dlg->wdata;
134 struct MuttWindow *win_env = window_find_child(dlg, WT_CUSTOM);
135 struct MuttWindow *win_preview = shared->win_preview;
136 struct MuttWindow *win_preview_bar = shared->win_preview_bar;
137
138 const bool c_show_preview = cs_subset_bool(shared->sub, "compose_show_preview");
139 const short c_preview_min_rows = cs_subset_number(shared->sub, "compose_preview_min_rows");
140
141 // How many rows are available for the preview window?
142 // Total rows - (envelope window + attachments + number of status bars)
143 int rows_available = dlg->state.rows -
144 (win_env->state.rows + shared->adata->actx->idxlen + 3);
145
146 if (c_show_preview && rows_available >= c_preview_min_rows)
147 {
148 window_set_visible(win_preview, true);
149 window_set_visible(win_preview_bar, true);
151 }
152 else
153 {
154 window_set_visible(win_preview, false);
155 window_set_visible(win_preview_bar, false);
157 }
158
159 return 0;
160}
void attachment_size_fixed(struct MuttWindow *win)
Make the Attachment Window fixed-size.
Definition attach.c:302
void attachment_size_max(struct MuttWindow *win)
Make the Attachment Window maximised.
Definition attach.c:315
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition helpers.c:143
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
@ WT_CUSTOM
Window with a custom drawing function.
Definition mutt_window.h:95
struct MuttWindow * win_preview
Message preview window.
Definition shared_data.h:41
struct MuttWindow * win_preview_bar
Status bar divider above preview.
Definition shared_data.h:42
struct ComposeAttachData * adata
Attachments.
Definition shared_data.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preview_recalc()

static int preview_recalc ( struct MuttWindow * win)
static

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

Definition at line 344 of file preview.c.

345{
346 if (!win)
347 return -1;
348
349 win->actions |= WA_REPAINT;
350 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
351 return 0;
352}
+ 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

Definition at line 170 of file window.c.

171{
172 win->actions |= WA_REPAINT;
173 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
174
175 return 0;
176}
+ 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 731 of file window.c.

732{
733 struct EnvelopeWindowData *wdata = win->wdata;
734
735 const int cur_rows = win->state.rows;
736 const int new_rows = calc_envelope(win, wdata);
737
738 if (new_rows != cur_rows)
739 {
740 win->req_rows = new_rows;
742 }
743
744 win->actions |= WA_REPAINT;
745 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
746 return 0;
747}
static int calc_envelope(struct MuttWindow *win, struct EnvelopeWindowData *wdata)
Calculate how many rows the envelope will need.
Definition window.c:304
Data to fill the Envelope Window.
Definition wdata.h:38
+ 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 162 of file msgwin.c.

163{
164 win->actions |= WA_REPAINT;
165 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
166 return 0;
167}
+ 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:

◆ utilwin_recalc()

static int utilwin_recalc ( struct MuttWindow * win)
static

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

Definition at line 84 of file utilwin.c.

85{
86 win->actions |= WA_REPAINT;
87 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
88 return 0;
89}
+ 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 126 of file helpbar.c.

127{
129 if (!wdata)
130 return 0;
131
132 FREE(&wdata->help_str);
133
134 struct MuttWindow *win_focus = window_get_focus();
135 if (!win_focus)
136 return 0;
137
138 // Ascend the Window tree until we find help_data
139 while (win_focus && !win_focus->help_data)
140 win_focus = win_focus->parent;
141
142 if (!win_focus)
143 return 0;
144
145 struct Buffer *helpstr = buf_pool_get();
146 compile_help(win_focus->help_md, win_focus->help_data, helpstr);
147
148 wdata->help_md = win_focus->help_md;
149 wdata->help_data = win_focus->help_data;
150 wdata->help_str = buf_strdup(helpstr);
151 buf_pool_release(&helpstr);
152
153 win->actions |= WA_REPAINT;
154 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
155 return 0;
156}
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:571
struct HelpbarWindowData * helpbar_wdata_get(struct MuttWindow *win)
Get the Helpbar data for this window.
Definition wdata.c:64
static void compile_help(const struct MenuDefinition *md, const struct Mapping *items, struct Buffer *buf)
Create the text for the help menu.
Definition helpbar.c:108
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
Help Bar Window data -.
Definition private.h:34
char * help_str
Formatted Help Bar string.
Definition private.h:37
const struct MenuDefinition * help_md
Menu Definition for key bindings.
Definition private.h:35
const struct Mapping * help_data
Data for the Help Bar.
Definition private.h:36
const struct Mapping * help_data
Data for the Help Bar.
const struct MenuDefinition * help_md
Menu Definition for key bindings.
+ 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 92 of file ibar.c.

93{
94 struct Buffer *buf = buf_pool_get();
95
96 struct IBarPrivateData *ibar_data = win->wdata;
97 struct IndexSharedData *shared = ibar_data->shared;
98 struct IndexPrivateData *priv = ibar_data->priv;
100
101 const struct Expando *c_status_format = cs_subset_expando(shared->sub, "status_format");
102 menu_status_line(buf, shared, priv->menu, win->state.cols, c_status_format);
103
104 if (!mutt_str_equal(buf_string(buf), ibar_data->status_format))
105 {
106 mutt_str_replace(&ibar_data->status_format, buf_string(buf));
107 win->actions |= WA_REPAINT;
108 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
109 }
110
111 const bool c_ts_enabled = cs_subset_bool(shared->sub, "ts_enabled");
112 if (c_ts_enabled && mod_data && mod_data->ts_supported)
113 {
114 buf_reset(buf);
115 const struct Expando *c_ts_status_format = cs_subset_expando(shared->sub, "ts_status_format");
116 menu_status_line(buf, shared, priv->menu, -1, c_ts_status_format);
117 if (!mutt_str_equal(buf_string(buf), ibar_data->ts_status_format))
118 {
120 win->actions |= WA_REPAINT;
121 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
122 }
123
124 buf_reset(buf);
125 const struct Expando *c_ts_icon_format = cs_subset_expando(shared->sub, "ts_icon_format");
126 menu_status_line(buf, shared, priv->menu, -1, c_ts_icon_format);
127 if (!mutt_str_equal(buf_string(buf), ibar_data->ts_icon_format))
128 {
129 mutt_str_replace(&ibar_data->ts_icon_format, buf_string(buf));
130 win->actions |= WA_REPAINT;
131 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
132 }
133 }
134
135 buf_pool_release(&buf);
136 return 0;
137}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
void menu_status_line(struct Buffer *buf, struct IndexSharedData *shared, struct Menu *menu, int max_cols, const struct Expando *exp)
Create the status line.
Definition status.c:51
Gui private Module data.
Definition module_data.h:32
bool ts_supported
Terminal Setting is supported.
Definition module_data.h:43
Data to draw the Index Bar.
Definition ibar.c:81
char * ts_icon_format
Cached terminal icon string.
Definition ibar.c:86
struct IndexSharedData * shared
Shared Index data.
Definition ibar.c:82
char * ts_status_format
Cached terminal status string.
Definition ibar.c:85
char * status_format
Cached screen status string.
Definition ibar.c:84
struct IndexPrivateData * priv
Private Index data.
Definition ibar.c:83
Private state data for the Index.
struct Menu * menu
Menu controlling the index.
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:38
+ 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 594 of file index.c.

595{
596 win->actions |= WA_REPAINT;
597 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
598 return 0;
599}
+ 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 81 of file window.c.

82{
83 if (win->type != WT_MENU)
84 return 0;
85
86 win->actions |= WA_REPAINT;
87 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
88 return 0;
89}
@ WT_MENU
An Window containing a Menu.
Definition mutt_window.h:98
enum WindowType type
Window type, e.g. WT_SIDEBAR.
+ 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 125 of file pager.c.

126{
127 win->actions |= WA_REPAINT;
128 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
129 return 0;
130}
+ 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 90 of file pbar.c.

91{
92 struct PBarPrivateData *pbar_data = win->wdata;
93 struct IndexSharedData *shared = pbar_data->shared;
94 struct PagerPrivateData *priv = pbar_data->priv;
95 if (!priv || !priv->pview)
96 return 0;
97
98 struct Buffer *buf = buf_pool_get();
99 char pager_progress_str[65] = { 0 }; /* Lots of space for translations */
100
101 long offset;
102 if (priv->lines && (priv->cur_line <= priv->lines_used))
103 offset = priv->lines[priv->cur_line].offset;
104 else
105 offset = priv->bytes_read;
106
107 if (offset < (priv->st.st_size - 1))
108 {
109 const long percent = (100 * offset) / priv->st.st_size;
110 /* L10N: Pager position percentage.
111 `%ld` is the number, `%%` is the percent symbol.
112 They may be reordered, or space inserted, if you wish. */
113 snprintf(pager_progress_str, sizeof(pager_progress_str), _("%ld%%"), percent);
114 }
115 else
116 {
117 const char *msg = (priv->top_line == 0) ?
118 /* L10N: Status bar message: the entire email is visible in the pager */
119 _("all") :
120 /* L10N: Status bar message: the end of the email is visible in the pager */
121 _("end");
122 mutt_str_copy(pager_progress_str, msg, sizeof(pager_progress_str));
123 }
124
125 if ((priv->pview->mode == PAGER_MODE_EMAIL) || (priv->pview->mode == PAGER_MODE_ATTACH_E))
126 {
127 int msg_in_pager = shared->mailbox_view ? shared->mailbox_view->msg_in_pager : -1;
128
129 const struct Expando *c_pager_format = cs_subset_expando(shared->sub, "pager_format");
130 mutt_make_string(buf, win->state.cols, c_pager_format, shared->mailbox, msg_in_pager,
131 shared->email, MUTT_FORMAT_NONE, pager_progress_str);
132 }
133 else
134 {
135 buf_printf(buf, "%s (%s)", priv->pview->banner, pager_progress_str);
136 }
137
138 if (!mutt_str_equal(buf_string(buf), pbar_data->pager_format))
139 {
140 mutt_str_replace(&pbar_data->pager_format, buf_string(buf));
141 win->actions |= WA_REPAINT;
142 }
143
144 buf_pool_release(&buf);
145 return 0;
146}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
int mutt_make_string(struct Buffer *buf, size_t max_cols, const struct Expando *exp, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
Definition dlg_index.c:824
#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:586
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition lib.h:139
@ PAGER_MODE_ATTACH_E
A special case of PAGER_MODE_ATTACH - attachment is a full-blown email message.
Definition lib.h:141
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:51
int msg_in_pager
Message currently shown in the pager.
Definition mview.h:45
Data to draw the Pager Bar.
Definition pbar.c:81
struct PagerPrivateData * priv
Private Pager data.
Definition pbar.c:83
char * pager_format
Cached status string.
Definition pbar.c:84
struct IndexSharedData * shared
Shared Index data.
Definition pbar.c:82
Private state data for the Pager.
int cur_line
Current line (last line visible on screen)
int lines_used
Size of lines array (used entries)
struct Line * lines
Array of text lines in pager.
LOFF_T bytes_read
Number of bytes read from file.
int top_line
First visible line on screen.
struct stat st
Stats about Email file.
struct PagerView * pview
Object to view in the pager.
enum PagerMode mode
Pager mode.
Definition lib.h:175
const char * banner
Title to display in status bar.
Definition lib.h:177
+ 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 135 of file window.c.

136{
137 if (!win || !win->wdata)
138 return -1;
139
140 struct ProgressWindowData *wdata = win->wdata;
141 wdata->display_pos = wdata->update_pos;
142 wdata->display_time = wdata->update_time;
143
144 if (wdata->is_bytes)
145 {
146 struct Buffer *pretty = buf_pool_get();
147 mutt_str_pretty_size(pretty, wdata->display_pos);
148 mutt_str_copy(wdata->pretty_pos, buf_string(pretty), sizeof(wdata->pretty_pos));
149 buf_pool_release(&pretty);
150 }
151
152 if ((wdata->update_percent < 0) && (wdata->size != 0))
153 wdata->display_percent = MIN(100 * wdata->display_pos / wdata->size, 100);
154 else
155 wdata->display_percent = wdata->update_percent;
156
157 win->actions |= WA_REPAINT;
158 return 0;
159}
#define MIN(a, b)
Return the minimum of two values.
Definition memory.h:40
int mutt_str_pretty_size(struct Buffer *buf, size_t num)
Display an abbreviated size, like 3.4K.
Definition muttlib.c:935
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 557 of file window.c.

558{
560 struct IndexSharedData *shared = wdata->shared;
561
562 if (ARRAY_EMPTY(&wdata->entries))
563 {
564 struct MailboxArray ma = neomutt_mailboxes_get(NeoMutt, MUTT_MAILBOX_ANY);
565 struct Mailbox **mp = NULL;
566 ARRAY_FOREACH(mp, &ma)
567 {
568 struct Mailbox *m = *mp;
569
570 if (m->visible)
571 sb_add_mailbox(wdata, m);
572 }
573 ARRAY_FREE(&ma); // Clean up the ARRAY, but not the Mailboxes
574 }
575
576 if (!prepare_sidebar(wdata, win->state.rows))
577 {
578 win->actions |= WA_REPAINT;
579 return 0;
580 }
581
582 int num_rows = win->state.rows;
583 int num_cols = win->state.cols;
584
585 if (ARRAY_EMPTY(&wdata->entries) || (num_rows <= 0))
586 return 0;
587
588 if (wdata->top_index < 0)
589 return 0;
590
591 int width = num_cols - wdata->divider_width;
592 int row = 0;
593 struct Mailbox *m_cur = shared->mailbox;
594 struct SbEntry **sbep = NULL;
595 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->top_index)
596 {
597 if (row >= num_rows)
598 break;
599
600 if ((*sbep)->is_hidden)
601 continue;
602
603 struct SbEntry *entry = (*sbep);
604 struct Mailbox *m = entry->mailbox;
605
606 const int entryidx = ARRAY_FOREACH_IDX_sbep;
607 entry->color = calc_color(m, (entryidx == wdata->opn_index),
608 (entryidx == wdata->hil_index));
609
610 if (m_cur && (m_cur->realpath[0] != '\0') &&
611 mutt_str_equal(m->realpath, m_cur->realpath))
612 {
613 m->msg_unread = m_cur->msg_unread;
614 m->msg_count = m_cur->msg_count;
615 m->msg_flagged = m_cur->msg_flagged;
616 }
617
619 make_sidebar_entry(entry->display, sizeof(entry->display), width, entry, shared);
620 row++;
621 }
622
623 win->actions |= WA_REPAINT;
624 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
625 return 0;
626}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition array.h:235
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition mailbox.h:41
struct MailboxArray neomutt_mailboxes_get(struct NeoMutt *n, enum MailboxType type)
Get an Array of matching Mailboxes.
Definition neomutt.c:604
void sb_add_mailbox(struct SidebarWindowData *wdata, struct Mailbox *m)
Add a Mailbox to the Sidebar.
Definition sidebar.c:99
struct SidebarWindowData * sb_wdata_get(struct MuttWindow *win)
Get the Sidebar data for this window.
Definition wdata.c:77
static const struct AttrColor * calc_color(const struct Mailbox *m, bool current, bool highlight)
Calculate the colour of a Sidebar row.
Definition window.c:222
void sb_entry_set_display_name(struct SbEntry *entry)
Set the display name for an SbEntry.
Definition window.c:306
static bool prepare_sidebar(struct SidebarWindowData *wdata, int page_size)
Prepare the list of SbEntry's for the sidebar display.
Definition window.c:472
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:359
A mailbox.
Definition mailbox.h:81
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition mailbox.h:83
int msg_count
Total number of messages.
Definition mailbox.h:90
bool visible
True if a result of "mailboxes".
Definition mailbox.h:132
int msg_flagged
Number of flagged messages.
Definition mailbox.h:92
int msg_unread
Number of unread messages.
Definition mailbox.h:91
Info about folders in the sidebar.
Definition private.h:40
const struct AttrColor * color
Colour to use.
Definition private.h:46
char display[256]
Formatted string to display.
Definition private.h:42
struct Mailbox * mailbox
Mailbox this represents.
Definition private.h:44
Sidebar private Window data -.
Definition private.h:89
int top_index
First mailbox visible in sidebar.
Definition private.h:94
short divider_width
Width of the divider in screen columns.
Definition private.h:103
int hil_index
Highlighted mailbox.
Definition private.h:96
struct IndexSharedData * shared
Shared Index Data.
Definition private.h:91
int opn_index
Current (open) mailbox.
Definition private.h:95
struct MuttWindow * win
Sidebar Window.
Definition private.h:90
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: