NeoMutt  2025-12-11-177-g48e272
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Sidebar functions. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "functions.h"
#include "lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

void sidebar_init_keys (struct SubMenu *sm_generic)
 Initialise the Sidebar Keybindings - Implements ::init_keys_api.
 
struct SubMenusidebar_get_submenu (void)
 
bool sb_next (struct SidebarWindowData *wdata)
 Find the next unhidden Mailbox.
 
static struct SbEntry ** sb_next_new (struct SidebarWindowData *wdata, size_t begin, size_t end)
 Return the next mailbox with new messages.
 
bool sb_prev (struct SidebarWindowData *wdata)
 Find the previous unhidden Mailbox.
 
static struct SbEntry ** sb_prev_new (struct SidebarWindowData *wdata, size_t begin, size_t end)
 Return the previous mailbox with new messages.
 
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 -.
 
int sb_function_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform a Sidebar function - Implements function_dispatcher_t -.
 

Variables

static struct SubMenuSmSidebar = NULL
 Sidebar functions.
 
static const struct MenuFuncOp OpSidebar []
 Functions for the Sidebar Window.
 
static const struct SidebarFunction SidebarFunctions []
 All the NeoMutt functions that the Sidebar supports.
 

Detailed Description

Sidebar functions.

Authors
  • Pietro Cerutti
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file functions.c.

Function Documentation

◆ sidebar_init_keys()

void sidebar_init_keys ( struct SubMenu * sm_generic)

Initialise the Sidebar Keybindings - Implements ::init_keys_api.

Definition at line 70 of file functions.c.

71{
72 struct MenuDefinition *md = NULL;
73 struct SubMenu *sm = NULL;
74
76 md = km_register_menu(MENU_SIDEBAR, "sidebar");
77 km_menu_add_submenu(md, sm);
78
79 SmSidebar = sm;
80}
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:91
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:107
static struct SubMenu * SmSidebar
Sidebar functions.
Definition functions.c:45
static const struct MenuFuncOp OpSidebar[]
Functions for the Sidebar Window.
Definition functions.c:51
Functions for a Dialog or Window.
Definition menu.h:81
Collection of related functions.
Definition menu.h:69
@ MENU_SIDEBAR
Sidebar menu.
Definition type.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sidebar_get_submenu()

struct SubMenu * sidebar_get_submenu ( void )

Definition at line 82 of file functions.c.

83{
84 return SmSidebar;
85}
+ Here is the caller graph for this function:

◆ sb_next()

bool sb_next ( struct SidebarWindowData * wdata)

Find the next unhidden Mailbox.

Parameters
wdataSidebar data
Return values
trueMailbox found

Definition at line 92 of file functions.c.

93{
94 struct SbEntry **sbep = NULL;
95 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->hil_index + 1)
96 {
97 if (!(*sbep)->is_hidden)
98 {
99 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
100 return true;
101 }
102 }
103
104 return false;
105}
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition array.h:235
Info about folders in the sidebar.
Definition private.h:40
int hil_index
Highlighted mailbox.
Definition private.h:94
struct SbEntryArray entries
Items to display in the sidebar.
Definition private.h:90
+ Here is the caller graph for this function:

◆ sb_next_new()

static struct SbEntry ** sb_next_new ( struct SidebarWindowData * wdata,
size_t begin,
size_t end )
static

Return the next mailbox with new messages.

Parameters
wdataSidebar data
beginStarting index for searching
endEnding index for searching
Return values
ptrPointer to the first entry with new messages
NULLNone could be found

Definition at line 115 of file functions.c.

116{
117 struct SbEntry **sbep = NULL;
118 ARRAY_FOREACH_FROM_TO(sbep, &wdata->entries, begin, end)
119 {
120 if ((*sbep)->mailbox->has_new || ((*sbep)->mailbox->msg_unread != 0))
121 return sbep;
122 }
123 return NULL;
124}
#define ARRAY_FOREACH_FROM_TO(elem, head, from, to)
Iterate between two indexes.
Definition array.h:261
+ Here is the caller graph for this function:

◆ sb_prev()

bool sb_prev ( struct SidebarWindowData * wdata)

Find the previous unhidden Mailbox.

Parameters
wdataSidebar data
Return values
trueMailbox found

Definition at line 131 of file functions.c.

132{
133 struct SbEntry **sbep = NULL, **prev = NULL;
134 ARRAY_FOREACH_TO(sbep, &wdata->entries, wdata->hil_index)
135 {
136 if (!(*sbep)->is_hidden)
137 prev = sbep;
138 }
139
140 if (prev)
141 {
142 wdata->hil_index = ARRAY_IDX(&wdata->entries, prev);
143 return true;
144 }
145
146 return false;
147}
#define ARRAY_IDX(head, elem)
Return the index of an element of the array.
Definition array.h:324
#define ARRAY_FOREACH_TO(elem, head, to)
Iterate from the beginning to an index.
Definition array.h:247
+ Here is the caller graph for this function:

◆ sb_prev_new()

static struct SbEntry ** sb_prev_new ( struct SidebarWindowData * wdata,
size_t begin,
size_t end )
static

Return the previous mailbox with new messages.

Parameters
wdataSidebar data
beginStarting index for searching
endEnding index for searching
Return values
ptrPointer to the first entry with new messages
NULLNone could be found

Definition at line 157 of file functions.c.

158{
159 struct SbEntry **sbep = NULL, **prev = NULL;
160 ARRAY_FOREACH_FROM_TO(sbep, &wdata->entries, begin, end)
161 {
162 if ((*sbep)->mailbox->has_new || ((*sbep)->mailbox->msg_unread != 0))
163 prev = sbep;
164 }
165
166 return prev;
167}
+ Here is the caller graph for this function:

Variable Documentation

◆ SmSidebar

struct SubMenu* SmSidebar = NULL
static

Sidebar functions.

Definition at line 45 of file functions.c.

◆ OpSidebar

const struct MenuFuncOp OpSidebar[]
static
Initial value:
= {
{ "sidebar-first", OP_SIDEBAR_FIRST },
{ "sidebar-last", OP_SIDEBAR_LAST },
{ "sidebar-next", OP_SIDEBAR_NEXT },
{ "sidebar-next-new", OP_SIDEBAR_NEXT_NEW },
{ "sidebar-open", OP_SIDEBAR_OPEN },
{ "sidebar-page-down", OP_SIDEBAR_PAGE_DOWN },
{ "sidebar-page-up", OP_SIDEBAR_PAGE_UP },
{ "sidebar-prev", OP_SIDEBAR_PREV },
{ "sidebar-prev-new", OP_SIDEBAR_PREV_NEW },
{ "sidebar-toggle-virtual", OP_SIDEBAR_TOGGLE_VIRTUAL },
{ "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE },
{ NULL, 0 },
}

Functions for the Sidebar Window.

Definition at line 51 of file functions.c.

51 { /* map: sidebar */
52 { "sidebar-first", OP_SIDEBAR_FIRST },
53 { "sidebar-last", OP_SIDEBAR_LAST },
54 { "sidebar-next", OP_SIDEBAR_NEXT },
55 { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW },
56 { "sidebar-open", OP_SIDEBAR_OPEN },
57 { "sidebar-page-down", OP_SIDEBAR_PAGE_DOWN },
58 { "sidebar-page-up", OP_SIDEBAR_PAGE_UP },
59 { "sidebar-prev", OP_SIDEBAR_PREV },
60 { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW },
61 { "sidebar-toggle-virtual", OP_SIDEBAR_TOGGLE_VIRTUAL },
62 { "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE },
63 { NULL, 0 },
64};

◆ SidebarFunctions

const struct SidebarFunction SidebarFunctions[]
static
Initial value:
= {
{ OP_SIDEBAR_FIRST, op_sidebar_first },
{ OP_SIDEBAR_LAST, op_sidebar_last },
{ OP_SIDEBAR_NEXT, op_sidebar_next },
{ OP_SIDEBAR_NEXT_NEW, op_sidebar_next_new },
{ OP_SIDEBAR_OPEN, op_sidebar_open },
{ OP_SIDEBAR_PAGE_DOWN, op_sidebar_page_down },
{ OP_SIDEBAR_PAGE_UP, op_sidebar_page_up },
{ OP_SIDEBAR_PREV, op_sidebar_prev },
{ OP_SIDEBAR_PREV_NEW, op_sidebar_prev_new },
{ OP_SIDEBAR_TOGGLE_VIRTUAL, op_sidebar_toggle_virtual },
{ OP_SIDEBAR_TOGGLE_VISIBLE, op_sidebar_toggle_visible },
{ 0, NULL },
}
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 -.
Definition functions.c:282
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 -.
Definition functions.c:308
static int op_sidebar_last(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Selects the last unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:199
static int op_sidebar_first(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Selects the first unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:174
static int op_sidebar_prev(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Selects the previous unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:334
static int op_sidebar_open(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Open highlighted mailbox - Implements sidebar_function_t -.
Definition functions.c:268
static int op_sidebar_next(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Selects the next unhidden mailbox - Implements sidebar_function_t -.
Definition functions.c:223
static int op_sidebar_toggle_visible(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Make the sidebar (in)visible - Implements sidebar_function_t -.
Definition functions.c:380
static int op_sidebar_toggle_virtual(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Deprecated - Implements sidebar_function_t -.
Definition functions.c:391
static int op_sidebar_next_new(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Selects the next new mailbox - Implements sidebar_function_t -.
Definition functions.c:243
static int op_sidebar_prev_new(struct SidebarWindowData *wdata, const struct KeyEvent *event)
Selects the previous new mailbox - Implements sidebar_function_t -.
Definition functions.c:354

All the NeoMutt functions that the Sidebar supports.

Definition at line 402 of file functions.c.

402 {
403 // clang-format off
404 { OP_SIDEBAR_FIRST, op_sidebar_first },
405 { OP_SIDEBAR_LAST, op_sidebar_last },
406 { OP_SIDEBAR_NEXT, op_sidebar_next },
407 { OP_SIDEBAR_NEXT_NEW, op_sidebar_next_new },
408 { OP_SIDEBAR_OPEN, op_sidebar_open },
409 { OP_SIDEBAR_PAGE_DOWN, op_sidebar_page_down },
410 { OP_SIDEBAR_PAGE_UP, op_sidebar_page_up },
411 { OP_SIDEBAR_PREV, op_sidebar_prev },
412 { OP_SIDEBAR_PREV_NEW, op_sidebar_prev_new },
413 { OP_SIDEBAR_TOGGLE_VIRTUAL, op_sidebar_toggle_virtual },
414 { OP_SIDEBAR_TOGGLE_VISIBLE, op_sidebar_toggle_visible },
415 { 0, NULL },
416 // clang-format on
417};