NeoMutt  2024-04-25-1-g3de005
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Editor functions. More...

#include "config.h"
#include <string.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, sizeof(wchar_t));
141 memcpy(savebuf, es->wbuf + es->curpos, savelen * sizeof(wchar_t));
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 * sizeof(wchar_t));
154 }
155
156 /* Restore suffix */
157 memcpy(es->wbuf + es->curpos, savebuf, savelen * sizeof(wchar_t));
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
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:45
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.

◆ EditorDefaultBindings

const struct MenuOpSeq EditorDefaultBindings[]

Key bindings for the Editor Menu.

Definition at line 88 of file functions.c.

◆ EnterFunctions

const struct EnterFunction EnterFunctions[]
static

All the NeoMutt functions that Enter supports.

Definition at line 447 of file functions.c.