diff --git a/src/global.c b/src/global.c index ca2049c6..a399e548 100644 --- a/src/global.c +++ b/src/global.c @@ -1063,8 +1063,8 @@ void shortcut_init(void) add_to_sclist(MMAIN, "F14", 0, do_replace, 0); add_to_sclist(MMOST, "^K", 0, do_cut_text_void, 0); add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0); - add_to_sclist(MMAIN, "^U", 0, do_uncut_text, 0); - add_to_sclist(MMAIN, "F10", 0, do_uncut_text, 0); + add_to_sclist(MMOST, "^U", 0, do_uncut_text, 0); + add_to_sclist(MMOST, "F10", 0, do_uncut_text, 0); #ifndef DISABLE_JUSTIFY add_to_sclist(MMAIN, "^J", 0, do_justify_void, 0); add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0); diff --git a/src/prompt.c b/src/prompt.c index 5c6b03db..280dc7ca 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -145,7 +145,10 @@ int do_statusbar_input(bool *ran_func, bool *finished) do_statusbar_delete(); else if (s->scfunc == do_backspace) do_statusbar_backspace(); - else { + else if (s->scfunc == do_uncut_text) { + if (cutbuffer != NULL) + do_statusbar_uncut_text(); + } else { /* Handle any other shortcut in the current menu, setting * ran_func to TRUE if we try to run their associated functions, * and setting finished to TRUE to indicatethat we're done after @@ -363,6 +366,23 @@ size_t statusbar_xplustabs(void) return strnlenpt(answer, statusbar_x); } +/* 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, statusbar_x); + strncpy(fusion + statusbar_x, cutbuffer->data, pastelen); + strcpy(fusion + statusbar_x + pastelen, answer + statusbar_x); + + free(answer); + answer = fusion; + statusbar_x += pastelen; +} + /* Return the column number of the first character of the answer that is * displayed in the statusbar when the cursor is at the given column, * with the available room for the answer starting at base. Note that diff --git a/src/proto.h b/src/proto.h index c8fbb1ff..d74ace67 100644 --- a/src/proto.h +++ b/src/proto.h @@ -448,6 +448,7 @@ 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); diff --git a/src/rcfile.c b/src/rcfile.c index 95fe88a5..069c3e27 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -357,9 +357,9 @@ bool is_universal(void (*func)(void)) #ifndef NANO_TINY func == do_prev_word_void || func == do_next_word_void || #endif - func == do_verbatim_input || func == do_cut_text_void || func == do_delete || func == do_backspace || - func == do_tab || func == do_enter) + func == do_cut_text_void || func == do_uncut_text || + func == do_tab || func == do_enter || func == do_verbatim_input) return TRUE; else return FALSE;