NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
lib.h
Go to the documentation of this file.
1 
38 #ifndef MUTT_MENU_LIB_H
39 #define MUTT_MENU_LIB_H
40 
41 #include "config.h"
42 #include <stdbool.h>
43 #include <stdint.h>
44 #include <stdio.h>
45 #include "mutt/lib.h"
46 #include "type.h"
47 
48 struct ConfigSubset;
49 
50 typedef uint8_t MenuRedrawFlags;
51 #define MENU_REDRAW_NO_FLAGS 0
52 #define MENU_REDRAW_INDEX (1 << 0)
53 #define MENU_REDRAW_MOTION (1 << 1)
54 #define MENU_REDRAW_CURRENT (1 << 2)
55 #define MENU_REDRAW_STATUS (1 << 3)
56 #define MENU_REDRAW_FULL (1 << 4)
57 #define MENU_REDRAW_BODY (1 << 5)
58 #define MENU_REDRAW_FLOW (1 << 6)
59 
60 
67 struct Menu
68 {
69  const char *title;
70  int current;
71  int max;
73  enum MenuType type;
74  int pagelen;
75  bool tagprefix : 1;
76  struct MuttWindow *win;
78  struct ConfigSubset *sub;
79 
80  /* Setting a non-empty dialog overrides normal menu behavior.
81  * In dialog mode menubar is hidden and prompt keys are checked before
82  * normal menu movement keys. This can cause problems with scrolling, if
83  * prompt keys override movement keys. */
84  ARRAY_HEAD(, char *) dialog;
85  char *prompt;
86  char *keys;
87 
88  /* the following are used only by menu_loop() */
89  int top;
90  int oldcurrent;
91  int search_dir;
92  int tagged;
93  bool custom_search : 1;
94 
105  void (*make_entry)(struct Menu *menu, char *buf, size_t buflen, int line);
106 
118  int (*search)(struct Menu *menu, regex_t *rx, int line);
119 
130  int (*tag)(struct Menu *menu, int sel, int act);
131 
142  int (*color)(struct Menu *menu, int line);
143 
151  void (*custom_redraw)(struct Menu *menu);
152 
153  struct Notify *notify;
154 
155  void *mdata;
156 
170  void (*mdata_free)(struct Menu *menu, void **ptr);
171 };
172 
173 // Simple movement
174 MenuRedrawFlags menu_bottom_page (struct Menu *menu);
177 MenuRedrawFlags menu_current_top (struct Menu *menu);
178 MenuRedrawFlags menu_first_entry (struct Menu *menu);
179 MenuRedrawFlags menu_half_down (struct Menu *menu);
180 MenuRedrawFlags menu_half_up (struct Menu *menu);
181 MenuRedrawFlags menu_last_entry (struct Menu *menu);
182 MenuRedrawFlags menu_middle_page (struct Menu *menu);
183 MenuRedrawFlags menu_next_entry (struct Menu *menu);
184 MenuRedrawFlags menu_next_line (struct Menu *menu);
185 MenuRedrawFlags menu_next_page (struct Menu *menu);
186 MenuRedrawFlags menu_prev_entry (struct Menu *menu);
187 MenuRedrawFlags menu_prev_line (struct Menu *menu);
188 MenuRedrawFlags menu_prev_page (struct Menu *menu);
189 MenuRedrawFlags menu_top_page (struct Menu *menu);
190 
191 void menu_redraw_current(struct Menu *menu);
192 void menu_redraw_full (struct Menu *menu);
193 void menu_redraw_index (struct Menu *menu);
194 void menu_redraw_motion (struct Menu *menu);
195 void menu_redraw_status (struct Menu *menu);
196 int menu_redraw (struct Menu *menu);
197 
198 void menu_add_dialog_row(struct Menu *menu, const char *row);
199 void menu_cleanup(void);
201 void menu_init(void);
202 int menu_loop(struct Menu *menu);
203 
204 struct MuttWindow *menu_new_window(enum MenuType type, struct ConfigSubset *sub);
205 
206 int menu_get_index(struct Menu *menu);
207 MenuRedrawFlags menu_set_index(struct Menu *menu, int index);
208 MenuRedrawFlags menu_move_selection(struct Menu *menu, int index);
209 void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw);
210 MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative);
211 MenuRedrawFlags menu_set_and_notify(struct Menu *menu, int top, int index);
212 void menu_adjust(struct Menu *menu);
213 
214 #endif /* MUTT_MENU_LIB_H */
MenuType
Types of GUI selections.
Definition: type.h:35
Definition: lib.h:67
int oldcurrent
For driver use only.
Definition: lib.h:90
char * prompt
Prompt for user, similar to mutt_multi_choice.
Definition: lib.h:85
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:105
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:73
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
struct MuttWindow * win_ibar
Definition: lib.h:77
const char * title
Title of this menu.
Definition: lib.h:69
A set of inherited config items.
Definition: subset.h:46
void * mdata
Private data.
Definition: lib.h:155
int top
Entry that is the top of the current page.
Definition: lib.h:89
bool tagprefix
User has pressed <tag-prefix>
Definition: lib.h:75
Notification API.
Definition: notify.c:50
int search_dir
Direction of search.
Definition: lib.h:91
void(* custom_redraw)(struct Menu *menu)
Definition: lib.h:151
struct Notify * notify
Notifications.
Definition: lib.h:153
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:130
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:93
int pagelen
Number of entries per screen.
Definition: lib.h:74
char * keys
Keys used in the prompt.
Definition: lib.h:86
int tagged
Number of tagged entries.
Definition: lib.h:92
int max
Number of entries in the menu.
Definition: lib.h:71
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:170
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
Convenience wrapper for the library headers.
int(* search)(struct Menu *menu, regex_t *rx, int line)
Definition: lib.h:118
int(* color)(struct Menu *menu, int line)
Definition: lib.h:142
Menu types.
ARRAY_HEAD(, char *) dialog
Dialog lines themselves.