NeoMutt  2025-12-11-435-g4ac674
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 Menu *menu, const struct KeyEvent *event)
 Handle all the common Menu movements - Implements menu_function_t -.
 
static int menu_search (struct Menu *menu, const struct KeyEvent *event)
 Handle Menu searching - Implements menu_function_t -.
 
static int op_help (struct Menu *menu, const struct KeyEvent *event)
 Show the help screen - Implements menu_function_t -.
 
static int op_jump (struct Menu *menu, const struct KeyEvent *event)
 Jump to an index number - Implements menu_function_t -.
 

Detailed Description

Prototype for a Menu Function.

Parameters
menuMenu
eventEvent to process
Return values
enumFunctionRetval
Precondition
menu is not NULL
event is not NULL

Function Documentation

◆ menu_movement()

static int menu_movement ( struct Menu * menu,
const struct KeyEvent * event )
static

Handle all the common Menu movements - Implements menu_function_t -.

Definition at line 142 of file functions.c.

143{
144 switch (event->op)
145 {
146 case OP_BOTTOM_PAGE:
147 menu_bottom_page(menu);
148 return FR_SUCCESS;
149
150 case OP_CURRENT_BOTTOM:
152 return FR_SUCCESS;
153
154 case OP_CURRENT_MIDDLE:
156 return FR_SUCCESS;
157
158 case OP_CURRENT_TOP:
159 menu_current_top(menu);
160 return FR_SUCCESS;
161
162 case OP_FIRST_ENTRY:
163 menu_first_entry(menu);
164 return FR_SUCCESS;
165
166 case OP_HALF_DOWN:
167 menu_half_down(menu);
168 return FR_SUCCESS;
169
170 case OP_HALF_UP:
171 menu_half_up(menu);
172 return FR_SUCCESS;
173
174 case OP_LAST_ENTRY:
175 menu_last_entry(menu);
176 return FR_SUCCESS;
177
178 case OP_MIDDLE_PAGE:
179 menu_middle_page(menu);
180 return FR_SUCCESS;
181
182 case OP_NEXT_ENTRY:
183 menu_next_entry(menu);
184 return FR_SUCCESS;
185
186 case OP_NEXT_LINE:
187 menu_next_line(menu);
188 return FR_SUCCESS;
189
190 case OP_NEXT_PAGE:
191 menu_next_page(menu);
192 return FR_SUCCESS;
193
194 case OP_PREV_ENTRY:
195 menu_prev_entry(menu);
196 return FR_SUCCESS;
197
198 case OP_PREV_LINE:
199 menu_prev_line(menu);
200 return FR_SUCCESS;
201
202 case OP_PREV_PAGE:
203 menu_prev_page(menu);
204 return FR_SUCCESS;
205
206 case OP_TOP_PAGE:
207 menu_top_page(menu);
208 return FR_SUCCESS;
209
210 default:
211 return FR_UNKNOWN;
212 }
213}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:34
MenuRedrawFlags menu_next_page(struct Menu *menu)
Move the focus to the next page in the menu.
Definition move.c:565
MenuRedrawFlags menu_bottom_page(struct Menu *menu)
Move the focus to the bottom of the page.
Definition move.c:366
MenuRedrawFlags menu_half_up(struct Menu *menu)
Move the focus up half a page in the menu.
Definition move.c:509
MenuRedrawFlags menu_prev_line(struct Menu *menu)
Move the view up one line, keeping the selection the same.
Definition move.c:529
MenuRedrawFlags menu_current_bottom(struct Menu *menu)
Move the current selection to the bottom of the window.
Definition move.c:487
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition move.c:467
MenuRedrawFlags menu_middle_page(struct Menu *menu)
Move the focus to the centre of the page.
Definition move.c:346
MenuRedrawFlags menu_first_entry(struct Menu *menu)
Move the focus to the first entry in the menu.
Definition move.c:413
MenuRedrawFlags menu_half_down(struct Menu *menu)
Move the focus down half a page in the menu.
Definition move.c:519
MenuRedrawFlags menu_top_page(struct Menu *menu)
Move the focus to the top of the page.
Definition move.c:336
MenuRedrawFlags menu_last_entry(struct Menu *menu)
Move the focus to the last entry in the menu.
Definition move.c:429
MenuRedrawFlags menu_prev_page(struct Menu *menu)
Move the focus to the previous page in the menu.
Definition move.c:555
MenuRedrawFlags menu_next_line(struct Menu *menu)
Move the view down one line, keeping the selection the same.
Definition move.c:542
MenuRedrawFlags menu_prev_entry(struct Menu *menu)
Move the focus to the previous item in the menu.
Definition move.c:385
MenuRedrawFlags menu_current_top(struct Menu *menu)
Move the current selection to the top of the window.
Definition move.c:446
MenuRedrawFlags menu_next_entry(struct Menu *menu)
Move the focus to the next item in the menu.
Definition move.c:399
int op
Function opcode, e.g. OP_HELP.
Definition get.h:52
+ Here is the call graph for this function:

◆ menu_search()

static int menu_search ( struct Menu * menu,
const struct KeyEvent * event )
static

Handle Menu searching - Implements menu_function_t -.

Definition at line 218 of file functions.c.

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

◆ op_help()

static int op_help ( struct Menu * menu,
const struct KeyEvent * event )
static

Show the help screen - Implements menu_function_t -.

Definition at line 232 of file functions.c.

233{
234 mutt_help(menu->md);
235 menu->redraw = MENU_REDRAW_FULL;
236 return FR_SUCCESS;
237}
void mutt_help(const struct MenuDefinition *md)
Display the Help Page.
Definition help.c:147
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:60
MenuRedrawFlags redraw
When to redraw the screen.
Definition lib.h:83
const struct MenuDefinition * md
Menu definition for keymap entries.
Definition lib.h:84
+ Here is the call graph for this function:

◆ op_jump()

static int op_jump ( struct Menu * menu,
const struct KeyEvent * event )
static

Jump to an index number - Implements menu_function_t -.

Definition at line 242 of file functions.c.

243{
244 if (menu->max == 0)
245 {
246 mutt_error(_("No entries"));
247 return FR_SUCCESS;
248 }
249
250 const int digit = event->op - OP_JUMP;
251 if ((digit > 0) && (digit < 10))
252 {
253 mutt_unget_ch('0' + digit);
254 }
255
256 struct Buffer *buf = buf_pool_get();
257 if ((mw_get_field(_("Jump to: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0) &&
258 !buf_is_empty(buf))
259 {
260 int n = 0;
261 if (mutt_str_atoi_full(buf_string(buf), &n) && (n > 0) && (n < (menu->max + 1)))
262 {
263 menu_set_index(menu, n - 1); // msg numbers are 0-based
264 }
265 else
266 {
267 mutt_error(_("Invalid index number"));
268 }
269 }
270
271 buf_pool_release(&buf);
272 return FR_SUCCESS;
273}
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
int digit(const char *s)
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition wdata.h:42
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition get.c:122
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:270
#define mutt_error(...)
Definition logging2.h:94
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:60
#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
int max
Number of entries in the menu.
Definition lib.h:82
+ Here is the call graph for this function: