NeoMutt  2020-08-07-1-gab41a1
Teaching an old dog new tricks
DOXYGEN
mutt_menu.h
Go to the documentation of this file.
1 
23 #ifndef MUTT_MENU_H
24 #define MUTT_MENU_H
25 
26 #include "config.h"
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <stdio.h>
30 #include "mutt/lib.h"
31 #include "keymap.h"
32 
33 /* These Config Variables are only used in menu.c */
34 extern short C_MenuContext;
35 extern bool C_MenuMoveOff;
36 extern bool C_MenuScroll;
37 
38 typedef uint16_t MuttRedrawFlags;
39 #define REDRAW_NO_FLAGS 0
40 #define REDRAW_INDEX (1 << 0)
41 #define REDRAW_MOTION (1 << 1)
42 #define REDRAW_MOTION_RESYNC (1 << 2)
43 #define REDRAW_CURRENT (1 << 3)
44 #define REDRAW_STATUS (1 << 4)
45 #define REDRAW_FULL (1 << 5)
46 #define REDRAW_BODY (1 << 6)
47 #define REDRAW_FLOW (1 << 7)
48 #ifdef USE_SIDEBAR
49 #define REDRAW_SIDEBAR (1 << 8)
50 #endif
51 
55 struct Menu
56 {
57  const char *title;
58  void *mdata;
59  int current;
60  int max;
62  enum MenuType type;
63  int pagelen;
64  bool tagprefix : 1;
65  bool is_mailbox_list : 1;
68 
69  /* Setting dialog != NULL overrides normal menu behavior.
70  * In dialog mode menubar is hidden and prompt keys are checked before
71  * normal menu movement keys. This can cause problems with scrolling, if
72  * prompt keys override movement keys. */
73  char **dialog;
74  int dsize;
75  char *prompt;
76  char *keys;
77 
78  /* the following are used only by mutt_menu_loop() */
79  int top;
80  int oldcurrent;
81  int search_dir;
82  int tagged;
83  bool custom_search : 1;
84 
92  void (*make_entry)(char *buf, size_t buflen, struct Menu *menu, int line);
93 
102  int (*search)(struct Menu *menu, regex_t *rx, int line);
103 
111  int (*tag)(struct Menu *menu, int sel, int act);
112 
119  int (*color)(int line);
120 
125  void (*custom_redraw)(struct Menu *menu);
126 
127  void *redraw_data;
128 };
129 
130 void menu_bottom_page(struct Menu *menu);
131 void menu_check_recenter(struct Menu *menu);
132 void menu_current_bottom(struct Menu *menu);
133 void menu_current_middle(struct Menu *menu);
134 void menu_current_top(struct Menu *menu);
135 void menu_first_entry(struct Menu *menu);
136 void menu_half_down(struct Menu *menu);
137 void menu_half_up(struct Menu *menu);
138 void menu_last_entry(struct Menu *menu);
139 void menu_middle_page(struct Menu *menu);
140 void menu_next_line(struct Menu *menu);
141 void menu_next_page(struct Menu *menu);
142 void menu_prev_line(struct Menu *menu);
143 void menu_prev_page(struct Menu *menu);
144 void menu_redraw_current(struct Menu *menu);
145 void menu_redraw_full(struct Menu *menu);
146 void menu_redraw_index(struct Menu *menu);
147 void menu_redraw_motion(struct Menu *menu);
148 #ifdef USE_SIDEBAR
149 void menu_redraw_sidebar(struct Menu *menu);
150 #endif
151 void menu_redraw_status(struct Menu *menu);
152 int menu_redraw(struct Menu *menu);
153 void menu_top_page(struct Menu *menu);
154 void mutt_menu_add_dialog_row(struct Menu *menu, const char *row);
155 void mutt_menu_current_redraw(void);
156 void mutt_menu_free(struct Menu **ptr);
157 void mutt_menu_init(void);
158 int mutt_menu_loop(struct Menu *menu);
159 struct Menu *mutt_menu_new(enum MenuType type);
160 void mutt_menu_pop_current(struct Menu *menu);
161 void mutt_menu_push_current(struct Menu *menu);
164 void mutt_menu_set_redraw_full(enum MenuType menu);
166 
169 
170 #endif /* MUTT_MENU_H */
void menu_check_recenter(struct Menu *menu)
Recentre the menu on screen.
Definition: menu.c:565
void menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition: menu.c:874
void mutt_menu_set_current_redraw_full(void)
Flag the current menu to be fully redrawn.
Definition: menu.c:1097
Manage keymappings.
GUI selectable list of items.
Definition: mutt_menu.h:55
Data passed to a notification function.
Definition: observer.h:39
void mutt_menu_set_redraw(enum MenuType menu, MuttRedrawFlags redraw)
Set redraw flags on a menu.
Definition: menu.c:1111
MenuType
Types of GUI selections.
Definition: keymap.h:72
int oldcurrent
For driver use only.
Definition: mutt_menu.h:80
struct Menu * mutt_menu_new(enum MenuType type)
Create a new Menu.
Definition: menu.c:967
char * prompt
Prompt for user, similar to mutt_multi_choice.
Definition: mutt_menu.h:75
void menu_current_top(struct Menu *menu)
Move the current selection to the top of the window.
Definition: menu.c:859
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:73
void menu_next_page(struct Menu *menu)
Move the focus to the next page in the menu.
Definition: menu.c:745
void menu_redraw_index(struct Menu *menu)
Force the redraw of the index.
Definition: menu.c:404
void menu_redraw_full(struct Menu *menu)
Force the redraw of the Menu.
Definition: menu.c:352
A division of the screen.
Definition: mutt_window.h:115
bool C_MenuMoveOff
Config: Allow the last menu item to move off the bottom of the screen.
Definition: menu.c:58
short C_MenuContext
Config: Number of lines of overlap when changing pages in the index.
Definition: menu.c:57
void mutt_menu_push_current(struct Menu *menu)
Add a new Menu to the stack.
Definition: menu.c:1033
void mutt_menu_set_current_redraw(MuttRedrawFlags redraw)
Set redraw flags on the current menu.
Definition: menu.c:1087
void mutt_menu_set_redraw_full(enum MenuType menu)
Flag a menu to be fully redrawn.
Definition: menu.c:1123
void * redraw_data
Definition: mutt_menu.h:127
void menu_middle_page(struct Menu *menu)
Move the focus to the centre of the page.
Definition: menu.c:811
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:62
struct MuttWindow * win_ibar
Definition: mutt_menu.h:67
const char * title
Title of this menu.
Definition: mutt_menu.h:57
void menu_redraw_status(struct Menu *menu)
Force the redraw of the status bar.
Definition: menu.c:374
void menu_half_down(struct Menu *menu)
Move the focus down half a page in the menu.
Definition: menu.c:763
void menu_redraw_motion(struct Menu *menu)
Force the redraw of the list part of the menu.
Definition: menu.c:455
void menu_first_entry(struct Menu *menu)
Move the focus to the first entry in the menu.
Definition: menu.c:829
void menu_current_bottom(struct Menu *menu)
Move the current selection to the bottom of the window.
Definition: menu.c:891
void menu_next_line(struct Menu *menu)
Move the view down one line, keeping the selection the same.
Definition: menu.c:646
void mutt_menu_add_dialog_row(struct Menu *menu, const char *row)
Add a row to a Menu.
Definition: menu.c:1008
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:58
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:119
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
void mutt_menu_init(void)
Initialise all the Menus.
Definition: menu.c:956
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
Definition: menu.c:1295
bool tagprefix
Definition: mutt_menu.h:64
bool is_mailbox_list
Definition: mutt_menu.h:65
void menu_bottom_page(struct Menu *menu)
Move the focus to the bottom of the page.
Definition: menu.c:794
int search_dir
Direction of search.
Definition: mutt_menu.h:81
int mutt_menu_loop(struct Menu *menu)
Menu event loop.
Definition: menu.c:1338
void(* custom_redraw)(struct Menu *menu)
Redraw the menu.
Definition: mutt_menu.h:125
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:111
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: mutt_menu.h:83
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
char * keys
Keys used in the prompt.
Definition: mutt_menu.h:76
int tagged
Number of tagged entries.
Definition: mutt_menu.h:82
int mutt_menu_config_observer(struct NotifyCallback *nc)
Listen for config changes affecting the menu - Implements observer_t.
Definition: menu.c:1637
void mutt_menu_free(struct Menu **ptr)
Destroy a menu.
Definition: menu.c:986
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
void menu_half_up(struct Menu *menu)
Move the focus up half a page in the menu.
Definition: menu.c:772
int mutt_menu_color_observer(struct NotifyCallback *nc)
Listen for colour changes affecting the menu - Implements observer_t.
Definition: menu.c:1593
void menu_redraw_sidebar(struct Menu *menu)
Force the redraw of the sidebar.
Definition: menu.c:391
void menu_last_entry(struct Menu *menu)
Move the focus to the last entry in the menu.
Definition: menu.c:844
void menu_prev_page(struct Menu *menu)
Move the focus to the previous page in the menu.
Definition: menu.c:754
int dsize
Number of allocated dialog lines.
Definition: mutt_menu.h:74
bool C_MenuScroll
Config: Scroll the menu/index by one line, rather than a page.
Definition: menu.c:59
void menu_redraw_current(struct Menu *menu)
Redraw the current menu.
Definition: menu.c:515
void mutt_menu_pop_current(struct Menu *menu)
Remove a Menu from the stack.
Definition: menu.c:1051
int const char int line
Definition: acutest.h:617
int current
Current entry.
Definition: mutt_menu.h:59
void menu_top_page(struct Menu *menu)
Move the focus to the top of the page.
Definition: menu.c:781
struct MuttWindow * win_index
Definition: mutt_menu.h:66
Convenience wrapper for the library headers.
void menu_prev_line(struct Menu *menu)
Move the view up one line, keeping the selection the same.
Definition: menu.c:672
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:102
void(* make_entry)(char *buf, size_t buflen, struct Menu *menu, int line)
Format a item for a menu.
Definition: mutt_menu.h:92
uint16_t MuttRedrawFlags
Flags, e.g. REDRAW_INDEX.
Definition: mutt_menu.h:38
void mutt_menu_current_redraw(void)
Redraw the current menu.
Definition: menu.c:1132