NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
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() -. More...
 
int attach_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -. More...
 
static int cbar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -. More...
 
static int env_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -. More...
 
static int msgwin_recalc (struct MuttWindow *win)
 Recalculate the display of the Message Window - Implements MuttWindow::recalc() -. More...
 
static int sbar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -. More...
 
static int helpbar_recalc (struct MuttWindow *win)
 Recalculate the display of the Help Bar - Implements MuttWindow::recalc() -Generate the help string from data on the focused Window. More...
 
static int ibar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -. More...
 
static int menu_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -. More...
 
static int pbar_recalc (struct MuttWindow *win)
 Recalculate the Window data - Implements MuttWindow::recalc() -. More...
 
int sb_recalc (struct MuttWindow *win)
 Recalculate the Sidebar display - Implements MuttWindow::recalc() -. More...
 

Detailed Description

Recalculate the Window data.

Parameters
winWindow
Return values
0Success
-1Error

Function Documentation

◆ alias_recalc()

int alias_recalc ( struct MuttWindow win)

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

Definition at line 87 of file gui.c.

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

◆ attach_recalc()

int attach_recalc ( struct MuttWindow win)

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

Definition at line 131 of file attach.c.

132 {
133 #if 0
134  struct ComposeBarData *attach_data = win->wdata;
135  struct ComposeRedrawData *rd = attach_data->rd;
136 
137  char buf[1024] = { 0 };
138  const char *const c_compose_format =
139  cs_subset_string(rd->sub, "compose_format");
140  mutt_expando_format(buf, sizeof(buf), 0, win->state.cols, NONULL(c_compose_format),
141  compose_format_str, (intptr_t) rd->menu, MUTT_FORMAT_NO_FLAGS);
142 
143  if (!mutt_str_equal(buf, attach_data->compose_format))
144  {
145  mutt_str_replace(&attach_data->compose_format, buf);
146  win->actions |= WA_REPAINT;
147  }
148 #endif
149  win->actions |= WA_REPAINT;
150  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
151  return 0;
152 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
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:780
#define NONULL(x)
Definition: string2.h:37
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
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 -Expando Description %a Total nu...
Definition: cbar.c:103
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
Data to fill the Compose Bar Window.
Definition: cbar_data.h:33
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
char * compose_format
Cached status string.
Definition: cbar_data.h:35
Log at debug level 5.
Definition: logging.h:44
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:

◆ cbar_recalc()

static int cbar_recalc ( struct MuttWindow win)
static

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

Definition at line 158 of file cbar.c.

159 {
160  char buf[1024] = { 0 };
161  struct ComposeSharedData *shared = win->parent->wdata;
162 
163  const char *const c_compose_format =
164  cs_subset_string(shared->sub, "compose_format");
165  mutt_expando_format(buf, sizeof(buf), 0, win->state.cols, NONULL(c_compose_format),
166  compose_format_str, (intptr_t) shared, MUTT_FORMAT_NO_FLAGS);
167 
168  struct ComposeBarData *cbar_data = win->wdata;
169  if (!mutt_str_equal(buf, cbar_data->compose_format))
170  {
171  mutt_str_replace(&cbar_data->compose_format, buf);
172  win->actions |= WA_REPAINT;
173  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
174  }
175 
176  return 0;
177 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
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:780
#define NONULL(x)
Definition: string2.h:37
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
Shared Compose Data.
Definition: shared_data.h:29
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 -Expando Description %a Total nu...
Definition: cbar.c:103
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
Data to fill the Compose Bar Window.
Definition: cbar_data.h:33
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
char * compose_format
Cached status string.
Definition: cbar_data.h:35
Log at debug level 5.
Definition: logging.h:44
void * wdata
Private data.
Definition: mutt_window.h:145
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:31
+ Here is the call graph for this function:
+ 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 665 of file envelope.c.

666 {
667  struct ComposeSharedData *shared = win->parent->wdata;
668  struct ComposeEnvelopeData *edata = win->wdata;
669 
670  const int cur_rows = win->state.rows;
671  const int new_rows = calc_envelope(win, shared, edata);
672 
673  if (new_rows != cur_rows)
674  {
675  win->req_rows = new_rows;
677  }
678 
679  win->actions |= WA_REPAINT;
680  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
681  return 0;
682 }
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
static int calc_envelope(struct MuttWindow *win, struct ComposeSharedData *shared, struct ComposeEnvelopeData *edata)
Calculate how many rows the envelope will need.
Definition: envelope.c:210
Shared Compose Data.
Definition: shared_data.h:29
Data to fill the Compose Envelope Window.
Definition: env_data.h:37
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:361
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
short req_rows
Number of rows required.
Definition: mutt_window.h:125
Log at debug level 5.
Definition: logging.h:44
void * wdata
Private data.
Definition: mutt_window.h:145
+ 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 104 of file msgwin.c.

105 {
106  if (window_is_focused(win)) // Someone else is using it
107  return 0;
108 
109  win->actions |= WA_REPAINT;
110  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
111  return 0;
112 }
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
bool window_is_focused(struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:650
Log at debug level 5.
Definition: logging.h:44
+ Here is the call graph for this function:
+ 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 81 of file sbar.c.

82 {
83  if (!win)
84  return -1;
85 
86  win->actions |= WA_REPAINT;
87  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
88  return 0;
89 }
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Log at debug level 5.
Definition: logging.h:44
+ 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 143 of file helpbar.c.

144 {
146  if (!wdata)
147  return 0;
148 
149  FREE(&wdata->help_str);
150 
152  if (!win_focus)
153  return 0;
154 
155  // Ascend the Window tree until we find help_data
156  while (win_focus && !win_focus->help_data)
157  win_focus = win_focus->parent;
158 
159  if (!win_focus)
160  return 0;
161 
162  char helpstr[1024] = { 0 };
163  compile_help(helpstr, sizeof(helpstr), win_focus->help_menu, win_focus->help_data);
164 
165  wdata->help_menu = win_focus->help_menu;
166  wdata->help_data = win_focus->help_data;
167  wdata->help_str = mutt_str_dup(helpstr);
168 
169  win->actions |= WA_REPAINT;
170  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
171  return 0;
172 }
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
char * help_str
Formatted Help Bar string.
Definition: private.h:37
struct HelpbarWindowData * helpbar_wdata_get(struct MuttWindow *win)
Get the Helpbar data for this window.
Definition: wdata.c:61
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
static struct MuttWindow * win_focus
Definition: window.c:36
struct MuttWindow * window_get_focus(void)
Get the currently focussed Window.
Definition: mutt_window.c:664
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: private.h:35
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
const struct Mapping * help_data
Data for the Help Bar.
Definition: private.h:36
Help Bar Window data -.
Definition: private.h:33
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
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:116
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
#define FREE(x)
Definition: memory.h:40
Log at debug level 5.
Definition: logging.h:44
void * wdata
Private data.
Definition: mutt_window.h:145
+ 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 90 of file ibar.c.

91 {
92  char buf[1024] = { 0 };
93 
94  struct IBarPrivateData *ibar_data = win->wdata;
95  struct IndexSharedData *shared = ibar_data->shared;
96  struct IndexPrivateData *priv = ibar_data->priv;
97 
98  const char *c_status_format = cs_subset_string(shared->sub, "status_format");
99  menu_status_line(buf, sizeof(buf), shared, priv->menu, win->state.cols,
100  NONULL(c_status_format));
101 
102  if (!mutt_str_equal(buf, ibar_data->status_format))
103  {
104  mutt_str_replace(&ibar_data->status_format, buf);
105  win->actions |= WA_REPAINT;
106  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
107  }
108 
109  const bool c_ts_enabled = cs_subset_bool(shared->sub, "ts_enabled");
110  if (c_ts_enabled && TsSupported)
111  {
112  const char *c_ts_status_format =
113  cs_subset_string(shared->sub, "ts_status_format");
114  menu_status_line(buf, sizeof(buf), shared, priv->menu, sizeof(buf),
115  NONULL(c_ts_status_format));
116  if (!mutt_str_equal(buf, ibar_data->ts_status_format))
117  {
118  mutt_str_replace(&ibar_data->ts_status_format, buf);
119  win->actions |= WA_REPAINT;
120  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
121  }
122 
123  const char *c_ts_icon_format =
124  cs_subset_string(shared->sub, "ts_icon_format");
125  menu_status_line(buf, sizeof(buf), shared, priv->menu, sizeof(buf),
126  NONULL(c_ts_icon_format));
127  if (!mutt_str_equal(buf, ibar_data->ts_icon_format))
128  {
129  mutt_str_replace(&ibar_data->ts_icon_format, buf);
130  win->actions |= WA_REPAINT;
131  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
132  }
133  }
134 
135  return 0;
136 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
char * ts_icon_format
Cached terminal icon string.
Definition: ibar.c:84
#define NONULL(x)
Definition: string2.h:37
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
struct IndexSharedData * shared
Shared Index data.
Definition: ibar.c:80
struct Menu * menu
Menu controlling the index.
Definition: private_data.h:44
Private state data for the Index.
Definition: private_data.h:34
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:38
char * status_format
Cached screen status string.
Definition: ibar.c:82
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:36
char * ts_status_format
Cached terminal status string.
Definition: ibar.c:83
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
struct IndexPrivateData * priv
Private Index data.
Definition: ibar.c:81
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
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:445
bool TsSupported
Terminal Setting is supported.
Definition: terminal.c:43
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Data to draw the Index Bar.
Definition: ibar.c:78
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
Log at debug level 5.
Definition: logging.h:44
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:
+ 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 82 of file window.c.

83 {
84  if (win->type != WT_MENU)
85  return 0;
86 
87  // struct Menu *menu = win->wdata;
88 
89  win->actions |= WA_REPAINT;
90  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
91  return 0;
92 }
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Log at debug level 5.
Definition: logging.h:44
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
An Window containing a Menu.
Definition: mutt_window.h:98
+ 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  if (!mutt_window_is_visible(win))
96  return 0;
97 
98  char buf[1024] = { 0 };
99 
100  struct PBarPrivateData *pbar_data = win->wdata;
101  struct IndexSharedData *shared = pbar_data->shared;
102  struct PagerPrivateData *priv = pbar_data->priv;
103 
104  char pager_progress_str[65]; /* Lots of space for translations */
105  if (priv->last_pos < priv->sb.st_size - 1)
106  {
107  snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%",
108  (100 * priv->last_offset / priv->sb.st_size));
109  }
110  else
111  {
112  const char *msg = (priv->topline == 0) ?
113  /* L10N: Status bar message: the entire email is visible in the pager */
114  _("all") :
115  /* L10N: Status bar message: the end of the email is visible in the pager */
116  _("end");
117  mutt_str_copy(pager_progress_str, msg, sizeof(pager_progress_str));
118  }
119 
120  if ((priv->pview->mode == PAGER_MODE_EMAIL) || (priv->pview->mode == PAGER_MODE_ATTACH_E))
121  {
122  int msg_in_pager = shared->ctx ? shared->ctx->msg_in_pager : -1;
123 
124  const char *c_pager_format = cs_subset_string(shared->sub, "pager_format");
125  mutt_make_string(buf, sizeof(buf), win->state.cols, NONULL(c_pager_format),
126  shared->mailbox, msg_in_pager, shared->email,
127  MUTT_FORMAT_NO_FLAGS, pager_progress_str);
128  }
129  else
130  {
131  snprintf(buf, sizeof(buf), "%s (%s)", priv->pview->banner, pager_progress_str);
132  }
133 
134  if (!mutt_str_equal(buf, pbar_data->pager_format))
135  {
136  mutt_str_replace(&pbar_data->pager_format, buf);
137  win->actions |= WA_REPAINT;
138  }
139 
140  return 0;
141 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
#define NONULL(x)
Definition: string2.h:37
int msg_in_pager
Message currently shown in the pager.
Definition: context.h:43
struct stat sb
Definition: private_data.h:67
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:38
struct IndexSharedData * shared
Shared Index data.
Definition: pbar.c:85
#define _(a)
Definition: message.h:28
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:36
A special case of PAGER_MODE_ATTACH - attachment is a full-blown email message.
Definition: lib.h:133
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
Private state data for the Pager.
Definition: private_data.h:39
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
char * pager_format
Cached status string.
Definition: pbar.c:87
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:1409
struct Context * ctx
Current Mailbox view.
Definition: shared_data.h:39
enum PagerMode mode
Pager mode.
Definition: lib.h:157
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:131
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:529
struct PagerPrivateData * priv
Private Pager data.
Definition: pbar.c:86
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
Data to draw the Pager Bar.
Definition: pbar.c:83
struct PagerView * pview
Definition: private_data.h:44
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:749
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
const char * banner
Title to display in status bar.
Definition: lib.h:159
void * wdata
Private data.
Definition: mutt_window.h:145
+ 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 695 of file window.c.

696 {
697  if (!mutt_window_is_visible(win))
698  return 0;
699 
700  struct SidebarWindowData *wdata = sb_wdata_get(win);
701  struct IndexSharedData *shared = wdata->shared;
702 
703  if (ARRAY_EMPTY(&wdata->entries))
704  {
705  struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
707  struct MailboxNode *np = NULL;
708  STAILQ_FOREACH(np, &ml, entries)
709  {
710  if (!(np->mailbox->flags & MB_HIDDEN))
711  sb_add_mailbox(wdata, np->mailbox);
712  }
714  }
715 
716  if (!prepare_sidebar(wdata, win->state.rows))
717  {
718  win->actions |= WA_REPAINT;
719  return 0;
720  }
721 
722  int num_rows = win->state.rows;
723  int num_cols = win->state.cols;
724 
725  if (ARRAY_EMPTY(&wdata->entries) || (num_rows <= 0))
726  return 0;
727 
728  if (wdata->top_index < 0)
729  return 0;
730 
731  int width = num_cols - wdata->divider_width;
732  int row = 0;
733  struct Mailbox *m_cur = shared->mailbox;
734  struct SbEntry **sbep = NULL;
735  ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->top_index)
736  {
737  if (row >= num_rows)
738  break;
739 
740  if ((*sbep)->is_hidden)
741  continue;
742 
743  struct SbEntry *entry = (*sbep);
744  struct Mailbox *m = entry->mailbox;
745 
746  const int entryidx = ARRAY_FOREACH_IDX;
747  entry->color =
748  calc_color(m, (entryidx == wdata->opn_index), (entryidx == wdata->hil_index));
749 
750  if (m_cur && (m_cur->realpath[0] != '\0') &&
751  mutt_str_equal(m->realpath, m_cur->realpath))
752  {
753  m->msg_unread = m_cur->msg_unread;
754  m->msg_count = m_cur->msg_count;
755  m->msg_flagged = m_cur->msg_flagged;
756  }
757 
758  const char *path = mailbox_path(m);
759 
760  const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
761  // Try to abbreviate the full path
762  const char *abbr = abbrev_folder(path, c_folder, m->type);
763  if (!abbr)
764  abbr = abbrev_url(path, m->type);
765  const char *short_path = abbr ? abbr : path;
766 
767  /* Compute the depth */
768  const char *last_part = abbr;
769  const char *const c_sidebar_delim_chars =
770  cs_subset_string(NeoMutt->sub, "sidebar_delim_chars");
771  entry->depth = calc_path_depth(abbr, c_sidebar_delim_chars, &last_part);
772 
773  const bool short_path_is_abbr = (short_path == abbr);
774  const bool c_sidebar_short_path =
775  cs_subset_bool(NeoMutt->sub, "sidebar_short_path");
776  if (c_sidebar_short_path)
777  {
778  short_path = last_part;
779  }
780 
781  // Don't indent if we were unable to create an abbreviation.
782  // Otherwise, the full path will be indent, and it looks unusual.
783  const bool c_sidebar_folder_indent =
784  cs_subset_bool(NeoMutt->sub, "sidebar_folder_indent");
785  if (c_sidebar_folder_indent && short_path_is_abbr)
786  {
787  const short c_sidebar_component_depth =
788  cs_subset_number(NeoMutt->sub, "sidebar_component_depth");
789  if (c_sidebar_component_depth > 0)
790  entry->depth -= c_sidebar_component_depth;
791  }
792  else if (!c_sidebar_folder_indent)
793  entry->depth = 0;
794 
795  mutt_str_copy(entry->box, short_path, sizeof(entry->box));
796  make_sidebar_entry(entry->display, sizeof(entry->display), width, entry, shared);
797  row++;
798  }
799 
800  win->actions |= WA_REPAINT;
801  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
802  return 0;
803 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:215
char display[256]
Formatted string to display.
Definition: private.h:42
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
int msg_count
Total number of messages.
Definition: mailbox.h:91
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
int opn_index
Current (open) mailbox.
Definition: private.h:68
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
int top_index
First mailbox visible in sidebar.
Definition: private.h:67
int msg_unread
Number of unread messages.
Definition: mailbox.h:92
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:93
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:141
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
Match any Mailbox type.
Definition: mailbox.h:45
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:164
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:36
Sidebar private Window data -.
Definition: private.h:62
enum ColorId color
Colour to use.
Definition: private.h:46
Info about folders in the sidebar.
Definition: private.h:39
int hil_index
Highlighted mailbox.
Definition: private.h:69
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
Container for Accounts, Notifications.
Definition: neomutt.h:36
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
struct Mailbox * mailbox
Mailbox this represents.
Definition: private.h:44
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
#define MB_HIDDEN
Definition: mailbox.h:38
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
char box[256]
Mailbox path (possibly abbreviated)
Definition: private.h:41
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:529
A mailbox.
Definition: mailbox.h:81
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition: array.h:217
short divider_width
Width of the divider in screen columns.
Definition: private.h:74
uint8_t flags
e.g. MB_NORMAL
Definition: mailbox.h:134
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:749
int depth
Indentation depth.
Definition: private.h:43
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:324
List of Mailboxes.
Definition: mailbox.h:156
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
Log at debug level 5.
Definition: logging.h:44
struct IndexSharedData * shared
Definition: private.h:64
void * wdata
Private data.
Definition: mutt_window.h:145
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:158
+ Here is the call graph for this function:
+ Here is the caller graph for this function: