NeoMutt  2023-05-17-16-g61469c
Teaching an old dog new tricks
DOXYGEN
Menu Function API

Prototype for a Menu Function. More...

+ Collaboration diagram for Menu Function API:

Functions

static int menu_movement (struct Menu *menu, int op)
 Handle all the common Menu movements - Implements menu_function_t -. More...
 
static int menu_search (struct Menu *menu, int op)
 Handle Menu searching - Implements menu_function_t -. More...
 
static int op_help (struct Menu *menu, int op)
 Show the help screen - Implements menu_function_t -. More...
 
static int op_jump (struct Menu *menu, int op)
 Jump to an index number - Implements menu_function_t -. More...
 

Detailed Description

Prototype for a Menu Function.

Parameters
menuMenu
opOperation to perform, e.g. OP_NEXT_PAGE
Return values
enumFunctionRetval

Function Documentation

◆ menu_movement()

static int menu_movement ( struct Menu menu,
int  op 
)
static

Handle all the common Menu movements - Implements menu_function_t -.

Definition at line 139 of file functions.c.

140{
141 switch (op)
142 {
143 case OP_BOTTOM_PAGE:
144 menu_bottom_page(menu);
145 return FR_SUCCESS;
146
147 case OP_CURRENT_BOTTOM:
149 return FR_SUCCESS;
150
151 case OP_CURRENT_MIDDLE:
153 return FR_SUCCESS;
154
155 case OP_CURRENT_TOP:
156 menu_current_top(menu);
157 return FR_SUCCESS;
158
159 case OP_FIRST_ENTRY:
160 menu_first_entry(menu);
161 return FR_SUCCESS;
162
163 case OP_HALF_DOWN:
164 menu_half_down(menu);
165 return FR_SUCCESS;
166
167 case OP_HALF_UP:
168 menu_half_up(menu);
169 return FR_SUCCESS;
170
171 case OP_LAST_ENTRY:
172 menu_last_entry(menu);
173 return FR_SUCCESS;
174
175 case OP_MIDDLE_PAGE:
176 menu_middle_page(menu);
177 return FR_SUCCESS;
178
179 case OP_NEXT_ENTRY:
180 menu_next_entry(menu);
181 return FR_SUCCESS;
182
183 case OP_NEXT_LINE:
184 menu_next_line(menu);
185 return FR_SUCCESS;
186
187 case OP_NEXT_PAGE:
188 menu_next_page(menu);
189 return FR_SUCCESS;
190
191 case OP_PREV_ENTRY:
192 menu_prev_entry(menu);
193 return FR_SUCCESS;
194
195 case OP_PREV_LINE:
196 menu_prev_line(menu);
197 return FR_SUCCESS;
198
199 case OP_PREV_PAGE:
200 menu_prev_page(menu);
201 return FR_SUCCESS;
202
203 case OP_TOP_PAGE:
204 menu_top_page(menu);
205 return FR_SUCCESS;
206
207 default:
208 return FR_UNKNOWN;
209 }
210}
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
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
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
MenuRedrawFlags menu_current_bottom(struct Menu *menu)
Move the current selection to the bottom of the window.
Definition: move.c:484
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition: move.c:464
MenuRedrawFlags menu_middle_page(struct Menu *menu)
Move the focus to the centre of the page.
Definition: move.c:343
MenuRedrawFlags menu_first_entry(struct Menu *menu)
Move the focus to the first entry in the menu.
Definition: move.c:410
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_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
MenuRedrawFlags menu_next_entry(struct Menu *menu)
Move the focus to the next item in the menu.
Definition: move.c:396
+ Here is the call graph for this function:

◆ menu_search()

static int menu_search ( struct Menu menu,
int  op 
)
static

Handle Menu searching - Implements menu_function_t -.

Definition at line 215 of file functions.c.

216{
217 if (menu->search)
218 {
219 int index = search(menu, op);
220 if (index != -1)
221 menu_set_index(menu, index);
222 }
223 return FR_SUCCESS;
224}
static int search(struct Menu *menu, int op)
Search a menu.
Definition: functions.c:57
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:169
int(* search)(struct Menu *menu, regex_t *rx, int line)
Definition: lib.h:110
+ Here is the call graph for this function:

◆ op_help()

static int op_help ( struct Menu menu,
int  op 
)
static

Show the help screen - Implements menu_function_t -.

Definition at line 229 of file functions.c.

230{
231 mutt_help(menu->type);
232 menu->redraw = MENU_REDRAW_FULL;
233 return FR_SUCCESS;
234}
void mutt_help(enum MenuType menu)
Display the help menu.
Definition: help.c:385
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:60
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:73
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:74
+ Here is the call graph for this function:

◆ op_jump()

static int op_jump ( struct Menu menu,
int  op 
)
static

Jump to an index number - Implements menu_function_t -.

Definition at line 239 of file functions.c.

240{
241 if (menu->max == 0)
242 {
243 mutt_error(_("No entries"));
244 return FR_SUCCESS;
245 }
246
247 const int digit = op - OP_JUMP;
248 if (digit > 0 && digit < 10)
249 {
250 mutt_unget_ch('0' + digit);
251 }
252
253 struct Buffer *buf = buf_pool_get();
254 if ((buf_get_field(_("Jump to: "), buf, MUTT_COMP_NO_FLAGS, false, NULL, NULL, NULL) == 0) &&
255 !buf_is_empty(buf))
256 {
257 int n = 0;
258 if (mutt_str_atoi_full(buf_string(buf), &n) && (n > 0) && (n < (menu->max + 1)))
259 {
260 menu_set_index(menu, n - 1); // msg numbers are 0-based
261 }
262 else
263 {
264 mutt_error(_("Invalid index number"));
265 }
266 }
267
268 buf_pool_release(&buf);
269 return FR_SUCCESS;
270}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:301
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:78
int digit(const char *s)
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition: curs_lib.c:522
int buf_get_field(const char *field, struct Buffer *buf, CompletionFlags complete, bool multiple, struct Mailbox *m, char ***files, int *numfiles)
Ask the user for a string.
Definition: window.c:180
#define mutt_error(...)
Definition: logging2.h:87
#define _(a)
Definition: message.h:28
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:55
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:106
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:119
String manipulation buffer.
Definition: buffer.h:34
int max
Number of entries in the menu.
Definition: lib.h:72
+ Here is the call graph for this function: