NeoMutt  2025-12-11-872-g385a04
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c
Go to the documentation of this file.
1
22
28
29#include "config.h"
30#include <wchar.h>
31#include "mutt/lib.h"
32#include "config/lib.h"
33#include "core/lib.h"
34#include "gui/lib.h"
35#include "mutt.h"
36#include "functions.h"
37#include "complete/lib.h"
38#include "history/lib.h"
39#include "key/lib.h"
40#include "menu/lib.h"
41#include "enter.h"
42#include "module_data.h"
43#include "state.h"
44#include "wdata.h"
45
46// clang-format off
50static const struct MenuFuncOp OpEditor[] = { /* map: editor */
51 { "backspace", OP_EDITOR_BACKSPACE },
52 { "backward-char", OP_EDITOR_BACKWARD_CHAR },
53 { "backward-word", OP_EDITOR_BACKWARD_WORD },
54 { "bol", OP_EDITOR_BOL },
55 { "capitalize-word", OP_EDITOR_CAPITALIZE_WORD },
56 { "complete", OP_EDITOR_COMPLETE },
57 { "complete-query", OP_EDITOR_COMPLETE_QUERY },
58 { "delete-char", OP_EDITOR_DELETE_CHAR },
59 { "downcase-word", OP_EDITOR_DOWNCASE_WORD },
60 { "eol", OP_EDITOR_EOL },
61 { "forward-char", OP_EDITOR_FORWARD_CHAR },
62 { "forward-word", OP_EDITOR_FORWARD_WORD },
63 { "help", OP_HELP },
64 { "history-down", OP_EDITOR_HISTORY_DOWN },
65 { "history-search", OP_EDITOR_HISTORY_SEARCH },
66 { "history-up", OP_EDITOR_HISTORY_UP },
67 { "kill-eol", OP_EDITOR_KILL_EOL },
68 { "kill-eow", OP_EDITOR_KILL_EOW },
69 { "kill-line", OP_EDITOR_KILL_LINE },
70 { "kill-whole-line", OP_EDITOR_KILL_WHOLE_LINE },
71 { "kill-word", OP_EDITOR_KILL_WORD },
72 { "mailbox-cycle", OP_EDITOR_MAILBOX_CYCLE },
73 { "quote-char", OP_EDITOR_QUOTE_CHAR },
74 { "redraw-screen", OP_REDRAW },
75 { "transpose-chars", OP_EDITOR_TRANSPOSE_CHARS },
76 { "upcase-word", OP_EDITOR_UPCASE_WORD },
77 // Deprecated
78 { "buffy-cycle", OP_EDITOR_MAILBOX_CYCLE, MFF_DEPRECATED },
79 { NULL, 0 },
80};
81
85static const struct MenuOpSeq EditorDefaultBindings[] = { /* map: editor */
86 { OP_EDITOR_BACKSPACE, "<backspace>" },
87 { OP_EDITOR_BACKSPACE, "\010" }, // <Ctrl-H>
88 { OP_EDITOR_BACKSPACE, "\177" }, // <Backspace>
89 { OP_EDITOR_BACKWARD_CHAR, "<left>" },
90 { OP_EDITOR_BACKWARD_CHAR, "\002" }, // <Ctrl-B>
91 { OP_EDITOR_BACKWARD_WORD, "\033b" }, // <Alt-b>
92 { OP_EDITOR_BOL, "<home>" },
93 { OP_EDITOR_BOL, "\001" }, // <Ctrl-A>
94 { OP_EDITOR_CAPITALIZE_WORD, "\033c" }, // <Alt-c>
95 { OP_EDITOR_COMPLETE, "\t" }, // <Tab>
96 { OP_EDITOR_COMPLETE_QUERY, "\024" }, // <Ctrl-T>
97 { OP_EDITOR_DELETE_CHAR, "<delete>" },
98 { OP_EDITOR_DELETE_CHAR, "\004" }, // <Ctrl-D>
99 { OP_EDITOR_DOWNCASE_WORD, "\033l" }, // <Alt-l>
100 { OP_EDITOR_EOL, "<end>" },
101 { OP_EDITOR_EOL, "\005" }, // <Ctrl-E>
102 { OP_EDITOR_FORWARD_CHAR, "<right>" },
103 { OP_EDITOR_FORWARD_CHAR, "\006" }, // <Ctrl-F>
104 { OP_EDITOR_FORWARD_WORD, "\033f" }, // <Alt-f>
105 { OP_EDITOR_HISTORY_DOWN, "<down>" },
106 { OP_EDITOR_HISTORY_DOWN, "\016" }, // <Ctrl-N>
107 { OP_EDITOR_HISTORY_SEARCH, "\022" }, // <Ctrl-R>
108 { OP_EDITOR_HISTORY_UP, "<up>" },
109 { OP_EDITOR_HISTORY_UP, "\020" }, // <Ctrl-P>
110 { OP_EDITOR_KILL_EOL, "\013" }, // <Ctrl-K>
111 { OP_EDITOR_KILL_EOW, "\033d" }, // <Alt-d>
112 { OP_EDITOR_KILL_LINE, "\025" }, // <Ctrl-U>
113 { OP_EDITOR_KILL_WORD, "\027" }, // <Ctrl-W>
114 { OP_EDITOR_MAILBOX_CYCLE, " " }, // <Space>
115 { OP_EDITOR_QUOTE_CHAR, "\026" }, // <Ctrl-V>
116 { OP_EDITOR_UPCASE_WORD, "\033u" }, // <Alt-u>
117 { OP_HELP, "\033?" }, // <Alt-?>
118 { OP_REDRAW, "\014" }, // <Ctrl-L>
119 { 0, NULL },
120};
121// clang-format on
122
126void editor_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
127{
129 ASSERT(mod_data);
130
131 struct MenuDefinition *md = NULL;
132 struct SubMenu *sm = NULL;
133
135 md = km_register_menu(MENU_EDITOR, "editor");
136 km_menu_add_submenu(md, sm);
138
139 mod_data->md_editor = md;
140 mod_data->sm_editor = sm;
141}
142
149void replace_part(struct EnterState *es, size_t from, const char *buf)
150{
151 /* Save the suffix */
152 size_t savelen = es->lastchar - es->curpos;
153 wchar_t *savebuf = NULL;
154
155 if (savelen)
156 {
157 savebuf = MUTT_MEM_CALLOC(savelen, wchar_t);
158 wmemcpy(savebuf, es->wbuf + es->curpos, savelen);
159 }
160
161 /* Convert to wide characters */
162 es->curpos = mutt_mb_mbstowcs(&es->wbuf, &es->wbuflen, from, buf);
163
164 if (savelen)
165 {
166 /* Make space for suffix */
167 if (es->curpos + savelen > es->wbuflen)
168 {
169 es->wbuflen = es->curpos + savelen;
170 MUTT_MEM_REALLOC(&es->wbuf, es->wbuflen, wchar_t);
171 }
172
173 /* Restore suffix */
174 wmemcpy(es->wbuf + es->curpos, savebuf, savelen);
175 FREE(&savebuf);
176 }
177
178 es->lastchar = es->curpos + savelen;
179}
180
181// -----------------------------------------------------------------------------
182
191static int op_editor_complete(struct EnterFunctionData *fdata, const struct KeyEvent *event)
192{
193 struct EnterWindowData *wdata = fdata->wdata;
194 if (wdata->tabs == 0)
195 {
196 if (wdata->cd)
198 else
199 wdata->cd = completion_data_new();
200 }
201
202 wdata->tabs++;
203 wdata->redraw = ENTER_REDRAW_LINE;
204
205 if (wdata->comp_api && wdata->comp_api->complete)
206 return wdata->comp_api->complete(wdata, event->op);
207
208 return FR_NO_ACTION;
209}
210
211// -----------------------------------------------------------------------------
212
216static int op_editor_history_down(struct EnterFunctionData *fdata, const struct KeyEvent *event)
217{
218 struct EnterWindowData *wdata = fdata->wdata;
219 if (wdata->hclass == HC_NONE)
220 return FR_SUCCESS;
221
222 wdata->state->curpos = wdata->state->lastchar;
223 if (mutt_hist_at_scratch(wdata->hclass))
224 {
225 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
227 }
228 replace_part(wdata->state, 0, mutt_hist_next(wdata->hclass));
229 wdata->redraw = ENTER_REDRAW_INIT;
230 return FR_SUCCESS;
231}
232
237 const struct KeyEvent *event)
238{
239 struct EnterWindowData *wdata = fdata->wdata;
240 if (wdata->hclass == HC_NONE)
241 return FR_SUCCESS;
242
243 wdata->state->curpos = wdata->state->lastchar;
244 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
245 mutt_hist_complete(wdata->buffer, wdata->hclass);
246 replace_part(wdata->state, 0, wdata->buffer->data);
247 return FR_CONTINUE;
248}
249
253static int op_editor_history_up(struct EnterFunctionData *fdata, const struct KeyEvent *event)
254{
255 struct EnterWindowData *wdata = fdata->wdata;
256 if (wdata->hclass == HC_NONE)
257 return FR_SUCCESS;
258
259 wdata->state->curpos = wdata->state->lastchar;
260 if (mutt_hist_at_scratch(wdata->hclass))
261 {
262 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf, wdata->state->curpos);
264 }
265 replace_part(wdata->state, 0, mutt_hist_prev(wdata->hclass));
266 wdata->redraw = ENTER_REDRAW_INIT;
267 return FR_SUCCESS;
268}
269
270// -----------------------------------------------------------------------------
271
275static int op_editor_backspace(struct EnterFunctionData *fdata, const struct KeyEvent *event)
276{
277 struct EnterWindowData *wdata = fdata->wdata;
278 int rc = editor_backspace(wdata->state);
279
280 if ((rc == FR_ERROR) && editor_buffer_is_empty(wdata->state))
281 {
282 const bool c_abort_backspace = cs_subset_bool(fdata->n->sub, "abort_backspace");
283 if (c_abort_backspace)
284 {
285 buf_reset(wdata->buffer);
286 wdata->done = true;
287 rc = FR_SUCCESS;
288 }
289 }
290
291 return rc;
292}
293
297static int op_editor_backward_char(struct EnterFunctionData *fdata, const struct KeyEvent *event)
298{
299 struct EnterWindowData *wdata = fdata->wdata;
300 return editor_backward_char(wdata->state);
301}
302
306static int op_editor_backward_word(struct EnterFunctionData *fdata, const struct KeyEvent *event)
307{
308 struct EnterWindowData *wdata = fdata->wdata;
309 return editor_backward_word(wdata->state);
310}
311
315static int op_editor_bol(struct EnterFunctionData *fdata, const struct KeyEvent *event)
316{
317 struct EnterWindowData *wdata = fdata->wdata;
318 return editor_bol(wdata->state);
319}
320
329 const struct KeyEvent *event)
330{
331 struct EnterWindowData *wdata = fdata->wdata;
332 enum EnterCase ec;
333 switch (event->op)
334 {
335 case OP_EDITOR_CAPITALIZE_WORD:
336 ec = EC_CAPITALIZE;
337 break;
338 case OP_EDITOR_DOWNCASE_WORD:
339 ec = EC_DOWNCASE;
340 break;
341 case OP_EDITOR_UPCASE_WORD:
342 ec = EC_UPCASE;
343 break;
344 default:
345 return FR_ERROR;
346 }
347 return editor_case_word(wdata->state, ec);
348}
349
353static int op_editor_delete_char(struct EnterFunctionData *fdata, const struct KeyEvent *event)
354{
355 struct EnterWindowData *wdata = fdata->wdata;
356 return editor_delete_char(wdata->state);
357}
358
362static int op_editor_eol(struct EnterFunctionData *fdata, const struct KeyEvent *event)
363{
364 struct EnterWindowData *wdata = fdata->wdata;
365 int rc = editor_eol(wdata->state);
366 wdata->redraw = ENTER_REDRAW_INIT;
367 return rc;
368}
369
373static int op_editor_forward_char(struct EnterFunctionData *fdata, const struct KeyEvent *event)
374{
375 struct EnterWindowData *wdata = fdata->wdata;
376 return editor_forward_char(wdata->state);
377}
378
382static int op_editor_forward_word(struct EnterFunctionData *fdata, const struct KeyEvent *event)
383{
384 struct EnterWindowData *wdata = fdata->wdata;
385 return editor_forward_word(wdata->state);
386}
387
391static int op_editor_kill_eol(struct EnterFunctionData *fdata, const struct KeyEvent *event)
392{
393 struct EnterWindowData *wdata = fdata->wdata;
394 return editor_kill_eol(wdata->state);
395}
396
400static int op_editor_kill_eow(struct EnterFunctionData *fdata, const struct KeyEvent *event)
401{
402 struct EnterWindowData *wdata = fdata->wdata;
403 return editor_kill_eow(wdata->state);
404}
405
409static int op_editor_kill_line(struct EnterFunctionData *fdata, const struct KeyEvent *event)
410{
411 struct EnterWindowData *wdata = fdata->wdata;
412 return editor_kill_line(wdata->state);
413}
414
419 const struct KeyEvent *event)
420{
421 struct EnterWindowData *wdata = fdata->wdata;
422 return editor_kill_whole_line(wdata->state);
423}
424
428static int op_editor_kill_word(struct EnterFunctionData *fdata, const struct KeyEvent *event)
429{
430 struct EnterWindowData *wdata = fdata->wdata;
431 return editor_kill_word(wdata->state);
432}
433
441static int op_editor_quote_char(struct EnterFunctionData *fdata, const struct KeyEvent *event)
442{
443 struct EnterWindowData *wdata = fdata->wdata;
444 struct KeyEvent event_q = { 0, OP_NULL };
445 do
446 {
447 window_redraw(NULL);
448 event_q = mutt_getch(GETCH_NONE);
449 } while ((event_q.op == OP_TIMEOUT) || (event_q.op == OP_REPAINT));
450
451 if (event_q.op != OP_ABORT)
452 {
453 if (self_insert(wdata, event_q.ch))
454 {
455 wdata->done = true;
456 return FR_SUCCESS;
457 }
458 }
459 return FR_SUCCESS;
460}
461
466 const struct KeyEvent *event)
467{
468 struct EnterWindowData *wdata = fdata->wdata;
469 return editor_transpose_chars(wdata->state);
470}
471
475static int op_help(struct EnterFunctionData *fdata, const struct KeyEvent *event)
476{
478 return FR_SUCCESS;
479}
480
484static int op_redraw(struct EnterFunctionData *fdata, const struct KeyEvent *event)
485{
486 clearok(stdscr, true);
489 window_redraw(NULL);
490 return FR_SUCCESS;
491}
492
493// -----------------------------------------------------------------------------
494
498static const struct EnterFunction EnterFunctions[] = {
499 // clang-format off
500 { OP_EDITOR_BACKSPACE, op_editor_backspace },
501 { OP_EDITOR_BACKWARD_CHAR, op_editor_backward_char },
502 { OP_EDITOR_BACKWARD_WORD, op_editor_backward_word },
503 { OP_EDITOR_BOL, op_editor_bol },
504 { OP_EDITOR_CAPITALIZE_WORD, op_editor_capitalize_word },
505 { OP_EDITOR_COMPLETE, op_editor_complete },
506 { OP_EDITOR_COMPLETE_QUERY, op_editor_complete },
507 { OP_EDITOR_DELETE_CHAR, op_editor_delete_char },
508 { OP_EDITOR_DOWNCASE_WORD, op_editor_capitalize_word },
509 { OP_EDITOR_EOL, op_editor_eol },
510 { OP_EDITOR_FORWARD_CHAR, op_editor_forward_char },
511 { OP_EDITOR_FORWARD_WORD, op_editor_forward_word },
512 { OP_EDITOR_HISTORY_DOWN, op_editor_history_down },
513 { OP_EDITOR_HISTORY_SEARCH, op_editor_history_search },
514 { OP_EDITOR_HISTORY_UP, op_editor_history_up },
515 { OP_EDITOR_KILL_EOL, op_editor_kill_eol },
516 { OP_EDITOR_KILL_EOW, op_editor_kill_eow },
517 { OP_EDITOR_KILL_LINE, op_editor_kill_line },
518 { OP_EDITOR_KILL_WHOLE_LINE, op_editor_kill_whole_line },
519 { OP_EDITOR_KILL_WORD, op_editor_kill_word },
520 { OP_EDITOR_MAILBOX_CYCLE, op_editor_complete },
521 { OP_EDITOR_QUOTE_CHAR, op_editor_quote_char },
522 { OP_EDITOR_TRANSPOSE_CHARS, op_editor_transpose_chars },
523 { OP_EDITOR_UPCASE_WORD, op_editor_capitalize_word },
524 { OP_HELP, op_help },
525 { OP_REDRAW, op_redraw },
526 { 0, NULL },
527 // clang-format on
528};
529
533int enter_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
534{
535 if (!event || !win || !win->wdata)
536 return FR_UNKNOWN;
537
538 const int op = event->op;
539
541
542 struct EnterFunctionData fdata = {
543 .n = NeoMutt,
544 .mod_data = mod_data,
545 .wdata = win->wdata,
546 };
547
548 int rc = FR_UNKNOWN;
549 for (size_t i = 0; EnterFunctions[i].op != OP_NULL; i++)
550 {
551 const struct EnterFunction *fn = &EnterFunctions[i];
552 if (fn->op == op)
553 {
554 rc = fn->function(&fdata, event);
555 break;
556 }
557 }
558
559 if (rc == FR_UNKNOWN) // Not our function
560 return rc;
561
562 const char *result = dispatcher_get_retval_name(rc);
563 mutt_debug(LL_DEBUG1, "Handled %s (%d) -> %s\n", opcodes_get_name(op), op, NONULL(result));
564
566 return rc;
567}
568
574{
576 ASSERT(mod_data);
577
578 return mod_data->md_editor;
579}
580
586{
588 ASSERT(mod_data);
589
590 return mod_data->sm_editor;
591}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
Auto-completion.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
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
const char * dispatcher_get_retval_name(int rv)
Get the name of a return value.
Definition dispatcher.c:55
void dispatcher_flush_on_error(int rv)
Flush pending keys after a dispatch error.
Definition dispatcher.c:65
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:34
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
@ FR_CONTINUE
Remain in the Dialog.
Definition dispatcher.h:35
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
struct MenuDefinition * editor_get_menu_definition(void)
Get the Editor Menu Definition.
Definition functions.c:573
static const struct MenuOpSeq EditorDefaultBindings[]
Key bindings for the Editor Menu.
Definition functions.c:85
static const struct MenuFuncOp OpEditor[]
Functions for the Editor Menu.
Definition functions.c:50
struct SubMenu * editor_get_submenu(void)
Get the Editor SubMenu.
Definition functions.c:585
static const struct EnterFunction EnterFunctions[]
All the NeoMutt functions that Enter supports.
Definition functions.c:498
void editor_init_keys(struct NeoMutt *n, struct SubMenu *sm_generic)
Initialise the Editor Keybindings - Implements ::init_keys_api.
Definition functions.c:126
void replace_part(struct EnterState *es, size_t from, const char *buf)
Search and replace on a buffer.
Definition functions.c:149
Editor functions.
bool self_insert(struct EnterWindowData *wdata, int ch)
Insert a normal character.
Definition window.c:88
Editor private Module data.
Struct to store the cursor position when entering text.
Enter Window Data.
@ ENTER_REDRAW_LINE
Redraw entire line.
Definition wdata.h:38
@ ENTER_REDRAW_INIT
Go to end of line and redraw.
Definition wdata.h:37
int editor_backward_word(struct EnterState *es)
Move the cursor to the beginning of the word.
Definition enter.c:88
bool editor_buffer_is_empty(struct EnterState *es)
Is the Enter buffer empty?
Definition enter.c:384
int editor_kill_line(struct EnterState *es)
Delete chars from cursor to beginning the line.
Definition enter.c:289
int editor_delete_char(struct EnterState *es)
Delete the char under the cursor.
Definition enter.c:155
int editor_bol(struct EnterState *es)
Jump to the beginning of the line.
Definition enter.c:107
int editor_backspace(struct EnterState *es)
Delete the char in front of the cursor.
Definition enter.c:46
int editor_kill_word(struct EnterState *es)
Delete the word in front of the cursor.
Definition enter.c:327
int editor_eol(struct EnterState *es)
Jump to the end of the line.
Definition enter.c:177
int editor_kill_eow(struct EnterState *es)
Delete chars from the cursor to the end of the word.
Definition enter.c:250
int editor_transpose_chars(struct EnterState *es)
Transpose character under cursor with previous.
Definition enter.c:360
int editor_kill_eol(struct EnterState *es)
Delete chars from cursor to end of line.
Definition enter.c:235
int editor_forward_word(struct EnterState *es)
Move the cursor to the end of the word.
Definition enter.c:212
int editor_backward_char(struct EnterState *es)
Move the cursor one character to the left.
Definition enter.c:69
int editor_case_word(struct EnterState *es, enum EnterCase ec)
Change the case of the word.
Definition enter.c:123
int editor_kill_whole_line(struct EnterState *es)
Delete all chars on the line.
Definition enter.c:310
int editor_forward_char(struct EnterState *es)
Move the cursor one character to the right.
Definition enter.c:192
Enter buffer.
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
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
@ MFF_DEPRECATED
Function is deprecated.
Definition get.h:67
int enter_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
Perform an Enter function - Implements function_dispatcher_t -.
Definition functions.c:533
static int op_editor_delete_char(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Delete the char under the cursor - Implements enter_function_t -.
Definition functions.c:353
static int op_editor_history_up(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Scroll up through the history list - Implements enter_function_t -.
Definition functions.c:253
static int op_editor_backspace(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Delete the char in front of the cursor - Implements enter_function_t -.
Definition functions.c:275
static int op_editor_bol(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Jump to the beginning of the line - Implements enter_function_t -.
Definition functions.c:315
static int op_editor_complete(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Complete filename or alias - Implements enter_function_t -.
Definition functions.c:191
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 -.
Definition functions.c:391
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 -.
Definition functions.c:382
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 -.
Definition functions.c:306
static int op_editor_history_down(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Scroll down through the history list - Implements enter_function_t -.
Definition functions.c:216
static int op_editor_capitalize_word(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Capitalize the word - Implements enter_function_t - This function handles:
Definition functions.c:328
static int op_help(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Display Help - Implements enter_function_t -.
Definition functions.c:475
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 -.
Definition functions.c:400
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 -.
Definition functions.c:428
static int op_editor_quote_char(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Quote the next typed key - Implements enter_function_t -.
Definition functions.c:441
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 -.
Definition functions.c:373
static int op_editor_kill_line(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Delete all chars on the line - Implements enter_function_t -.
Definition functions.c:409
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 -.
Definition functions.c:297
static int op_editor_eol(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Jump to the end of the line - Implements enter_function_t -.
Definition functions.c:362
static int op_editor_kill_whole_line(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Delete all chars on the line - Implements enter_function_t -.
Definition functions.c:418
static int op_redraw(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Redraw the screen - Implements enter_function_t -.
Definition functions.c:484
static int op_editor_transpose_chars(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Transpose character under cursor with previous - Implements enter_function_t -.
Definition functions.c:465
static int op_editor_history_search(struct EnterFunctionData *fdata, const struct KeyEvent *event)
Search through the history list - Implements enter_function_t -.
Definition functions.c:236
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
Convenience wrapper for the gui headers.
void mutt_help(const struct MenuDefinition *md)
Display the Help Page.
Definition help.c:146
Read/write command history from/to a file.
@ 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
void mutt_hist_complete(struct Buffer *buf, enum HistoryClass hclass)
Complete a string from a history list.
Definition history.c:664
bool mutt_hist_at_scratch(enum HistoryClass hclass)
Is the current History position at the 'scratch' place?
Definition history.c:631
char * mutt_hist_prev(enum HistoryClass hclass)
Get the previous string in a History.
Definition history.c:537
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:121
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:87
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:104
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:134
Manage keymappings.
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, const char *buf)
Convert a string from multibyte to wide characters.
Definition mbyte.c:292
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
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
#define MUTT_MEM_REALLOC(pptr, n, type)
Definition memory.h:55
GUI present the user with a selectable list.
@ MODULE_ID_EDITOR
ModuleEditor, Edit a string
Definition module_api.h:63
Convenience wrapper for the library headers.
Many unsorted constants and some structs.
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition resize.c:76
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
void window_invalidate_all(void)
Mark all windows as in need of repaint.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition opcodes.c:48
#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
#define ASSERT(COND)
Definition signal2.h:59
#define NONULL(x)
Definition string2.h:44
char * data
Pointer to data.
Definition buffer.h:37
enum FunctionRetval(* complete)(struct EnterWindowData *wdata, int op)
Definition compapi.h:46
Editor private Module data.
Definition module_data.h:30
struct SubMenu * sm_editor
Editor functions.
Definition module_data.h:33
struct MenuDefinition * md_editor
Editor Menu Definition.
Definition module_data.h:32
Data passed to Enter worker functions.
Definition functions.h:42
struct EditorModuleData * mod_data
Editor module data.
Definition functions.h:44
struct NeoMutt * n
NeoMutt application data.
Definition functions.h:43
struct EnterWindowData * wdata
Enter window data.
Definition functions.h:45
A NeoMutt function.
Definition functions.h:66
int op
Op code, e.g. OP_SEARCH.
Definition functions.h:67
enter_function_t function
Function to call.
Definition functions.h:68
Keep our place when entering a string.
Definition state.h:32
size_t curpos
Position of the cursor.
Definition state.h:36
size_t wbuflen
Length of buffer.
Definition state.h:34
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
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
struct Buffer * buffer
struct Buffer for the result
Definition wdata.h:59
bool done
Is text-entry done?
Definition wdata.h:76
const struct CompleteOps * comp_api
Auto-Completion API.
Definition wdata.h:63
struct EnterState * state
Current state of text entry.
Definition wdata.h:61
enum EnterRedrawFlags redraw
What needs redrawing? See EnterRedrawFlags.
Definition wdata.h:68
enum HistoryClass hclass
History to use, e.g. HC_NEO_COMMAND.
Definition wdata.h:62
An event such as a keypress.
Definition get.h:75
int op
Function opcode, e.g. OP_HELP.
Definition get.h:77
int ch
Raw key pressed.
Definition get.h:76
Functions for a Dialog or Window.
Definition menu.h:77
Mapping between a function and an operation.
Definition menu.h:35
Mapping between an operation and a key sequence.
Definition menu.h:45
void * wdata
Private data.
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Collection of related functions.
Definition menu.h:65
@ MENU_EDITOR
Text entry area.
Definition type.h:42