NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
DOXYGEN
functions.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <string.h>
31#include <wchar.h>
32#include "mutt/lib.h"
33#include "config/helpers.h"
34#include "core/lib.h"
35#include "alias/lib.h"
36#include "gui/lib.h"
37#include "mutt.h"
38#include "functions.h"
39#include "browser/lib.h"
40#include "complete/lib.h"
41#include "history/lib.h"
42#include "pattern/lib.h"
43#include "enter.h"
44#include "keymap.h"
45#include "mutt_history.h"
46#include "mutt_mailbox.h"
47#include "muttlib.h"
48#include "opcodes.h"
49#include "state.h" // IWYU pragma: keep
50#include "wdata.h"
51
58static void replace_part(struct EnterState *es, size_t from, const char *buf)
59{
60 /* Save the suffix */
61 size_t savelen = es->lastchar - es->curpos;
62 wchar_t *savebuf = NULL;
63
64 if (savelen)
65 {
66 savebuf = mutt_mem_calloc(savelen, sizeof(wchar_t));
67 memcpy(savebuf, es->wbuf + es->curpos, savelen * sizeof(wchar_t));
68 }
69
70 /* Convert to wide characters */
71 es->curpos = mutt_mb_mbstowcs(&es->wbuf, &es->wbuflen, from, buf);
72
73 if (savelen)
74 {
75 /* Make space for suffix */
76 if (es->curpos + savelen > es->wbuflen)
77 {
78 es->wbuflen = es->curpos + savelen;
79 mutt_mem_realloc(&es->wbuf, es->wbuflen * sizeof(wchar_t));
80 }
81
82 /* Restore suffix */
83 memcpy(es->wbuf + es->curpos, savebuf, savelen * sizeof(wchar_t));
84 FREE(&savebuf);
85 }
86
87 es->lastchar = es->curpos + savelen;
88}
89
90// -----------------------------------------------------------------------------
91
97static int complete_file_simple(struct EnterWindowData *wdata)
98{
99 int rc = FR_SUCCESS;
100 size_t i;
101 for (i = wdata->state->curpos;
102 (i > 0) && !mutt_mb_is_shell_char(wdata->state->wbuf[i - 1]); i--)
103 {
104 }
105 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf + i,
106 wdata->state->curpos - i);
107 if (wdata->tempbuf && (wdata->templen == (wdata->state->lastchar - i)) &&
108 (memcmp(wdata->tempbuf, wdata->state->wbuf + i,
109 (wdata->state->lastchar - i) * sizeof(wchar_t)) == 0))
110 {
111 mutt_select_file(wdata->buf, wdata->buflen, MUTT_SEL_NO_FLAGS, wdata->m, NULL, NULL);
112 if (wdata->buf[0] != '\0')
113 replace_part(wdata->state, i, wdata->buf);
114 return FR_CONTINUE;
115 }
116
117 if (mutt_complete(wdata->cd, wdata->buf, wdata->buflen) == 0)
118 {
119 wdata->templen = wdata->state->lastchar - i;
120 mutt_mem_realloc(&wdata->tempbuf, wdata->templen * sizeof(wchar_t));
121 memcpy(wdata->tempbuf, wdata->state->wbuf + i, wdata->templen * sizeof(wchar_t));
122 }
123 else
124 {
125 rc = FR_ERROR;
126 }
127
128 replace_part(wdata->state, i, wdata->buf);
129 return rc;
130}
131
138{
139 /* invoke the alias-menu to get more addresses */
140 size_t i;
141 for (i = wdata->state->curpos; (i > 0) && (wdata->state->wbuf[i - 1] != ',') &&
142 (wdata->state->wbuf[i - 1] != ':');
143 i--)
144 {
145 }
146 for (; (i < wdata->state->lastchar) && (wdata->state->wbuf[i] == ' '); i++)
147 ; // do nothing
148
149 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf + i,
150 wdata->state->curpos - i);
151 int rc = alias_complete(wdata->buf, wdata->buflen, NeoMutt->sub);
152 replace_part(wdata->state, i, wdata->buf);
153 if (rc != 1)
154 {
155 return FR_CONTINUE;
156 }
157
158 return FR_SUCCESS;
159}
160
166static int complete_label(struct EnterWindowData *wdata)
167{
168 size_t i;
169 for (i = wdata->state->curpos; (i > 0) && (wdata->state->wbuf[i - 1] != ',') &&
170 (wdata->state->wbuf[i - 1] != ':');
171 i--)
172 {
173 }
174 for (; (i < wdata->state->lastchar) && (wdata->state->wbuf[i] == ' '); i++)
175 ; // do nothing
176
177 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf + i,
178 wdata->state->curpos - i);
179 int rc = mutt_label_complete(wdata->cd, wdata->buf, wdata->buflen, wdata->tabs);
180 replace_part(wdata->state, i, wdata->buf);
181 if (rc != 1)
182 return FR_CONTINUE;
183
184 return FR_SUCCESS;
185}
186
192static int complete_pattern(struct EnterWindowData *wdata)
193{
194 size_t i = wdata->state->curpos;
195 if (i && (wdata->state->wbuf[i - 1] == '~'))
196 {
197 if (dlg_select_pattern(wdata->buf, wdata->buflen))
198 replace_part(wdata->state, i - 1, wdata->buf);
199 return FR_CONTINUE;
200 }
201
202 for (; (i > 0) && (wdata->state->wbuf[i - 1] != '~'); i--)
203 ; // do nothing
204
205 if ((i > 0) && (i < wdata->state->curpos) &&
206 (wdata->state->wbuf[i - 1] == '~') && (wdata->state->wbuf[i] == 'y'))
207 {
208 i++;
209 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf + i,
210 wdata->state->curpos - i);
211 int rc = mutt_label_complete(wdata->cd, wdata->buf, wdata->buflen, wdata->tabs);
212 replace_part(wdata->state, i, wdata->buf);
213 if (rc != 1)
214 {
215 return FR_CONTINUE;
216 }
217 }
218 else
219 {
220 return FR_NO_ACTION;
221 }
222
223 return FR_SUCCESS;
224}
225
231static int complete_alias_query(struct EnterWindowData *wdata)
232{
233 size_t i = wdata->state->curpos;
234 if (i != 0)
235 {
236 for (; (i > 0) && (wdata->state->wbuf[i - 1] != ','); i--)
237 ; // do nothing
238
239 for (; (i < wdata->state->curpos) && (wdata->state->wbuf[i] == ' '); i++)
240 ; // do nothing
241 }
242
243 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf + i,
244 wdata->state->curpos - i);
245 struct Buffer *tmp = buf_pool_get();
246 buf_strcpy(tmp, wdata->buf);
248 mutt_str_copy(wdata->buf, buf_string(tmp), wdata->buflen);
249 buf_pool_release(&tmp);
250 replace_part(wdata->state, i, wdata->buf);
251
252 return FR_CONTINUE;
253}
254
260static int complete_command(struct EnterWindowData *wdata)
261{
262 int rc = FR_SUCCESS;
263 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
264 size_t i = strlen(wdata->buf);
265 if ((i != 0) && (wdata->buf[i - 1] == '=') &&
266 (mutt_var_value_complete(wdata->cd, wdata->buf, wdata->buflen, i) != 0))
267 {
268 wdata->tabs = 0;
269 }
270 else if (mutt_command_complete(wdata->cd, wdata->buf, wdata->buflen, i, wdata->tabs) == 0)
271 {
272 rc = FR_ERROR;
273 }
274
275 replace_part(wdata->state, 0, wdata->buf);
276 return rc;
277}
278
284static int complete_file_mbox(struct EnterWindowData *wdata)
285{
286 int rc = FR_SUCCESS;
287 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
288
289 /* see if the path has changed from the last time */
290 if ((!wdata->tempbuf && !wdata->state->lastchar) ||
291 (wdata->tempbuf && (wdata->templen == wdata->state->lastchar) &&
292 (memcmp(wdata->tempbuf, wdata->state->wbuf,
293 wdata->state->lastchar * sizeof(wchar_t)) == 0)))
294 {
295 mutt_select_file(wdata->buf, wdata->buflen,
298 wdata->m, wdata->files, wdata->numfiles);
299 if (wdata->buf[0] != '\0')
300 {
301 mutt_pretty_mailbox(wdata->buf, wdata->buflen);
302 if (!wdata->pass)
303 mutt_hist_add(wdata->hclass, wdata->buf, true);
304 wdata->done = true;
305 return FR_SUCCESS;
306 }
307
308 /* file selection cancelled */
309 return FR_CONTINUE;
310 }
311
312 if (mutt_complete(wdata->cd, wdata->buf, wdata->buflen) == 0)
313 {
314 wdata->templen = wdata->state->lastchar;
315 mutt_mem_realloc(&wdata->tempbuf, wdata->templen * sizeof(wchar_t));
316 memcpy(wdata->tempbuf, wdata->state->wbuf, wdata->templen * sizeof(wchar_t));
317 }
318 else
319 {
320 return FR_ERROR; // let the user know that nothing matched
321 }
322 replace_part(wdata->state, 0, wdata->buf);
323 return rc;
324}
325
326#ifdef USE_NOTMUCH
332static int complete_nm_query(struct EnterWindowData *wdata)
333{
334 int rc = FR_SUCCESS;
335 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
336 size_t len = strlen(wdata->buf);
337 if (!mutt_nm_query_complete(wdata->cd, wdata->buf, wdata->buflen, len, wdata->tabs))
338 rc = FR_ERROR;
339
340 replace_part(wdata->state, 0, wdata->buf);
341 return rc;
342}
343
349static int complete_nm_tag(struct EnterWindowData *wdata)
350{
351 int rc = FR_SUCCESS;
352 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
353 if (!mutt_nm_tag_complete(wdata->cd, wdata->buf, wdata->buflen, wdata->tabs))
354 rc = FR_ERROR;
355
356 replace_part(wdata->state, 0, wdata->buf);
357 return rc;
358}
359#endif
360
368static int op_editor_complete(struct EnterWindowData *wdata, int op)
369{
370 if (wdata->tabs == 0)
371 {
372 if (wdata->cd)
374 else
375 wdata->cd = completion_data_new();
376 }
377
378 wdata->tabs++;
379 wdata->redraw = ENTER_REDRAW_LINE;
380 if (wdata->flags & MUTT_COMP_FILE_SIMPLE)
381 return complete_file_simple(wdata);
382
383 if ((wdata->flags & MUTT_COMP_ALIAS) && (op == OP_EDITOR_COMPLETE))
384 return complete_alias_complete(wdata);
385
386 if ((wdata->flags & MUTT_COMP_LABEL) && (op == OP_EDITOR_COMPLETE))
387 return complete_label(wdata);
388
389 if ((wdata->flags & MUTT_COMP_PATTERN) && (op == OP_EDITOR_COMPLETE))
390 return complete_pattern(wdata);
391
392 if ((wdata->flags & MUTT_COMP_ALIAS) && (op == OP_EDITOR_COMPLETE_QUERY))
393 return complete_alias_query(wdata);
394
395 if (wdata->flags & MUTT_COMP_COMMAND)
396 return complete_command(wdata);
397
399 return complete_file_mbox(wdata);
400
401#ifdef USE_NOTMUCH
402 if (wdata->flags & MUTT_COMP_NM_QUERY)
403 return complete_nm_query(wdata);
404
405 if (wdata->flags & MUTT_COMP_NM_TAG)
406 return complete_nm_tag(wdata);
407#endif
408
409 return FR_NO_ACTION;
410}
411
412// -----------------------------------------------------------------------------
413
417static int op_editor_history_down(struct EnterWindowData *wdata, int op)
418{
419 wdata->state->curpos = wdata->state->lastchar;
420 if (mutt_hist_at_scratch(wdata->hclass))
421 {
422 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
423 mutt_hist_save_scratch(wdata->hclass, wdata->buf);
424 }
425 replace_part(wdata->state, 0, mutt_hist_next(wdata->hclass));
426 wdata->redraw = ENTER_REDRAW_INIT;
427 return FR_SUCCESS;
428}
429
433static int op_editor_history_search(struct EnterWindowData *wdata, int op)
434{
435 wdata->state->curpos = wdata->state->lastchar;
436 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
437 mutt_hist_complete(wdata->buf, wdata->buflen, wdata->hclass);
438 replace_part(wdata->state, 0, wdata->buf);
439 return FR_CONTINUE;
440}
441
445static int op_editor_history_up(struct EnterWindowData *wdata, int op)
446{
447 wdata->state->curpos = wdata->state->lastchar;
448 if (mutt_hist_at_scratch(wdata->hclass))
449 {
450 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
451 mutt_hist_save_scratch(wdata->hclass, wdata->buf);
452 }
453 replace_part(wdata->state, 0, mutt_hist_prev(wdata->hclass));
454 wdata->redraw = ENTER_REDRAW_INIT;
455 return FR_SUCCESS;
456}
457
461static int op_editor_mailbox_cycle(struct EnterWindowData *wdata, int op)
462{
463 if (wdata->flags & MUTT_COMP_FILE_MBOX)
464 {
465 wdata->first = true; /* clear input if user types a real key later */
466 mutt_mb_wcstombs(wdata->buf, wdata->buflen, wdata->state->wbuf, wdata->state->curpos);
467
468 struct Buffer *pool = buf_pool_get();
469 buf_addstr(pool, wdata->buf);
470 mutt_mailbox_next(wdata->m, pool);
471 mutt_str_copy(wdata->buf, buf_string(pool), wdata->buflen);
472 buf_pool_release(&pool);
473
474 wdata->state->curpos = wdata->state->lastchar =
475 mutt_mb_mbstowcs(&wdata->state->wbuf, &wdata->state->wbuflen, 0, wdata->buf);
476 return FR_SUCCESS;
477 }
478 else if (!(wdata->flags & MUTT_COMP_FILE))
479 {
480 return FR_NO_ACTION;
481 }
482
483 return op_editor_complete(wdata, op);
484}
485
486// -----------------------------------------------------------------------------
487
491static int op_editor_backspace(struct EnterWindowData *wdata, int op)
492{
493 int rc = editor_backspace(wdata->state);
494
495 if ((rc == FR_ERROR) && editor_buffer_is_empty(wdata->state))
496 {
497 const bool c_abort_backspace = cs_subset_bool(NeoMutt->sub, "abort_backspace");
498 if (c_abort_backspace)
499 {
500 wdata->buf[0] = '\0';
501 wdata->done = true;
502 rc = FR_SUCCESS;
503 }
504 }
505
506 return rc;
507}
508
512static int op_editor_backward_char(struct EnterWindowData *wdata, int op)
513{
514 return editor_backward_char(wdata->state);
515}
516
520static int op_editor_backward_word(struct EnterWindowData *wdata, int op)
521{
522 return editor_backward_word(wdata->state);
523}
524
528static int op_editor_bol(struct EnterWindowData *wdata, int op)
529{
530 return editor_bol(wdata->state);
531}
532
540static int op_editor_capitalize_word(struct EnterWindowData *wdata, int op)
541{
542 enum EnterCase ec;
543 switch (op)
544 {
545 case OP_EDITOR_CAPITALIZE_WORD:
546 ec = EC_CAPITALIZE;
547 break;
548 case OP_EDITOR_DOWNCASE_WORD:
549 ec = EC_DOWNCASE;
550 break;
551 case OP_EDITOR_UPCASE_WORD:
552 ec = EC_UPCASE;
553 break;
554 default:
555 return FR_ERROR;
556 }
557 return editor_case_word(wdata->state, ec);
558}
559
563static int op_editor_delete_char(struct EnterWindowData *wdata, int op)
564{
565 return editor_delete_char(wdata->state);
566}
567
571static int op_editor_eol(struct EnterWindowData *wdata, int op)
572{
573 int rc = editor_eol(wdata->state);
574 wdata->redraw = ENTER_REDRAW_INIT;
575 return rc;
576}
577
581static int op_editor_forward_char(struct EnterWindowData *wdata, int op)
582{
583 return editor_forward_char(wdata->state);
584}
585
589static int op_editor_forward_word(struct EnterWindowData *wdata, int op)
590{
591 return editor_forward_word(wdata->state);
592}
593
597static int op_editor_kill_eol(struct EnterWindowData *wdata, int op)
598{
599 return editor_kill_eol(wdata->state);
600}
601
605static int op_editor_kill_eow(struct EnterWindowData *wdata, int op)
606{
607 return editor_kill_eow(wdata->state);
608}
609
613static int op_editor_kill_line(struct EnterWindowData *wdata, int op)
614{
615 return editor_kill_line(wdata->state);
616}
617
621static int op_editor_kill_whole_line(struct EnterWindowData *wdata, int op)
622{
623 return editor_kill_whole_line(wdata->state);
624}
625
629static int op_editor_kill_word(struct EnterWindowData *wdata, int op)
630{
631 return editor_kill_word(wdata->state);
632}
633
637static int op_editor_quote_char(struct EnterWindowData *wdata, int op)
638{
639 struct KeyEvent event = { OP_NULL, OP_NULL };
640 do
641 {
642 window_redraw(NULL);
643 event = mutt_getch();
644 } while (event.op == OP_TIMEOUT);
645 if (event.op != OP_ABORT)
646 {
647 if (self_insert(wdata, event.ch))
648 {
649 wdata->done = true;
650 return FR_SUCCESS;
651 }
652 }
653 return FR_SUCCESS;
654}
655
659static int op_editor_transpose_chars(struct EnterWindowData *wdata, int op)
660{
661 return editor_transpose_chars(wdata->state);
662}
663
664// -----------------------------------------------------------------------------
665
669static const struct EnterFunction EnterFunctions[] = {
670 // clang-format off
671 { OP_EDITOR_BACKSPACE, op_editor_backspace },
672 { OP_EDITOR_BACKWARD_CHAR, op_editor_backward_char },
673 { OP_EDITOR_BACKWARD_WORD, op_editor_backward_word },
674 { OP_EDITOR_BOL, op_editor_bol },
675 { OP_EDITOR_CAPITALIZE_WORD, op_editor_capitalize_word },
676 { OP_EDITOR_COMPLETE, op_editor_complete },
677 { OP_EDITOR_COMPLETE_QUERY, op_editor_complete },
678 { OP_EDITOR_DELETE_CHAR, op_editor_delete_char },
679 { OP_EDITOR_DOWNCASE_WORD, op_editor_capitalize_word },
680 { OP_EDITOR_EOL, op_editor_eol },
681 { OP_EDITOR_FORWARD_CHAR, op_editor_forward_char },
682 { OP_EDITOR_FORWARD_WORD, op_editor_forward_word },
683 { OP_EDITOR_HISTORY_DOWN, op_editor_history_down },
684 { OP_EDITOR_HISTORY_SEARCH, op_editor_history_search },
685 { OP_EDITOR_HISTORY_UP, op_editor_history_up },
686 { OP_EDITOR_KILL_EOL, op_editor_kill_eol },
687 { OP_EDITOR_KILL_EOW, op_editor_kill_eow },
688 { OP_EDITOR_KILL_LINE, op_editor_kill_line },
689 { OP_EDITOR_KILL_WHOLE_LINE, op_editor_kill_whole_line },
690 { OP_EDITOR_KILL_WORD, op_editor_kill_word },
691 { OP_EDITOR_MAILBOX_CYCLE, op_editor_mailbox_cycle },
692 { OP_EDITOR_QUOTE_CHAR, op_editor_quote_char },
693 { OP_EDITOR_TRANSPOSE_CHARS, op_editor_transpose_chars },
694 { OP_EDITOR_UPCASE_WORD, op_editor_capitalize_word },
695 { 0, NULL },
696 // clang-format on
697};
698
703{
704 if (!win || !win->wdata)
705 return FR_UNKNOWN;
706
707 struct EnterWindowData *wdata = win->wdata;
708
709 int rc = FR_UNKNOWN;
710 for (size_t i = 0; EnterFunctions[i].op != OP_NULL; i++)
711 {
712 const struct EnterFunction *fn = &EnterFunctions[i];
713 if (fn->op == op)
714 {
715 rc = fn->function(wdata, op);
716 break;
717 }
718 }
719
720 if (rc == FR_UNKNOWN) // Not our function
721 return rc;
722
723 const char *result = dispacher_get_retval_name(rc);
724 mutt_debug(LL_DEBUG1, "Handled %s (%d) -> %s\n", opcodes_get_name(op), op, NONULL(result));
725
726 return rc;
727}
Email Aliases.
Select a Mailbox from a list.
#define MUTT_SEL_FOLDER
Select a local directory.
Definition: lib.h:58
#define MUTT_SEL_MULTI
Multi-selection is enabled.
Definition: lib.h:57
#define MUTT_SEL_NO_FLAGS
No flags are set.
Definition: lib.h:55
void mutt_select_file(char *file, size_t filelen, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file.
Definition: browser.c:1443
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:238
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:401
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:90
int mutt_complete(struct CompletionData *cd, char *buf, size_t buflen)
Attempt to complete a partial pathname.
Definition: complete.c:58
int mutt_var_value_complete(struct CompletionData *cd, char *buf, size_t buflen, int pos)
Complete a variable/value.
Definition: helpers.c:560
bool mutt_nm_query_complete(struct CompletionData *cd, char *buf, size_t buflen, int pos, int numtabs)
Complete to the nearest notmuch tag.
Definition: helpers.c:437
int mutt_command_complete(struct CompletionData *cd, char *buf, size_t buflen, int pos, int numtabs)
Complete a command name.
Definition: helpers.c:164
bool mutt_nm_tag_complete(struct CompletionData *cd, char *buf, size_t buflen, int numtabs)
Complete to the nearest notmuch tag.
Definition: helpers.c:501
int mutt_label_complete(struct CompletionData *cd, char *buf, size_t buflen, int numtabs)
Complete a label name.
Definition: helpers.c:368
Auto-completion.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
Convenience wrapper for the core headers.
struct KeyEvent mutt_getch(void)
Read a character from the input buffer.
Definition: curs_lib.c:243
struct CompletionData * completion_data_new(void)
Create new Completion Data.
Definition: data.c:70
void completion_data_reset(struct CompletionData *cd)
Wipe the stored Completion Data.
Definition: data.c:84
const char * dispacher_get_retval_name(int rv)
Get the name of a return value.
Definition: dispatcher.c:54
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
@ FR_CONTINUE
Remain in the Dialog.
Definition: dispatcher.h:34
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
int alias_complete(char *buf, size_t buflen, struct ConfigSubset *sub)
Alias completion routine.
Definition: dlg_alias.c:384
bool dlg_select_pattern(char *buf, size_t buflen)
Show menu to select a Pattern.
Definition: dlg_pattern.c:335
int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
Perform auto-complete using an Address Query.
Definition: dlg_query.c:448
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:481
static int complete_file_simple(struct EnterWindowData *wdata)
Complete a filename.
Definition: functions.c:97
static void replace_part(struct EnterState *es, size_t from, const char *buf)
Search and replace on a buffer.
Definition: functions.c:58
static int complete_nm_query(struct EnterWindowData *wdata)
Complete a Notmuch Query.
Definition: functions.c:332
static int complete_alias_complete(struct EnterWindowData *wdata)
Complete an Alias.
Definition: functions.c:137
static int complete_file_mbox(struct EnterWindowData *wdata)
Complete a Mailbox.
Definition: functions.c:284
static int complete_label(struct EnterWindowData *wdata)
Complete a label.
Definition: functions.c:166
static int complete_alias_query(struct EnterWindowData *wdata)
Complete an Alias Query.
Definition: functions.c:231
static int complete_nm_tag(struct EnterWindowData *wdata)
Complete a Notmuch Tag.
Definition: functions.c:349
static int complete_command(struct EnterWindowData *wdata)
Complete a NeoMutt Command.
Definition: functions.c:260
static const struct EnterFunction EnterFunctions[]
All the NeoMutt functions that Enter supports.
Definition: functions.c:669
static int complete_pattern(struct EnterWindowData *wdata)
Complete a NeoMutt Pattern.
Definition: functions.c:192
bool self_insert(struct EnterWindowData *wdata, int ch)
Insert a normal character.
Definition: window.c:91
@ ENTER_REDRAW_LINE
Redraw entire line.
Definition: wdata.h:39
@ ENTER_REDRAW_INIT
Go to end of line and redraw.
Definition: wdata.h:38
int editor_backward_word(struct EnterState *es)
Move the cursor to the beginning of the word.
Definition: enter.c:90
bool editor_buffer_is_empty(struct EnterState *es)
Is the Enter buffer empty?
Definition: enter.c:387
int editor_kill_line(struct EnterState *es)
Delete chars from cursor to beginning the line.
Definition: enter.c:291
int editor_delete_char(struct EnterState *es)
Delete the char under the cursor.
Definition: enter.c:157
int editor_bol(struct EnterState *es)
Jump to the beginning of the line.
Definition: enter.c:109
int editor_backspace(struct EnterState *es)
Delete the char in front of the cursor.
Definition: enter.c:47
int editor_kill_word(struct EnterState *es)
Delete the word in front of the cursor.
Definition: enter.c:329
int editor_eol(struct EnterState *es)
Jump to the end of the line.
Definition: enter.c:179
int editor_kill_eow(struct EnterState *es)
Delete chars from the cursor to the end of the word.
Definition: enter.c:252
int editor_transpose_chars(struct EnterState *es)
Transpose character under cursor with previous.
Definition: enter.c:363
int editor_kill_eol(struct EnterState *es)
Delete chars from cursor to end of line.
Definition: enter.c:237
int editor_forward_word(struct EnterState *es)
Move the cursor to the end of the word.
Definition: enter.c:214
int editor_backward_char(struct EnterState *es)
Move the cursor one character to the left.
Definition: enter.c:71
int editor_case_word(struct EnterState *es, enum EnterCase ec)
Change the case of the word.
Definition: enter.c:125
int editor_kill_whole_line(struct EnterState *es)
Delete all chars on the line.
Definition: enter.c:312
int editor_forward_char(struct EnterState *es)
Move the cursor one character to the right.
Definition: enter.c:194
Enter buffer.
EnterCase
Change the case of a word.
Definition: enter.h:35
@ EC_UPCASE
Upper case (all characters)
Definition: enter.h:37
@ EC_DOWNCASE
Lower case (all characters)
Definition: enter.h:38
@ EC_CAPITALIZE
Capitalize word (first character only)
Definition: enter.h:36
int enter_function_dispatcher(struct MuttWindow *win, int op)
Perform an Enter function - Implements function_dispatcher_t -.
Definition: functions.c:702
static int op_editor_kill_line(struct EnterWindowData *wdata, int op)
Delete all chars on the line - Implements enter_function_t -.
Definition: functions.c:613
static int op_editor_mailbox_cycle(struct EnterWindowData *wdata, int op)
Cycle among incoming mailboxes - Implements enter_function_t -.
Definition: functions.c:461
static int op_editor_delete_char(struct EnterWindowData *wdata, int op)
Delete the char under the cursor - Implements enter_function_t -.
Definition: functions.c:563
static int op_editor_history_down(struct EnterWindowData *wdata, int op)
Scroll down through the history list - Implements enter_function_t -.
Definition: functions.c:417
static int op_editor_history_search(struct EnterWindowData *wdata, int op)
Search through the history list - Implements enter_function_t -.
Definition: functions.c:433
static int op_editor_backward_char(struct EnterWindowData *wdata, int op)
Move the cursor one character to the left - Implements enter_function_t -.
Definition: functions.c:512
static int op_editor_complete(struct EnterWindowData *wdata, int op)
Complete filename or alias - Implements enter_function_t -.
Definition: functions.c:368
static int op_editor_history_up(struct EnterWindowData *wdata, int op)
Scroll up through the history list - Implements enter_function_t -.
Definition: functions.c:445
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 -.
Definition: functions.c:605
static int op_editor_eol(struct EnterWindowData *wdata, int op)
Jump to the end of the line - Implements enter_function_t -.
Definition: functions.c:571
static int op_editor_forward_word(struct EnterWindowData *wdata, int op)
Move the cursor to the end of the word - Implements enter_function_t -.
Definition: functions.c:589
static int op_editor_backward_word(struct EnterWindowData *wdata, int op)
Move the cursor to the beginning of the word - Implements enter_function_t -.
Definition: functions.c:520
static int op_editor_kill_word(struct EnterWindowData *wdata, int op)
Delete the word in front of the cursor - Implements enter_function_t -.
Definition: functions.c:629
static int op_editor_quote_char(struct EnterWindowData *wdata, int op)
Quote the next typed key - Implements enter_function_t -.
Definition: functions.c:637
static int op_editor_forward_char(struct EnterWindowData *wdata, int op)
Move the cursor one character to the right - Implements enter_function_t -.
Definition: functions.c:581
static int op_editor_kill_whole_line(struct EnterWindowData *wdata, int op)
Delete all chars on the line - Implements enter_function_t -.
Definition: functions.c:621
static int op_editor_transpose_chars(struct EnterWindowData *wdata, int op)
Transpose character under cursor with previous - Implements enter_function_t -.
Definition: functions.c:659
static int op_editor_backspace(struct EnterWindowData *wdata, int op)
Delete the char in front of the cursor - Implements enter_function_t -.
Definition: functions.c:491
static int op_editor_kill_eol(struct EnterWindowData *wdata, int op)
Delete chars from cursor to end of line - Implements enter_function_t -.
Definition: functions.c:597
static int op_editor_capitalize_word(struct EnterWindowData *wdata, int op)
Capitalize the word - Implements enter_function_t - This function handles:
Definition: functions.c:540
static int op_editor_bol(struct EnterWindowData *wdata, int op)
Jump to the beginning of the line - Implements enter_function_t -.
Definition: functions.c:528
#define mutt_debug(LEVEL,...)
Definition: logging2.h:87
Convenience wrapper for the gui headers.
Helper functions to get config values.
Read/write command history from/to a file.
char * mutt_hist_next(enum HistoryClass hclass)
Get the next string in a History.
Definition: history.c:525
void mutt_hist_save_scratch(enum HistoryClass hclass, const char *str)
Save a temporary string to the History.
Definition: history.c:664
bool mutt_hist_at_scratch(enum HistoryClass hclass)
Is the current History position at the 'scratch' place?
Definition: history.c:647
void mutt_hist_add(enum HistoryClass hclass, const char *str, bool save)
Add a string to a history.
Definition: history.c:485
char * mutt_hist_prev(enum HistoryClass hclass)
Get the previous string in a History.
Definition: history.c:553
Manage keymappings.
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen)
Convert a string from wide to multibyte characters.
Definition: mbyte.c:237
bool mutt_mb_is_shell_char(wchar_t ch)
Is character not typically part of a pathname.
Definition: mbyte.c:343
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:294
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
#define FREE(x)
Definition: memory.h:43
Convenience wrapper for the library headers.
Keep track when processing files.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:653
Many unsorted constants and some structs.
#define MUTT_COMP_ALIAS
Alias completion (in alias dialog)
Definition: mutt.h:56
#define MUTT_COMP_PATTERN
Pattern mode (in pattern dialog)
Definition: mutt.h:64
#define MUTT_COMP_FILE
File completion (in browser)
Definition: mutt.h:58
#define MUTT_COMP_COMMAND
Complete a NeoMutt command.
Definition: mutt.h:57
#define MUTT_COMP_NM_TAG
Notmuch tag +/- mode.
Definition: mutt.h:63
#define MUTT_COMP_LABEL
Label completion.
Definition: mutt.h:61
#define MUTT_COMP_NM_QUERY
Notmuch query mode.
Definition: mutt.h:62
#define MUTT_COMP_FILE_SIMPLE
File completion (no browser)
Definition: mutt.h:60
#define MUTT_COMP_FILE_MBOX
File completion, plus incoming folders (in browser)
Definition: mutt.h:59
void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass)
Complete a string from a history list.
Definition: mutt_history.c:43
Read/write command history from/to a file.
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
Incoming folders completion routine.
Definition: mutt_mailbox.c:373
Mailbox helper functions.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:605
Some miscellaneous functions.
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:48
All user-callable functions.
#define OP_TIMEOUT
Definition: opcodes.h:32
#define OP_ABORT
Definition: opcodes.h:33
Match patterns to emails.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
Progress Bar Window Data.
Sidebar functions.
#define NONULL(x)
Definition: string2.h:37
String manipulation buffer.
Definition: buffer.h:34
A NeoMutt function.
Definition: functions.h:46
int op
Op code, e.g. OP_SEARCH.
Definition: functions.h:47
enter_function_t function
Function to call.
Definition: functions.h:48
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:46
bool pass
Password mode, conceal characters.
Definition: wdata.h:60
int tabs
Number of times the user has hit tab.
Definition: wdata.h:66
int * numfiles
Number of files selected.
Definition: wdata.h:55
CompletionFlags flags
Flags, see CompletionFlags.
Definition: wdata.h:51
size_t buflen
Length of result buffer.
Definition: wdata.h:49
struct CompletionData * cd
Auto-completion state data.
Definition: wdata.h:70
bool done
Is text-entry done?
Definition: wdata.h:68
bool first
First time through, no input yet.
Definition: wdata.h:61
bool multiple
Allow multiple matches.
Definition: wdata.h:52
char *** files
List of files selected.
Definition: wdata.h:54
wchar_t * tempbuf
Buffer used by completion.
Definition: wdata.h:63
char * buf
Buffer for the result.
Definition: wdata.h:48
struct EnterState * state
Current state of text entry.
Definition: wdata.h:56
enum EnterRedrawFlags redraw
What needs redrawing? See EnterRedrawFlags.
Definition: wdata.h:59
struct Mailbox * m
Mailbox.
Definition: wdata.h:53
enum HistoryClass hclass
History to use, e.g. HC_COMMAND.
Definition: wdata.h:62
size_t templen
Length of complete buffer.
Definition: wdata.h:64
An event such as a keypress.
Definition: keymap.h:65
int op
Function opcode, e.g. OP_HELP.
Definition: keymap.h:67
int ch
Raw key pressed.
Definition: keymap.h:66
void * wdata
Private data.
Definition: mutt_window.h:145
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39