NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Menu Function API

Prototype for a Menu Function. More...

+ Collaboration diagram for Menu Function API:

Functions

static int menu_movement (struct MenuFunctionData *fdata, const struct KeyEvent *event)
 Handle all the common Menu movements - Implements menu_function_t -.
 
static int menu_search (struct MenuFunctionData *fdata, const struct KeyEvent *event)
 Handle Menu searching - Implements menu_function_t -.
 
static int op_help (struct MenuFunctionData *fdata, const struct KeyEvent *event)
 Show the help screen - Implements menu_function_t -.
 
static int op_jump (struct MenuFunctionData *fdata, const struct KeyEvent *event)
 Jump to an index number - Implements menu_function_t -.
 

Detailed Description

Prototype for a Menu Function.

Parameters
fdataMenu Function context data
eventEvent to process
Return values
enumFunctionRetval
Precondition
fdata is not NULL
event is not NULL

Function Documentation

◆ menu_movement()

static int menu_movement ( struct MenuFunctionData * fdata,
const struct KeyEvent * event )
static

Handle all the common Menu movements - Implements menu_function_t -.

This function handles:

  • OP_BOTTOM_PAGE
  • OP_CURRENT_BOTTOM
  • OP_CURRENT_MIDDLE
  • OP_CURRENT_TOP
  • OP_FIRST_ENTRY
  • OP_HALF_DOWN
  • OP_HALF_UP
  • OP_LAST_ENTRY
  • OP_MIDDLE_PAGE
  • OP_NEXT_ENTRY
  • OP_NEXT_LINE
  • OP_NEXT_PAGE
  • OP_PREV_ENTRY
  • OP_PREV_LINE
  • OP_PREV_PAGE
  • OP_TOP_PAGE

Definition at line 165 of file functions.c.

166{
167 struct Menu *menu = fdata->menu;
168 const int old_top = menu->top;
169 const int old_current = menu->current;
171
172 const int count = event->count;
173 switch (event->op)
174 {
175 case OP_BOTTOM_PAGE:
176 flags = menu_bottom_page(menu);
177 return (menu->max == 0) ? FR_ERROR : FR_SUCCESS;
178
179 case OP_CURRENT_BOTTOM:
180 flags = menu_current_bottom(menu);
181 return (menu->max == 0) ? FR_ERROR : FR_SUCCESS;
182
183 case OP_CURRENT_MIDDLE:
184 flags = menu_current_middle(menu);
185 return (menu->max == 0) ? FR_ERROR : FR_SUCCESS;
186
187 case OP_CURRENT_TOP:
188 flags = menu_current_top(menu);
189 return (menu->max == 0) ? FR_ERROR : FR_SUCCESS;
190
191 case OP_FIRST_ENTRY:
192 flags = menu_first_entry(menu, count);
193 return (menu->max == 0) ? FR_ERROR : FR_SUCCESS;
194
195 case OP_HALF_DOWN:
196 menu_half_down(menu, count);
197 return FR_SUCCESS;
198
199 case OP_HALF_UP:
200 menu_half_up(menu, count);
201 return FR_SUCCESS;
202
203 case OP_LAST_ENTRY:
204 flags = menu_last_entry(menu, count);
205 return (menu->max == 0) ? FR_ERROR : FR_SUCCESS;
206
207 case OP_MIDDLE_PAGE:
208 flags = menu_middle_page(menu);
209 return (menu->max == 0) ? FR_ERROR : FR_SUCCESS;
210
211 case OP_NEXT_ENTRY:
212 flags = menu_next_entry(menu, count);
213 return ((flags == MENU_REDRAW_NONE) && (menu->top == old_top) &&
214 (menu->current == old_current)) ?
215 FR_ERROR :
217
218 case OP_NEXT_LINE:
219 flags = menu_next_line(menu, count);
220 return ((flags == MENU_REDRAW_NONE) && (menu->top == old_top) &&
221 (menu->current == old_current)) ?
222 FR_ERROR :
224
225 case OP_NEXT_PAGE:
226 menu_next_page(menu, count);
227 return FR_SUCCESS;
228
229 case OP_PREV_ENTRY:
230 flags = menu_prev_entry(menu, count);
231 return ((flags == MENU_REDRAW_NONE) && (menu->top == old_top) &&
232 (menu->current == old_current)) ?
233 FR_ERROR :
235
236 case OP_PREV_LINE:
237 flags = menu_prev_line(menu, count);
238 return ((flags == MENU_REDRAW_NONE) && (menu->top == old_top) &&
239 (menu->current == old_current)) ?
240 FR_ERROR :
242
243 case OP_PREV_PAGE:
244 menu_prev_page(menu, count);
245 return FR_SUCCESS;
246
247 case OP_TOP_PAGE:
248 menu_top_page(menu);
249 return FR_SUCCESS;
250
251 default:
252 return FR_UNKNOWN;
253 }
254}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:34
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
MenuRedrawFlags menu_bottom_page(struct Menu *menu)
Move the focus to the bottom of the page.
Definition move.c:369
MenuRedrawFlags menu_next_page(struct Menu *menu, int count)
Move the focus to the next page in the menu.
Definition move.c:590
MenuRedrawFlags menu_prev_page(struct Menu *menu, int count)
Move the focus to the previous page in the menu.
Definition move.c:579
MenuRedrawFlags menu_current_bottom(struct Menu *menu)
Move the current selection to the bottom of the window.
Definition move.c:506
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition move.c:486
MenuRedrawFlags menu_middle_page(struct Menu *menu)
Move the focus to the centre of the page.
Definition move.c:349
MenuRedrawFlags menu_first_entry(struct Menu *menu, int count)
Move the focus to the first entry in the menu.
Definition move.c:425
uint8_t MenuRedrawFlags
Definition lib.h:66
MenuRedrawFlags menu_prev_line(struct Menu *menu, int count)
Move the view up one line, keeping the selection the same.
Definition move.c:551
MenuRedrawFlags menu_top_page(struct Menu *menu)
Move the focus to the top of the page.
Definition move.c:339
@ MENU_REDRAW_NONE
No flags are set.
Definition lib.h:60
MenuRedrawFlags menu_prev_entry(struct Menu *menu, int count)
Move the focus to the previous item in the menu.
Definition move.c:389
MenuRedrawFlags menu_next_line(struct Menu *menu, int count)
Move the view down one line, keeping the selection the same.
Definition move.c:565
MenuRedrawFlags menu_last_entry(struct Menu *menu, int count)
Move the focus to the last entry in the menu.
Definition move.c:445
MenuRedrawFlags menu_next_entry(struct Menu *menu, int count)
Move the focus to the next item in the menu.
Definition move.c:407
MenuRedrawFlags menu_current_top(struct Menu *menu)
Move the current selection to the top of the window.
Definition move.c:465
MenuRedrawFlags menu_half_down(struct Menu *menu, int count)
Move the focus down half a page in the menu.
Definition move.c:540
MenuRedrawFlags menu_half_up(struct Menu *menu, int count)
Move the focus up half a page in the menu.
Definition move.c:529
int op
Function opcode, e.g. OP_HELP.
Definition get.h:77
struct Menu * menu
Menu data.
Definition functions.h:34
Definition lib.h:86
int current
Current entry.
Definition lib.h:87
int top
Entry that is the top of the current page.
Definition lib.h:98
int max
Number of entries in the menu.
Definition lib.h:88
int old_current
For driver use only.
Definition lib.h:99
+ Here is the call graph for this function:

◆ menu_search()

static int menu_search ( struct MenuFunctionData * fdata,
const struct KeyEvent * event )
static

Handle Menu searching - Implements menu_function_t -.

This function handles:

  • OP_SEARCH
  • OP_SEARCH_NEXT
  • OP_SEARCH_OPPOSITE
  • OP_SEARCH_REVERSE

Definition at line 265 of file functions.c.

266{
267 struct Menu *menu = fdata->menu;
268 if (menu->search)
269 {
270 int index = -1;
271 const int rc = search(menu, event->op, &index);
272 if ((rc == FR_SUCCESS) && (index != -1))
273 menu_set_index(menu, index);
274 return rc;
275 }
276 return FR_SUCCESS;
277}
static int search(struct Menu *menu, int op, int *match)
Search a menu.
Definition functions.c:59
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:127
+ Here is the call graph for this function:

◆ op_help()

static int op_help ( struct MenuFunctionData * fdata,
const struct KeyEvent * event )
static

Show the help screen - Implements menu_function_t -.

Definition at line 282 of file functions.c.

283{
284 struct Menu *menu = fdata->menu;
285 mutt_help(menu->md);
286 menu->redraw = MENU_REDRAW_FULL;
287 return FR_SUCCESS;
288}
void mutt_help(const struct MenuDefinition *md)
Display the Help Page.
Definition help.c:146
@ MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:64
MenuRedrawFlags redraw
When to redraw the screen.
Definition lib.h:89
const struct MenuDefinition * md
Menu definition for keymap entries.
Definition lib.h:90
+ Here is the call graph for this function:

◆ op_jump()

static int op_jump ( struct MenuFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to an index number - Implements menu_function_t -.

Definition at line 293 of file functions.c.

294{
295 struct Menu *menu = fdata->menu;
296 if (menu->max == 0)
297 {
298 mutt_error(_("No entries"));
299 return FR_ERROR;
300 }
301
302 struct Buffer *buf = buf_pool_get();
303 int rc = FR_ERROR;
304
305 int num = event->count;
306 if (num == 0)
307 {
308 if ((mw_get_field(_("Jump to: "), buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0) ||
309 buf_is_empty(buf))
310 {
311 rc = FR_NO_ACTION;
312 goto done;
313 }
314
315 if (!mutt_str_atoi_full(buf_string(buf), &num) || (num < 1) || (num > menu->max))
316 {
317 mutt_error(_("Invalid index number"));
318 goto done;
319 }
320 }
321
322 menu_set_index(menu, num - 1); // msg numbers are 0-based
323 rc = FR_SUCCESS;
324
325done:
326 buf_pool_release(&buf);
327 return rc;
328}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
@ MUTT_COMP_NONE
No flags are set.
Definition wdata.h:46
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition window.c:502
#define mutt_error(...)
Definition logging2.h:94
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:61
#define _(a)
Definition message.h:28
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
String manipulation buffer.
Definition buffer.h:36
+ Here is the call graph for this function: