diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h index 46e9ff88f..d6bb43a10 100644 --- a/src/editor/edit-impl.h +++ b/src/editor/edit-impl.h @@ -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); diff --git a/src/editor/edit.c b/src/editor/edit.c index 39cbb50f0..7f1337651 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -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); diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index cd209c341..5fb523730 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -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; }