NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
complete.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stddef.h>
31#include "mutt/lib.h"
32#include "core/lib.h"
33#include "gui/lib.h"
34#include "lib.h"
35#include "complete/lib.h"
36#include "editor/lib.h"
37
42{
43 if (!wdata || (op != OP_EDITOR_COMPLETE))
44 return FR_NO_ACTION;
45
46 /* invoke the alias-menu to get more addresses */
47 size_t i;
48 for (i = wdata->state->curpos; (i > 0) && (wdata->state->wbuf[i - 1] != ',') &&
49 (wdata->state->wbuf[i - 1] != ':');
50 i--)
51 {
52 }
53 for (; (i < wdata->state->lastchar) && (wdata->state->wbuf[i] == ' '); i++)
54 ; // do nothing
55
56 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf + i, wdata->state->curpos - i);
57 int rc = alias_complete(wdata->buffer, NeoMutt->sub);
58 replace_part(wdata->state, i, buf_string(wdata->buffer));
59 if (rc != 1)
60 {
61 return FR_CONTINUE;
62 }
63
64 return FR_SUCCESS;
65}
66
71{
72 if (!wdata || (op != OP_EDITOR_COMPLETE_QUERY))
73 return FR_NO_ACTION;
74
75 size_t i = wdata->state->curpos;
76 if (i != 0)
77 {
78 for (; (i > 0) && (wdata->state->wbuf[i - 1] != ','); i--)
79 ; // do nothing
80
81 for (; (i < wdata->state->curpos) && (wdata->state->wbuf[i] == ' '); i++)
82 ; // do nothing
83 }
84
85 buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf + i, wdata->state->curpos - i);
87 replace_part(wdata->state, i, buf_string(wdata->buffer));
88
89 return FR_CONTINUE;
90}
91
96{
97 if (op == OP_EDITOR_COMPLETE)
98 return complete_alias_complete(wdata, op);
99 if (op == OP_EDITOR_COMPLETE_QUERY)
100 return complete_alias_query(wdata, op);
101
102 return FR_NO_ACTION;
103}
104
110};
const struct CompleteOps CompleteAliasOps
Auto-Completion of Aliases.
Definition: complete.c:108
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
Auto-completion.
Convenience wrapper for the core headers.
FunctionRetval
Possible return values for NeoMutt functions.
Definition: dispatcher.h:32
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
@ 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(struct Buffer *buf, struct ConfigSubset *sub)
Alias completion routine.
Definition: dlg_alias.c:442
int query_complete(struct Buffer *buf, struct ConfigSubset *sub)
Perform auto-complete using an Address Query.
Definition: dlg_query.c:480
void replace_part(struct EnterState *es, size_t from, const char *buf)
Search and replace on a buffer.
Definition: functions.c:132
Edit a string.
enum FunctionRetval complete_alias_query(struct EnterWindowData *wdata, int op)
Complete an Alias Query - Implements CompleteOps::complete() -.
Definition: complete.c:70
enum FunctionRetval complete_alias(struct EnterWindowData *wdata, int op)
Alias completion wrapper - Implements CompleteOps::complete() -.
Definition: complete.c:95
enum FunctionRetval complete_alias_complete(struct EnterWindowData *wdata, int op)
Complete an Alias - Implements CompleteOps::complete() -.
Definition: complete.c:41
Convenience wrapper for the gui headers.
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
Convenience wrapper for the library headers.
Key value store.
enum FunctionRetval(* complete)(struct EnterWindowData *wdata, int op)
Definition: compapi.h:46
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
Data to fill the Enter Window.
Definition: wdata.h:46
struct Buffer * buffer
struct Buffer for the result
Definition: wdata.h:48
struct EnterState * state
Current state of text entry.
Definition: wdata.h:50
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46