NeoMutt  2025-12-11-949-g4870ee
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions_sidebar.c File Reference

Sidebar functions. More...

#include "config.h"
#include <stdbool.h>
#include <string.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "functions_sidebar.h"
#include "lib.h"
#include "editor/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "functions_fuzzy.h"
#include "module_data.h"
+ Include dependency graph for functions_sidebar.c:

Go to the source code of this file.

Functions

void sidebar_init_keys (struct NeoMutt *n, struct SubMenu *sm_generic)
 Initialise the Sidebar Keybindings - Implements ::init_keys_api.
 
struct SubMenusidebar_get_submenu (void)
 Get the Sidebar SubMenu.
 
bool sb_next (struct SidebarWindowData *wdata)
 Find the next unhidden Mailbox.
 
static bool sb_next_n (struct SidebarWindowData *wdata, int count)
 Move down N unhidden Mailboxes, capping at the last.
 
static bool sb_prev_n (struct SidebarWindowData *wdata, int count)
 Move up N unhidden Mailboxes, capping at the first.
 
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.
 
int op_sidebar_first (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the first unhidden mailbox - Implements sidebar_function_t -.
 
int op_sidebar_last (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the last unhidden mailbox - Implements sidebar_function_t -.
 
int op_sidebar_next (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the next unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_next_new (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the next new mailbox - Implements sidebar_function_t -.
 
int op_sidebar_open (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Open highlighted mailbox - Implements sidebar_function_t -.
 
int op_sidebar_page_down (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.
 
int op_sidebar_page_up (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.
 
int op_sidebar_prev (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the previous unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_prev_new (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Selects the previous new mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_visible (struct SidebarFunctionData *fdata, const struct KeyEvent *event)
 Make the sidebar (in)visible - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_virtual (struct SidebarFunctionData *fdata, 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 const struct MenuFuncOp OpSidebar []
 Functions for the Sidebar Window.
 
const struct MenuOpSeq SidebarDefaultBindings []
 Key bindings 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_sidebar.c.

Function Documentation

◆ sidebar_init_keys()

void sidebar_init_keys ( struct NeoMutt * n,
struct SubMenu * sm_generic )

Initialise the Sidebar Keybindings - Implements ::init_keys_api.

Definition at line 78 of file functions_sidebar.c.

79{
81 ASSERT(mod_data);
82
83 struct MenuDefinition *md = NULL;
84 struct SubMenu *sm = NULL;
85 struct SubMenu *sm_editor = editor_get_submenu();
86 ASSERT(sm_editor);
87
89 md = km_register_menu(MENU_SIDEBAR, "sidebar");
90 km_menu_add_submenu(md, sm);
91 km_menu_add_submenu(md, sm_editor);
93
94 mod_data->md_sidebar = md;
95 mod_data->sm_sidebar = sm;
96}
struct SubMenu * editor_get_submenu(void)
Get the Editor SubMenu.
Definition functions.c:587
const struct MenuOpSeq SidebarDefaultBindings[]
Key bindings for the Sidebar Window.
static const struct MenuFuncOp OpSidebar[]
Functions for the Sidebar Window.
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:88
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:105
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
@ MODULE_ID_SIDEBAR
ModuleSidebar, Sidebar
Definition module_api.h:93
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
#define ASSERT(COND)
Definition signal2.h:59
Functions for a Dialog or Window.
Definition menudef.h:44
Sidebar private Module data.
Definition module_data.h:32
struct MenuDefinition * md_sidebar
Sidebar Menu Definition.
Definition module_data.h:34
struct SubMenu * sm_sidebar
Sidebar functions.
Definition module_data.h:35
Collection of related functions.
Definition menudef.h:33
@ MENU_SIDEBAR
Sidebar menu.
Definition type.h:51
+ 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 )

Get the Sidebar SubMenu.

Return values
ptrSidebar SubMenu

Definition at line 102 of file functions_sidebar.c.

103{
105 ASSERT(mod_data);
106
107 return mod_data->sm_sidebar;
108}
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ 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 115 of file functions_sidebar.c.

116{
117 struct SbEntry **sbep = NULL;
118 ARRAY_FOREACH_FROM(sbep, &wdata->entries, wdata->hil_index + 1)
119 {
120 if (!(*sbep)->is_hidden)
121 {
122 wdata->hil_index = ARRAY_FOREACH_IDX_sbep;
123 return true;
124 }
125 }
126
127 return false;
128}
#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:96
struct SbEntryArray entries
Items to display in the sidebar.
Definition private.h:92
+ Here is the caller graph for this function:

◆ sb_next_n()

static bool sb_next_n ( struct SidebarWindowData * wdata,
int count )
static

Move down N unhidden Mailboxes, capping at the last.

Parameters
wdataSidebar data
countNumber of entries to move
Return values
trueMoved at least one entry
falseAlready at the last unhidden entry

Definition at line 137 of file functions_sidebar.c.

138{
139 int orig = wdata->hil_index;
140 for (int i = 0; i < count; i++)
141 {
142 if (!sb_next(wdata))
143 break;
144 }
145 return (wdata->hil_index != orig);
146}
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_prev_n()

static bool sb_prev_n ( struct SidebarWindowData * wdata,
int count )
static

Move up N unhidden Mailboxes, capping at the first.

Parameters
wdataSidebar data
countNumber of entries to move
Return values
trueMoved at least one entry
falseAlready at the first unhidden entry

Definition at line 155 of file functions_sidebar.c.

156{
157 int orig = wdata->hil_index;
158 for (int i = 0; i < count; i++)
159 {
160 if (!sb_prev(wdata))
161 break;
162 }
163 return (wdata->hil_index != orig);
164}
bool sb_prev(struct SidebarWindowData *wdata)
Find the previous unhidden Mailbox.
+ Here is the call graph for this function:
+ 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 174 of file functions_sidebar.c.

175{
176 struct SbEntry **sbep = NULL;
177 ARRAY_FOREACH_FROM_TO(sbep, &wdata->entries, begin, end)
178 {
179 if ((*sbep)->mailbox->has_new || ((*sbep)->mailbox->msg_unread != 0))
180 return sbep;
181 }
182 return NULL;
183}
#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 190 of file functions_sidebar.c.

191{
192 struct SbEntry **sbep = NULL, **prev = NULL;
193 ARRAY_FOREACH_TO(sbep, &wdata->entries, wdata->hil_index)
194 {
195 if (!(*sbep)->is_hidden)
196 prev = sbep;
197 }
198
199 if (prev)
200 {
201 wdata->hil_index = ARRAY_IDX(&wdata->entries, prev);
202 return true;
203 }
204
205 return false;
206}
#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 216 of file functions_sidebar.c.

217{
218 struct SbEntry **sbep = NULL, **prev = NULL;
219 ARRAY_FOREACH_FROM_TO(sbep, &wdata->entries, begin, end)
220 {
221 if ((*sbep)->mailbox->has_new || ((*sbep)->mailbox->msg_unread != 0))
222 prev = sbep;
223 }
224
225 return prev;
226}
+ Here is the caller graph for this function:

Variable Documentation

◆ 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-start-search", OP_SIDEBAR_START_SEARCH },
{ "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_sidebar.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-start-search", OP_SIDEBAR_START_SEARCH },
62 { "sidebar-toggle-virtual", OP_SIDEBAR_TOGGLE_VIRTUAL },
63 { "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE },
64 { NULL, 0 },
65};

◆ SidebarDefaultBindings

const struct MenuOpSeq SidebarDefaultBindings[]
Initial value:
= {
{ 0, NULL },
}

Key bindings for the Sidebar Window.

Definition at line 70 of file functions_sidebar.c.

70 { /* map: sidebar */
71 { 0, NULL },
72};

◆ 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_START_SEARCH, op_sidebar_start_search },
{ OP_SIDEBAR_TOGGLE_VIRTUAL, op_sidebar_toggle_virtual },
{ OP_SIDEBAR_TOGGLE_VISIBLE, op_sidebar_toggle_visible },
{ 0, NULL },
}
int op_sidebar_start_search(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the last unhidden mailbox - Implements sidebar_function_t -.
int op_sidebar_open(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Open highlighted mailbox - Implements sidebar_function_t -.
int op_sidebar_page_down(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.
int op_sidebar_prev(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the previous unhidden mailbox - Implements sidebar_function_t -.
int op_sidebar_page_up(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.
static int op_sidebar_toggle_visible(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Make the sidebar (in)visible - Implements sidebar_function_t -.
static int op_sidebar_toggle_virtual(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Deprecated - Implements sidebar_function_t -.
int op_sidebar_next(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the next unhidden mailbox - Implements sidebar_function_t -.
int op_sidebar_first(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the first unhidden mailbox - Implements sidebar_function_t -.
static int op_sidebar_next_new(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the next new mailbox - Implements sidebar_function_t -.
static int op_sidebar_prev_new(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the previous new mailbox - Implements sidebar_function_t -.
int op_sidebar_last(struct SidebarFunctionData *fdata, const struct KeyEvent *event)
Selects the last unhidden mailbox - Implements sidebar_function_t -.

All the NeoMutt functions that the Sidebar supports.

Definition at line 526 of file functions_sidebar.c.

526 {
527 // clang-format off
528 { OP_SIDEBAR_FIRST, op_sidebar_first },
529 { OP_SIDEBAR_LAST, op_sidebar_last },
530 { OP_SIDEBAR_NEXT, op_sidebar_next },
531 { OP_SIDEBAR_NEXT_NEW, op_sidebar_next_new },
532 { OP_SIDEBAR_OPEN, op_sidebar_open },
533 { OP_SIDEBAR_PAGE_DOWN, op_sidebar_page_down },
534 { OP_SIDEBAR_PAGE_UP, op_sidebar_page_up },
535 { OP_SIDEBAR_PREV, op_sidebar_prev },
536 { OP_SIDEBAR_PREV_NEW, op_sidebar_prev_new },
537 { OP_SIDEBAR_START_SEARCH, op_sidebar_start_search },
538 { OP_SIDEBAR_TOGGLE_VIRTUAL, op_sidebar_toggle_virtual },
539 { OP_SIDEBAR_TOGGLE_VISIBLE, op_sidebar_toggle_visible },
540 { 0, NULL },
541 // clang-format on
542};