NeoMutt  2025-12-11-435-g4ac674
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, const struct KeyEvent *event)
 Selects the first unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_last (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the last unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_next (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the next unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_next_new (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the next new mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_open (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Open highlighted mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_page_down (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.
 
static int op_sidebar_page_up (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.
 
static int op_sidebar_prev (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the previous unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_prev_new (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the previous new mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_visible (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Make the sidebar (in)visible - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_virtual (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Deprecated - Implements sidebar_function_t -.
 

Detailed Description

Prototype for a Sidebar Function.

Parameters
wdataSidebar Window data
eventEvent to process
Return values
enumFunctionRetval
Precondition
wdata is not NULL
event is not NULL

Function Documentation

◆ op_sidebar_first()

static int op_sidebar_first ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

Selects the first unhidden mailbox - Implements sidebar_function_t -.

Definition at line 182 of file functions.c.

183{
184 if (!mutt_window_is_visible(wdata->win))
185 return FR_NO_ACTION;
186
187 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
188 return FR_NO_ACTION;
189
190 int orig_hil_index = wdata->hil_index;
191
192 wdata->hil_index = 0;
193 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
194 if (!sb_next(wdata))
195 wdata->hil_index = orig_hil_index;
196
197 if (orig_hil_index == wdata->hil_index)
198 return FR_NO_ACTION;
199
200 wdata->win->actions |= WA_RECALC;
201 return FR_SUCCESS;
202}
#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:40
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
#define WA_RECALC
Recalculate the contents of the Window.
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
Definition functions.c:100
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
int hil_index
Highlighted mailbox.
Definition private.h:96
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:

◆ op_sidebar_last()

static int op_sidebar_last ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

Selects the last unhidden mailbox - Implements sidebar_function_t -.

Definition at line 207 of file functions.c.

208{
209 if (!mutt_window_is_visible(wdata->win))
210 return FR_NO_ACTION;
211
212 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
213 return FR_NO_ACTION;
214
215 int orig_hil_index = wdata->hil_index;
216
217 wdata->hil_index = ARRAY_SIZE(&wdata->entries);
218 if (!sb_prev(wdata))
219 wdata->hil_index = orig_hil_index;
220
221 if (orig_hil_index == wdata->hil_index)
222 return FR_NO_ACTION;
223
224 wdata->win->actions |= WA_RECALC;
225 return FR_SUCCESS;
226}
#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:139
+ Here is the call graph for this function:

◆ op_sidebar_next()

static int op_sidebar_next ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

Selects the next unhidden mailbox - Implements sidebar_function_t -.

Definition at line 231 of file functions.c.

232{
233 if (!mutt_window_is_visible(wdata->win))
234 return FR_NO_ACTION;
235
236 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
237 return FR_NO_ACTION;
238
239 if (!sb_next(wdata))
240 return FR_NO_ACTION;
241
242 wdata->win->actions |= WA_RECALC;
243 return FR_SUCCESS;
244}
+ Here is the call graph for this function:

◆ op_sidebar_next_new()

static int op_sidebar_next_new ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
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 251 of file functions.c.

252{
253 if (!mutt_window_is_visible(wdata->win))
254 return FR_NO_ACTION;
255
256 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
257 if ((max_entries == 0) || (wdata->hil_index < 0))
258 return FR_NO_ACTION;
259
260 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
261 struct SbEntry **sbep = NULL;
262 if ((sbep = sb_next_new(wdata, wdata->hil_index + 1, max_entries)) ||
263 (c_sidebar_next_new_wrap && (sbep = sb_next_new(wdata, 0, wdata->hil_index))))
264 {
265 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
266 wdata->win->actions |= WA_RECALC;
267 return FR_SUCCESS;
268 }
269
270 return FR_NO_ACTION;
271}
#define ARRAY_IDX(head, elem)
Return the index of an element of the array.
Definition array.h:324
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
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:123
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Info about folders in the sidebar.
Definition private.h:42
+ Here is the call graph for this function:

◆ op_sidebar_open()

static int op_sidebar_open ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

Open highlighted mailbox - Implements sidebar_function_t -.

Definition at line 276 of file functions.c.

277{
278 struct MuttWindow *win_sidebar = wdata->win;
279 if (!mutt_window_is_visible(win_sidebar))
280 return FR_NO_ACTION;
281
282 struct MuttWindow *dlg = dialog_find(win_sidebar);
283 index_change_folder(dlg, sb_get_highlight(win_sidebar));
284 return FR_SUCCESS;
285}
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:1465
struct Mailbox * sb_get_highlight(struct MuttWindow *win)
Get the Mailbox that's highlighted in the sidebar.
Definition sidebar.c:75
void * wdata
Private data.
+ Here is the call graph for this function:

◆ op_sidebar_page_down()

static int op_sidebar_page_down ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

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

Definition at line 290 of file functions.c.

291{
292 if (!mutt_window_is_visible(wdata->win))
293 return FR_NO_ACTION;
294
295 if (ARRAY_EMPTY(&wdata->entries) || (wdata->bot_index < 0))
296 return FR_NO_ACTION;
297
298 int orig_hil_index = wdata->hil_index;
299
300 wdata->hil_index = wdata->bot_index;
301 sb_next(wdata);
302 /* If the rest of the entries are hidden, go up to the last unhidden one */
303 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
304 sb_prev(wdata);
305
306 if (orig_hil_index == wdata->hil_index)
307 return FR_NO_ACTION;
308
309 wdata->win->actions |= WA_RECALC;
310 return FR_SUCCESS;
311}
int bot_index
Last mailbox visible in sidebar.
Definition private.h:97
+ Here is the call graph for this function:

◆ op_sidebar_page_up()

static int op_sidebar_page_up ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

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

Definition at line 316 of file functions.c.

317{
318 if (!mutt_window_is_visible(wdata->win))
319 return FR_NO_ACTION;
320
321 if (ARRAY_EMPTY(&wdata->entries) || (wdata->top_index < 0))
322 return FR_NO_ACTION;
323
324 int orig_hil_index = wdata->hil_index;
325
326 wdata->hil_index = wdata->top_index;
327 sb_prev(wdata);
328 /* If the rest of the entries are hidden, go down to the last unhidden one */
329 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
330 sb_next(wdata);
331
332 if (orig_hil_index == wdata->hil_index)
333 return FR_NO_ACTION;
334
335 wdata->win->actions |= WA_RECALC;
336 return FR_SUCCESS;
337}
int top_index
First mailbox visible in sidebar.
Definition private.h:94
+ Here is the call graph for this function:

◆ op_sidebar_prev()

static int op_sidebar_prev ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

Selects the previous unhidden mailbox - Implements sidebar_function_t -.

Definition at line 342 of file functions.c.

343{
344 if (!mutt_window_is_visible(wdata->win))
345 return FR_NO_ACTION;
346
347 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
348 return FR_NO_ACTION;
349
350 if (!sb_prev(wdata))
351 return FR_NO_ACTION;
352
353 wdata->win->actions |= WA_RECALC;
354 return FR_SUCCESS;
355}
+ Here is the call graph for this function:

◆ op_sidebar_prev_new()

static int op_sidebar_prev_new ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
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 362 of file functions.c.

363{
364 if (!mutt_window_is_visible(wdata->win))
365 return FR_NO_ACTION;
366
367 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
368 if ((max_entries == 0) || (wdata->hil_index < 0))
369 return FR_NO_ACTION;
370
371 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
372 struct SbEntry **sbep = NULL;
373 if ((sbep = sb_prev_new(wdata, 0, wdata->hil_index)) ||
374 (c_sidebar_next_new_wrap &&
375 (sbep = sb_prev_new(wdata, wdata->hil_index + 1, max_entries))))
376 {
377 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
378 wdata->win->actions |= WA_RECALC;
379 return FR_SUCCESS;
380 }
381
382 return FR_NO_ACTION;
383}
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:165
+ Here is the call graph for this function:

◆ op_sidebar_toggle_visible()

static int op_sidebar_toggle_visible ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

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

Definition at line 388 of file functions.c.

390{
391 bool_str_toggle(NeoMutt->sub, "sidebar_visible", NULL);
392 mutt_window_reflow(NULL);
393 return FR_SUCCESS;
394}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition bool.c:229
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
+ Here is the call graph for this function:

◆ op_sidebar_toggle_virtual()

static int op_sidebar_toggle_virtual ( struct SidebarWindowData * wdata,
const struct KeyEvent * event )
static

Deprecated - Implements sidebar_function_t -.

Definition at line 399 of file functions.c.

401{
402 return FR_SUCCESS;
403}