Commit a847d37b authored by David Lawrence Ramsey's avatar David Lawrence Ramsey Committed by Benno Schulenberg
Browse files

tweaks: split the grafting code off from copy_from_buffer()

Later on we're going to need the ability to graft a buffer into the
current file buffer without making a copy of it first.
parent 1cb945fe
Showing with 13 additions and 4 deletions
+13 -4
...@@ -392,9 +392,9 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot, ...@@ -392,9 +392,9 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
new_magicline(); 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. */ * at the current cursor position. */
void copy_from_buffer(filestruct *somebuffer) void ingraft_buffer(filestruct *somebuffer)
{ {
filestruct *top_save; filestruct *top_save;
size_t current_x_save = openfile->current_x; size_t current_x_save = openfile->current_x;
...@@ -427,8 +427,8 @@ void copy_from_buffer(filestruct *somebuffer) ...@@ -427,8 +427,8 @@ void copy_from_buffer(filestruct *somebuffer)
free_filestruct(openfile->fileage); free_filestruct(openfile->fileage);
/* Put the top and bottom of the current filestruct at the top and /* Put the top and bottom of the current filestruct at the top and
* bottom of a copy of the passed buffer. */ * bottom of the passed buffer. */
openfile->fileage = copy_filestruct(somebuffer); openfile->fileage = somebuffer;
openfile->filebot = openfile->fileage; openfile->filebot = openfile->fileage;
while (openfile->filebot->next != NULL) while (openfile->filebot->next != NULL)
openfile->filebot = openfile->filebot->next; openfile->filebot = openfile->filebot->next;
...@@ -484,6 +484,14 @@ void copy_from_buffer(filestruct *somebuffer) ...@@ -484,6 +484,14 @@ void copy_from_buffer(filestruct *somebuffer)
new_magicline(); 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. */ /* Create a new openfilestruct node. */
openfilestruct *make_new_opennode(void) openfilestruct *make_new_opennode(void)
{ {
......
...@@ -432,6 +432,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x, ...@@ -432,6 +432,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
void unpartition_filestruct(partition **p); void unpartition_filestruct(partition **p);
void extract_buffer(filestruct **file_top, filestruct **file_bot, void extract_buffer(filestruct **file_top, filestruct **file_bot,
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x); filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
void ingraft_buffer(filestruct *somebuffer);
void copy_from_buffer(filestruct *somebuffer); void copy_from_buffer(filestruct *somebuffer);
openfilestruct *make_new_opennode(void); openfilestruct *make_new_opennode(void);
void unlink_opennode(openfilestruct *fileptr); void unlink_opennode(openfilestruct *fileptr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment