NeoMutt  2025-12-11-694-ga89709
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 -.
 
static int op_sidebar_abort_search (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Close the Sidebar Search - Implements sidebar_function_t -.
 
static int op_sidebar_start_search (struct SidebarWindowData *wdata, const struct KeyEvent *event)
 Selects the last unhidden mailbox - 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 198 of file functions.c.

199{
200 if (!mutt_window_is_visible(wdata->win))
201 return FR_NO_ACTION;
202
203 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
204 return FR_NO_ACTION;
205
206 int orig_hil_index = wdata->hil_index;
207
208 wdata->hil_index = 0;
209 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
210 if (!sb_next(wdata))
211 wdata->hil_index = orig_hil_index;
212
213 if (orig_hil_index == wdata->hil_index)
214 return FR_NO_ACTION;
215
216 wdata->win->actions |= WA_RECALC;
217 return FR_SUCCESS;
218}
#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:116
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
int hil_index
Highlighted mailbox.
Definition private.h:98
struct MuttWindow * win
Sidebar Window.
Definition private.h:92
struct SbEntryArray entries
Items to display in the sidebar.
Definition private.h:94
+ 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 223 of file functions.c.

224{
225 if (!mutt_window_is_visible(wdata->win))
226 return FR_NO_ACTION;
227
228 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
229 return FR_NO_ACTION;
230
231 int orig_hil_index = wdata->hil_index;
232
233 wdata->hil_index = ARRAY_SIZE(&wdata->entries);
234 if (!sb_prev(wdata))
235 wdata->hil_index = orig_hil_index;
236
237 if (orig_hil_index == wdata->hil_index)
238 return FR_NO_ACTION;
239
240 wdata->win->actions |= WA_RECALC;
241 return FR_SUCCESS;
242}
#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:155
+ 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 247 of file functions.c.

248{
249 if (!mutt_window_is_visible(wdata->win))
250 return FR_NO_ACTION;
251
252 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
253 return FR_NO_ACTION;
254
255 if (!sb_next(wdata))
256 return FR_NO_ACTION;
257
258 wdata->win->actions |= WA_RECALC;
259 return FR_SUCCESS;
260}
+ 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 267 of file functions.c.

268{
269 if (!mutt_window_is_visible(wdata->win))
270 return FR_NO_ACTION;
271
272 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
273 if ((max_entries == 0) || (wdata->hil_index < 0))
274 return FR_NO_ACTION;
275
276 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
277 struct SbEntry **sbep = NULL;
278 if ((sbep = sb_next_new(wdata, wdata->hil_index + 1, max_entries)) ||
279 (c_sidebar_next_new_wrap && (sbep = sb_next_new(wdata, 0, wdata->hil_index))))
280 {
281 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
282 wdata->win->actions |= WA_RECALC;
283 return FR_SUCCESS;
284 }
285
286 return FR_NO_ACTION;
287}
#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:139
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 292 of file functions.c.

293{
294 struct MuttWindow *win_sidebar = wdata->win;
295 if (!mutt_window_is_visible(win_sidebar))
296 return FR_NO_ACTION;
297
298 struct MuttWindow *dlg = dialog_find(win_sidebar);
299 index_change_folder(dlg, sb_get_highlight(win_sidebar));
300 return FR_SUCCESS;
301}
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:1484
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 306 of file functions.c.

307{
308 if (!mutt_window_is_visible(wdata->win))
309 return FR_NO_ACTION;
310
311 if (ARRAY_EMPTY(&wdata->entries) || (wdata->bot_index < 0))
312 return FR_NO_ACTION;
313
314 int orig_hil_index = wdata->hil_index;
315
316 wdata->hil_index = wdata->bot_index;
317 sb_next(wdata);
318 /* If the rest of the entries are hidden, go up to the last unhidden one */
319 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
320 sb_prev(wdata);
321
322 if (orig_hil_index == wdata->hil_index)
323 return FR_NO_ACTION;
324
325 wdata->win->actions |= WA_RECALC;
326 return FR_SUCCESS;
327}
int bot_index
Last mailbox visible in sidebar.
Definition private.h:99
+ 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 332 of file functions.c.

333{
334 if (!mutt_window_is_visible(wdata->win))
335 return FR_NO_ACTION;
336
337 if (ARRAY_EMPTY(&wdata->entries) || (wdata->top_index < 0))
338 return FR_NO_ACTION;
339
340 int orig_hil_index = wdata->hil_index;
341
342 wdata->hil_index = wdata->top_index;
343 sb_prev(wdata);
344 /* If the rest of the entries are hidden, go down to the last unhidden one */
345 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
346 sb_next(wdata);
347
348 if (orig_hil_index == wdata->hil_index)
349 return FR_NO_ACTION;
350
351 wdata->win->actions |= WA_RECALC;
352 return FR_SUCCESS;
353}
int top_index
First mailbox visible in sidebar.
Definition private.h:96
+ 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 358 of file functions.c.

359{
360 if (!mutt_window_is_visible(wdata->win))
361 return FR_NO_ACTION;
362
363 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
364 return FR_NO_ACTION;
365
366 if (!sb_prev(wdata))
367 return FR_NO_ACTION;
368
369 wdata->win->actions |= WA_RECALC;
370 return FR_SUCCESS;
371}
+ 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 378 of file functions.c.

379{
380 if (!mutt_window_is_visible(wdata->win))
381 return FR_NO_ACTION;
382
383 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
384 if ((max_entries == 0) || (wdata->hil_index < 0))
385 return FR_NO_ACTION;
386
387 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
388 struct SbEntry **sbep = NULL;
389 if ((sbep = sb_prev_new(wdata, 0, wdata->hil_index)) ||
390 (c_sidebar_next_new_wrap &&
391 (sbep = sb_prev_new(wdata, wdata->hil_index + 1, max_entries))))
392 {
393 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
394 wdata->win->actions |= WA_RECALC;
395 return FR_SUCCESS;
396 }
397
398 return FR_NO_ACTION;
399}
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:181
+ 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 404 of file functions.c.

406{
407 bool_str_toggle(NeoMutt->sub, "sidebar_visible", NULL);
408 mutt_window_reflow(NULL);
409 return FR_SUCCESS;
410}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition bool.c:231
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 415 of file functions.c.

417{
418 return FR_SUCCESS;
419}

◆ op_sidebar_abort_search()

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

Close the Sidebar Search - Implements sidebar_function_t -.

Close the Sidebar Search without a selection.

Definition at line 493 of file functions.c.

494{
495 if (wdata->search_active)
496 return FR_DONE;
497 else
498 return FR_NO_ACTION;
499}
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:36
bool search_active
Sidebar Search is running.
Definition private.h:101

◆ op_sidebar_start_search()

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

Selects the last unhidden mailbox - Implements sidebar_function_t -.

Definition at line 504 of file functions.c.

505{
506 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
507 {
508 mutt_warning(_("There are no mailboxes"));
509 return FR_NO_ACTION;
510 }
511
512 const bool was_visible = cs_subset_bool(NeoMutt->sub, "sidebar_visible");
513 if (!was_visible)
514 {
515 cs_subset_str_native_set(NeoMutt->sub, "sidebar_visible", true, NULL);
516 mutt_window_reflow(NULL);
517 }
518
519 struct Buffer *buf = buf_pool_get();
520 int orghlidx = wdata->hil_index;
521
522 struct SbEntry **sbep = NULL;
523 ARRAY_FOREACH(sbep, &wdata->entries)
524 {
525 struct SbEntry *sbe = *sbep;
526 if (sbe->box[0] == '\0')
528 }
529
530 int rc = FR_NO_ACTION;
531 wdata->search_active = true;
532 if (mw_get_field_notify(_("Sidebar search: "), buf, MUTT_COMP_UNBUFFERED,
533 HC_NONE, NULL, NULL, sidebar_matcher_cb, wdata->win,
535 {
536 wdata->hil_index = orghlidx;
537 goto done;
538 }
539
540 if (!buf || buf_is_empty(buf) || (wdata->hil_index == -1))
541 {
542 wdata->hil_index = orghlidx;
543 goto done;
544 }
545
546 ARRAY_FOREACH(sbep, &wdata->entries)
547 {
548 struct SbEntry *sbe = *sbep;
549 sbe->score = -1;
550 }
551 rc = FR_SUCCESS;
552
553done:
554 ARRAY_FOREACH(sbep, &wdata->entries)
555 {
556 (*sbep)->mailbox->visible = true;
557 }
558 wdata->search_active = false;
559 wdata->repage = false;
560 wdata->win->actions |= WA_RECALC;
561
562 if (rc == FR_SUCCESS)
563 {
564 struct MuttWindow *dlg = dialog_find(wdata->win);
566 }
567
568 if (!was_visible)
569 {
570 cs_subset_str_native_set(NeoMutt->sub, "sidebar_visible", false, NULL);
571 mutt_window_reflow(NULL);
572 }
573
574 buf_pool_release(&buf);
575 return rc;
576}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
int mw_get_field_notify(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata, get_field_callback_t callback, void *cb_data, const struct MenuDefinition *md, function_dispatcher_t fn_disp)
Ask the user for a string and call a notify function on keypress.
Definition window.c:265
#define MUTT_COMP_UNBUFFERED
Ignore macro buffer.
Definition wdata.h:45
int sb_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
Perform a Sidebar function - Implements function_dispatcher_t -.
Definition functions.c:605
#define mutt_warning(...)
Definition logging2.h:92
@ HC_NONE
No History.
Definition lib.h:63
#define _(a)
Definition message.h:28
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
struct MenuDefinition * MdSidebar
Sidebar Menu Definition.
Definition functions.c:48
static void sidebar_matcher_cb(const char *text, void *data)
React to keys as they are entered - Implements get_field_callback_t.
Definition functions.c:424
void sb_entry_set_display_name(struct SbEntry *entry)
Set the display name for an SbEntry.
Definition window.c:305
String manipulation buffer.
Definition buffer.h:36
int score
Fuzzy-match score.
Definition private.h:49
char box[256]
Mailbox path (possibly abbreviated)
Definition private.h:43
bool repage
Force RECALC to recompute the paging used for the overlays.
Definition private.h:100
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition subset.c:303
+ Here is the call graph for this function: