NeoMutt  2025-12-11-924-g64e75a
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Enter Function API

Prototype for a Enter Function. More...

Functions

static int op_editor_complete (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Complete filename or alias - Implements enter_function_t -.
 
static int op_editor_history_down (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Scroll down through the history list - Implements enter_function_t -.
 
static int op_editor_history_search (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Search through the history list - Implements enter_function_t -.
 
static int op_editor_history_up (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Scroll up through the history list - Implements enter_function_t -.
 
static int op_editor_backspace (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Delete the char in front of the cursor - Implements enter_function_t -.
 
static int op_editor_backward_char (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Move the cursor one character to the left - Implements enter_function_t -.
 
static int op_editor_backward_word (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Move the cursor to the beginning of the word - Implements enter_function_t -.
 
static int op_editor_bol (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Jump to the beginning of the line - Implements enter_function_t -.
 
static int op_editor_capitalize_word (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Capitalize the word - Implements enter_function_t - This function handles:
 
static int op_editor_delete_char (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Delete the char under the cursor - Implements enter_function_t -.
 
static int op_editor_eol (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Jump to the end of the line - Implements enter_function_t -.
 
static int op_editor_forward_char (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Move the cursor one character to the right - Implements enter_function_t -.
 
static int op_editor_forward_word (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Move the cursor to the end of the word - Implements enter_function_t -.
 
static int op_editor_kill_eol (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Delete chars from cursor to end of line - Implements enter_function_t -.
 
static int op_editor_kill_eow (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Delete chars from the cursor to the end of the word - Implements enter_function_t -.
 
static int op_editor_kill_line (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Delete all chars on the line - Implements enter_function_t -.
 
static int op_editor_kill_whole_line (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Delete all chars on the line - Implements enter_function_t -.
 
static int op_editor_kill_word (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Delete the word in front of the cursor - Implements enter_function_t -.
 
static int op_editor_quote_char (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Quote the next typed key - Implements enter_function_t -.
 
static int op_editor_transpose_chars (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Transpose character under cursor with previous - Implements enter_function_t -.
 
static int op_help (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Display Help - Implements enter_function_t -.
 
static int op_redraw (struct EnterFunctionData *fdata, const struct KeyEvent *event)
 Redraw the screen - Implements enter_function_t -.
 

Detailed Description

Prototype for a Enter Function.

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

Function Documentation

◆ op_editor_complete()

static int op_editor_complete ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Complete filename or alias - Implements enter_function_t -.

This function handles:

  • OP_EDITOR_COMPLETE
  • OP_EDITOR_COMPLETE_QUERY
  • OP_EDITOR_MAILBOX_CYCLE

Definition at line 192 of file functions.c.

193{
194 struct EnterWindowData *wdata = fdata->wdata;
195 if (wdata->tabs == 0)
196 {
197 if (wdata->cd)
199 else
200 wdata->cd = completion_data_new();
201 }
202
203 wdata->tabs++;
204 wdata->redraw = ENTER_REDRAW_LINE;
205
206 if (wdata->comp_api && wdata->comp_api->complete)
207 return wdata->comp_api->complete(wdata, event->op);
208
209 return FR_NO_ACTION;
210}
struct CompletionData * completion_data_new(void)
Create new Completion Data.
Definition data.c:71
void completion_data_reset(struct CompletionData *cd)
Wipe the stored Completion Data.
Definition data.c:85
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
@ ENTER_REDRAW_LINE
Redraw entire line.
Definition wdata.h:38
enum FunctionRetval(* complete)(struct EnterWindowData *wdata, int op)
Definition compapi.h:46
struct EnterWindowData * wdata
Enter window data.
Definition functions.h:45
Data to fill the Enter Window.
Definition wdata.h:57
int tabs
Number of times the user has hit tab.
Definition wdata.h:74
struct CompletionData * cd
Auto-completion state data.
Definition wdata.h:78
const struct CompleteOps * comp_api
Auto-Completion API.
Definition wdata.h:63
enum EnterRedrawFlags redraw
What needs redrawing? See EnterRedrawFlags.
Definition wdata.h:68
int op
Function opcode, e.g. OP_HELP.
Definition get.h:77
+ Here is the call graph for this function:

◆ op_editor_history_down()

static int op_editor_history_down ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Scroll down through the history list - Implements enter_function_t -.

Definition at line 217 of file functions.c.

218{
219 struct EnterWindowData *wdata = fdata->wdata;
220 if (wdata->hclass == HC_NONE)
221 return FR_SUCCESS;
222
223 wdata->state->curpos = wdata->state->lastchar;
224 if (mutt_hist_at_scratch(wdata->hclass))
225 {
226 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
228 }
229 replace_part(wdata->state, 0, mutt_hist_next(wdata->hclass));
230 wdata->redraw = ENTER_REDRAW_INIT;
231 return FR_SUCCESS;
232}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
void replace_part(struct EnterState *es, size_t from, const char *buf)
Search and replace on a buffer.
Definition functions.c:150
@ ENTER_REDRAW_INIT
Go to end of line and redraw.
Definition wdata.h:37
@ HC_NONE
No History.
Definition lib.h:64
char * mutt_hist_next(enum HistoryClass hclass)
Get the next string in a History.
Definition history.c:509
void mutt_hist_save_scratch(enum HistoryClass hclass, const char *str)
Save a temporary string to the History.
Definition history.c:648
bool mutt_hist_at_scratch(enum HistoryClass hclass)
Is the current History position at the 'scratch' place?
Definition history.c:631
void buf_mb_wcstombs(struct Buffer *dest, const wchar_t *wstr, size_t wlen)
Convert a string from wide to multibyte characters.
Definition mbyte.c:257
size_t curpos
Position of the cursor.
Definition state.h:36
wchar_t * wbuf
Buffer for the string being entered.
Definition state.h:33
size_t lastchar
Position of the last character.
Definition state.h:35
struct Buffer * buffer
struct Buffer for the result
Definition wdata.h:59
struct EnterState * state
Current state of text entry.
Definition wdata.h:61
enum HistoryClass hclass
History to use, e.g. HC_NEO_COMMAND.
Definition wdata.h:62
+ Here is the call graph for this function:

◆ op_editor_history_search()

static int op_editor_history_search ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Search through the history list - Implements enter_function_t -.

Definition at line 237 of file functions.c.

239{
240 struct EnterWindowData *wdata = fdata->wdata;
241 if (wdata->hclass == HC_NONE)
242 return FR_SUCCESS;
243
244 wdata->state->curpos = wdata->state->lastchar;
245 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
246 mutt_hist_complete(wdata->buffer, wdata->hclass);
247 replace_part(wdata->state, 0, wdata->buffer->data);
248 return FR_CONTINUE;
249}
@ FR_CONTINUE
Remain in the Dialog.
Definition dispatcher.h:35
void mutt_hist_complete(struct Buffer *buf, enum HistoryClass hclass)
Complete a string from a history list.
Definition history.c:664
char * data
Pointer to data.
Definition buffer.h:37
+ Here is the call graph for this function:

◆ op_editor_history_up()

static int op_editor_history_up ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Scroll up through the history list - Implements enter_function_t -.

Definition at line 254 of file functions.c.

255{
256 struct EnterWindowData *wdata = fdata->wdata;
257 if (wdata->hclass == HC_NONE)
258 return FR_SUCCESS;
259
260 wdata->state->curpos = wdata->state->lastchar;
261 if (mutt_hist_at_scratch(wdata->hclass))
262 {
263 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
265 }
266 replace_part(wdata->state, 0, mutt_hist_prev(wdata->hclass));
267 wdata->redraw = ENTER_REDRAW_INIT;
268 return FR_SUCCESS;
269}
char * mutt_hist_prev(enum HistoryClass hclass)
Get the previous string in a History.
Definition history.c:537
+ Here is the call graph for this function:

◆ op_editor_backspace()

static int op_editor_backspace ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Delete the char in front of the cursor - Implements enter_function_t -.

Definition at line 276 of file functions.c.

277{
278 struct EnterWindowData *wdata = fdata->wdata;
279 int rc = editor_backspace(wdata->state);
280
281 if ((rc == FR_ERROR) && editor_buffer_is_empty(wdata->state))
282 {
283 const bool c_abort_backspace = cs_subset_bool(fdata->n->sub, "abort_backspace");
284 if (c_abort_backspace)
285 {
286 buf_reset(wdata->buffer);
287 wdata->done = true;
288 rc = FR_SUCCESS;
289 }
290 }
291
292 return rc;
293}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:91
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
bool editor_buffer_is_empty(struct EnterState *es)
Is the Enter buffer empty?
Definition enter.c:384
int editor_backspace(struct EnterState *es)
Delete the char in front of the cursor.
Definition enter.c:46
struct NeoMutt * n
NeoMutt application data.
Definition functions.h:43
bool done
Is text-entry done?
Definition wdata.h:76
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:

◆ op_editor_backward_char()

static int op_editor_backward_char ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Move the cursor one character to the left - Implements enter_function_t -.

Definition at line 298 of file functions.c.

299{
300 struct EnterWindowData *wdata = fdata->wdata;
301 return editor_backward_char(wdata->state);
302}
int editor_backward_char(struct EnterState *es)
Move the cursor one character to the left.
Definition enter.c:69
+ Here is the call graph for this function:

◆ op_editor_backward_word()

static int op_editor_backward_word ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Move the cursor to the beginning of the word - Implements enter_function_t -.

Definition at line 307 of file functions.c.

308{
309 struct EnterWindowData *wdata = fdata->wdata;
310 return editor_backward_word(wdata->state);
311}
int editor_backward_word(struct EnterState *es)
Move the cursor to the beginning of the word.
Definition enter.c:88
+ Here is the call graph for this function:

◆ op_editor_bol()

static int op_editor_bol ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to the beginning of the line - Implements enter_function_t -.

Definition at line 316 of file functions.c.

317{
318 struct EnterWindowData *wdata = fdata->wdata;
319 return editor_bol(wdata->state);
320}
int editor_bol(struct EnterState *es)
Jump to the beginning of the line.
Definition enter.c:107
+ Here is the call graph for this function:

◆ op_editor_capitalize_word()

static int op_editor_capitalize_word ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Capitalize the word - Implements enter_function_t - This function handles:

  • OP_EDITOR_CAPITALIZE_WORD
  • OP_EDITOR_DOWNCASE_WORD
  • OP_EDITOR_UPCASE_WORD

Definition at line 329 of file functions.c.

331{
332 struct EnterWindowData *wdata = fdata->wdata;
333 enum EnterCase ec;
334 switch (event->op)
335 {
336 case OP_EDITOR_CAPITALIZE_WORD:
337 ec = EC_CAPITALIZE;
338 break;
339 case OP_EDITOR_DOWNCASE_WORD:
340 ec = EC_DOWNCASE;
341 break;
342 case OP_EDITOR_UPCASE_WORD:
343 ec = EC_UPCASE;
344 break;
345 default:
346 return FR_ERROR;
347 }
348 return editor_case_word(wdata->state, ec);
349}
int editor_case_word(struct EnterState *es, enum EnterCase ec)
Change the case of the word.
Definition enter.c:123
EnterCase
Change the case of a word.
Definition enter.h:34
@ EC_UPCASE
Upper case (all characters)
Definition enter.h:36
@ EC_DOWNCASE
Lower case (all characters)
Definition enter.h:37
@ EC_CAPITALIZE
Capitalize word (first character only)
Definition enter.h:35
+ Here is the call graph for this function:

◆ op_editor_delete_char()

static int op_editor_delete_char ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Delete the char under the cursor - Implements enter_function_t -.

Definition at line 354 of file functions.c.

355{
356 struct EnterWindowData *wdata = fdata->wdata;
357 return editor_delete_char(wdata->state);
358}
int editor_delete_char(struct EnterState *es)
Delete the char under the cursor.
Definition enter.c:155
+ Here is the call graph for this function:

◆ op_editor_eol()

static int op_editor_eol ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to the end of the line - Implements enter_function_t -.

Definition at line 363 of file functions.c.

364{
365 struct EnterWindowData *wdata = fdata->wdata;
366 int rc = editor_eol(wdata->state);
367 wdata->redraw = ENTER_REDRAW_INIT;
368 return rc;
369}
int editor_eol(struct EnterState *es)
Jump to the end of the line.
Definition enter.c:177
+ Here is the call graph for this function:

◆ op_editor_forward_char()

static int op_editor_forward_char ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Move the cursor one character to the right - Implements enter_function_t -.

Definition at line 374 of file functions.c.

375{
376 struct EnterWindowData *wdata = fdata->wdata;
377 return editor_forward_char(wdata->state);
378}
int editor_forward_char(struct EnterState *es)
Move the cursor one character to the right.
Definition enter.c:192
+ Here is the call graph for this function:

◆ op_editor_forward_word()

static int op_editor_forward_word ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Move the cursor to the end of the word - Implements enter_function_t -.

Definition at line 383 of file functions.c.

384{
385 struct EnterWindowData *wdata = fdata->wdata;
386 return editor_forward_word(wdata->state);
387}
int editor_forward_word(struct EnterState *es)
Move the cursor to the end of the word.
Definition enter.c:212
+ Here is the call graph for this function:

◆ op_editor_kill_eol()

static int op_editor_kill_eol ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Delete chars from cursor to end of line - Implements enter_function_t -.

Definition at line 392 of file functions.c.

393{
394 struct EnterWindowData *wdata = fdata->wdata;
395 return editor_kill_eol(wdata->state);
396}
int editor_kill_eol(struct EnterState *es)
Delete chars from cursor to end of line.
Definition enter.c:235
+ Here is the call graph for this function:

◆ op_editor_kill_eow()

static int op_editor_kill_eow ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Delete chars from the cursor to the end of the word - Implements enter_function_t -.

Definition at line 401 of file functions.c.

402{
403 struct EnterWindowData *wdata = fdata->wdata;
404 return editor_kill_eow(wdata->state);
405}
int editor_kill_eow(struct EnterState *es)
Delete chars from the cursor to the end of the word.
Definition enter.c:250
+ Here is the call graph for this function:

◆ op_editor_kill_line()

static int op_editor_kill_line ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Delete all chars on the line - Implements enter_function_t -.

Definition at line 410 of file functions.c.

411{
412 struct EnterWindowData *wdata = fdata->wdata;
413 return editor_kill_line(wdata->state);
414}
int editor_kill_line(struct EnterState *es)
Delete chars from cursor to beginning the line.
Definition enter.c:289
+ Here is the call graph for this function:

◆ op_editor_kill_whole_line()

static int op_editor_kill_whole_line ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Delete all chars on the line - Implements enter_function_t -.

Definition at line 419 of file functions.c.

421{
422 struct EnterWindowData *wdata = fdata->wdata;
423 return editor_kill_whole_line(wdata->state);
424}
int editor_kill_whole_line(struct EnterState *es)
Delete all chars on the line.
Definition enter.c:310
+ Here is the call graph for this function:

◆ op_editor_kill_word()

static int op_editor_kill_word ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Delete the word in front of the cursor - Implements enter_function_t -.

Definition at line 429 of file functions.c.

430{
431 struct EnterWindowData *wdata = fdata->wdata;
432 return editor_kill_word(wdata->state);
433}
int editor_kill_word(struct EnterState *es)
Delete the word in front of the cursor.
Definition enter.c:327
+ Here is the call graph for this function:

◆ op_editor_quote_char()

static int op_editor_quote_char ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Quote the next typed key - Implements enter_function_t -.

As part of the line-editor, this function uses the message window.

See also
GUI: Message Windows

Definition at line 442 of file functions.c.

443{
444 struct EnterWindowData *wdata = fdata->wdata;
445 struct KeyEvent event_q = { 0, OP_NULL };
446 do
447 {
448 window_redraw(NULL);
449 event_q = mutt_getch(GETCH_NONE);
450 } while ((event_q.op == OP_TIMEOUT) || (event_q.op == OP_REPAINT));
451
452 if (event_q.op != OP_ABORT)
453 {
454 if (self_insert(wdata, event_q.ch))
455 {
456 wdata->done = true;
457 return FR_SUCCESS;
458 }
459 }
460 return FR_SUCCESS;
461}
bool self_insert(struct EnterWindowData *wdata, int ch)
Insert a normal character.
Definition window.c:88
struct KeyEvent mutt_getch(GetChFlags flags)
Read a character from the input buffer.
Definition get.c:319
@ GETCH_NONE
No flags are set.
Definition get.h:38
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
#define OP_TIMEOUT
1 second with no events
Definition opcodes.h:35
#define OP_REPAINT
Repaint is needed.
Definition opcodes.h:34
#define OP_ABORT
$abort_key pressed (Ctrl-G)
Definition opcodes.h:36
An event such as a keypress.
Definition get.h:75
int ch
Raw key pressed.
Definition get.h:76
+ Here is the call graph for this function:

◆ op_editor_transpose_chars()

static int op_editor_transpose_chars ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Transpose character under cursor with previous - Implements enter_function_t -.

Definition at line 466 of file functions.c.

468{
469 struct EnterWindowData *wdata = fdata->wdata;
470 return editor_transpose_chars(wdata->state);
471}
int editor_transpose_chars(struct EnterState *es)
Transpose character under cursor with previous.
Definition enter.c:360
+ Here is the call graph for this function:

◆ op_help()

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

Display Help - Implements enter_function_t -.

Definition at line 476 of file functions.c.

477{
479 return FR_SUCCESS;
480}
void mutt_help(const struct MenuDefinition *md)
Display the Help Page.
Definition help.c:146
struct MenuDefinition * md_editor
Editor Menu Definition.
Definition module_data.h:32
struct EditorModuleData * mod_data
Editor module data.
Definition functions.h:44
+ Here is the call graph for this function:

◆ op_redraw()

static int op_redraw ( struct EnterFunctionData * fdata,
const struct KeyEvent * event )
static

Redraw the screen - Implements enter_function_t -.

Definition at line 485 of file functions.c.

486{
488 clearok(stdscr, true);
491 window_redraw(NULL);
492 return FR_SUCCESS;
493}
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition resize.c:76
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
void window_invalidate_all(void)
Mark all windows as in need of repaint.
+ Here is the call graph for this function: