NeoMutt  2025-12-11-769-g906513
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

Definition at line 190 of file functions.c.

191{
192 struct EnterWindowData *wdata = fdata->wdata;
193 if (wdata->tabs == 0)
194 {
195 if (wdata->cd)
197 else
198 wdata->cd = completion_data_new();
199 }
200
201 wdata->tabs++;
202 wdata->redraw = ENTER_REDRAW_LINE;
203
204 if (wdata->comp_api && wdata->comp_api->complete)
205 return wdata->comp_api->complete(wdata, event->op);
206
207 return FR_NO_ACTION;
208}
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:51
int tabs
Number of times the user has hit tab.
Definition wdata.h:68
struct CompletionData * cd
Auto-completion state data.
Definition wdata.h:72
const struct CompleteOps * comp_api
Auto-Completion API.
Definition wdata.h:57
enum EnterRedrawFlags redraw
What needs redrawing? See EnterRedrawFlags.
Definition wdata.h:62
int op
Function opcode, e.g. OP_HELP.
Definition get.h:52
+ 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 215 of file functions.c.

216{
217 struct EnterWindowData *wdata = fdata->wdata;
218 if (wdata->hclass == HC_NONE)
219 return FR_SUCCESS;
220
221 wdata->state->curpos = wdata->state->lastchar;
222 if (mutt_hist_at_scratch(wdata->hclass))
223 {
224 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
226 }
227 replace_part(wdata->state, 0, mutt_hist_next(wdata->hclass));
228 wdata->redraw = ENTER_REDRAW_INIT;
229 return FR_SUCCESS;
230}
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:149
@ ENTER_REDRAW_INIT
Go to end of line and redraw.
Definition wdata.h:37
@ HC_NONE
No History.
Definition lib.h:63
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:53
struct EnterState * state
Current state of text entry.
Definition wdata.h:55
enum HistoryClass hclass
History to use, e.g. HC_NEO_COMMAND.
Definition wdata.h:56
+ 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 235 of file functions.c.

237{
238 struct EnterWindowData *wdata = fdata->wdata;
239 if (wdata->hclass == HC_NONE)
240 return FR_SUCCESS;
241
242 wdata->state->curpos = wdata->state->lastchar;
243 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
244 mutt_hist_complete(wdata->buffer, wdata->hclass);
245 replace_part(wdata->state, 0, wdata->buffer->data);
246 return FR_CONTINUE;
247}
@ 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 252 of file functions.c.

253{
254 struct EnterWindowData *wdata = fdata->wdata;
255 if (wdata->hclass == HC_NONE)
256 return FR_SUCCESS;
257
258 wdata->state->curpos = wdata->state->lastchar;
259 if (mutt_hist_at_scratch(wdata->hclass))
260 {
261 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
263 }
264 replace_part(wdata->state, 0, mutt_hist_prev(wdata->hclass));
265 wdata->redraw = ENTER_REDRAW_INIT;
266 return FR_SUCCESS;
267}
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 274 of file functions.c.

275{
276 struct EnterWindowData *wdata = fdata->wdata;
277 int rc = editor_backspace(wdata->state);
278
279 if ((rc == FR_ERROR) && editor_buffer_is_empty(wdata->state))
280 {
281 const bool c_abort_backspace = cs_subset_bool(fdata->n->sub, "abort_backspace");
282 if (c_abort_backspace)
283 {
284 buf_reset(wdata->buffer);
285 wdata->done = true;
286 rc = FR_SUCCESS;
287 }
288 }
289
290 return rc;
291}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
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:70
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 296 of file functions.c.

297{
298 struct EnterWindowData *wdata = fdata->wdata;
299 return editor_backward_char(wdata->state);
300}
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 305 of file functions.c.

306{
307 struct EnterWindowData *wdata = fdata->wdata;
308 return editor_backward_word(wdata->state);
309}
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 314 of file functions.c.

315{
316 struct EnterWindowData *wdata = fdata->wdata;
317 return editor_bol(wdata->state);
318}
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 327 of file functions.c.

329{
330 struct EnterWindowData *wdata = fdata->wdata;
331 enum EnterCase ec;
332 switch (event->op)
333 {
334 case OP_EDITOR_CAPITALIZE_WORD:
335 ec = EC_CAPITALIZE;
336 break;
337 case OP_EDITOR_DOWNCASE_WORD:
338 ec = EC_DOWNCASE;
339 break;
340 case OP_EDITOR_UPCASE_WORD:
341 ec = EC_UPCASE;
342 break;
343 default:
344 return FR_ERROR;
345 }
346 return editor_case_word(wdata->state, ec);
347}
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 352 of file functions.c.

353{
354 struct EnterWindowData *wdata = fdata->wdata;
355 return editor_delete_char(wdata->state);
356}
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 361 of file functions.c.

362{
363 struct EnterWindowData *wdata = fdata->wdata;
364 int rc = editor_eol(wdata->state);
365 wdata->redraw = ENTER_REDRAW_INIT;
366 return rc;
367}
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 372 of file functions.c.

373{
374 struct EnterWindowData *wdata = fdata->wdata;
375 return editor_forward_char(wdata->state);
376}
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 381 of file functions.c.

382{
383 struct EnterWindowData *wdata = fdata->wdata;
384 return editor_forward_word(wdata->state);
385}
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 390 of file functions.c.

391{
392 struct EnterWindowData *wdata = fdata->wdata;
393 return editor_kill_eol(wdata->state);
394}
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 399 of file functions.c.

400{
401 struct EnterWindowData *wdata = fdata->wdata;
402 return editor_kill_eow(wdata->state);
403}
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 408 of file functions.c.

409{
410 struct EnterWindowData *wdata = fdata->wdata;
411 return editor_kill_line(wdata->state);
412}
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 417 of file functions.c.

419{
420 struct EnterWindowData *wdata = fdata->wdata;
421 return editor_kill_whole_line(wdata->state);
422}
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 427 of file functions.c.

428{
429 struct EnterWindowData *wdata = fdata->wdata;
430 return editor_kill_word(wdata->state);
431}
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 440 of file functions.c.

441{
442 struct EnterWindowData *wdata = fdata->wdata;
443 struct KeyEvent event_q = { 0, OP_NULL };
444 do
445 {
446 window_redraw(NULL);
447 event_q = mutt_getch(GETCH_NO_FLAGS);
448 } while ((event_q.op == OP_TIMEOUT) || (event_q.op == OP_REPAINT));
449
450 if (event_q.op != OP_ABORT)
451 {
452 if (self_insert(wdata, event_q.ch))
453 {
454 wdata->done = true;
455 return FR_SUCCESS;
456 }
457 }
458 return FR_SUCCESS;
459}
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:201
#define GETCH_NO_FLAGS
No flags are set.
Definition get.h:34
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:50
int ch
Raw key pressed.
Definition get.h:51
+ 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 464 of file functions.c.

466{
467 struct EnterWindowData *wdata = fdata->wdata;
468 return editor_transpose_chars(wdata->state);
469}
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 474 of file functions.c.

475{
477 return FR_SUCCESS;
478}
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 483 of file functions.c.

484{
485 clearok(stdscr, true);
488 window_redraw(NULL);
489 return FR_SUCCESS;
490}
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition resize.c:76
void window_invalidate_all(void)
Mark all windows as in need of repaint.
+ Here is the call graph for this function: