NeoMutt  2020-09-25
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 
49 
52 struct Menu
53 {
54  const char *title;
55  void *mdata;
56  int current;
57  int max;
59  enum MenuType type;
60  int pagelen;
61  bool tagprefix : 1;
62  bool is_mailbox_list : 1;
65 
66  /* Setting a non-empty dialog overrides normal menu behavior.
67  * In dialog mode menubar is hidden and prompt keys are checked before
68  * normal menu movement keys. This can cause problems with scrolling, if
69  * prompt keys override movement keys. */
70  ARRAY_HEAD(,char*) dialog;
71  char *prompt;
72  char *keys;
73 
74  /* the following are used only by mutt_menu_loop() */
75  int top;
76  int oldcurrent;
77  int search_dir;
78  int tagged;
79  bool custom_search : 1;
80 
88  void (*make_entry)(char *buf, size_t buflen, struct Menu *menu, int line);
89 
98  int (*search)(struct Menu *menu, regex_t *rx, int line);
99 
107  int (*tag)(struct Menu *menu, int sel, int act);
108 
115  int (*color)(int line);
116 
121  void (*custom_redraw)(struct Menu *menu);
122 
123  void *redraw_data;
124 };
125 
126 void menu_bottom_page(struct Menu *menu);
127 void menu_check_recenter(struct Menu *menu);
128 void menu_current_bottom(struct Menu *menu);
129 void menu_current_middle(struct Menu *menu);
130 void menu_current_top(struct Menu *menu);
131 void menu_first_entry(struct Menu *menu);
132 void menu_half_down(struct Menu *menu);
133 void menu_half_up(struct Menu *menu);
134 void menu_last_entry(struct Menu *menu);
135 void menu_middle_page(struct Menu *menu);
136 void menu_next_line(struct Menu *menu);
137 void menu_next_page(struct Menu *menu);
138 void menu_prev_line(struct Menu *menu);
139 void menu_prev_page(struct Menu *menu);
140 void menu_redraw_current(struct Menu *menu);
141 void menu_redraw_full(struct Menu *menu);
142 void menu_redraw_index(struct Menu *menu);
143 void menu_redraw_motion(struct Menu *menu);
144 void menu_redraw_status(struct Menu *menu);
145 int menu_redraw(struct Menu *menu);
146 void menu_top_page(struct Menu *menu);
147 void mutt_menu_add_dialog_row(struct Menu *menu, const char *row);
148 void mutt_menu_current_redraw(void);
149 void mutt_menu_free(struct Menu **ptr);
150 void mutt_menu_init(void);
151 int mutt_menu_loop(struct Menu *menu);
152 struct Menu *mutt_menu_new(enum MenuType type);
153 void mutt_menu_pop_current(struct Menu *menu);
154 void mutt_menu_push_current(struct Menu *menu);
157 void mutt_menu_set_redraw_full(enum MenuType menu);
159 
162 
163 #endif /* MUTT_MENU_H */
void menu_check_recenter(struct Menu *menu)
Recentre the menu on screen.
Definition: menu.c:543
void menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition: menu.c:852
void mutt_menu_set_current_redraw_full(void)
Flag the current menu to be fully redrawn.
Definition: menu.c:1065
Manage keymappings.
GUI selectable list of items.
Definition: mutt_menu.h:52
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:1079
MenuType
Types of GUI selections.
Definition: keymap.h:72
int oldcurrent
For driver use only.
Definition: mutt_menu.h:76
struct Menu * mutt_menu_new(enum MenuType type)
Create a new Menu.
Definition: menu.c:945
char * prompt
Prompt for user, similar to mutt_multi_choice.
Definition: mutt_menu.h:71
void menu_current_top(struct Menu *menu)
Move the current selection to the top of the window.
Definition: menu.c:837
void menu_next_page(struct Menu *menu)
Move the focus to the next page in the menu.
Definition: menu.c:723
void menu_redraw_index(struct Menu *menu)
Force the redraw of the index.
Definition: menu.c:382
void menu_redraw_full(struct Menu *menu)
Force the redraw of the Menu.
Definition: menu.c:347
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:55
short C_MenuContext
Config: Number of lines of overlap when changing pages in the index.
Definition: menu.c:54
void mutt_menu_push_current(struct Menu *menu)
Add a new Menu to the stack.
Definition: menu.c:1007
void mutt_menu_set_current_redraw(MuttRedrawFlags redraw)
Set redraw flags on the current menu.
Definition: menu.c:1055
void mutt_menu_set_redraw_full(enum MenuType menu)
Flag a menu to be fully redrawn.
Definition: menu.c:1091
void * redraw_data
Definition: mutt_menu.h:123
void menu_middle_page(struct Menu *menu)
Move the focus to the centre of the page.
Definition: menu.c:789
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:59
struct MuttWindow * win_ibar
Definition: mutt_menu.h:64
const char * title
Title of this menu.
Definition: mutt_menu.h:54
void menu_redraw_status(struct Menu *menu)
Force the redraw of the status bar.
Definition: menu.c:366
void menu_half_down(struct Menu *menu)
Move the focus down half a page in the menu.
Definition: menu.c:741
void menu_redraw_motion(struct Menu *menu)
Force the redraw of the list part of the menu.
Definition: menu.c:433
void menu_first_entry(struct Menu *menu)
Move the focus to the first entry in the menu.
Definition: menu.c:807
void menu_current_bottom(struct Menu *menu)
Move the current selection to the bottom of the window.
Definition: menu.c:869
void menu_next_line(struct Menu *menu)
Move the view down one line, keeping the selection the same.
Definition: menu.c:624
void mutt_menu_add_dialog_row(struct Menu *menu, const char *row)
Add a row to a Menu.
Definition: menu.c:985
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:55
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:115
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:75
void mutt_menu_init(void)
Initialise all the Menus.
Definition: menu.c:934
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
Definition: menu.c:1263
bool tagprefix
Definition: mutt_menu.h:61
bool is_mailbox_list
Definition: mutt_menu.h:62
void menu_bottom_page(struct Menu *menu)
Move the focus to the bottom of the page.
Definition: menu.c:772
int search_dir
Direction of search.
Definition: mutt_menu.h:77
int mutt_menu_loop(struct Menu *menu)
Menu event loop.
Definition: menu.c:1302
void(* custom_redraw)(struct Menu *menu)
Redraw the menu.
Definition: mutt_menu.h:121
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:107
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
char * keys
Keys used in the prompt.
Definition: mutt_menu.h:72
int tagged
Number of tagged entries.
Definition: mutt_menu.h:78
int mutt_menu_config_observer(struct NotifyCallback *nc)
Listen for config changes affecting the menu - Implements observer_t.
Definition: menu.c:1601
void mutt_menu_free(struct Menu **ptr)
Destroy a menu.
Definition: menu.c:964
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
void menu_half_up(struct Menu *menu)
Move the focus up half a page in the menu.
Definition: menu.c:750
int mutt_menu_color_observer(struct NotifyCallback *nc)
Listen for colour changes affecting the menu - Implements observer_t.
Definition: menu.c:1557
void menu_last_entry(struct Menu *menu)
Move the focus to the last entry in the menu.
Definition: menu.c:822
void menu_prev_page(struct Menu *menu)
Move the focus to the previous page in the menu.
Definition: menu.c:732
bool C_MenuScroll
Config: Scroll the menu/index by one line, rather than a page.
Definition: menu.c:56
void menu_redraw_current(struct Menu *menu)
Redraw the current menu.
Definition: menu.c:493
void mutt_menu_pop_current(struct Menu *menu)
Remove a Menu from the stack.
Definition: menu.c:1019
int current
Current entry.
Definition: mutt_menu.h:56
void menu_top_page(struct Menu *menu)
Move the focus to the top of the page.
Definition: menu.c:759
struct MuttWindow * win_index
Definition: mutt_menu.h:63
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:650
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:98
void(* make_entry)(char *buf, size_t buflen, struct Menu *menu, int line)
Format a item for a menu.
Definition: mutt_menu.h:88
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:1100
ARRAY_HEAD(, char *) dialog
Dialog lines themselves.