mark inserted from file

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Ilia Maslakov 2011-02-18 14:39:52 +00:00
parent dc6bd875c4
commit ecd8ca2292
3 changed files with 34 additions and 7 deletions

View File

@ -288,7 +288,8 @@ int edit_insert_file_cmd (WEdit * edit);
void edit_insert_over (WEdit * edit);
void edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width,
long *start_pos, long *end_pos, int *col1, int *col2);
int edit_insert_column_of_text_from_file (WEdit * edit, int file);
int edit_insert_column_of_text_from_file (WEdit * edit, int file,
long *start_pos, long *end_pos, int *col1, int *col2);
long edit_insert_file (WEdit * edit, const char *filename);
int edit_load_back_cmd (WEdit * edit);
int edit_load_forward_cmd (WEdit * edit);

View File

@ -2060,7 +2060,17 @@ edit_insert_file (WEdit * edit, const char *filename)
}
if (vertical_insertion)
{
blocklen = edit_insert_column_of_text_from_file (edit, file);
long mark1, mark2;
int c1, c2;
blocklen = edit_insert_column_of_text_from_file (edit, file, &mark1, &mark2, &c1, &c2);
edit_set_markers (edit, edit->curs1, mark2, c1, c2);
/* highlight inserted text then not persistent blocks */
if (!option_persistent_selections)
{
if (!edit->column_highlight)
edit_push_undo_action (edit, COLUMN_OFF);
edit->column_highlight = 1;
}
}
else
{
@ -2069,8 +2079,16 @@ edit_insert_file (WEdit * edit, const char *filename)
for (i = 0; i < blocklen; i++)
edit_insert (edit, buf[i]);
}
/* highlight inserted text then not persistent blocks */
if (!option_persistent_selections)
{
edit_set_markers (edit, edit->curs1, current, 0, 0);
if (edit->column_highlight)
edit_push_undo_action (edit, COLUMN_ON);
edit->column_highlight = 0;
}
}
edit->force |= REDRAW_PAGE;
ins_len = edit->curs1 - current;
edit_cursor_move (edit, current - edit->curs1);
g_free (buf);

View File

@ -1960,17 +1960,21 @@ edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int wid
/* --------------------------------------------------------------------------------------------- */
int
edit_insert_column_of_text_from_file (WEdit * edit, int file)
edit_insert_column_of_text_from_file (WEdit * edit, int file,
long *start_pos, long *end_pos, int *col1, int *col2)
{
long cursor;
int i, col;
int blocklen = -1, width;
int col;
int blocklen = -1, width = 0;
unsigned char *data;
cursor = edit->curs1;
col = edit_get_col (edit);
data = g_malloc0 (TEMP_BUF_LEN);
while ((blocklen = mc_read (file, (char *) data, TEMP_BUF_LEN)) > 0)
{
int i;
for (width = 0; width < blocklen; width++)
{
if (data[width] == '\n')
@ -2018,9 +2022,13 @@ edit_insert_column_of_text_from_file (WEdit * edit, int file)
edit_insert (edit, data[i]);
}
}
*col1 = col;
*col2 = col + width;
*start_pos = cursor;
*end_pos = edit->curs1;
edit_cursor_move (edit, cursor - edit->curs1);
g_free (data);
edit->force |= REDRAW_PAGE;
return blocklen;
}