NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
private.h File Reference

Private Menu functions. More...

#include <stddef.h>
+ Include dependency graph for private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void menu_free (struct Menu **ptr)
 Free a Menu.
 
struct Menumenu_new (const struct MenuDefinition *md, struct MuttWindow *win, struct ConfigSubset *sub)
 Create a new Menu.
 
void menu_add_observers (struct Menu *menu)
 Add the notification observers.
 

Detailed Description

Private Menu functions.

Authors
  • 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 private.h.

Function Documentation

◆ menu_free()

void menu_free ( struct Menu ** ptr)

Free a Menu.

Parameters
ptrMenu to free

Definition at line 116 of file menu.c.

117{
118 if (!ptr || !*ptr)
119 return;
120
121 struct Menu *menu = *ptr;
122
123 notify_free(&menu->notify);
124
125 if (menu->mdata_free && menu->mdata)
126 menu->mdata_free(menu, &menu->mdata); // Custom function to free private data
127
128 FREE(ptr);
129}
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
Definition lib.h:80
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition lib.h:163
struct Notify * notify
Notifications.
Definition lib.h:147
void * mdata
Private data.
Definition lib.h:149
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_new()

struct Menu * menu_new ( const struct MenuDefinition * md,
struct MuttWindow * win,
struct ConfigSubset * sub )

Create a new Menu.

Parameters
mdMenu Definition
winParent Window
subConfig items
Return values
ptrNew Menu

Definition at line 138 of file menu.c.

140{
141 struct Menu *menu = MUTT_MEM_CALLOC(1, struct Menu);
142
143 menu->md = md;
144 menu->redraw = MENU_REDRAW_FULL;
145 menu->color = default_color;
146 menu->search = generic_search;
147 menu->notify = notify_new();
148 menu->win = win;
149 menu->page_len = win->state.rows;
150 menu->sub = sub;
151 menu->show_indicator = true;
152
154 menu_add_observers(menu);
155
156 return menu;
157}
static const struct AttrColor * default_color(struct Menu *menu, int line)
Get the default colour for a line of the menu - Implements Menu::color() -.
Definition menu.c:50
static int generic_search(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex - Implements Menu::search() -.
Definition menu.c:58
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:60
void menu_add_observers(struct Menu *menu)
Add the notification observers.
Definition observer.c:134
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
struct MuttWindow * win
Window holding the Menu.
Definition lib.h:88
const struct AttrColor *(* color)(struct Menu *menu, int line)
Definition lib.h:145
MenuRedrawFlags redraw
When to redraw the screen.
Definition lib.h:83
bool show_indicator
Show the Indicator colour.
Definition lib.h:87
int(* search)(struct Menu *menu, regex_t *rx, int line)
Definition lib.h:121
const struct MenuDefinition * md
Menu definition for keymap entries.
Definition lib.h:84
struct ConfigSubset * sub
Inherited config items.
Definition lib.h:89
int page_len
Number of entries per screen.
Definition lib.h:85
struct WindowState state
Current state of the Window.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_add_observers()

void menu_add_observers ( struct Menu * menu)

Add the notification observers.

Parameters
menuMenu

Definition at line 134 of file observer.c.

135{
136 struct MuttWindow *win = menu->win;
137
141}
void mutt_color_observer_add(observer_t callback, void *global_data)
Add an observer.
Definition notify.c:61
static int menu_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition observer.c:97
static int menu_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition observer.c:70
static int menu_color_observer(struct NotifyCallback *nc)
Notification that a Color has changed - Implements observer_t -.
Definition observer.c:41
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition notify.c:191
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function: