NeoMutt  2022-04-29-81-g9c5a59
Teaching an old dog new tricks
Go to the documentation of this file.
40 #ifndef MUTT_MENU_LIB_H
41 #define MUTT_MENU_LIB_H
43 #include "config.h"
44 #include <stddef.h>
45 #include <stdbool.h>
46 #include <stdint.h>
47 #include "mutt/lib.h"
48 #include "type.h"
50 struct ConfigSubset;
51 struct MuttWindow;
53 // Observers of #NT_MENU will not be passed any Event data.
54 typedef uint8_t MenuRedrawFlags;
56 #define MENU_REDRAW_INDEX (1 << 0)
57 #define MENU_REDRAW_MOTION (1 << 1)
58 #define MENU_REDRAW_CURRENT (1 << 2)
59 #define MENU_REDRAW_FULL (1 << 3)
68 struct Menu
69 {
70  int current;
71  int max;
73  enum MenuType type;
74  int page_len;
75  bool tag_prefix : 1;
76  struct MuttWindow *win;
77  struct ConfigSubset *sub;
79  /* the following are used only by menu_loop() */
80  int top;
82  int search_dir;
83  int num_tagged;
84  bool custom_search : 1;
96  void (*make_entry)(struct Menu *menu, char *buf, size_t buflen, int line);
109  int (*search)(struct Menu *menu, regex_t *rx, int line);
121  int (*tag)(struct Menu *menu, int sel, int act);
133  struct AttrColor *(*color)(struct Menu *menu, int line);
135  struct Notify *notify;
137  void *mdata;
152  void (*mdata_free)(struct Menu *menu, void **ptr);
153 };
155 // Simple movement
156 MenuRedrawFlags menu_bottom_page (struct Menu *menu);
159 MenuRedrawFlags menu_current_top (struct Menu *menu);
160 MenuRedrawFlags menu_first_entry (struct Menu *menu);
161 MenuRedrawFlags menu_half_down (struct Menu *menu);
162 MenuRedrawFlags menu_half_up (struct Menu *menu);
163 MenuRedrawFlags menu_last_entry (struct Menu *menu);
164 MenuRedrawFlags menu_middle_page (struct Menu *menu);
165 MenuRedrawFlags menu_next_entry (struct Menu *menu);
166 MenuRedrawFlags menu_next_line (struct Menu *menu);
167 MenuRedrawFlags menu_next_page (struct Menu *menu);
168 MenuRedrawFlags menu_prev_entry (struct Menu *menu);
169 MenuRedrawFlags menu_prev_line (struct Menu *menu);
170 MenuRedrawFlags menu_prev_page (struct Menu *menu);
171 MenuRedrawFlags menu_top_page (struct Menu *menu);
173 void menu_redraw_current(struct Menu *menu);
174 void menu_redraw_full (struct Menu *menu);
175 void menu_redraw_index (struct Menu *menu);
176 void menu_redraw_motion (struct Menu *menu);
177 int menu_redraw (struct Menu *menu);
179 void menu_add_dialog_row(struct Menu *menu, const char *row);
180 void menu_cleanup(void);
182 void menu_init(void);
184 struct MuttWindow *menu_window_new(enum MenuType type, struct ConfigSubset *sub);
186 int menu_get_index(struct Menu *menu);
187 MenuRedrawFlags menu_set_index(struct Menu *menu, int index);
188 MenuRedrawFlags menu_move_selection(struct Menu *menu, int index);
189 void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw);
190 MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative);
191 MenuRedrawFlags menu_set_and_notify(struct Menu *menu, int top, int index);
192 void menu_adjust(struct Menu *menu);
194 int menu_function_dispatcher(struct MuttWindow *win, int op);
195 int menu_tagging_dispatcher(struct MuttWindow *win, int op);
197 #endif /* MUTT_MENU_LIB_H */
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:319
enum MenuType menu_get_current_type(void)
Get the type of the current Window.
Definition: menu.c:84
void menu_init(void)
Initialise all the Menus.
Definition: menu.c:74
MenuRedrawFlags menu_next_page(struct Menu *menu)
Move the focus to the next page in the menu.
Definition: move.c:562
MenuRedrawFlags menu_bottom_page(struct Menu *menu)
Move the focus to the bottom of the page.
Definition: move.c:363
void menu_cleanup(void)
Free the saved Menu searches.
Definition: menu.c:65
void menu_adjust(struct Menu *menu)
Reapply the config to the Menu.
Definition: move.c:319
MenuRedrawFlags menu_half_up(struct Menu *menu)
Move the focus up half a page in the menu.
Definition: move.c:506
MenuRedrawFlags menu_prev_line(struct Menu *menu)
Move the view up one line, keeping the selection the same.
Definition: move.c:526
void menu_redraw_current(struct Menu *menu)
Redraw the current menu.
Definition: draw.c:445
MenuRedrawFlags menu_current_bottom(struct Menu *menu)
Move the current selection to the bottom of the window.
Definition: move.c:484
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:254
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition: move.c:464
void menu_redraw_index(struct Menu *menu)
Force the redraw of the index.
Definition: draw.c:329
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
Definition: draw.c:481
MenuRedrawFlags menu_middle_page(struct Menu *menu)
Move the focus to the centre of the page.
Definition: move.c:343
struct MuttWindow * menu_window_new(enum MenuType type, struct ConfigSubset *sub)
Create a new Menu Window.
Definition: window.c:136
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:178
MenuRedrawFlags menu_set_and_notify(struct Menu *menu, int top, int index)
Set the Menu selection/view and notify others.
Definition: move.c:66
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:154
MenuRedrawFlags menu_first_entry(struct Menu *menu)
Move the focus to the first entry in the menu.
Definition: move.c:410
void menu_redraw_full(struct Menu *menu)
Force the redraw of the Menu.
Definition: draw.c:315
uint8_t MenuRedrawFlags
Definition: lib.h:51
MenuRedrawFlags menu_half_down(struct Menu *menu)
Move the focus down half a page in the menu.
Definition: move.c:516
MenuRedrawFlags menu_top_page(struct Menu *menu)
Move the focus to the top of the page.
Definition: move.c:333
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection, keeping within between [0, menu->max].
Definition: move.c:236
MenuRedrawFlags menu_last_entry(struct Menu *menu)
Move the focus to the last entry in the menu.
Definition: move.c:426
MenuRedrawFlags menu_prev_page(struct Menu *menu)
Move the focus to the previous page in the menu.
Definition: move.c:552
MenuRedrawFlags menu_next_line(struct Menu *menu)
Move the view down one line, keeping the selection the same.
Definition: move.c:539
MenuRedrawFlags menu_prev_entry(struct Menu *menu)
Move the focus to the previous item in the menu.
Definition: move.c:382
MenuRedrawFlags menu_current_top(struct Menu *menu)
Move the current selection to the top of the window.
Definition: move.c:443
void menu_add_dialog_row(struct Menu *menu, const char *row)
void menu_redraw_motion(struct Menu *menu)
Force the redraw of the list part of the menu.
Definition: draw.c:386
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:168
MenuRedrawFlags menu_next_entry(struct Menu *menu)
Move the focus to the next item in the menu.
Definition: move.c:396
Convenience wrapper for the library headers.
A curses colour and its attributes.
Definition: attr.h:35
A set of inherited config items.
Definition: subset.h:47
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
int search_dir
Direction of search.
Definition: lib.h:82
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
int current
Current entry.
Definition: lib.h:70
int num_tagged
Number of tagged entries.
Definition: lib.h:83
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* search)(struct Menu *menu, regex_t *rx, int line)
Definition: lib.h:109
int top
Entry that is the top of the current page.
Definition: lib.h:80
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:121
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:73
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:77
struct Notify * notify
Definition: lib.h:135
void * mdata
Private data.
Definition: lib.h:137
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:75
int max
Number of entries in the menu.
Definition: lib.h:71
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:84
int page_len
Number of entries per screen.
Definition: lib.h:74
int old_current
For driver use only.
Definition: lib.h:81
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
Notification API.
Definition: notify.c:51
Menu types.
Types of GUI selections.
Definition: type.h:36