Add events for panels in filemanager.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2014-04-23 03:05:24 +03:00
parent 785144d625
commit ad0999f2f1
9 changed files with 1888 additions and 1308 deletions

View File

@ -494,7 +494,7 @@ copy_region (WInput * in, int x_first, int x_last)
if (last == first) if (last == first)
{ {
/* Copy selected files to clipboard */ /* Copy selected files to clipboard */
mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "panel_save_current_file_to_clip_file", NULL, mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "save_current_file_to_clip_file", NULL,
NULL, NULL); NULL, NULL);
/* try use external clipboard utility */ /* try use external clipboard utility */
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL, NULL, NULL); mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL, NULL, NULL);

View File

@ -117,17 +117,17 @@ clipboard_file_from_ext_clip (event_info_t * event_info, gpointer data, GError *
while (TRUE) while (TRUE)
{ {
GError *error = NULL; GError *mcerror = NULL;
p->out.len = MC_PIPE_BUFSIZE; p->out.len = MC_PIPE_BUFSIZE;
p->err.len = MC_PIPE_BUFSIZE; p->err.len = MC_PIPE_BUFSIZE;
mc_pread (p, &error); mc_pread (p, &mcerror);
if (error != NULL) if (mcerror != NULL)
{ {
/* don't show error message */ /* don't show error message */
g_error_free (error); g_error_free (mcerror);
break; break;
} }
@ -168,7 +168,7 @@ clipboard_file_from_ext_clip (event_info_t * event_info, gpointer data, GError *
/* event callback */ /* event callback */
gboolean gboolean
clipboard_text_to_file (event_info_t * event_info, gpointer data, GError ** error) clipboard_text_to_file (event_info_t * event_info, gpointer data, GError ** mcerror)
{ {
int file; int file;
vfs_path_t *fname_vpath = NULL; vfs_path_t *fname_vpath = NULL;
@ -176,7 +176,7 @@ clipboard_text_to_file (event_info_t * event_info, gpointer data, GError ** erro
const char *text = (const char *) data; const char *text = (const char *) data;
(void) event_info; (void) event_info;
(void) error; (void) mcerror;
if (text == NULL) if (text == NULL)
return FALSE; return FALSE;
@ -203,7 +203,7 @@ clipboard_text_to_file (event_info_t * event_info, gpointer data, GError ** erro
/* event callback */ /* event callback */
gboolean gboolean
clipboard_text_from_file (event_info_t * event_info, gpointer data, GError ** error) clipboard_text_from_file (event_info_t * event_info, gpointer data, GError ** mcerror)
{ {
char buf[BUF_LARGE]; char buf[BUF_LARGE];
FILE *f; FILE *f;
@ -211,7 +211,7 @@ clipboard_text_from_file (event_info_t * event_info, gpointer data, GError ** er
char **text = (char **) data; char **text = (char **) data;
gboolean first = TRUE; gboolean first = TRUE;
(void) error; (void) mcerror;
fname = mc_config_get_full_path (EDIT_CLIP_FILE); fname = mc_config_get_full_path (EDIT_CLIP_FILE);
f = fopen (fname, "r"); f = fopen (fname, "r");

View File

@ -80,6 +80,7 @@
#include "src/diffviewer/ydiff.h" #include "src/diffviewer/ydiff.h"
#endif #endif
#include "event.h"
#include "fileopctx.h" #include "fileopctx.h"
#include "file.h" /* file operation routines */ #include "file.h" /* file operation routines */
#include "find.h" /* find_file() */ #include "find.h" /* find_file() */
@ -125,15 +126,20 @@ static const char *machine_str = N_("Enter machine name (F1 for details):");
* Run viewer (internal or external) on the currently selected file. * Run viewer (internal or external) on the currently selected file.
* If normal is TRUE, force internal viewer and raw mode (used for F13). * If normal is TRUE, force internal viewer and raw mode (used for F13).
*/ */
static void static void
do_view_cmd (gboolean normal) do_view_cmd (WPanel * panel, gboolean normal)
{ {
file_entry_t *fe;
fe = selection (panel);
/* Directories are viewed by changing to them */ /* Directories are viewed by changing to them */
if (S_ISDIR (selection (current_panel)->st.st_mode) || link_isdir (selection (current_panel))) if (S_ISDIR (fe->st.st_mode) || link_isdir (fe))
{ {
vfs_path_t *fname_vpath; vfs_path_t *fname_vpath;
if (confirm_view_dir && (current_panel->marked || current_panel->dirs_marked)) if (confirm_view_dir && (panel->marked || panel->dirs_marked))
{ {
if (query_dialog if (query_dialog
(_("Confirmation"), _("Files tagged, want to cd?"), D_NORMAL, 2, (_("Confirmation"), _("Files tagged, want to cd?"), D_NORMAL, 2,
@ -142,7 +148,7 @@ do_view_cmd (gboolean normal)
return; return;
} }
} }
fname_vpath = vfs_path_from_str (selection (current_panel)->fname); fname_vpath = vfs_path_from_str (fe->fname);
if (!do_cd (fname_vpath, cd_exact)) if (!do_cd (fname_vpath, cd_exact))
message (D_ERROR, MSG_ERROR, _("Cannot change directory")); message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
vfs_path_free (fname_vpath); vfs_path_free (fname_vpath);
@ -152,8 +158,8 @@ do_view_cmd (gboolean normal)
int file_idx; int file_idx;
vfs_path_t *filename_vpath; vfs_path_t *filename_vpath;
file_idx = current_panel->selected; file_idx = panel->selected;
filename_vpath = vfs_path_from_str (current_panel->dir.list[file_idx].fname); filename_vpath = vfs_path_from_str (panel->dir.list[file_idx].fname);
view_file (filename_vpath, normal, use_internal_view != 0); view_file (filename_vpath, normal, use_internal_view != 0);
vfs_path_free (filename_vpath); vfs_path_free (filename_vpath);
} }
@ -626,12 +632,20 @@ view_file (const vfs_path_t * filename_vpath, gboolean plain_view, gboolean inte
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* event callback */
/** Run user's preferred viewer on the currently selected file */ /** Run user's preferred viewer on the currently selected file */
void gboolean
view_cmd (void) mc_panel_cmd_file_view (event_info_t * event_info, gpointer data, GError ** error)
{ {
do_view_cmd (FALSE); WPanel *panel = (WPanel *) data;
(void) error;
(void) event_info;
do_view_cmd (panel, FALSE);
return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -657,11 +671,20 @@ view_file_cmd (void)
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* event callback */
/** Run plain internal viewer on the currently selected file */ /** Run plain internal viewer on the currently selected file */
void
view_raw_cmd (void) gboolean
mc_panel_cmd_file_view_raw (event_info_t * event_info, gpointer data, GError ** error)
{ {
do_view_cmd (TRUE); WPanel *panel = (WPanel *) data;
(void) error;
(void) event_info;
do_view_cmd (panel, TRUE);
return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -757,12 +780,17 @@ edit_cmd_force_internal (void)
#endif #endif
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* event callback */
void gboolean
edit_cmd_new (void) mc_panel_cmd_edit_new (event_info_t * event_info, gpointer data, GError ** error)
{ {
vfs_path_t *fname_vpath = NULL; vfs_path_t *fname_vpath = NULL;
(void) error;
(void) data;
(void) event_info;
if (editor_ask_filename_before_edit) if (editor_ask_filename_before_edit)
{ {
char *fname; char *fname;
@ -770,7 +798,7 @@ edit_cmd_new (void)
fname = input_expand_dialog (_("Edit file"), _("Enter file name:"), fname = input_expand_dialog (_("Edit file"), _("Enter file name:"),
MC_HISTORY_EDIT_LOAD, "", INPUT_COMPLETE_FILENAMES); MC_HISTORY_EDIT_LOAD, "", INPUT_COMPLETE_FILENAMES);
if (fname == NULL) if (fname == NULL)
return; return TRUE;
if (*fname != '\0') if (*fname != '\0')
fname_vpath = vfs_path_from_str (fname); fname_vpath = vfs_path_from_str (fname);
@ -784,6 +812,8 @@ edit_cmd_new (void)
do_edit (fname_vpath); do_edit (fname_vpath);
vfs_path_free (fname_vpath); vfs_path_free (fname_vpath);
return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -815,31 +845,47 @@ rename_cmd (void)
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* event callback */
/** Invoked by F15. Copy, default to the same panel, ignore marks. */ /** Invoked by F15. Copy, default to the same panel, ignore marks. */
void gboolean
copy_cmd_local (void) mc_panel_cmd_copy_single (event_info_t * event_info, gpointer data, GError ** error)
{ {
WPanel *panel = (WPanel *) data;
(void) error;
(void) event_info;
save_cwds_stat (); save_cwds_stat ();
if (panel_operate (current_panel, OP_COPY, TRUE)) if (panel_operate (panel, OP_COPY, TRUE))
{ {
update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen (); repaint_screen ();
} }
return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* event callback */
/** Invoked by F16. Move/rename, default to the same panel. */ /** Invoked by F16. Move/rename, default to the same panel. */
void gboolean
rename_cmd_local (void) mc_panel_cmd_rename_single (event_info_t * event_info, gpointer data, GError ** error)
{ {
WPanel *panel = (WPanel *) data;
(void) error;
(void) event_info;
save_cwds_stat (); save_cwds_stat ();
if (panel_operate (current_panel, OP_MOVE, TRUE)) if (panel_operate (panel, OP_MOVE, TRUE))
{ {
update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen (); repaint_screen ();
} }
return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -908,18 +954,26 @@ delete_cmd (void)
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* event callback */
/** Invoked by F18. Remove selected file, regardless of marked files. */ /** Invoked by F18. Remove selected file, regardless of marked files. */
void gboolean
delete_cmd_local (void) mc_panel_cmd_delete_single (event_info_t * event_info, gpointer data, GError ** error)
{ {
WPanel *panel = (WPanel *) data;
(void) error;
(void) event_info;
save_cwds_stat (); save_cwds_stat ();
if (panel_operate (current_panel, OP_DELETE, TRUE)) if (panel_operate (panel, OP_DELETE, TRUE))
{ {
update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen (); repaint_screen ();
} }
return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -1132,6 +1186,8 @@ hotlist_cmd (void)
g_free (target); g_free (target);
} }
/* --------------------------------------------------------------------------------------------- */
#ifdef ENABLE_VFS #ifdef ENABLE_VFS
void void
vfs_list (void) vfs_list (void)
@ -1715,7 +1771,7 @@ void
encoding_cmd (void) encoding_cmd (void)
{ {
if (SELECTED_IS_PANEL) if (SELECTED_IS_PANEL)
panel_change_encoding (MENU_PANEL); mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "select_codepage", MENU_PANEL, NULL, NULL);
} }
#endif #endif

View File

@ -46,23 +46,17 @@ void dirsizes_cmd (void);
gboolean view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gboolean view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view,
gboolean internal, long start_line); gboolean internal, long start_line);
gboolean view_file (const vfs_path_t * filename_vpath, gboolean normal, gboolean internal); gboolean view_file (const vfs_path_t * filename_vpath, gboolean normal, gboolean internal);
void view_cmd (void);
void view_file_cmd (void); void view_file_cmd (void);
void view_raw_cmd (void);
void view_filtered_cmd (void); void view_filtered_cmd (void);
void edit_file_at_line (const vfs_path_t * what_vpath, gboolean internal, long start_line); void edit_file_at_line (const vfs_path_t * what_vpath, gboolean internal, long start_line);
void edit_cmd (void); void edit_cmd (void);
void edit_cmd_new (void);
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
void edit_cmd_force_internal (void); void edit_cmd_force_internal (void);
#endif #endif
void copy_cmd (void); void copy_cmd (void);
void copy_cmd_local (void);
void rename_cmd (void); void rename_cmd (void);
void rename_cmd_local (void);
void mkdir_cmd (void); void mkdir_cmd (void);
void delete_cmd (void); void delete_cmd (void);
void delete_cmd_local (void);
void find_cmd (void); void find_cmd (void);
void filter_cmd (void); void filter_cmd (void);
void reread_cmd (void); void reread_cmd (void);

View File

@ -75,10 +75,78 @@ mc_filemanager_init_events (GError ** error)
}; };
/* *INDENT-ON* */ /* *INDENT-ON* */
/* *INDENT-OFF* */
event_init_group_t filemanager_group_events[] =
{
{"update_panels", mc_panel_cmd_update_panels, NULL},
{"save_current_file_to_clip_file", mc_panel_cmd_save_current_file_to_clip_file, NULL},
{"chdir_other", mc_panel_cmd_chdir_other, NULL},
{"chdir_other_if_link", mc_panel_cmd_chdir_other_if_link, NULL},
{"copy_single", mc_panel_cmd_copy_single, NULL},
{"delete_single", mc_panel_cmd_delete_single, NULL},
{"enter", mc_panel_cmd_enter, NULL},
{"view_raw", mc_panel_cmd_file_view_raw, NULL},
{"view", mc_panel_cmd_file_view, NULL},
{"edit_new", mc_panel_cmd_edit_new, NULL},
{"rename_single", mc_panel_cmd_rename_single, NULL},
{"goto_page_down", mc_panel_cmd_goto_page_down, NULL},
{"goto_page_up", mc_panel_cmd_goto_page_up, NULL},
{"ch_sub_dir", mc_panel_cmd_ch_sub_dir, NULL},
{"ch_parent_dir", mc_panel_cmd_ch_parent_dir, NULL},
{"directory_history_list", mc_panel_cmd_directory_history_list, NULL},
{"directory_history_next", mc_panel_cmd_directory_history_next, NULL},
{"directory_history_prev", mc_panel_cmd_directory_history_prev, NULL},
{"goto_bottom_screen", mc_panel_cmd_goto_bottom_screen, NULL},
{"goto_middle_screen", mc_panel_cmd_goto_middle_screen, NULL},
{"goto_top_screen", mc_panel_cmd_goto_top_screen, NULL},
{"mark", mc_panel_cmd_mark, NULL},
{"mark_up", mc_panel_cmd_mark_up, NULL},
{"mark_down", mc_panel_cmd_mark_down, NULL},
{"mark_left", mc_panel_cmd_mark_left, NULL},
{"mark_right", mc_panel_cmd_mark_right, NULL},
{"cd_parent_smart", mc_panel_cmd_cd_parent_smart, NULL},
{"goto_up", mc_panel_cmd_goto_up, NULL},
{"goto_down", mc_panel_cmd_goto_down, NULL},
{"goto_left", mc_panel_cmd_goto_left, NULL},
{"goto_right", mc_panel_cmd_goto_right, NULL},
{"goto_home", mc_panel_cmd_goto_home, NULL},
{"goto_end", mc_panel_cmd_goto_end, NULL},
{"content_scroll_left", mc_panel_cmd_content_scroll_left, NULL},
{"content_scroll_right", mc_panel_cmd_content_scroll_right, NULL},
{"search", mc_panel_cmd_search, NULL},
{"search_stop", mc_panel_cmd_search_stop, NULL},
{"sync_other", mc_panel_cmd_sync_other, NULL},
{"sort_order_select", mc_panel_cmd_sort_order_select, NULL},
{"sort_order_prev", mc_panel_cmd_sort_order_prev, NULL},
{"sort_order_next", mc_panel_cmd_sort_order_next, NULL},
{"sort_order_reverse", mc_panel_cmd_sort_order_next, NULL},
{"sort_by_name", mc_panel_cmd_sort_order_next, NULL},
{"sort_by_extension", mc_panel_cmd_sort_order_next, NULL},
{"sort_by_size", mc_panel_cmd_sort_order_next, NULL},
{"sort_by_mtime", mc_panel_cmd_sort_order_next, NULL},
{"select_files", mc_panel_cmd_select_files, NULL},
{"unselect_files", mc_panel_cmd_unselect_files, NULL},
{"select_invert_files", mc_panel_cmd_select_invert_files, NULL},
{"select_files_by_extension", mc_panel_cmd_select_files_by_extension, NULL},
#ifdef HAVE_CHARSET
{"select_codepage", mc_panel_cmd_select_codepage, NULL},
#endif /* HAVE_CHARSET */
{NULL, NULL, NULL}
};
/* *INDENT-ON* */
/* *INDENT-OFF* */ /* *INDENT-OFF* */
event_init_t standard_events[] = event_init_t standard_events[] =
{ {
{MCEVENT_GROUP_TREEVIEW, treeview_group_events}, {MCEVENT_GROUP_TREEVIEW, treeview_group_events},
{MCEVENT_GROUP_FILEMANAGER, filemanager_group_events},
{NULL, NULL} {NULL, NULL}
}; };
/* *INDENT-ON* */ /* *INDENT-ON* */

View File

@ -36,6 +36,74 @@ gboolean mc_tree_cmd_rmdir (event_info_t * event_info, gpointer data, GError **
gboolean mc_tree_cmd_chdir (event_info_t * event_info, gpointer data, GError ** error); gboolean mc_tree_cmd_chdir (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_tree_cmd_show_box (event_info_t * event_info, gpointer data, GError ** error); gboolean mc_tree_cmd_show_box (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_update_panels (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_save_current_file_to_clip_file (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_chdir_other (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_chdir_other_if_link (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_copy_single (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_delete_single (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_enter (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_file_view_raw (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_file_view (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_edit_new (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_rename_single (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_page_down (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_page_up (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_ch_sub_dir (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_ch_parent_dir (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_directory_history_list (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_directory_history_next (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_directory_history_prev (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_goto_bottom_screen (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_goto_middle_screen (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_goto_top_screen (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_mark (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_mark_up (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_mark_down (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_mark_left (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_mark_right (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_cd_parent_smart (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_up (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_down (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_left (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_right (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_home (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_goto_end (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_content_scroll_left (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_content_scroll_right (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_search (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_search_stop (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sync_other (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sort_order_select (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sort_order_prev (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sort_order_next (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sort_order_reverse (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_sort_by_name (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sort_by_extension (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sort_by_size (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_sort_by_mtime (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_select_files (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_unselect_files (event_info_t * event_info, gpointer data, GError ** error);
gboolean mc_panel_cmd_select_invert_files (event_info_t * event_info, gpointer data,
GError ** error);
gboolean mc_panel_cmd_select_files_by_extension (event_info_t * event_info, gpointer data,
GError ** error);
#ifdef HAVE_CHARSET
gboolean mc_panel_cmd_select_codepage (event_info_t * event_info, gpointer data, GError ** error);
#endif /* HAVE_CHARSET */
/*** inline functions ****************************************************************************/ /*** inline functions ****************************************************************************/

View File

@ -1108,6 +1108,9 @@ static cb_ret_t
midnight_execute_cmd (Widget * sender, unsigned long command) midnight_execute_cmd (Widget * sender, unsigned long command)
{ {
cb_ret_t res = MSG_HANDLED; cb_ret_t res = MSG_HANDLED;
const char *event_group_name = MCEVENT_GROUP_FILEMANAGER;
const char *event_name = NULL;
event_return_t ret;
(void) sender; (void) sender;
@ -1385,7 +1388,7 @@ midnight_execute_cmd (Widget * sender, unsigned long command)
user_file_menu_cmd (); user_file_menu_cmd ();
break; break;
case CK_View: case CK_View:
view_cmd (); event_name = "view";
break; break;
case CK_ViewFile: case CK_ViewFile:
view_file_cmd (); view_file_cmd ();
@ -1397,11 +1400,118 @@ midnight_execute_cmd (Widget * sender, unsigned long command)
res = MSG_NOT_HANDLED; res = MSG_NOT_HANDLED;
} }
if (mc_event_raise (event_group_name, event_name, current_panel, &ret, NULL))
{
return (ret.b) ? MSG_HANDLED : MSG_NOT_HANDLED;
}
return res; return res;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static cb_ret_t
midnight_handle_raw_keys (int parm)
{
unsigned long command;
if (ctl_x_map_enabled)
{
ctl_x_map_enabled = FALSE;
command = keybind_lookup_keymap_command (main_x_map, parm);
if (command != CK_IgnoreKey)
return midnight_execute_cmd (NULL, command);
}
/* FIXME: should handle all menu shortcuts before this point */
if (the_menubar->is_active)
return MSG_NOT_HANDLED;
if (parm == '\t')
input_free_completions (cmdline);
if (parm == '\n')
{
size_t i;
/* HACK: don't execute command in the command line if Enter was pressed
in the quick viewer panel. */
/* TODO: currently, when one of panels is other than view_listing,
current_panel points to view_listing panel all time independently of
it's activity. Thus, we can't use get_current_type() here.
current_panel should point to actualy current active panel
independently of it's type. */
if (current_panel->active == 0 && get_other_type () == view_quick)
return MSG_NOT_HANDLED;
for (i = 0; cmdline->buffer[i] != '\0' &&
(cmdline->buffer[i] == ' ' || cmdline->buffer[i] == '\t'); i++)
;
if (cmdline->buffer[i] != '\0')
{
send_message (cmdline, NULL, MSG_KEY, parm, NULL);
return MSG_HANDLED;
}
input_insert (cmdline, "", FALSE);
cmdline->point = 0;
}
/* Ctrl-Enter and Alt-Enter */
if (((parm & ~(KEY_M_CTRL | KEY_M_ALT)) == '\n') && (parm & (KEY_M_CTRL | KEY_M_ALT)))
{
put_prog_name ();
return MSG_HANDLED;
}
/* Ctrl-Shift-Enter */
if (parm == (KEY_M_CTRL | KEY_M_SHIFT | '\n'))
{
midnight_put_panel_path (current_panel);
put_prog_name ();
return MSG_HANDLED;
}
if ((!mc_global.tty.alternate_plus_minus
|| !(mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)) && !quote
&& !current_panel->searching)
{
if (!only_leading_plus_minus)
{
/* Special treatement, since the input line will eat them */
if (parm == '+')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Select, NULL);
if (parm == '\\' || parm == '-')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Unselect, NULL);
if (parm == '*')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_SelectInvert,
NULL);
}
else if (!command_prompt || !cmdline->buffer[0])
{
/* Special treatement '+', '-', '\', '*' only when this is
* first char on input line
*/
if (parm == '+')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Select, NULL);
if (parm == '\\' || parm == '-')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Unselect, NULL);
if (parm == '*')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_SelectInvert,
NULL);
}
}
return MSG_NOT_HANDLED;
}
/* --------------------------------------------------------------------------------------------- */
static cb_ret_t static cb_ret_t
midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{ {
@ -1445,100 +1555,7 @@ midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
return MSG_HANDLED; return MSG_HANDLED;
case MSG_KEY: case MSG_KEY:
if (ctl_x_map_enabled) return midnight_handle_raw_keys (parm);
{
ctl_x_map_enabled = FALSE;
command = keybind_lookup_keymap_command (main_x_map, parm);
if (command != CK_IgnoreKey)
return midnight_execute_cmd (NULL, command);
}
/* FIXME: should handle all menu shortcuts before this point */
if (the_menubar->is_active)
return MSG_NOT_HANDLED;
if (parm == '\t')
input_free_completions (cmdline);
if (parm == '\n')
{
size_t i;
/* HACK: don't execute command in the command line if Enter was pressed
in the quick viewer panel. */
/* TODO: currently, when one of panels is other than view_listing,
current_panel points to view_listing panel all time independently of
it's activity. Thus, we can't use get_current_type() here.
current_panel should point to actualy current active panel
independently of it's type. */
if (current_panel->active == 0 && get_other_type () == view_quick)
return MSG_NOT_HANDLED;
for (i = 0; cmdline->buffer[i] != '\0' &&
(cmdline->buffer[i] == ' ' || cmdline->buffer[i] == '\t'); i++)
;
if (cmdline->buffer[i] != '\0')
{
send_message (cmdline, NULL, MSG_KEY, parm, NULL);
return MSG_HANDLED;
}
input_insert (cmdline, "", FALSE);
cmdline->point = 0;
}
/* Ctrl-Enter and Alt-Enter */
if (((parm & ~(KEY_M_CTRL | KEY_M_ALT)) == '\n') && (parm & (KEY_M_CTRL | KEY_M_ALT)))
{
put_prog_name ();
return MSG_HANDLED;
}
/* Ctrl-Shift-Enter */
if (parm == (KEY_M_CTRL | KEY_M_SHIFT | '\n'))
{
midnight_put_panel_path (current_panel);
put_prog_name ();
return MSG_HANDLED;
}
if ((!mc_global.tty.alternate_plus_minus
|| !(mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)) && !quote
&& !current_panel->searching)
{
if (!only_leading_plus_minus)
{
/* Special treatement, since the input line will eat them */
if (parm == '+')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Select, NULL);
if (parm == '\\' || parm == '-')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Unselect,
NULL);
if (parm == '*')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_SelectInvert,
NULL);
}
else if (!command_prompt || cmdline->buffer[0] == '\0')
{
/* Special treatement '+', '-', '\', '*' only when this is
* first char on input line
*/
if (parm == '+')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Select, NULL);
if (parm == '\\' || parm == '-')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_Unselect,
NULL);
if (parm == '*')
return send_message (current_panel, midnight_dlg, MSG_ACTION, CK_SelectInvert,
NULL);
}
}
return MSG_NOT_HANDLED;
case MSG_HOTKEY_HANDLED: case MSG_HOTKEY_HANDLED:
if ((get_current_type () == view_listing) && current_panel->searching) if ((get_current_type () == view_listing) && current_panel->searching)

File diff suppressed because it is too large Load Diff

View File

@ -161,7 +161,6 @@ void panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order);
void panel_re_sort (WPanel * panel); void panel_re_sort (WPanel * panel);
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
void panel_change_encoding (WPanel * panel);
vfs_path_t *remove_encoding_from_path (const vfs_path_t * vpath); vfs_path_t *remove_encoding_from_path (const vfs_path_t * vpath);
#endif #endif