NeoMutt  2025-12-11-949-g4870ee
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Mailing-list Function API

Prototype for a Mailing-list Function. More...

+ Collaboration diagram for Mailing-list Function API:

Functions

static int op_quit (struct ListData *ld, const struct KeyEvent *event)
 Save changes and exit this dialog - Implements mlist_function_t -.
 
static int op_select_action (struct ListData *ld, const struct KeyEvent *event)
 Execute the selected mailing-list action - Implements mlist_function_t -.
 

Detailed Description

Prototype for a Mailing-list Function.

Parameters
ldMailing-list dialog state
eventEvent to process
Return values
enumFunctionRetval
Precondition
ld is not NULL
event is not NULL

Function Documentation

◆ op_quit()

static int op_quit ( struct ListData * ld,
const struct KeyEvent * event )
static

Save changes and exit this dialog - Implements mlist_function_t -.

Parameters
ldDialog state
eventEvent being handled
Return values
enumFunctionRetval

Definition at line 187 of file functions.c.

188{
189 ld->done = true;
190 return FR_SUCCESS;
191}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
bool done
Exit the dialog.
Definition functions.h:70

◆ op_select_action()

static int op_select_action ( struct ListData * ld,
const struct KeyEvent * event )
static

Execute the selected mailing-list action - Implements mlist_function_t -.

Parameters
ldDialog state
eventEvent being handled
Return values
enumFunctionRetval

For a specific list opcode (e.g. OP_LIST_UNSUBSCRIBE) the matching action is used. If there are several matches (e.g. mailto: and https: links), the first match is selected, but the action is not performed. For a generic selection the currently highlighted action is used.

Definition at line 204 of file functions.c.

205{
206 const struct ListEntry *entry = NULL;
207
208 if (event && (event->op != OP_GENERIC_SELECT_ENTRY))
209 {
210 int first_match = -1;
211 int num_matches = 0;
212 for (int i = 0; i < ARRAY_SIZE(&ld->entries); i++)
213 {
214 const struct ListEntry *candidate = ARRAY_GET(&ld->entries, i);
215 if (candidate && (candidate->action->op == event->op))
216 {
217 if (first_match < 0)
218 first_match = i;
219 num_matches++;
220 }
221 }
222
223 if (num_matches == 0)
224 return FR_NO_ACTION;
225
226 menu_set_index(ld->menu, first_match);
227
228 // Several matches: just select the first, let the user choose
229 if (num_matches > 1)
230 return FR_SUCCESS;
231
232 entry = ARRAY_GET(&ld->entries, first_match);
233 }
234 else
235 {
236 entry = ARRAY_GET(&ld->entries, menu_get_index(ld->menu));
237 }
238
239 if (!entry)
240 return FR_NO_ACTION;
241
242 ld->done = compose_list_action(ld, entry);
243 return FR_SUCCESS;
244}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
bool candidate(struct CompletionData *cd, char *user, const char *src, char *dest, size_t dlen)
Helper function for completion.
Definition helpers.c:79
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:153
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:167
static bool compose_list_action(struct ListData *ld, const struct ListEntry *entry)
Compose a message for a mailing-list action.
Definition functions.c:126
int op
Function opcode, e.g. OP_HELP.
Definition get.h:77
struct Menu * menu
Dialog menu.
Definition functions.h:65
struct ListEntryArray entries
Menu rows.
Definition functions.h:68
A mailing-list action in the dialog.
Definition functions.h:48
+ Here is the call graph for this function: