diff --git a/src/nano.c b/src/nano.c index 542348b6621370a8baa84df8938c893f2b5e54fd..6d3d4dfbe625df2e6f5febe3513676d8187b346c 100644 --- a/src/nano.c +++ b/src/nano.c @@ -392,9 +392,9 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot, new_magicline(); } -/* Copy all text from the given filestruct to the current filestruct +/* Meld the given buffer into the current file buffer * at the current cursor position. */ -void copy_from_buffer(filestruct *somebuffer) +void ingraft_buffer(filestruct *somebuffer) { filestruct *top_save; size_t current_x_save = openfile->current_x; @@ -427,8 +427,8 @@ void copy_from_buffer(filestruct *somebuffer) free_filestruct(openfile->fileage); /* Put the top and bottom of the current filestruct at the top and - * bottom of a copy of the passed buffer. */ - openfile->fileage = copy_filestruct(somebuffer); + * bottom of the passed buffer. */ + openfile->fileage = somebuffer; openfile->filebot = openfile->fileage; while (openfile->filebot->next != NULL) openfile->filebot = openfile->filebot->next; @@ -484,6 +484,14 @@ void copy_from_buffer(filestruct *somebuffer) new_magicline(); } +/* Meld a copy of the given buffer into the current file buffer. */ +void copy_from_buffer(filestruct *somebuffer) +{ + filestruct *the_copy = copy_filestruct(somebuffer); + + ingraft_buffer(the_copy); +} + /* Create a new openfilestruct node. */ openfilestruct *make_new_opennode(void) { diff --git a/src/proto.h b/src/proto.h index de899f04922871cda16de1501041b7ac84d4f4bd..06d278db68007c1229fefc3aca34519df8d0f222 100644 --- a/src/proto.h +++ b/src/proto.h @@ -432,6 +432,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x, void unpartition_filestruct(partition **p); void extract_buffer(filestruct **file_top, filestruct **file_bot, filestruct *top, size_t top_x, filestruct *bot, size_t bot_x); +void ingraft_buffer(filestruct *somebuffer); void copy_from_buffer(filestruct *somebuffer); openfilestruct *make_new_opennode(void); void unlink_opennode(openfilestruct *fileptr);