NeoMutt  2024-11-14-34-g5aaf0d
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 173 of file functions.c.

174{
175 if (wdata->tabs == 0)
176 {
177 if (wdata->cd)
179 else
180 wdata->cd = completion_data_new();
181 }
182
183 wdata->tabs++;
184 wdata->redraw = ENTER_REDRAW_LINE;
185
186 if (wdata->comp_api && wdata->comp_api->complete)
187 return wdata->comp_api->complete(wdata, op);
188
189 return FR_NO_ACTION;
190}
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 197 of file functions.c.

198{
199 wdata->state->curpos = wdata->state->lastchar;
200 if (mutt_hist_at_scratch(wdata->hclass))
201 {
202 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
204 }
205 replace_part(wdata->state, 0, mutt_hist_next(wdata->hclass));
206 wdata->redraw = ENTER_REDRAW_INIT;
207 return FR_SUCCESS;
208}
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:132
@ 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:534
void mutt_hist_save_scratch(enum HistoryClass hclass, const char *str)
Save a temporary string to the History.
Definition: history.c:673
bool mutt_hist_at_scratch(enum HistoryClass hclass)
Is the current History position at the 'scratch' place?
Definition: history.c:656
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 213 of file functions.c.

214{
215 wdata->state->curpos = wdata->state->lastchar;
216 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
217 mutt_hist_complete(wdata->buffer, wdata->hclass);
218 replace_part(wdata->state, 0, wdata->buffer->data);
219 return FR_CONTINUE;
220}
@ FR_CONTINUE
Remain in the Dialog.
Definition: dispatcher.h:34
void mutt_hist_complete(struct Buffer *buf, enum HistoryClass hclass)
Complete a string from a history list.
Definition: history.c:689
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 225 of file functions.c.

226{
227 wdata->state->curpos = wdata->state->lastchar;
228 if (mutt_hist_at_scratch(wdata->hclass))
229 {
230 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
232 }
233 replace_part(wdata->state, 0, mutt_hist_prev(wdata->hclass));
234 wdata->redraw = ENTER_REDRAW_INIT;
235 return FR_SUCCESS;
236}
char * mutt_hist_prev(enum HistoryClass hclass)
Get the previous string in a History.
Definition: history.c:562
+ 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 243 of file functions.c.

244{
245 int rc = editor_backspace(wdata->state);
246
247 if ((rc == FR_ERROR) && editor_buffer_is_empty(wdata->state))
248 {
249 const bool c_abort_backspace = cs_subset_bool(NeoMutt->sub, "abort_backspace");
250 if (c_abort_backspace)
251 {
252 buf_reset(wdata->buffer);
253 wdata->done = true;
254 rc = FR_SUCCESS;
255 }
256 }
257
258 return rc;
259}
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:385
int editor_backspace(struct EnterState *es)
Delete the char in front of the cursor.
Definition: enter.c:47
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 264 of file functions.c.

265{
266 return editor_backward_char(wdata->state);
267}
int editor_backward_char(struct EnterState *es)
Move the cursor one character to the left.
Definition: enter.c:70
+ 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 272 of file functions.c.

273{
274 return editor_backward_word(wdata->state);
275}
int editor_backward_word(struct EnterState *es)
Move the cursor to the beginning of the word.
Definition: enter.c:89
+ 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 280 of file functions.c.

281{
282 return editor_bol(wdata->state);
283}
int editor_bol(struct EnterState *es)
Jump to the beginning of the line.
Definition: enter.c:108
+ 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 292 of file functions.c.

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

316{
317 return editor_delete_char(wdata->state);
318}
int editor_delete_char(struct EnterState *es)
Delete the char under the cursor.
Definition: enter.c:156
+ 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 323 of file functions.c.

324{
325 int rc = editor_eol(wdata->state);
326 wdata->redraw = ENTER_REDRAW_INIT;
327 return rc;
328}
int editor_eol(struct EnterState *es)
Jump to the end of the line.
Definition: enter.c:178
+ 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 333 of file functions.c.

334{
335 return editor_forward_char(wdata->state);
336}
int editor_forward_char(struct EnterState *es)
Move the cursor one character to the right.
Definition: enter.c:193
+ 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 341 of file functions.c.

342{
343 return editor_forward_word(wdata->state);
344}
int editor_forward_word(struct EnterState *es)
Move the cursor to the end of the word.
Definition: enter.c:213
+ 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 349 of file functions.c.

350{
351 return editor_kill_eol(wdata->state);
352}
int editor_kill_eol(struct EnterState *es)
Delete chars from cursor to end of line.
Definition: enter.c:236
+ 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 357 of file functions.c.

358{
359 return editor_kill_eow(wdata->state);
360}
int editor_kill_eow(struct EnterState *es)
Delete chars from the cursor to the end of the word.
Definition: enter.c:251
+ 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 365 of file functions.c.

366{
367 return editor_kill_line(wdata->state);
368}
int editor_kill_line(struct EnterState *es)
Delete chars from cursor to beginning the line.
Definition: enter.c:290
+ 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 373 of file functions.c.

374{
375 return editor_kill_whole_line(wdata->state);
376}
int editor_kill_whole_line(struct EnterState *es)
Delete all chars on the line.
Definition: enter.c:311
+ 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 381 of file functions.c.

382{
383 return editor_kill_word(wdata->state);
384}
int editor_kill_word(struct EnterState *es)
Delete the word in front of the cursor.
Definition: enter.c:328
+ 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 393 of file functions.c.

394{
395 struct KeyEvent event = { 0, OP_NULL };
396 do
397 {
398 window_redraw(NULL);
399 event = mutt_getch(GETCH_NO_FLAGS);
400 } while ((event.op == OP_TIMEOUT) || (event.op == OP_REPAINT));
401
402 if (event.op != OP_ABORT)
403 {
404 if (self_insert(wdata, event.ch))
405 {
406 wdata->done = true;
407 return FR_SUCCESS;
408 }
409 }
410 return FR_SUCCESS;
411}
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:633
#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 416 of file functions.c.

417{
418 return editor_transpose_chars(wdata->state);
419}
int editor_transpose_chars(struct EnterState *es)
Transpose character under cursor with previous.
Definition: enter.c:361
+ 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 424 of file functions.c.

425{
427 return FR_SUCCESS;
428}
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 433 of file functions.c.

434{
435 clearok(stdscr, true);
438 window_redraw(NULL);
439 return FR_SUCCESS;
440}
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:766
+ Here is the call graph for this function: