diff --git a/src/editor/edit.c b/src/editor/edit.c index fb4e173f7..8513a9261 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -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; } diff --git a/src/keybind-defaults.c b/src/keybind-defaults.c index be7b02d09..8de77f621 100644 --- a/src/keybind-defaults.c +++ b/src/keybind-defaults.c @@ -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"}, diff --git a/src/keybind-defaults.h b/src/keybind-defaults.h index 45a5a17de..9914e3cf1 100644 --- a/src/keybind-defaults.h +++ b/src/keybind-defaults.h @@ -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 */ diff --git a/src/setup.c b/src/setup.c index 7cb9250ca..4c9b7fb40 100644 --- a/src/setup.c +++ b/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) diff --git a/src/viewer/actions_cmd.c b/src/viewer/actions_cmd.c index 00e8cdbc6..4f8925006 100644 --- a/src/viewer/actions_cmd.c +++ b/src/viewer/actions_cmd.c @@ -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; diff --git a/src/viewer/display.c b/src/viewer/display.c index a1491fbb5..7e68b9aea 100644 --- a/src/viewer/display.c +++ b/src/viewer/display.c @@ -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); diff --git a/src/viewer/internal.h b/src/viewer/internal.h index a30909769..8c078583f 100644 --- a/src/viewer/internal.h +++ b/src/viewer/internal.h @@ -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; diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c index 58dd88237..aed360a02 100644 --- a/src/viewer/mcviewer.c +++ b/src/viewer/mcviewer.c @@ -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;