From 5ef63751203f6854ef08bb1fd170f02424fa6957 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 27 Feb 2011 17:03:31 +0300 Subject: [PATCH] Symbolic names of keymap sections are defined. Signed-off-by: Andrew Borodin --- lib/keybind.h | 15 +++++++++++++++ src/keybind-defaults.c | 26 +++++++++++++------------- src/setup.c | 26 +++++++++++++------------- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/lib/keybind.h b/lib/keybind.h index 3532d77d8..42fb04daf 100644 --- a/lib/keybind.h +++ b/lib/keybind.h @@ -8,6 +8,21 @@ /*** typedefs(not structures) and defined constants **********************************************/ +/* keymap sections */ +#define KEYMAP_SECTION_MAIN "main" +#define KEYMAP_SECTION_MAIN_EXT "main:xmap" +#define KEYMAP_SECTION_PANEL "panel" +#define KEYMAP_SECTION_DIALOG "dialog" +#define KEYMAP_SECTION_INPUT "input" +#define KEYMAP_SECTION_LISTBOX "listbox" +#define KEYMAP_SECTION_TREE "tree" +#define KEYMAP_SECTION_HELP "help" +#define KEYMAP_SECTION_EDITOR "editor" +#define KEYMAP_SECTION_EDITOR_EXT "editor:xmap" +#define KEYMAP_SECTION_VIEWER "viewer" +#define KEYMAP_SECTION_VIEWER_HEX "viewer:hex" +#define KEYMAP_SECTION_DIFFVIEWER "diffviewer" + #define KEYMAP_SHORTCUT_LENGTH 32 /* FIXME: is 32 bytes enough for shortcut? */ #define CK_PipeBlock(i) (10000+(i)) diff --git a/src/keybind-defaults.c b/src/keybind-defaults.c index d4ca0ee41..b46b87e46 100644 --- a/src/keybind-defaults.c +++ b/src/keybind-defaults.c @@ -565,22 +565,22 @@ create_default_keymap (void) keymap = mc_config_init (NULL); - create_default_keymap_section (keymap, "main", default_main_keymap); - create_default_keymap_section (keymap, "main:xmap", default_main_x_keymap); - create_default_keymap_section (keymap, "panel", default_panel_keymap); - create_default_keymap_section (keymap, "dialog", default_dialog_keymap); - create_default_keymap_section (keymap, "input", default_input_keymap); - create_default_keymap_section (keymap, "listbox", default_listbox_keymap); - create_default_keymap_section (keymap, "tree", default_tree_keymap); - create_default_keymap_section (keymap, "help", default_help_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_MAIN, default_main_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_MAIN_EXT, default_main_x_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_PANEL, default_panel_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_DIALOG, default_dialog_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_INPUT, default_input_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_LISTBOX, default_listbox_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_TREE, default_tree_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_HELP, default_help_keymap); #ifdef USE_INTERNAL_EDIT - create_default_keymap_section (keymap, "editor", default_editor_keymap); - create_default_keymap_section (keymap, "editor:xmap", default_editor_x_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_EDITOR, default_editor_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_EDITOR_EXT, default_editor_x_keymap); #endif - create_default_keymap_section (keymap, "viewer", default_viewer_keymap); - create_default_keymap_section (keymap, "viewer:hex", default_viewer_hex_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_VIEWER, default_viewer_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_VIEWER_HEX, default_viewer_hex_keymap); #ifdef USE_DIFF_VIEW - create_default_keymap_section (keymap, "diffviewer", default_diff_keymap); + create_default_keymap_section (keymap, KEYMAP_SECTION_DIFFVIEWER, default_diff_keymap); #endif return keymap; diff --git a/src/setup.c b/src/setup.c index 7bf39f4c5..31b504854 100644 --- a/src/setup.c +++ b/src/setup.c @@ -1171,43 +1171,43 @@ load_keymap_defs (gboolean load_from_file) if (mc_global_keymap != NULL) { main_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("main", main_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_MAIN, main_keymap, mc_global_keymap); main_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("main:xmap", main_x_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_MAIN_EXT, main_x_keymap, mc_global_keymap); panel_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("panel", panel_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_PANEL, panel_keymap, mc_global_keymap); dialog_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("dialog", dialog_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_DIALOG, dialog_keymap, mc_global_keymap); input_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("input", input_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_INPUT, input_keymap, mc_global_keymap); listbox_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("listbox", listbox_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_LISTBOX, listbox_keymap, mc_global_keymap); tree_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("tree", tree_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_TREE, tree_keymap, mc_global_keymap); help_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("help", help_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_HELP, help_keymap, mc_global_keymap); #ifdef USE_INTERNAL_EDIT editor_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("editor", editor_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_EDITOR, editor_keymap, mc_global_keymap); editor_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("editor:xmap", editor_x_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_EDITOR_EXT, editor_x_keymap, mc_global_keymap); #endif viewer_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("viewer", viewer_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_VIEWER, viewer_keymap, mc_global_keymap); viewer_hex_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("viewer:hex", viewer_hex_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_VIEWER_HEX, viewer_hex_keymap, mc_global_keymap); #ifdef USE_DIFF_VIEW diff_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); - load_keymap_from_section ("diffviewer", diff_keymap, mc_global_keymap); + load_keymap_from_section (KEYMAP_SECTION_DIFFVIEWER, diff_keymap, mc_global_keymap); #endif mc_config_deinit (mc_global_keymap);