NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h File Reference

Edit a string. More...

#include <stddef.h>
#include "enter.h"
#include "functions.h"
#include "state.h"
#include "wdata.h"
#include "history/lib.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void editor_init_keys (struct SubMenu *sm_generic)
 Initialise the Editor Keybindings - Implements ::init_keys_api.
 
int mw_get_field (const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
 Ask the user for a string -.
 
void replace_part (struct EnterState *es, size_t from, const char *buf)
 Search and replace on a buffer.
 

Detailed Description

Edit a string.

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 lib.h.

Function Documentation

◆ editor_init_keys()

void editor_init_keys ( struct SubMenu * sm_generic)

Initialise the Editor Keybindings - Implements ::init_keys_api.

Definition at line 131 of file functions.c.

132{
133 struct MenuDefinition *md = NULL;
134 struct SubMenu *sm = NULL;
135
137 md = km_register_menu(MENU_EDITOR, "editor");
138 km_menu_add_submenu(md, sm);
140
141 MdEditor = md;
142 SmEditor = sm;
143}
static const struct MenuOpSeq EditorDefaultBindings[]
Key bindings for the Editor Menu.
Definition functions.c:90
struct SubMenu * SmEditor
Editor functions.
Definition functions.c:49
static const struct MenuFuncOp OpEditor[]
Functions for the Editor Menu.
Definition functions.c:55
struct MenuDefinition * MdEditor
Editor Menu Definition.
Definition functions.c:46
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:91
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:107
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
Functions for a Dialog or Window.
Definition menu.h:80
Collection of related functions.
Definition menu.h:68
@ MENU_EDITOR
Text entry area.
Definition type.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 151 of file functions.c.

152{
153 /* Save the suffix */
154 size_t savelen = es->lastchar - es->curpos;
155 wchar_t *savebuf = NULL;
156
157 if (savelen)
158 {
159 savebuf = MUTT_MEM_CALLOC(savelen, wchar_t);
160 wmemcpy(savebuf, es->wbuf + es->curpos, savelen);
161 }
162
163 /* Convert to wide characters */
164 es->curpos = mutt_mb_mbstowcs(&es->wbuf, &es->wbuflen, from, buf);
165
166 if (savelen)
167 {
168 /* Make space for suffix */
169 if (es->curpos + savelen > es->wbuflen)
170 {
171 es->wbuflen = es->curpos + savelen;
172 MUTT_MEM_REALLOC(&es->wbuf, es->wbuflen, wchar_t);
173 }
174
175 /* Restore suffix */
176 wmemcpy(es->wbuf + es->curpos, savebuf, savelen);
177 FREE(&savebuf);
178 }
179
180 es->lastchar = es->curpos + savelen;
181}
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
#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
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: