NeoMutt  2024-04-25-85-g27bab4
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 EnterWindowData *wdata, int op)
 Complete filename or alias - Implements enter_function_t -.
 
static int op_editor_history_down (struct EnterWindowData *wdata, int op)
 Scroll down through the history list - Implements enter_function_t -.
 
static int op_editor_history_search (struct EnterWindowData *wdata, int op)
 Search through the history list - Implements enter_function_t -.
 
static int op_editor_history_up (struct EnterWindowData *wdata, int op)
 Scroll up through the history list - Implements enter_function_t -.
 
static int op_editor_backspace (struct EnterWindowData *wdata, int op)
 Delete the char in front of the cursor - Implements enter_function_t -.
 
static int op_editor_backward_char (struct EnterWindowData *wdata, int op)
 Move the cursor one character to the left - Implements enter_function_t -.
 
static int op_editor_backward_word (struct EnterWindowData *wdata, int op)
 Move the cursor to the beginning of the word - Implements enter_function_t -.
 
static int op_editor_bol (struct EnterWindowData *wdata, int op)
 Jump to the beginning of the line - Implements enter_function_t -.
 
static int op_editor_capitalize_word (struct EnterWindowData *wdata, int op)
 Capitalize the word - Implements enter_function_t - This function handles:
 
static int op_editor_delete_char (struct EnterWindowData *wdata, int op)
 Delete the char under the cursor - Implements enter_function_t -.
 
static int op_editor_eol (struct EnterWindowData *wdata, int op)
 Jump to the end of the line - Implements enter_function_t -.
 
static int op_editor_forward_char (struct EnterWindowData *wdata, int op)
 Move the cursor one character to the right - Implements enter_function_t -.
 
static int op_editor_forward_word (struct EnterWindowData *wdata, int op)
 Move the cursor to the end of the word - Implements enter_function_t -.
 
static int op_editor_kill_eol (struct EnterWindowData *wdata, int op)
 Delete chars from cursor to end of line - Implements enter_function_t -.
 
static int op_editor_kill_eow (struct EnterWindowData *wdata, int op)
 Delete chars from the cursor to the end of the word - Implements enter_function_t -.
 
static int op_editor_kill_line (struct EnterWindowData *wdata, int op)
 Delete all chars on the line - Implements enter_function_t -.
 
static int op_editor_kill_whole_line (struct EnterWindowData *wdata, int op)
 Delete all chars on the line - Implements enter_function_t -.
 
static int op_editor_kill_word (struct EnterWindowData *wdata, int op)
 Delete the word in front of the cursor - Implements enter_function_t -.
 
static int op_editor_quote_char (struct EnterWindowData *wdata, int op)
 Quote the next typed key - Implements enter_function_t -.
 
static int op_editor_transpose_chars (struct EnterWindowData *wdata, int op)
 Transpose character under cursor with previous - Implements enter_function_t -.
 
static int op_help (struct EnterWindowData *wdata, int op)
 Display Help - Implements enter_function_t -.
 
static int op_redraw (struct EnterWindowData *wdata, int op)
 Redraw the screen - Implements enter_function_t -.
 

Detailed Description

Prototype for a Enter Function.

Parameters
wdataEnter Window data
opOperation to perform, e.g. OP_ENTER_NEXT
Return values
enumFunctionRetval

Function Documentation

◆ op_editor_complete()

static int op_editor_complete ( struct EnterWindowData wdata,
int  op 
)
static

Complete filename or alias - Implements enter_function_t -.

This function handles:

  • OP_EDITOR_COMPLETE
  • OP_EDITOR_COMPLETE_QUERY

Definition at line 174 of file functions.c.

175{
176 if (wdata->tabs == 0)
177 {
178 if (wdata->cd)
180 else
181 wdata->cd = completion_data_new();
182 }
183
184 wdata->tabs++;
185 wdata->redraw = ENTER_REDRAW_LINE;
186
187 if (wdata->comp_api && wdata->comp_api->complete)
188 return wdata->comp_api->complete(wdata, op);
189
190 return FR_NO_ACTION;
191}
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:37
@ ENTER_REDRAW_LINE
Redraw entire line.
Definition: wdata.h:39
enum FunctionRetval(* complete)(struct EnterWindowData *wdata, int op)
Definition: compapi.h:46
int tabs
Number of times the user has hit tab.
Definition: wdata.h:63
struct CompletionData * cd
Auto-completion state data.
Definition: wdata.h:67
const struct CompleteOps * comp_api
Auto-Completion API.
Definition: wdata.h:52
enum EnterRedrawFlags redraw
What needs redrawing? See EnterRedrawFlags.
Definition: wdata.h:57
+ Here is the call graph for this function:

◆ op_editor_history_down()

static int op_editor_history_down ( struct EnterWindowData wdata,
int  op 
)
static

Scroll down through the history list - Implements enter_function_t -.

Definition at line 198 of file functions.c.

199{
200 wdata->state->curpos = wdata->state->lastchar;
201 if (mutt_hist_at_scratch(wdata->hclass))
202 {
203 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
205 }
206 replace_part(wdata->state, 0, mutt_hist_next(wdata->hclass));
207 wdata->redraw = ENTER_REDRAW_INIT;
208 return FR_SUCCESS;
209}
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:39
void replace_part(struct EnterState *es, size_t from, const char *buf)
Search and replace on a buffer.
Definition: functions.c:133
@ ENTER_REDRAW_INIT
Go to end of line and redraw.
Definition: wdata.h:38
char * mutt_hist_next(enum HistoryClass hclass)
Get the next string in a History.
Definition: history.c:530
void mutt_hist_save_scratch(enum HistoryClass hclass, const char *str)
Save a temporary string to the History.
Definition: history.c:669
bool mutt_hist_at_scratch(enum HistoryClass hclass)
Is the current History position at the 'scratch' place?
Definition: history.c:652
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:256
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:48
struct EnterState * state
Current state of text entry.
Definition: wdata.h:50
enum HistoryClass hclass
History to use, e.g. HC_NEO_COMMAND.
Definition: wdata.h:51
+ Here is the call graph for this function:

◆ op_editor_history_search()

static int op_editor_history_search ( struct EnterWindowData wdata,
int  op 
)
static

Search through the history list - Implements enter_function_t -.

Definition at line 214 of file functions.c.

215{
216 wdata->state->curpos = wdata->state->lastchar;
217 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
218 mutt_hist_complete(wdata->buffer->data, wdata->buffer->dsize, wdata->hclass);
219 replace_part(wdata->state, 0, wdata->buffer->data);
220 return FR_CONTINUE;
221}
@ FR_CONTINUE
Remain in the Dialog.
Definition: dispatcher.h:34
void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass)
Complete a string from a history list.
Definition: history.c:686
size_t dsize
Length of data.
Definition: buffer.h:39
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 EnterWindowData wdata,
int  op 
)
static

Scroll up through the history list - Implements enter_function_t -.

Definition at line 226 of file functions.c.

227{
228 wdata->state->curpos = wdata->state->lastchar;
229 if (mutt_hist_at_scratch(wdata->hclass))
230 {
231 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
233 }
234 replace_part(wdata->state, 0, mutt_hist_prev(wdata->hclass));
235 wdata->redraw = ENTER_REDRAW_INIT;
236 return FR_SUCCESS;
237}
char * mutt_hist_prev(enum HistoryClass hclass)
Get the previous string in a History.
Definition: history.c:558
+ Here is the call graph for this function:

◆ op_editor_backspace()

static int op_editor_backspace ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 244 of file functions.c.

245{
246 int rc = editor_backspace(wdata->state);
247
248 if ((rc == FR_ERROR) && editor_buffer_is_empty(wdata->state))
249 {
250 const bool c_abort_backspace = cs_subset_bool(NeoMutt->sub, "abort_backspace");
251 if (c_abort_backspace)
252 {
253 buf_reset(wdata->buffer);
254 wdata->done = true;
255 rc = FR_SUCCESS;
256 }
257 }
258
259 return rc;
260}
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:38
bool editor_buffer_is_empty(struct EnterState *es)
Is the Enter buffer empty?
Definition: enter.c:386
int editor_backspace(struct EnterState *es)
Delete the char in front of the cursor.
Definition: enter.c:48
bool done
Is text-entry done?
Definition: wdata.h:65
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
+ Here is the call graph for this function:

◆ op_editor_backward_char()

static int op_editor_backward_char ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 265 of file functions.c.

266{
267 return editor_backward_char(wdata->state);
268}
int editor_backward_char(struct EnterState *es)
Move the cursor one character to the left.
Definition: enter.c:71
+ Here is the call graph for this function:

◆ op_editor_backward_word()

static int op_editor_backward_word ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 273 of file functions.c.

274{
275 return editor_backward_word(wdata->state);
276}
int editor_backward_word(struct EnterState *es)
Move the cursor to the beginning of the word.
Definition: enter.c:90
+ Here is the call graph for this function:

◆ op_editor_bol()

static int op_editor_bol ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 281 of file functions.c.

282{
283 return editor_bol(wdata->state);
284}
int editor_bol(struct EnterState *es)
Jump to the beginning of the line.
Definition: enter.c:109
+ Here is the call graph for this function:

◆ op_editor_capitalize_word()

static int op_editor_capitalize_word ( struct EnterWindowData wdata,
int  op 
)
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 293 of file functions.c.

294{
295 enum EnterCase ec;
296 switch (op)
297 {
298 case OP_EDITOR_CAPITALIZE_WORD:
299 ec = EC_CAPITALIZE;
300 break;
301 case OP_EDITOR_DOWNCASE_WORD:
302 ec = EC_DOWNCASE;
303 break;
304 case OP_EDITOR_UPCASE_WORD:
305 ec = EC_UPCASE;
306 break;
307 default:
308 return FR_ERROR;
309 }
310 return editor_case_word(wdata->state, ec);
311}
int editor_case_word(struct EnterState *es, enum EnterCase ec)
Change the case of the word.
Definition: enter.c:125
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 EnterWindowData wdata,
int  op 
)
static

Delete the char under the cursor - Implements enter_function_t -.

Definition at line 316 of file functions.c.

317{
318 return editor_delete_char(wdata->state);
319}
int editor_delete_char(struct EnterState *es)
Delete the char under the cursor.
Definition: enter.c:157
+ Here is the call graph for this function:

◆ op_editor_eol()

static int op_editor_eol ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 324 of file functions.c.

325{
326 int rc = editor_eol(wdata->state);
327 wdata->redraw = ENTER_REDRAW_INIT;
328 return rc;
329}
int editor_eol(struct EnterState *es)
Jump to the end of the line.
Definition: enter.c:179
+ Here is the call graph for this function:

◆ op_editor_forward_char()

static int op_editor_forward_char ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 334 of file functions.c.

335{
336 return editor_forward_char(wdata->state);
337}
int editor_forward_char(struct EnterState *es)
Move the cursor one character to the right.
Definition: enter.c:194
+ Here is the call graph for this function:

◆ op_editor_forward_word()

static int op_editor_forward_word ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 342 of file functions.c.

343{
344 return editor_forward_word(wdata->state);
345}
int editor_forward_word(struct EnterState *es)
Move the cursor to the end of the word.
Definition: enter.c:214
+ Here is the call graph for this function:

◆ op_editor_kill_eol()

static int op_editor_kill_eol ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 350 of file functions.c.

351{
352 return editor_kill_eol(wdata->state);
353}
int editor_kill_eol(struct EnterState *es)
Delete chars from cursor to end of line.
Definition: enter.c:237
+ Here is the call graph for this function:

◆ op_editor_kill_eow()

static int op_editor_kill_eow ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 358 of file functions.c.

359{
360 return editor_kill_eow(wdata->state);
361}
int editor_kill_eow(struct EnterState *es)
Delete chars from the cursor to the end of the word.
Definition: enter.c:252
+ Here is the call graph for this function:

◆ op_editor_kill_line()

static int op_editor_kill_line ( struct EnterWindowData wdata,
int  op 
)
static

Delete all chars on the line - Implements enter_function_t -.

Definition at line 366 of file functions.c.

367{
368 return editor_kill_line(wdata->state);
369}
int editor_kill_line(struct EnterState *es)
Delete chars from cursor to beginning the line.
Definition: enter.c:291
+ Here is the call graph for this function:

◆ op_editor_kill_whole_line()

static int op_editor_kill_whole_line ( struct EnterWindowData wdata,
int  op 
)
static

Delete all chars on the line - Implements enter_function_t -.

Definition at line 374 of file functions.c.

375{
376 return editor_kill_whole_line(wdata->state);
377}
int editor_kill_whole_line(struct EnterState *es)
Delete all chars on the line.
Definition: enter.c:312
+ Here is the call graph for this function:

◆ op_editor_kill_word()

static int op_editor_kill_word ( struct EnterWindowData wdata,
int  op 
)
static

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

Definition at line 382 of file functions.c.

383{
384 return editor_kill_word(wdata->state);
385}
int editor_kill_word(struct EnterState *es)
Delete the word in front of the cursor.
Definition: enter.c:329
+ Here is the call graph for this function:

◆ op_editor_quote_char()

static int op_editor_quote_char ( struct EnterWindowData wdata,
int  op 
)
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 394 of file functions.c.

395{
396 struct KeyEvent event = { 0, OP_NULL };
397 do
398 {
399 window_redraw(NULL);
400 event = mutt_getch(GETCH_NO_FLAGS);
401 } while ((event.op == OP_TIMEOUT) || (event.op == OP_REPAINT));
402
403 if (event.op != OP_ABORT)
404 {
405 if (self_insert(wdata, event.ch))
406 {
407 wdata->done = true;
408 return FR_SUCCESS;
409 }
410 }
411 return FR_SUCCESS;
412}
struct KeyEvent mutt_getch(GetChFlags flags)
Read a character from the input buffer.
Definition: get.c:210
bool self_insert(struct EnterWindowData *wdata, int ch)
Insert a normal character.
Definition: window.c:89
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:51
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:634
#define OP_TIMEOUT
1 second with no events
Definition: opcodes.h:36
#define OP_REPAINT
Repaint is needed.
Definition: opcodes.h:34
#define OP_ABORT
$abort_key pressed (Ctrl-G)
Definition: opcodes.h:37
An event such as a keypress.
Definition: lib.h:81
int op
Function opcode, e.g. OP_HELP.
Definition: lib.h:83
int ch
Raw key pressed.
Definition: lib.h:82
+ Here is the call graph for this function:

◆ op_editor_transpose_chars()

static int op_editor_transpose_chars ( struct EnterWindowData wdata,
int  op 
)
static

Transpose character under cursor with previous - Implements enter_function_t -.

Definition at line 417 of file functions.c.

418{
419 return editor_transpose_chars(wdata->state);
420}
int editor_transpose_chars(struct EnterState *es)
Transpose character under cursor with previous.
Definition: enter.c:362
+ Here is the call graph for this function:

◆ op_help()

static int op_help ( struct EnterWindowData wdata,
int  op 
)
static

Display Help - Implements enter_function_t -.

Definition at line 425 of file functions.c.

426{
428 return FR_SUCCESS;
429}
void mutt_help(enum MenuType menu)
Display the help menu.
Definition: help.c:467
@ MENU_EDITOR
Text entry area.
Definition: type.h:44
+ Here is the call graph for this function:

◆ op_redraw()

static int op_redraw ( struct EnterWindowData wdata,
int  op 
)
static

Redraw the screen - Implements enter_function_t -.

Definition at line 434 of file functions.c.

435{
436 clearok(stdscr, true);
439 window_redraw(NULL);
440 return FR_SUCCESS;
441}
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.
Definition: mutt_window.c:767
+ Here is the call graph for this function: