NeoMutt  2024-03-23-23-gec7045
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Sidebar Function API

Prototype for a Sidebar Function. More...

+ Collaboration diagram for Sidebar Function API:

Functions

static int op_sidebar_first (struct SidebarWindowData *wdata, int op)
 Selects the first unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_last (struct SidebarWindowData *wdata, int op)
 Selects the last unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_next (struct SidebarWindowData *wdata, int op)
 Selects the next unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_next_new (struct SidebarWindowData *wdata, int op)
 Selects the next new mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_open (struct SidebarWindowData *wdata, int op)
 Open highlighted mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_page_down (struct SidebarWindowData *wdata, int op)
 Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.
 
static int op_sidebar_page_up (struct SidebarWindowData *wdata, int op)
 Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.
 
static int op_sidebar_prev (struct SidebarWindowData *wdata, int op)
 Selects the previous unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_prev_new (struct SidebarWindowData *wdata, int op)
 Selects the previous new mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_visible (struct SidebarWindowData *wdata, int op)
 Make the sidebar (in)visible - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_virtual (struct SidebarWindowData *wdata, int op)
 Deprecated - Implements sidebar_function_t -.
 

Detailed Description

Prototype for a Sidebar Function.

Parameters
wdataSidebar Window data
opOperation to perform, e.g. OP_SIDEBAR_NEXT
Return values
enumFunctionRetval

Function Documentation

◆ op_sidebar_first()

static int op_sidebar_first ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the first unhidden mailbox - Implements sidebar_function_t -.

Definition at line 129 of file functions.c.

130{
131 if (!mutt_window_is_visible(wdata->win))
132 return FR_NO_ACTION;
133
134 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
135 return FR_NO_ACTION;
136
137 int orig_hil_index = wdata->hil_index;
138
139 wdata->hil_index = 0;
140 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
141 if (!sb_next(wdata))
142 wdata->hil_index = orig_hil_index;
143
144 if (orig_hil_index == wdata->hil_index)
145 return FR_NO_ACTION;
146
147 wdata->win->actions |= WA_RECALC;
148 return FR_SUCCESS;
149}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:74
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:109
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:512
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:110
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
Definition: functions.c:47
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
int hil_index
Highlighted mailbox.
Definition: private.h:95
struct MuttWindow * win
Sidebar Window.
Definition: private.h:89
struct SbEntryArray entries
Items to display in the sidebar.
Definition: private.h:91
+ Here is the call graph for this function:

◆ op_sidebar_last()

static int op_sidebar_last ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the last unhidden mailbox - Implements sidebar_function_t -.

Definition at line 154 of file functions.c.

155{
156 if (!mutt_window_is_visible(wdata->win))
157 return FR_NO_ACTION;
158
159 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
160 return FR_NO_ACTION;
161
162 int orig_hil_index = wdata->hil_index;
163
164 wdata->hil_index = ARRAY_SIZE(&wdata->entries);
165 if (!sb_prev(wdata))
166 wdata->hil_index = orig_hil_index;
167
168 if (orig_hil_index == wdata->hil_index)
169 return FR_NO_ACTION;
170
171 wdata->win->actions |= WA_RECALC;
172 return FR_SUCCESS;
173}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
bool sb_prev(struct SidebarWindowData *wdata)
Find the previous unhidden Mailbox.
Definition: functions.c:86
+ Here is the call graph for this function:

◆ op_sidebar_next()

static int op_sidebar_next ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the next unhidden mailbox - Implements sidebar_function_t -.

Definition at line 178 of file functions.c.

179{
180 if (!mutt_window_is_visible(wdata->win))
181 return FR_NO_ACTION;
182
183 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
184 return FR_NO_ACTION;
185
186 if (!sb_next(wdata))
187 return FR_NO_ACTION;
188
189 wdata->win->actions |= WA_RECALC;
190 return FR_SUCCESS;
191}
+ Here is the call graph for this function:

◆ op_sidebar_next_new()

static int op_sidebar_next_new ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the next new mailbox - Implements sidebar_function_t -.

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

Definition at line 198 of file functions.c.

199{
200 if (!mutt_window_is_visible(wdata->win))
201 return FR_NO_ACTION;
202
203 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
204 if ((max_entries == 0) || (wdata->hil_index < 0))
205 return FR_NO_ACTION;
206
207 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
208 struct SbEntry **sbep = NULL;
209 if ((sbep = sb_next_new(wdata, wdata->hil_index + 1, max_entries)) ||
210 (c_sidebar_next_new_wrap && (sbep = sb_next_new(wdata, 0, wdata->hil_index))))
211 {
212 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
213 wdata->win->actions |= WA_RECALC;
214 return FR_SUCCESS;
215 }
216
217 return FR_NO_ACTION;
218}
#define ARRAY_IDX(head, elem)
Return the index of an element of the array.
Definition: array.h:259
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
static struct SbEntry ** sb_next_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
Return the next mailbox with new messages.
Definition: functions.c:70
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
+ Here is the call graph for this function:

◆ op_sidebar_open()

static int op_sidebar_open ( struct SidebarWindowData wdata,
int  op 
)
static

Open highlighted mailbox - Implements sidebar_function_t -.

Definition at line 223 of file functions.c.

224{
225 struct MuttWindow *win_sidebar = wdata->win;
226 if (!mutt_window_is_visible(win_sidebar))
227 return FR_NO_ACTION;
228
229 struct MuttWindow *dlg = dialog_find(win_sidebar);
230 index_change_folder(dlg, sb_get_highlight(win_sidebar));
231 return FR_SUCCESS;
232}
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:89
void index_change_folder(struct MuttWindow *dlg, struct Mailbox *m)
Change the current folder, cautiously.
Definition: dlg_index.c:1434
struct Mailbox * sb_get_highlight(struct MuttWindow *win)
Get the Mailbox that's highlighted in the sidebar.
Definition: sidebar.c:63
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:

◆ op_sidebar_page_down()

static int op_sidebar_page_down ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.

Definition at line 237 of file functions.c.

238{
239 if (!mutt_window_is_visible(wdata->win))
240 return FR_NO_ACTION;
241
242 if (ARRAY_EMPTY(&wdata->entries) || (wdata->bot_index < 0))
243 return FR_NO_ACTION;
244
245 int orig_hil_index = wdata->hil_index;
246
247 wdata->hil_index = wdata->bot_index;
248 sb_next(wdata);
249 /* If the rest of the entries are hidden, go up to the last unhidden one */
250 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
251 sb_prev(wdata);
252
253 if (orig_hil_index == wdata->hil_index)
254 return FR_NO_ACTION;
255
256 wdata->win->actions |= WA_RECALC;
257 return FR_SUCCESS;
258}
int bot_index
Last mailbox visible in sidebar.
Definition: private.h:96
+ Here is the call graph for this function:

◆ op_sidebar_page_up()

static int op_sidebar_page_up ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.

Definition at line 263 of file functions.c.

264{
265 if (!mutt_window_is_visible(wdata->win))
266 return FR_NO_ACTION;
267
268 if (ARRAY_EMPTY(&wdata->entries) || (wdata->top_index < 0))
269 return FR_NO_ACTION;
270
271 int orig_hil_index = wdata->hil_index;
272
273 wdata->hil_index = wdata->top_index;
274 sb_prev(wdata);
275 /* If the rest of the entries are hidden, go down to the last unhidden one */
276 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
277 sb_next(wdata);
278
279 if (orig_hil_index == wdata->hil_index)
280 return FR_NO_ACTION;
281
282 wdata->win->actions |= WA_RECALC;
283 return FR_SUCCESS;
284}
int top_index
First mailbox visible in sidebar.
Definition: private.h:93
+ Here is the call graph for this function:

◆ op_sidebar_prev()

static int op_sidebar_prev ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the previous unhidden mailbox - Implements sidebar_function_t -.

Definition at line 289 of file functions.c.

290{
291 if (!mutt_window_is_visible(wdata->win))
292 return FR_NO_ACTION;
293
294 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
295 return FR_NO_ACTION;
296
297 if (!sb_prev(wdata))
298 return FR_NO_ACTION;
299
300 wdata->win->actions |= WA_RECALC;
301 return FR_SUCCESS;
302}
+ Here is the call graph for this function:

◆ op_sidebar_prev_new()

static int op_sidebar_prev_new ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the previous new mailbox - Implements sidebar_function_t -.

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

Definition at line 309 of file functions.c.

310{
311 if (!mutt_window_is_visible(wdata->win))
312 return FR_NO_ACTION;
313
314 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
315 if ((max_entries == 0) || (wdata->hil_index < 0))
316 return FR_NO_ACTION;
317
318 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
319 struct SbEntry **sbep = NULL;
320 if ((sbep = sb_prev_new(wdata, 0, wdata->hil_index)) ||
321 (c_sidebar_next_new_wrap &&
322 (sbep = sb_prev_new(wdata, wdata->hil_index + 1, max_entries))))
323 {
324 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
325 wdata->win->actions |= WA_RECALC;
326 return FR_SUCCESS;
327 }
328
329 return FR_NO_ACTION;
330}
static struct SbEntry ** sb_prev_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
Return the previous mailbox with new messages.
Definition: functions.c:112
+ Here is the call graph for this function:

◆ op_sidebar_toggle_visible()

static int op_sidebar_toggle_visible ( struct SidebarWindowData wdata,
int  op 
)
static

Make the sidebar (in)visible - Implements sidebar_function_t -.

Definition at line 335 of file functions.c.

336{
337 bool_str_toggle(NeoMutt->sub, "sidebar_visible", NULL);
338 mutt_window_reflow(NULL);
339 return FR_SUCCESS;
340}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:224
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:344
+ Here is the call graph for this function:

◆ op_sidebar_toggle_virtual()

static int op_sidebar_toggle_virtual ( struct SidebarWindowData wdata,
int  op 
)
static

Deprecated - Implements sidebar_function_t -.

Definition at line 345 of file functions.c.

346{
347 return FR_SUCCESS;
348}