NeoMutt  2025-09-05-43-g177ed6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Editor functions. More...

#include "config.h"
#include <wchar.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "complete/lib.h"
#include "history/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "enter.h"
#include "functions.h"
#include "protos.h"
#include "state.h"
#include "wdata.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

void replace_part (struct EnterState *es, size_t from, const char *buf)
 Search and replace on a buffer.
 
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 -.
 
int enter_function_dispatcher (struct MuttWindow *win, int op)
 Perform an Enter function - Implements function_dispatcher_t -.
 

Variables

const struct MenuFuncOp OpEditor []
 Functions for the Editor Menu.
 
const struct MenuOpSeq EditorDefaultBindings []
 Key bindings for the Editor Menu.
 
static const struct EnterFunction EnterFunctions []
 All the NeoMutt functions that Enter supports.
 

Detailed Description

Editor functions.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file functions.c.

Function Documentation

◆ replace_part()

void replace_part ( struct EnterState * es,
size_t from,
const char * buf )

Search and replace on a buffer.

Parameters
esCurrent state of the input buffer
fromStarting point for the replacement
bufReplacement string

Definition at line 132 of file functions.c.

133{
134 /* Save the suffix */
135 size_t savelen = es->lastchar - es->curpos;
136 wchar_t *savebuf = NULL;
137
138 if (savelen)
139 {
140 savebuf = MUTT_MEM_CALLOC(savelen, wchar_t);
141 wmemcpy(savebuf, es->wbuf + es->curpos, savelen);
142 }
143
144 /* Convert to wide characters */
145 es->curpos = mutt_mb_mbstowcs(&es->wbuf, &es->wbuflen, from, buf);
146
147 if (savelen)
148 {
149 /* Make space for suffix */
150 if (es->curpos + savelen > es->wbuflen)
151 {
152 es->wbuflen = es->curpos + savelen;
153 MUTT_MEM_REALLOC(&es->wbuf, es->wbuflen, wchar_t);
154 }
155
156 /* Restore suffix */
157 wmemcpy(es->wbuf + es->curpos, savebuf, savelen);
158 FREE(&savebuf);
159 }
160
161 es->lastchar = es->curpos + savelen;
162}
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:291
#define FREE(x)
Definition memory.h:62
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:47
#define MUTT_MEM_REALLOC(pptr, n, type)
Definition memory.h:50
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ OpEditor

const struct MenuFuncOp OpEditor[]

Functions for the Editor Menu.

Definition at line 53 of file functions.c.

53 { /* map: editor */
54 { "backspace", OP_EDITOR_BACKSPACE },
55 { "backward-char", OP_EDITOR_BACKWARD_CHAR },
56 { "backward-word", OP_EDITOR_BACKWARD_WORD },
57 { "bol", OP_EDITOR_BOL },
58 { "capitalize-word", OP_EDITOR_CAPITALIZE_WORD },
59 { "complete", OP_EDITOR_COMPLETE },
60 { "complete-query", OP_EDITOR_COMPLETE_QUERY },
61 { "delete-char", OP_EDITOR_DELETE_CHAR },
62 { "downcase-word", OP_EDITOR_DOWNCASE_WORD },
63 { "eol", OP_EDITOR_EOL },
64 { "forward-char", OP_EDITOR_FORWARD_CHAR },
65 { "forward-word", OP_EDITOR_FORWARD_WORD },
66 { "help", OP_HELP },
67 { "history-down", OP_EDITOR_HISTORY_DOWN },
68 { "history-search", OP_EDITOR_HISTORY_SEARCH },
69 { "history-up", OP_EDITOR_HISTORY_UP },
70 { "kill-eol", OP_EDITOR_KILL_EOL },
71 { "kill-eow", OP_EDITOR_KILL_EOW },
72 { "kill-line", OP_EDITOR_KILL_LINE },
73 { "kill-whole-line", OP_EDITOR_KILL_WHOLE_LINE },
74 { "kill-word", OP_EDITOR_KILL_WORD },
75 { "mailbox-cycle", OP_EDITOR_MAILBOX_CYCLE },
76 { "quote-char", OP_EDITOR_QUOTE_CHAR },
77 { "redraw-screen", OP_REDRAW },
78 { "transpose-chars", OP_EDITOR_TRANSPOSE_CHARS },
79 { "upcase-word", OP_EDITOR_UPCASE_WORD },
80 // Deprecated
81 { "buffy-cycle", OP_EDITOR_MAILBOX_CYCLE, OP_DEPRECATED },
82 { NULL, 0 },
83};
#define OP_DEPRECATED
Convenience symbol.
Definition lib.h:109

◆ EditorDefaultBindings

const struct MenuOpSeq EditorDefaultBindings[]

Key bindings for the Editor Menu.

Definition at line 88 of file functions.c.

88 { /* map: editor */
89 { OP_EDITOR_BACKSPACE, "<backspace>" },
90 { OP_EDITOR_BACKSPACE, "\010" }, // <Ctrl-H>
91 { OP_EDITOR_BACKSPACE, "\177" }, // <Backspace>
92 { OP_EDITOR_BACKWARD_CHAR, "<left>" },
93 { OP_EDITOR_BACKWARD_CHAR, "\002" }, // <Ctrl-B>
94 { OP_EDITOR_BACKWARD_WORD, "\033b" }, // <Alt-b>
95 { OP_EDITOR_BOL, "<home>" },
96 { OP_EDITOR_BOL, "\001" }, // <Ctrl-A>
97 { OP_EDITOR_CAPITALIZE_WORD, "\033c" }, // <Alt-c>
98 { OP_EDITOR_COMPLETE, "\t" }, // <Tab>
99 { OP_EDITOR_COMPLETE_QUERY, "\024" }, // <Ctrl-T>
100 { OP_EDITOR_DELETE_CHAR, "<delete>" },
101 { OP_EDITOR_DELETE_CHAR, "\004" }, // <Ctrl-D>
102 { OP_EDITOR_DOWNCASE_WORD, "\033l" }, // <Alt-l>
103 { OP_EDITOR_EOL, "<end>" },
104 { OP_EDITOR_EOL, "\005" }, // <Ctrl-E>
105 { OP_EDITOR_FORWARD_CHAR, "<right>" },
106 { OP_EDITOR_FORWARD_CHAR, "\006" }, // <Ctrl-F>
107 { OP_EDITOR_FORWARD_WORD, "\033f" }, // <Alt-f>
108 { OP_EDITOR_HISTORY_DOWN, "<down>" },
109 { OP_EDITOR_HISTORY_DOWN, "\016" }, // <Ctrl-N>
110 { OP_EDITOR_HISTORY_SEARCH, "\022" }, // <Ctrl-R>
111 { OP_EDITOR_HISTORY_UP, "<up>" },
112 { OP_EDITOR_HISTORY_UP, "\020" }, // <Ctrl-P>
113 { OP_EDITOR_KILL_EOL, "\013" }, // <Ctrl-K>
114 { OP_EDITOR_KILL_EOW, "\033d" }, // <Alt-d>
115 { OP_EDITOR_KILL_LINE, "\025" }, // <Ctrl-U>
116 { OP_EDITOR_KILL_WORD, "\027" }, // <Ctrl-W>
117 { OP_EDITOR_MAILBOX_CYCLE, " " }, // <Space>
118 { OP_EDITOR_QUOTE_CHAR, "\026" }, // <Ctrl-V>
119 { OP_EDITOR_UPCASE_WORD, "\033u" }, // <Alt-u>
120 { OP_HELP, "\033?" }, // <Alt-?>
121 { OP_REDRAW, "\014" }, // <Ctrl-L>
122 { 0, NULL },
123};

◆ EnterFunctions

const struct EnterFunction EnterFunctions[]
static

All the NeoMutt functions that Enter supports.

Definition at line 447 of file functions.c.

447 {
448 // clang-format off
449 { OP_EDITOR_BACKSPACE, op_editor_backspace },
450 { OP_EDITOR_BACKWARD_CHAR, op_editor_backward_char },
451 { OP_EDITOR_BACKWARD_WORD, op_editor_backward_word },
452 { OP_EDITOR_BOL, op_editor_bol },
453 { OP_EDITOR_CAPITALIZE_WORD, op_editor_capitalize_word },
454 { OP_EDITOR_COMPLETE, op_editor_complete },
455 { OP_EDITOR_COMPLETE_QUERY, op_editor_complete },
456 { OP_EDITOR_DELETE_CHAR, op_editor_delete_char },
457 { OP_EDITOR_DOWNCASE_WORD, op_editor_capitalize_word },
458 { OP_EDITOR_EOL, op_editor_eol },
459 { OP_EDITOR_FORWARD_CHAR, op_editor_forward_char },
460 { OP_EDITOR_FORWARD_WORD, op_editor_forward_word },
461 { OP_EDITOR_HISTORY_DOWN, op_editor_history_down },
462 { OP_EDITOR_HISTORY_SEARCH, op_editor_history_search },
463 { OP_EDITOR_HISTORY_UP, op_editor_history_up },
464 { OP_EDITOR_KILL_EOL, op_editor_kill_eol },
465 { OP_EDITOR_KILL_EOW, op_editor_kill_eow },
466 { OP_EDITOR_KILL_LINE, op_editor_kill_line },
467 { OP_EDITOR_KILL_WHOLE_LINE, op_editor_kill_whole_line },
468 { OP_EDITOR_KILL_WORD, op_editor_kill_word },
469 { OP_EDITOR_MAILBOX_CYCLE, op_editor_complete },
470 { OP_EDITOR_QUOTE_CHAR, op_editor_quote_char },
471 { OP_EDITOR_TRANSPOSE_CHARS, op_editor_transpose_chars },
472 { OP_EDITOR_UPCASE_WORD, op_editor_capitalize_word },
473 { OP_HELP, op_help },
474 { OP_REDRAW, op_redraw },
475 { 0, NULL },
476 // clang-format on
477};
static int op_editor_kill_line(struct EnterWindowData *wdata, int op)
Delete all chars on the line - Implements enter_function_t -.
Definition functions.c:365
static int op_editor_delete_char(struct EnterWindowData *wdata, int op)
Delete the char under the cursor - Implements enter_function_t -.
Definition functions.c:315
static int op_editor_history_down(struct EnterWindowData *wdata, int op)
Scroll down through the history list - Implements enter_function_t -.
Definition functions.c:197
static int op_editor_history_search(struct EnterWindowData *wdata, int op)
Search through the history list - Implements enter_function_t -.
Definition functions.c:213
static int op_help(struct EnterWindowData *wdata, int op)
Display Help - Implements enter_function_t -.
Definition functions.c:424
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:264
static int op_editor_complete(struct EnterWindowData *wdata, int op)
Complete filename or alias - Implements enter_function_t -.
Definition functions.c:173
static int op_editor_history_up(struct EnterWindowData *wdata, int op)
Scroll up through the history list - Implements enter_function_t -.
Definition functions.c:225
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:357
static int op_editor_eol(struct EnterWindowData *wdata, int op)
Jump to the end of the line - Implements enter_function_t -.
Definition functions.c:323
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:341
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:272
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:381
static int op_editor_quote_char(struct EnterWindowData *wdata, int op)
Quote the next typed key - Implements enter_function_t -.
Definition functions.c:393
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:333
static int op_redraw(struct EnterWindowData *wdata, int op)
Redraw the screen - Implements enter_function_t -.
Definition functions.c:433
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:373
static int op_editor_transpose_chars(struct EnterWindowData *wdata, int op)
Transpose character under cursor with previous - Implements enter_function_t -.
Definition functions.c:416
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:243
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:349
static int op_editor_capitalize_word(struct EnterWindowData *wdata, int op)
Capitalize the word - Implements enter_function_t - This function handles:
Definition functions.c:292
static int op_editor_bol(struct EnterWindowData *wdata, int op)
Jump to the beginning of the line - Implements enter_function_t -.
Definition functions.c:280