mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-26 06:39:43 +03:00
tweaks: rename a constant, and rename and relocate a function
This commit is contained in:
parent
2b97d6563d
commit
6b8f446b52
@ -586,7 +586,7 @@ void shortcut_init(void)
|
||||
N_("Search backward for a string or a regular expression");
|
||||
const char *cut_gist =
|
||||
N_("Cut current line (or marked region) and store it in cutbuffer");
|
||||
const char *uncut_gist =
|
||||
const char *paste_gist =
|
||||
N_("Paste the contents of cutbuffer at current cursor position");
|
||||
const char *cursorpos_gist = N_("Display the position of the cursor");
|
||||
#ifdef ENABLE_SPELLER
|
||||
@ -791,7 +791,7 @@ void shortcut_init(void)
|
||||
N_("Cut Text"), WITHORSANS(cut_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(paste_text, MMAIN,
|
||||
N_("Paste Text"), WITHORSANS(uncut_gist), BLANKAFTER, NOVIEW);
|
||||
N_("Paste Text"), WITHORSANS(paste_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
|
36
src/prompt.c
36
src/prompt.c
@ -28,6 +28,23 @@ static char *prompt = NULL;
|
||||
static size_t typing_x = HIGHEST_POSITIVE;
|
||||
/* The cursor position in answer. */
|
||||
|
||||
/* Paste the first line of the cutbuffer into the current answer. */
|
||||
void paste_into_answer(void)
|
||||
{
|
||||
size_t pastelen = strlen(cutbuffer->data);
|
||||
char *fusion = charalloc(strlen(answer) + pastelen + 1);
|
||||
|
||||
/* Concatenate: the current answer before the cursor, the first line
|
||||
* of the cutbuffer, plus the rest of the current answer. */
|
||||
strncpy(fusion, answer, typing_x);
|
||||
strncpy(fusion + typing_x, cutbuffer->data, pastelen);
|
||||
strcpy(fusion + typing_x + pastelen, answer + typing_x);
|
||||
|
||||
free(answer);
|
||||
answer = fusion;
|
||||
typing_x += pastelen;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* Handle a mouse click on the status-bar prompt or the shortcut list. */
|
||||
int do_statusbar_mouse(void)
|
||||
@ -159,7 +176,7 @@ int do_statusbar_input(bool *finished)
|
||||
do_statusbar_backspace();
|
||||
else if (shortcut->func == paste_text) {
|
||||
if (cutbuffer != NULL)
|
||||
do_statusbar_uncut_text();
|
||||
paste_into_answer();
|
||||
} else {
|
||||
/* Handle any other shortcut in the current menu, setting finished
|
||||
* to TRUE to indicate that we're done after running or trying to
|
||||
@ -311,23 +328,6 @@ void do_statusbar_verbatim_input(void)
|
||||
free(bytes);
|
||||
}
|
||||
|
||||
/* Paste the first line of the cutbuffer into the current answer. */
|
||||
void do_statusbar_uncut_text(void)
|
||||
{
|
||||
size_t pastelen = strlen(cutbuffer->data);
|
||||
char *fusion = charalloc(strlen(answer) + pastelen + 1);
|
||||
|
||||
/* Concatenate: the current answer before the cursor, the first line
|
||||
* of the cutbuffer, plus the rest of the current answer. */
|
||||
strncpy(fusion, answer, typing_x);
|
||||
strncpy(fusion + typing_x, cutbuffer->data, pastelen);
|
||||
strcpy(fusion + typing_x + pastelen, answer + typing_x);
|
||||
|
||||
free(answer);
|
||||
answer = fusion;
|
||||
typing_x += pastelen;
|
||||
}
|
||||
|
||||
/* Return the column number of the first character of the answer that is
|
||||
* displayed in the status bar when the cursor is at the given column,
|
||||
* with the available room for the answer starting at base. Note that
|
||||
|
@ -453,7 +453,6 @@ void do_statusbar_right(void);
|
||||
void do_statusbar_backspace(void);
|
||||
void do_statusbar_delete(void);
|
||||
void do_statusbar_cut_text(void);
|
||||
void do_statusbar_uncut_text(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_statusbar_prev_word(void);
|
||||
void do_statusbar_next_word(void);
|
||||
|
Loading…
Reference in New Issue
Block a user