mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 17:29:28 +03:00
Merge branch '2463_dont_reset_selection_after_f11'
* 2463_dont_reset_selection_after_f11: do not set modify flag when user menu cancelled. Ticket #2463 (do not reset selection after execute user menu)
This commit is contained in:
commit
78b2f10ff1
@ -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);
|
||||||
|
@ -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;
|
||||||
@ -1685,22 +1685,23 @@ user_menu (WEdit * edit)
|
|||||||
edit_save_block (edit, block_file, start_mark, end_mark);
|
edit_save_block (edit, block_file, start_mark, end_mark);
|
||||||
|
|
||||||
/* run shell scripts from menu */
|
/* run shell scripts from menu */
|
||||||
user_menu_cmd (edit);
|
if (user_menu_cmd (edit) && (mc_stat (block_file, &status) == 0) && (status.st_size != 0))
|
||||||
|
|
||||||
if ((mc_stat (block_file, &status) == 0) && (status.st_size != 0))
|
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
|
|
||||||
|
/* i.e. we have marked block */
|
||||||
if (nomark == 0)
|
if (nomark == 0)
|
||||||
{
|
|
||||||
/* i.e. we have marked block */
|
|
||||||
rc = edit_block_delete_cmd (edit);
|
rc = edit_block_delete_cmd (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 +2013,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 +2029,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 +2065,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -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;
|
||||||
|
@ -1340,7 +1340,7 @@ help_cmd (void)
|
|||||||
void
|
void
|
||||||
user_file_menu_cmd (void)
|
user_file_menu_cmd (void)
|
||||||
{
|
{
|
||||||
user_menu_cmd (NULL);
|
(void) user_menu_cmd (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -850,7 +850,7 @@ expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
|
|||||||
* otherwise we are called from the mcedit menu.
|
* otherwise we are called from the mcedit menu.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
user_menu_cmd (struct WEdit *edit_widget)
|
user_menu_cmd (struct WEdit *edit_widget)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
@ -859,11 +859,12 @@ user_menu_cmd (struct WEdit *edit_widget)
|
|||||||
int col, i, accept_entry = 1;
|
int col, i, accept_entry = 1;
|
||||||
int selected, old_patterns;
|
int selected, old_patterns;
|
||||||
Listbox *listbox;
|
Listbox *listbox;
|
||||||
|
gboolean res = FALSE;
|
||||||
|
|
||||||
if (!vfs_current_is_local ())
|
if (!vfs_current_is_local ())
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR, "%s", _("Cannot execute commands on non-local filesystems"));
|
message (D_ERROR, MSG_ERROR, "%s", _("Cannot execute commands on non-local filesystems"));
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu = g_strdup (edit_widget ? EDIT_LOCAL_MENU : MC_LOCAL_MENU);
|
menu = g_strdup (edit_widget ? EDIT_LOCAL_MENU : MC_LOCAL_MENU);
|
||||||
@ -894,7 +895,7 @@ user_menu_cmd (struct WEdit *edit_widget)
|
|||||||
message (D_ERROR, MSG_ERROR, _("Cannot open file%s\n%s"), menu, unix_error_string (errno));
|
message (D_ERROR, MSG_ERROR, _("Cannot open file%s\n%s"), menu, unix_error_string (errno));
|
||||||
g_free (menu);
|
g_free (menu);
|
||||||
menu = NULL;
|
menu = NULL;
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_cols = 0;
|
max_cols = 0;
|
||||||
@ -990,7 +991,10 @@ user_menu_cmd (struct WEdit *edit_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (menu_lines == 0)
|
if (menu_lines == 0)
|
||||||
|
{
|
||||||
message (D_ERROR, MSG_ERROR, _("No suitable entries found in %s"), menu);
|
message (D_ERROR, MSG_ERROR, _("No suitable entries found in %s"), menu);
|
||||||
|
res = FALSE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
max_cols = min (max (max_cols, col), MAX_ENTRY_LEN);
|
max_cols = min (max (max_cols, col), MAX_ENTRY_LEN);
|
||||||
@ -1010,7 +1014,10 @@ user_menu_cmd (struct WEdit *edit_widget)
|
|||||||
|
|
||||||
selected = run_listbox (listbox);
|
selected = run_listbox (listbox);
|
||||||
if (selected >= 0)
|
if (selected >= 0)
|
||||||
|
{
|
||||||
execute_menu_command (edit_widget, entries[selected]);
|
execute_menu_command (edit_widget, entries[selected]);
|
||||||
|
res = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
do_refresh ();
|
do_refresh ();
|
||||||
}
|
}
|
||||||
@ -1020,6 +1027,7 @@ user_menu_cmd (struct WEdit *edit_widget)
|
|||||||
menu = NULL;
|
menu = NULL;
|
||||||
g_free (entries);
|
g_free (entries);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -19,7 +19,7 @@ struct WEdit;
|
|||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** declarations of public functions ************************************************************/
|
||||||
|
|
||||||
void user_menu_cmd (struct WEdit *edit_widget);
|
gboolean user_menu_cmd (struct WEdit *edit_widget);
|
||||||
char *expand_format (struct WEdit *edit_widget, char c, gboolean do_quote);
|
char *expand_format (struct WEdit *edit_widget, char c, gboolean do_quote);
|
||||||
int check_format_view (const char *);
|
int check_format_view (const char *);
|
||||||
int check_format_var (const char *, char **);
|
int check_format_var (const char *, char **);
|
||||||
|
Loading…
Reference in New Issue
Block a user