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.
Этот коммит содержится в:
родитель
1cb945fe8e
Коммит
a847d37b24
16
src/nano.c
16
src/nano.c
@ -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)
|
|||||||
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)
|
|||||||
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,
|
|||||||
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);
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user