Refactoring of keymap load/save.

src/keymap.[ch]: rename from src/keybind-defaults.[ch].

(keymap_load): rename from load_keymap_defs().
(keymap_free): rename from free_keymap_defs().

Move keymap load/save functions from src/setup.c to src/keymap.c.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-02-14 21:37:23 +03:00
parent 2ab7fd0390
commit 269ace6bf2
19 changed files with 346 additions and 353 deletions

View File

@ -82,7 +82,7 @@ libinternal_la_SOURCES = \
file_history.c file_history.h \
help.c help.h \
history.h \
keybind-defaults.c keybind-defaults.h \
keymap.c keymap.h \
learn.c learn.h \
setup.c setup.h \
textconf.c textconf.h \

View File

@ -55,7 +55,7 @@
#include "src/filemanager/layout.h" /* Needed for get_current_index and get_other_panel */
#include "src/execute.h" /* toggle_subshell() */
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "src/setup.h"
#include "src/history.h"
#ifdef HAVE_CHARSET

View File

@ -64,7 +64,7 @@
#include "src/usermenu.h" /* user_menu_cmd() */
#include "src/setup.h" /* option_tab_spacing */
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "edit-impl.h"
#include "editwidget.h"

View File

@ -67,7 +67,7 @@
#ifdef HAVE_CHARSET
#include "src/selcodepage.h"
#endif
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "src/util.h" /* check_for_default() */
#include "edit-impl.h"

View File

@ -49,7 +49,7 @@
#include "lib/widget.h"
#include "src/setup.h" /* drop_menus */
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "edit-impl.h"
#include "editwidget.h"

View File

@ -55,7 +55,7 @@
#include "lib/charsets.h"
#endif
#include "src/keybind-defaults.h" /* keybind_lookup_keymap_command() */
#include "src/keymap.h" /* keybind_lookup_keymap_command() */
#include "src/setup.h" /* home_dir */
#include "src/execute.h" /* toggle_subshell() */
#include "src/filemanager/cmd.h" /* save_setup_cmd() */

View File

@ -46,7 +46,7 @@
#include "lib/vfs/vfs.h"
#include "lib/widget.h"
#include "src/keybind-defaults.h" /* chattr_map */
#include "src/keymap.h" /* chattr_map */
#include "cmd.h" /* chattr_cmd(), chattr_get_as_str() */

View File

@ -61,7 +61,7 @@
#include "src/execute.h" /* toggle_subshell */
#include "src/setup.h" /* variables */
#include "src/learn.h" /* learn_keys() */
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "lib/fileloc.h" /* MC_FILEPOS_FILE */
#include "lib/keybind.h"
#include "lib/event.h"

View File

@ -60,7 +60,7 @@
#ifdef HAVE_CHARSET
#include "src/selcodepage.h" /* select_charset (), SELECT_CHARSET_NO_TRANSLATE */
#endif
#include "src/keybind-defaults.h" /* global_keymap_t */
#include "src/keymap.h" /* global_keymap_t */
#ifdef ENABLE_SUBSHELL
#include "src/subshell/subshell.h" /* do_subshell_chdir() */
#endif

View File

@ -56,7 +56,7 @@
#include "lib/event.h" /* mc_event_raise() */
#include "src/setup.h" /* confirm_delete, panels_options */
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "src/history.h"
#include "dir.h"

View File

@ -65,7 +65,7 @@
#include "lib/widget.h"
#include "lib/event-types.h"
#include "keybind-defaults.h"
#include "keymap.h"
#include "help.h"
/*** global variables ****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
Default values for keybinding engine
Default values and initialization of keybinding engine
Copyright (C) 2009-2021
Free Software Foundation, Inc.
@ -7,7 +7,7 @@
Written by:
Vitja Makarov, 2005
Ilia Maslakov <il.smind@gmail.com>, 2009, 2010
Andrew Borodin <aborodin@vmail.ru>, 2010, 2011
Andrew Borodin <aborodin@vmail.ru>, 2010-2021
This file is part of the Midnight Commander.
@ -28,9 +28,16 @@
#include <config.h>
#include "lib/global.h"
#include "lib/fileloc.h"
#include "lib/keybind.h"
#include "lib/mcconfig.h" /* mc_config_t */
#include "lib/util.h"
#include "lib/widget.h" /* dialog_map, input_map, listbox_map, menu_map, radio_map */
#include "keybind-defaults.h"
#include "args.h" /* mc_args__keymap_file */
#include "keymap.h"
/*** global variables ****************************************************************************/
@ -617,6 +624,7 @@ static const global_keymap_ini_t default_diff_keymap[] = {
/*** file scope variables ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -630,11 +638,9 @@ create_default_keymap_section (mc_config_t * keymap, const char *section,
mc_config_set_string_raw (keymap, section, k[i].key, k[i].value);
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
mc_config_t *
static mc_config_t *
create_default_keymap (void)
{
mc_config_t *keymap;
@ -667,3 +673,317 @@ create_default_keymap (void)
return keymap;
}
/* --------------------------------------------------------------------------------------------- */
static void
load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg)
{
gchar **profile_keys, **keys;
if (section_name == NULL)
return;
keys = mc_config_get_keys (cfg, section_name, NULL);
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
{
gchar **values;
values = mc_config_get_string_list (cfg, section_name, *profile_keys, NULL);
if (values != NULL)
{
long action;
action = keybind_lookup_action (*profile_keys);
if (action > 0)
{
gchar **curr_values;
for (curr_values = values; *curr_values != NULL; curr_values++)
keybind_cmd_bind (keymap, *curr_values, action);
}
g_strfreev (values);
}
}
g_strfreev (keys);
}
/* --------------------------------------------------------------------------------------------- */
/**
* Get name of config file.
*
* @param subdir If not NULL, config is also searched in specified subdir.
* @param config_file_name If relative, file if searched in standard paths.
*
* @return newly allocated string with config name or NULL if file is not found.
*/
static char *
load_setup_get_full_config_name (const char *subdir, const char *config_file_name)
{
/*
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
char *lc_basename, *ret;
char *file_name;
if (config_file_name == NULL)
return NULL;
/* check for .keymap suffix */
if (g_str_has_suffix (config_file_name, ".keymap"))
file_name = g_strdup (config_file_name);
else
file_name = g_strconcat (config_file_name, ".keymap", (char *) NULL);
canonicalize_pathname (file_name);
if (g_path_is_absolute (file_name))
return file_name;
lc_basename = g_path_get_basename (file_name);
g_free (file_name);
if (lc_basename == NULL)
return NULL;
if (subdir != NULL)
ret = g_build_filename (mc_config_get_path (), subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_config_get_path (), lc_basename, (char *) NULL);
if (exist_file (ret))
{
g_free (lc_basename);
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
if (subdir != NULL)
ret = g_build_filename (mc_global.share_data_dir, subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_global.share_data_dir, lc_basename, (char *) NULL);
g_free (lc_basename);
if (exist_file (ret))
{
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
return NULL;
}
/* --------------------------------------------------------------------------------------------- */
/**
Create new mc_config object from specified ini-file or
append data to existing mc_config object from ini-file
*/
static void
load_setup_init_config_from_file (mc_config_t ** config, const char *fname, gboolean read_only)
{
/*
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
if (exist_file (fname))
{
if (*config != NULL)
mc_config_read_file (*config, fname, read_only, TRUE);
else
*config = mc_config_init (fname, read_only);
}
}
/* --------------------------------------------------------------------------------------------- */
static mc_config_t *
load_setup_get_keymap_profile_config (gboolean load_from_file)
{
/*
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
mc_config_t *keymap_config;
char *share_keymap, *sysconfig_keymap;
char *fname, *fname2;
/* 0) Create default keymap */
keymap_config = create_default_keymap ();
if (!load_from_file)
return keymap_config;
/* load and merge global keymaps */
/* 1) /usr/share/mc (mc_global.share_data_dir) */
share_keymap = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, (char *) NULL);
load_setup_init_config_from_file (&keymap_config, share_keymap, TRUE);
/* 2) /etc/mc (mc_global.sysconfig_dir) */
sysconfig_keymap =
g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, (char *) NULL);
load_setup_init_config_from_file (&keymap_config, sysconfig_keymap, TRUE);
/* then load and merge one of user-defined keymap */
/* 3) --keymap=<keymap> */
fname = load_setup_get_full_config_name (NULL, mc_args__keymap_file);
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
g_free (fname);
/* 4) getenv("MC_KEYMAP") */
fname = load_setup_get_full_config_name (NULL, g_getenv ("MC_KEYMAP"));
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
MC_PTR_FREE (fname);
/* 5) main config; [Midnight Commander] -> keymap */
fname2 = mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION, "keymap", NULL);
if (fname2 != NULL && *fname2 != '\0')
fname = load_setup_get_full_config_name (NULL, fname2);
g_free (fname2);
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
g_free (fname);
/* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */
fname = mc_config_get_full_path (GLOBAL_KEYMAP_FILE);
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
done:
g_free (fname);
g_free (sysconfig_keymap);
g_free (share_keymap);
return keymap_config;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
keymap_load (gboolean load_from_file)
{
/*
* Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
* definitions override global settings.
*/
mc_config_t *mc_global_keymap;
mc_global_keymap = load_setup_get_keymap_profile_config (load_from_file);
if (mc_global_keymap != NULL)
{
#define LOAD_KEYMAP(s,km) \
km##_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); \
load_keymap_from_section (KEYMAP_SECTION_##s, km##_keymap, mc_global_keymap)
LOAD_KEYMAP (FILEMANAGER, filemanager);
LOAD_KEYMAP (FILEMANAGER_EXT, filemanager_x);
LOAD_KEYMAP (PANEL, panel);
LOAD_KEYMAP (DIALOG, dialog);
LOAD_KEYMAP (MENU, menu);
LOAD_KEYMAP (INPUT, input);
LOAD_KEYMAP (LISTBOX, listbox);
LOAD_KEYMAP (RADIO, radio);
LOAD_KEYMAP (TREE, tree);
LOAD_KEYMAP (HELP, help);
#ifdef ENABLE_EXT2FS_ATTR
LOAD_KEYMAP (CHATTR, chattr);
#endif
#ifdef USE_INTERNAL_EDIT
LOAD_KEYMAP (EDITOR, editor);
LOAD_KEYMAP (EDITOR_EXT, editor_x);
#endif
LOAD_KEYMAP (VIEWER, viewer);
LOAD_KEYMAP (VIEWER_HEX, viewer_hex);
#ifdef USE_DIFF_VIEW
LOAD_KEYMAP (DIFFVIEWER, diff);
#endif
#undef LOAD_KEYMAP
mc_config_deinit (mc_global_keymap);
}
#define SET_MAP(m) \
m##_map = (global_keymap_t *) m##_keymap->data
SET_MAP (filemanager);
SET_MAP (filemanager_x);
SET_MAP (panel);
SET_MAP (dialog);
SET_MAP (menu);
SET_MAP (input);
SET_MAP (listbox);
SET_MAP (radio);
SET_MAP (tree);
SET_MAP (help);
#ifdef ENABLE_EXT2FS_ATTR
SET_MAP (chattr);
#endif
#ifdef USE_INTERNAL_EDIT
SET_MAP (editor);
SET_MAP (editor_x);
#endif
SET_MAP (viewer);
SET_MAP (viewer_hex);
#ifdef USE_DIFF_VIEW
SET_MAP (diff);
#endif
#undef SET_MAP
}
/* --------------------------------------------------------------------------------------------- */
void
keymap_free (void)
{
#define FREE_KEYMAP(km) \
if (km##_keymap != NULL) \
g_array_free (km##_keymap, TRUE)
FREE_KEYMAP (filemanager);
FREE_KEYMAP (filemanager_x);
FREE_KEYMAP (panel);
FREE_KEYMAP (dialog);
FREE_KEYMAP (menu);
FREE_KEYMAP (input);
FREE_KEYMAP (listbox);
FREE_KEYMAP (radio);
FREE_KEYMAP (tree);
FREE_KEYMAP (help);
#ifdef ENABLE_EXT2FS_ATTR
FREE_KEYMAP (chattr);
#endif
#ifdef USE_INTERNAL_EDIT
FREE_KEYMAP (editor);
FREE_KEYMAP (editor_x);
#endif
FREE_KEYMAP (viewer);
FREE_KEYMAP (viewer_hex);
#ifdef USE_DIFF_VIEW
FREE_KEYMAP (diff);
#endif
#undef FREE_KEYMAP
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -56,7 +56,8 @@ extern const global_keymap_t *diff_map;
/*** declarations of public functions ************************************************************/
mc_config_t *create_default_keymap (void);
void keymap_load (gboolean load_from_file);
void keymap_free (void);
/*** inline functions ****************************************************************************/

View File

@ -70,6 +70,7 @@
#ifdef ENABLE_SUBSHELL
#include "subshell/subshell.h"
#endif
#include "keymap.h"
#include "setup.h" /* load_setup() */
#ifdef HAVE_CHARSET
@ -381,7 +382,7 @@ main (int argc, char *argv[])
/* Removing this from the X code let's us type C-c */
load_key_defs ();
load_keymap_defs (!mc_args__nokeymap);
keymap_load (!mc_args__nokeymap);
#ifdef USE_INTERNAL_EDIT
macros_list = g_array_new (TRUE, FALSE, sizeof (macros_t));
@ -460,7 +461,7 @@ main (int argc, char *argv[])
/* Save the tree store */
(void) tree_store_save ();
free_keymap_defs ();
keymap_free ();
/* Virtual File System shutdown */
vfs_shut ();

View File

@ -40,7 +40,6 @@
#include "lib/fileloc.h"
#include "lib/timefmt.h"
#include "lib/util.h"
#include "lib/widget.h"
#ifdef ENABLE_VFS_FTP
#include "src/vfs/ftpfs/ftpfs.h"
@ -64,7 +63,6 @@
#include "args.h"
#include "execute.h" /* pause_after_run */
#include "clipboard.h"
#include "keybind-defaults.h" /* keybind_lookup_action */
#ifdef HAVE_CHARSET
#include "selcodepage.h"
@ -440,90 +438,8 @@ static const struct
};
/* *INDENT-ON* */
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/**
* Get name of config file.
*
* @param subdir If not NULL, config is also searched in specified subdir.
* @param config_file_name If relative, file if searched in standard paths.
*
* @return newly allocated string with config name or NULL if file is not found.
*/
static char *
load_setup_get_full_config_name (const char *subdir, const char *config_file_name)
{
/*
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
char *lc_basename, *ret;
char *file_name;
if (config_file_name == NULL)
return NULL;
/* check for .keymap suffix */
if (g_str_has_suffix (config_file_name, ".keymap"))
file_name = g_strdup (config_file_name);
else
file_name = g_strconcat (config_file_name, ".keymap", (char *) NULL);
canonicalize_pathname (file_name);
if (g_path_is_absolute (file_name))
return file_name;
lc_basename = g_path_get_basename (file_name);
g_free (file_name);
if (lc_basename == NULL)
return NULL;
if (subdir != NULL)
ret = g_build_filename (mc_config_get_path (), subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_config_get_path (), lc_basename, (char *) NULL);
if (exist_file (ret))
{
g_free (lc_basename);
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
if (subdir != NULL)
ret = g_build_filename (mc_global.sysconfig_dir, subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_global.sysconfig_dir, lc_basename, (char *) NULL);
if (exist_file (ret))
{
g_free (lc_basename);
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
if (subdir != NULL)
ret = g_build_filename (mc_global.share_data_dir, subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_global.share_data_dir, lc_basename, (char *) NULL);
g_free (lc_basename);
if (exist_file (ret))
{
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
return NULL;
}
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static const char *
@ -587,27 +503,6 @@ setup__move_panels_config_into_separate_file (const char *profile)
mc_config_deinit (tmp_cfg);
}
/* --------------------------------------------------------------------------------------------- */
/**
Create new mc_config object from specified ini-file or
append data to existing mc_config object from ini-file
*/
static void
load_setup_init_config_from_file (mc_config_t ** config, const char *fname, gboolean read_only)
{
/*
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
if (exist_file (fname))
{
if (*config != NULL)
mc_config_read_file (*config, fname, read_only, TRUE);
else
*config = mc_config_init (fname, read_only);
}
}
/* --------------------------------------------------------------------------------------------- */
static void
@ -766,116 +661,6 @@ load_keys_from_section (const char *terminal, mc_config_t * cfg)
/* --------------------------------------------------------------------------------------------- */
static void
load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg)
{
gchar **profile_keys, **keys;
if (section_name == NULL)
return;
keys = mc_config_get_keys (cfg, section_name, NULL);
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
{
gchar **values;
values = mc_config_get_string_list (cfg, section_name, *profile_keys, NULL);
if (values != NULL)
{
long action;
action = keybind_lookup_action (*profile_keys);
if (action > 0)
{
gchar **curr_values;
for (curr_values = values; *curr_values != NULL; curr_values++)
keybind_cmd_bind (keymap, *curr_values, action);
}
g_strfreev (values);
}
}
g_strfreev (keys);
}
/* --------------------------------------------------------------------------------------------- */
static mc_config_t *
load_setup_get_keymap_profile_config (gboolean load_from_file)
{
/*
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
mc_config_t *keymap_config;
char *share_keymap, *sysconfig_keymap;
char *fname, *fname2;
/* 0) Create default keymap */
keymap_config = create_default_keymap ();
if (!load_from_file)
return keymap_config;
/* load and merge global keymaps */
/* 1) /usr/share/mc (mc_global.share_data_dir) */
share_keymap = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, (char *) NULL);
load_setup_init_config_from_file (&keymap_config, share_keymap, TRUE);
/* 2) /etc/mc (mc_global.sysconfig_dir) */
sysconfig_keymap =
g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, (char *) NULL);
load_setup_init_config_from_file (&keymap_config, sysconfig_keymap, TRUE);
/* then load and merge one of user-defined keymap */
/* 3) --keymap=<keymap> */
fname = load_setup_get_full_config_name (NULL, mc_args__keymap_file);
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
g_free (fname);
/* 4) getenv("MC_KEYMAP") */
fname = load_setup_get_full_config_name (NULL, g_getenv ("MC_KEYMAP"));
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
MC_PTR_FREE (fname);
/* 5) main config; [Midnight Commander] -> keymap */
fname2 = mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION, "keymap", NULL);
if (fname2 != NULL && *fname2 != '\0')
fname = load_setup_get_full_config_name (NULL, fname2);
g_free (fname2);
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
g_free (fname);
/* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */
fname = mc_config_get_full_path (GLOBAL_KEYMAP_FILE);
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
done:
g_free (fname);
g_free (sysconfig_keymap);
g_free (share_keymap);
return keymap_config;
}
/* --------------------------------------------------------------------------------------------- */
static void
panel_save_type (const char *section, panel_view_mode_t type)
{
@ -1295,7 +1080,6 @@ setup_save_config_show_error (const char *filename, GError ** mcerror)
}
}
/* --------------------------------------------------------------------------------------------- */
void
@ -1340,116 +1124,6 @@ load_anon_passwd (void)
/* --------------------------------------------------------------------------------------------- */
void
load_keymap_defs (gboolean load_from_file)
{
/*
* Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
* definitions override global settings.
*/
mc_config_t *mc_global_keymap;
mc_global_keymap = load_setup_get_keymap_profile_config (load_from_file);
if (mc_global_keymap != NULL)
{
#define LOAD_KEYMAP(s,km) \
km##_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); \
load_keymap_from_section (KEYMAP_SECTION_##s, km##_keymap, mc_global_keymap)
LOAD_KEYMAP (FILEMANAGER, filemanager);
LOAD_KEYMAP (FILEMANAGER_EXT, filemanager_x);
LOAD_KEYMAP (PANEL, panel);
LOAD_KEYMAP (DIALOG, dialog);
LOAD_KEYMAP (MENU, menu);
LOAD_KEYMAP (INPUT, input);
LOAD_KEYMAP (LISTBOX, listbox);
LOAD_KEYMAP (RADIO, radio);
LOAD_KEYMAP (TREE, tree);
LOAD_KEYMAP (HELP, help);
#ifdef ENABLE_EXT2FS_ATTR
LOAD_KEYMAP (CHATTR, chattr);
#endif
#ifdef USE_INTERNAL_EDIT
LOAD_KEYMAP (EDITOR, editor);
LOAD_KEYMAP (EDITOR_EXT, editor_x);
#endif
LOAD_KEYMAP (VIEWER, viewer);
LOAD_KEYMAP (VIEWER_HEX, viewer_hex);
#ifdef USE_DIFF_VIEW
LOAD_KEYMAP (DIFFVIEWER, diff);
#endif
#undef LOAD_KEYMAP
mc_config_deinit (mc_global_keymap);
}
#define SET_MAP(m) \
m##_map = (global_keymap_t *) m##_keymap->data
SET_MAP (filemanager);
SET_MAP (filemanager_x);
SET_MAP (panel);
SET_MAP (dialog);
SET_MAP (menu);
SET_MAP (input);
SET_MAP (listbox);
SET_MAP (radio);
SET_MAP (tree);
SET_MAP (help);
#ifdef ENABLE_EXT2FS_ATTR
SET_MAP (chattr);
#endif
#ifdef USE_INTERNAL_EDIT
SET_MAP (editor);
SET_MAP (editor_x);
#endif
SET_MAP (viewer);
SET_MAP (viewer_hex);
#ifdef USE_DIFF_VIEW
SET_MAP (diff);
#endif
#undef SET_MAP
}
/* --------------------------------------------------------------------------------------------- */
void
free_keymap_defs (void)
{
#define FREE_KEYMAP(km) \
if (km##_keymap != NULL) \
g_array_free (km##_keymap, TRUE)
FREE_KEYMAP (filemanager);
FREE_KEYMAP (filemanager_x);
FREE_KEYMAP (panel);
FREE_KEYMAP (dialog);
FREE_KEYMAP (menu);
FREE_KEYMAP (input);
FREE_KEYMAP (listbox);
FREE_KEYMAP (radio);
FREE_KEYMAP (tree);
FREE_KEYMAP (help);
#ifdef ENABLE_EXT2FS_ATTR
FREE_KEYMAP (chattr);
#endif
#ifdef USE_INTERNAL_EDIT
FREE_KEYMAP (editor);
FREE_KEYMAP (editor_x);
#endif
FREE_KEYMAP (viewer);
FREE_KEYMAP (viewer_hex);
#ifdef USE_DIFF_VIEW
FREE_KEYMAP (diff);
#endif
#undef FREE_KEYMAP
}
/* --------------------------------------------------------------------------------------------- */
void
panel_load_setup (WPanel * panel, const char *section)
{

View File

@ -153,9 +153,6 @@ void load_key_defs (void);
char *load_anon_passwd (void);
#endif /* ENABLE_VFS_FTP */
void load_keymap_defs (gboolean load_from_file);
void free_keymap_defs (void);
void panel_load_setup (WPanel * panel, const char *section);
void panel_save_setup (WPanel * panel, const char *section);

View File

@ -67,7 +67,7 @@
#include "src/history.h"
#include "src/file_history.h" /* show_file_history() */
#include "src/execute.h"
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "internal.h"

View File

@ -48,7 +48,7 @@
#endif
#include "src/setup.h" /* panels_options */
#include "src/keybind-defaults.h"
#include "src/keymap.h"
#include "internal.h"

View File

@ -11,7 +11,7 @@
#include "lib/widget.h"
#include "lib/vfs/vfs.h" /* vfs_path_t */
#include "src/keybind-defaults.h" /* global_keymap_t */
#include "src/keymap.h" /* global_keymap_t */
#include "src/filemanager/dir.h" /* dir_list */
#include "mcviewer.h"