mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Prepare to merge default and user-defined keymaps.
default_main_map and default_main_x_map renamed to default_main_keymap and default_main_x_keymap respectively to unified variable names. Editor: setup keymaps only once for all editors. Viewer: share single keymap array for all viewers. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
4fbdbd4456
commit
35b429f625
@ -558,19 +558,6 @@ edit_purge_widget (WEdit * edit)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
edit_set_keymap (void)
|
||||
{
|
||||
editor_map = default_editor_keymap;
|
||||
if (editor_keymap && editor_keymap->len > 0)
|
||||
editor_map = (global_keymap_t *) editor_keymap->data;
|
||||
|
||||
editor_x_map = default_editor_x_keymap;
|
||||
if (editor_x_keymap && editor_x_keymap->len > 0)
|
||||
editor_x_map = (global_keymap_t *) editor_x_keymap->data;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*
|
||||
TODO: if the user undos until the stack bottom, and the stack has not wrapped,
|
||||
then the file should be as it was when he loaded up. Then set edit->modified to 0.
|
||||
@ -2206,7 +2193,6 @@ edit_init (WEdit * edit, int lines, int columns, const char *filename, long line
|
||||
edit_move_to_line (edit, line - 1);
|
||||
}
|
||||
|
||||
edit_set_keymap ();
|
||||
edit_load_macro_cmd (edit);
|
||||
return edit;
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ const global_keymap_t *help_map;
|
||||
const global_keymap_t *editor_map;
|
||||
const global_keymap_t *editor_x_map;
|
||||
#endif
|
||||
const global_keymap_t *viewer_map;
|
||||
const global_keymap_t *viewer_hex_map;
|
||||
#ifdef USE_DIFF_VIEW
|
||||
const global_keymap_t *diff_map;
|
||||
#endif
|
||||
@ -68,7 +70,7 @@ const global_keymap_t *diff_map;
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/* midnight */
|
||||
const global_keymap_t default_main_map[] = {
|
||||
const global_keymap_t default_main_keymap[] = {
|
||||
{KEY_F (1), CK_Help, "F1"},
|
||||
{KEY_F (2), CK_UserMenu, "F2"},
|
||||
{KEY_F (3), CK_View, "F3"},
|
||||
@ -119,7 +121,7 @@ const global_keymap_t default_main_map[] = {
|
||||
{0, CK_IgnoreKey, ""}
|
||||
};
|
||||
|
||||
const global_keymap_t default_main_x_map[] = {
|
||||
const global_keymap_t default_main_x_keymap[] = {
|
||||
{'d', CK_CompareDirs, "d"},
|
||||
#ifdef USE_DIFF_VIEW
|
||||
{XCTRL ('d'), CK_CompareFiles, "C-d"},
|
||||
|
@ -43,14 +43,16 @@ extern const global_keymap_t *help_map;
|
||||
extern const global_keymap_t *editor_map;
|
||||
extern const global_keymap_t *editor_x_map;
|
||||
#endif
|
||||
extern const global_keymap_t *viewer_map;
|
||||
extern const global_keymap_t *viewer_hex_map;
|
||||
#ifdef USE_DIFF_VIEW
|
||||
extern const global_keymap_t *diff_map;
|
||||
#endif
|
||||
|
||||
|
||||
/* main.c */
|
||||
extern const global_keymap_t default_main_map[];
|
||||
extern const global_keymap_t default_main_x_map[];
|
||||
extern const global_keymap_t default_main_keymap[];
|
||||
extern const global_keymap_t default_main_x_keymap[];
|
||||
/* screen.c */
|
||||
extern const global_keymap_t default_panel_keymap[];
|
||||
/* dialog.c */
|
||||
|
22
src/setup.c
22
src/setup.c
@ -1210,11 +1210,11 @@ load_keymap_defs (gboolean load_from_file)
|
||||
mc_config_deinit (mc_global_keymap);
|
||||
}
|
||||
|
||||
main_map = default_main_map;
|
||||
main_map = default_main_keymap;
|
||||
if (main_keymap && main_keymap->len > 0)
|
||||
main_map = (global_keymap_t *) main_keymap->data;
|
||||
|
||||
main_x_map = default_main_x_map;
|
||||
main_x_map = default_main_x_keymap;
|
||||
if (main_x_keymap && main_x_keymap->len > 0)
|
||||
main_x_map = (global_keymap_t *) main_x_keymap->data;
|
||||
|
||||
@ -1242,6 +1242,24 @@ load_keymap_defs (gboolean load_from_file)
|
||||
if (help_keymap && help_keymap->len > 0)
|
||||
help_map = (global_keymap_t *) help_keymap->data;
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
editor_map = default_editor_keymap;
|
||||
if (editor_keymap && editor_keymap->len > 0)
|
||||
editor_map = (global_keymap_t *) editor_keymap->data;
|
||||
|
||||
editor_x_map = default_editor_x_keymap;
|
||||
if (editor_x_keymap && editor_x_keymap->len > 0)
|
||||
editor_x_map = (global_keymap_t *) editor_x_keymap->data;
|
||||
#endif
|
||||
|
||||
viewer_map = default_viewer_keymap;
|
||||
if (viewer_keymap && viewer_keymap->len > 0)
|
||||
viewer_map = (global_keymap_t *) viewer_keymap->data;
|
||||
|
||||
viewer_hex_map = default_viewer_hex_keymap;
|
||||
if (viewer_hex_keymap && viewer_hex_keymap->len > 0)
|
||||
viewer_hex_map = (global_keymap_t *) viewer_hex_keymap->data;
|
||||
|
||||
#ifdef USE_DIFF_VIEW
|
||||
diff_map = default_diff_keymap;
|
||||
if (diff_keymap && diff_keymap->len > 0)
|
||||
|
@ -399,12 +399,12 @@ mcview_handle_key (mcview_t * view, int key)
|
||||
if (view->hexedit_mode && (mcview_handle_editkey (view, key) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
|
||||
command = keybind_lookup_keymap_command (view->hex_map, key);
|
||||
command = keybind_lookup_keymap_command (viewer_hex_map, key);
|
||||
if ((command != CK_IgnoreKey) && (mcview_execute_cmd (view, command) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
command = keybind_lookup_keymap_command (view->plain_map, key);
|
||||
command = keybind_lookup_keymap_command (viewer_map, key);
|
||||
if ((command != CK_IgnoreKey) && (mcview_execute_cmd (view, command) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
#include "src/setup.h" /* panels_options */
|
||||
#include "src/main.h"
|
||||
#include "src/keybind-defaults.h"
|
||||
|
||||
#include "internal.h"
|
||||
#include "mcviewer.h"
|
||||
@ -81,7 +82,7 @@ mcview_set_buttonbar (mcview_t * view)
|
||||
{
|
||||
Dlg_head *h = view->widget.owner;
|
||||
WButtonBar *b = find_buttonbar (h);
|
||||
const global_keymap_t *keymap = view->hex_mode ? view->hex_map : view->plain_map;
|
||||
const global_keymap_t *keymap = view->hex_mode ? viewer_hex_map : viewer_map;
|
||||
|
||||
buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), keymap, (Widget *) view);
|
||||
|
||||
|
@ -175,10 +175,6 @@ typedef struct mcview_struct
|
||||
/* converter for translation of text */
|
||||
GIConv converter;
|
||||
|
||||
/* keymaps */
|
||||
const global_keymap_t *plain_map;
|
||||
const global_keymap_t *hex_map;
|
||||
|
||||
/* handle of search engine */
|
||||
mc_search_t *search;
|
||||
gchar *last_search_string;
|
||||
|
@ -186,19 +186,6 @@ mcview_real_event (Gpm_Event * event, void *x)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
mcview_set_keymap (mcview_t * view)
|
||||
{
|
||||
view->plain_map = default_viewer_keymap;
|
||||
if (viewer_keymap && viewer_keymap->len > 0)
|
||||
view->plain_map = (global_keymap_t *) viewer_keymap->data;
|
||||
|
||||
view->hex_map = default_viewer_hex_keymap;
|
||||
if (viewer_hex_keymap && viewer_hex_keymap->len > 0)
|
||||
view->hex_map = (global_keymap_t *) viewer_hex_keymap->data;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
@ -211,8 +198,6 @@ mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
|
||||
|
||||
init_widget (&view->widget, y, x, lines, cols, mcview_callback, mcview_real_event);
|
||||
|
||||
mcview_set_keymap (view);
|
||||
|
||||
view->hex_mode = FALSE;
|
||||
view->hexedit_mode = FALSE;
|
||||
view->locked = FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user