Ticket #2463 (do not reset selection after execute user menu)

do not reset selection after execute user menu

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
Ilia Maslakov 2011-01-03 23:04:02 +00:00
parent 186b2ff3f7
commit bf7675246f
3 changed files with 22 additions and 8 deletions

View File

@ -289,7 +289,7 @@ int edit_save_block_cmd (WEdit * edit);
int edit_insert_file_cmd (WEdit * edit); int edit_insert_file_cmd (WEdit * edit);
void edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width); void edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width);
int edit_insert_column_of_text_from_file (WEdit * edit, int file); int edit_insert_column_of_text_from_file (WEdit * edit, int file);
int edit_insert_file (WEdit * edit, const char *filename); long edit_insert_file (WEdit * edit, const char *filename);
int edit_load_back_cmd (WEdit * edit); int edit_load_back_cmd (WEdit * edit);
int edit_load_forward_cmd (WEdit * edit); int edit_load_forward_cmd (WEdit * edit);
void edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block); void edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block);

View File

@ -480,7 +480,7 @@ edit_load_file (WEdit * edit)
if (*edit->filename) if (*edit->filename)
{ {
edit->undo_stack_disable = 1; edit->undo_stack_disable = 1;
if (!edit_insert_file (edit, edit->filename)) if (edit_insert_file (edit, edit->filename) == 0)
{ {
edit_clean (edit); edit_clean (edit);
return 1; return 1;
@ -1699,8 +1699,13 @@ user_menu (WEdit * edit)
} }
if (rc == 0) if (rc == 0)
edit_insert_file (edit, block_file); {
long ins_len;
ins_len = edit_insert_file (edit, block_file);
if (nomark == 0 && ins_len > 0)
edit_set_markers (edit, start_mark, start_mark + ins_len, 0, 0);
}
/* truncate block file */ /* truncate block file */
fd = fopen (block_file, "w"); fd = fopen (block_file, "w");
if (fd != NULL) if (fd != NULL)
@ -2012,11 +2017,12 @@ edit_write_stream (WEdit * edit, FILE * f)
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/** inserts a file at the cursor, returns 1 on success */ /** inserts a file at the cursor, returns count of inserted bytes on success */
int long
edit_insert_file (WEdit * edit, const char *filename) edit_insert_file (WEdit * edit, const char *filename)
{ {
char *p; char *p;
long ins_len = 0;
p = edit_get_filter (filename); p = edit_get_filter (filename);
if (p != NULL) if (p != NULL)
@ -2027,6 +2033,7 @@ edit_insert_file (WEdit * edit, const char *filename)
if (f != NULL) if (f != NULL)
{ {
edit_insert_stream (edit, f); edit_insert_stream (edit, f);
ins_len = edit->curs1 - current;
edit_cursor_move (edit, current - edit->curs1); edit_cursor_move (edit, current - edit->curs1);
if (pclose (f) > 0) if (pclose (f) > 0)
{ {
@ -2062,25 +2069,32 @@ edit_insert_file (WEdit * edit, const char *filename)
blocklen = mc_read (file, buf, sizeof (VERTICAL_MAGIC)); blocklen = mc_read (file, buf, sizeof (VERTICAL_MAGIC));
if (blocklen > 0) if (blocklen > 0)
{ {
/* if contain signature VERTICAL_MAGIC tnen it vertical block */ /* if contain signature VERTICAL_MAGIC then it vertical block */
if (memcmp (buf, VERTICAL_MAGIC, sizeof (VERTICAL_MAGIC)) == 0) if (memcmp (buf, VERTICAL_MAGIC, sizeof (VERTICAL_MAGIC)) == 0)
vertical_insertion = 1; vertical_insertion = 1;
else else
mc_lseek (file, 0, SEEK_SET); mc_lseek (file, 0, SEEK_SET);
} }
if (vertical_insertion) if (vertical_insertion)
{
blocklen = edit_insert_column_of_text_from_file (edit, file); blocklen = edit_insert_column_of_text_from_file (edit, file);
}
else else
{
while ((blocklen = mc_read (file, (char *) buf, TEMP_BUF_LEN)) > 0) while ((blocklen = mc_read (file, (char *) buf, TEMP_BUF_LEN)) > 0)
{
for (i = 0; i < blocklen; i++) for (i = 0; i < blocklen; i++)
edit_insert (edit, buf[i]); edit_insert (edit, buf[i]);
}
}
ins_len = edit->curs1 - current;
edit_cursor_move (edit, current - edit->curs1); edit_cursor_move (edit, current - edit->curs1);
g_free (buf); g_free (buf);
mc_close (file); mc_close (file);
if (blocklen != 0) if (blocklen != 0)
return 0; return 0;
} }
return 1; return ins_len;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -2617,7 +2617,7 @@ edit_insert_file_cmd (WEdit * edit)
} }
else else
{ {
if (edit_insert_file (edit, exp)) if (edit_insert_file (edit, exp) != 0)
{ {
g_free (exp); g_free (exp);
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;