mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Refactoring of init/clean editor buffer.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
f56de22de5
commit
e056726606
@ -138,28 +138,6 @@ static const struct edit_filters
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/*** file scope functions ************************************************************************/
|
/*** file scope functions ************************************************************************/
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/**
|
|
||||||
* Initialize the buffers for an empty files.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
edit_init_buffers (WEdit * edit)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = 0; j <= MAXBUFF; j++)
|
|
||||||
{
|
|
||||||
edit->buffer.buffers1[j] = NULL;
|
|
||||||
edit->buffer.buffers2[j] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
edit->buffer.curs1 = 0;
|
|
||||||
edit->buffer.curs2 = 0;
|
|
||||||
edit->buffer.buffers2[0] = g_malloc0 (EDIT_BUF_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load file OR text into buffers. Set cursor to the beginning of file.
|
* Load file OR text into buffers. Set cursor to the beginning of file.
|
||||||
*
|
*
|
||||||
@ -401,7 +379,7 @@ edit_load_file (WEdit * edit)
|
|||||||
fast_load = FALSE;
|
fast_load = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_init_buffers (edit);
|
edit_buffer_init (&edit->buffer);
|
||||||
|
|
||||||
if (fast_load)
|
if (fast_load)
|
||||||
{
|
{
|
||||||
@ -2306,8 +2284,6 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
|
|||||||
gboolean
|
gboolean
|
||||||
edit_clean (WEdit * edit)
|
edit_clean (WEdit * edit)
|
||||||
{
|
{
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
if (edit == NULL)
|
if (edit == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -2327,11 +2303,8 @@ edit_clean (WEdit * edit)
|
|||||||
|
|
||||||
edit_free_syntax_rules (edit);
|
edit_free_syntax_rules (edit);
|
||||||
book_mark_flush (edit, -1);
|
book_mark_flush (edit, -1);
|
||||||
for (; j <= MAXBUFF; j++)
|
|
||||||
{
|
edit_buffer_clean (&edit->buffer);
|
||||||
g_free (edit->buffer.buffers1[j]);
|
|
||||||
g_free (edit->buffer.buffers2[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (edit->undo_stack);
|
g_free (edit->undo_stack);
|
||||||
g_free (edit->redo_stack);
|
g_free (edit->redo_stack);
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
|
|
||||||
#include "editbuffer.h"
|
#include "editbuffer.h"
|
||||||
@ -85,3 +88,39 @@
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/*** public functions ****************************************************************************/
|
/*** public functions ****************************************************************************/
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* Initialize editor buffers.
|
||||||
|
*
|
||||||
|
* @param buf pointer to editor buffer
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
edit_buffer_init (edit_buffer_t * buf)
|
||||||
|
{
|
||||||
|
memset (buf->buffers1, 0, sizeof (buf->buffers1));
|
||||||
|
memset (buf->buffers2, 0, sizeof (buf->buffers2));
|
||||||
|
buf->curs1 = 0;
|
||||||
|
buf->curs2 = 0;
|
||||||
|
buf->buffers2[0] = g_malloc0 (EDIT_BUF_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* Clean editor buffers.
|
||||||
|
*
|
||||||
|
* @param buf pointer to editor buffer
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
edit_buffer_clean (edit_buffer_t * buf)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
for (j = 0; j <= MAXBUFF; j++)
|
||||||
|
{
|
||||||
|
g_free (buf->buffers1[j]);
|
||||||
|
g_free (buf->buffers2[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -49,6 +49,9 @@ typedef struct edit_buffer_struct {
|
|||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** declarations of public functions ************************************************************/
|
||||||
|
|
||||||
|
void edit_buffer_init (edit_buffer_t * buf);
|
||||||
|
void edit_buffer_clean (edit_buffer_t * buf);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
#endif /* MC__EDIT_BUFFER_H */
|
#endif /* MC__EDIT_BUFFER_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user