mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Some refactoring.
Renamed name_key_map_t to name_keymap_t. Renamed global_key_map_t to global_keymap_t. Use more '#ifdef USE_INTERNAL_EDIT' preprocessor directives Removed unused variables and structure members. Aplly const modificator to keybind argument of keybind_cmd_bind(). Aplly const modificator to keyname argument of lookup_action(). Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
de56559df5
commit
b4b30941f5
@ -126,8 +126,7 @@ struct WEdit {
|
||||
|
||||
/* user map stuff */
|
||||
GIConv converter;
|
||||
const global_key_map_t *user_map;
|
||||
const global_key_map_t *ext_map;
|
||||
const global_keymap_t *user_map;
|
||||
|
||||
/* line break */
|
||||
LineBreaks lb;
|
||||
|
@ -725,7 +725,7 @@ edit_set_keymap (WEdit *edit)
|
||||
{
|
||||
edit->user_map = default_editor_keymap;
|
||||
if (editor_keymap && editor_keymap->len > 0)
|
||||
edit->user_map = (global_key_map_t *) editor_keymap->data;
|
||||
edit->user_map = (global_keymap_t *) editor_keymap->data;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
#include "keybind.h"
|
||||
|
||||
static const name_key_map_t command_names[] = {
|
||||
static const name_keymap_t command_names[] = {
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
{ "EditNoCommand", CK_Ignore_Key },
|
||||
{ "EditIgnoreKey", CK_Ignore_Key },
|
||||
@ -398,7 +398,7 @@ static const name_key_map_t command_names[] = {
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/* viewer/actions_cmd.c */
|
||||
const global_key_map_t default_viewer_keymap[] = {
|
||||
const global_keymap_t default_viewer_keymap[] = {
|
||||
|
||||
{ '?', CK_ViewSearch, "" },
|
||||
{ '/', CK_ViewSearch, "" },
|
||||
@ -451,7 +451,7 @@ const global_key_map_t default_viewer_keymap[] = {
|
||||
{ 0, 0, "" }
|
||||
};
|
||||
|
||||
const global_key_map_t default_viewer_hex_keymap[] = {
|
||||
const global_keymap_t default_viewer_hex_keymap[] = {
|
||||
|
||||
{ '\t', CK_HexViewToggleNavigationMode, "" },
|
||||
{ XCTRL ('a'), CK_ViewMoveToBol, "" },
|
||||
@ -474,8 +474,9 @@ const global_key_map_t default_viewer_hex_keymap[] = {
|
||||
{ 0, 0, "" }
|
||||
};
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
/* ../edit/editkeys.c */
|
||||
const global_key_map_t default_editor_keymap[] = {
|
||||
const global_keymap_t default_editor_keymap[] = {
|
||||
{ '\n', CK_Enter, "" },
|
||||
{ '\t', CK_Tab, "" },
|
||||
|
||||
@ -593,9 +594,10 @@ const global_key_map_t default_editor_keymap[] = {
|
||||
|
||||
{ 0, 0, "" }
|
||||
};
|
||||
#endif
|
||||
|
||||
/* screen.c */
|
||||
const global_key_map_t default_panel_keymap[] = {
|
||||
const global_keymap_t default_panel_keymap[] = {
|
||||
|
||||
{ ALT ('o'), CK_PanelChdirOtherPanel, "" },
|
||||
{ ALT ('l'), CK_PanelChdirToReadlink, "" },
|
||||
@ -635,7 +637,7 @@ const global_key_map_t default_panel_keymap[] = {
|
||||
};
|
||||
|
||||
/* main.c */
|
||||
const global_key_map_t default_main_map[] = {
|
||||
const global_keymap_t default_main_map[] = {
|
||||
{ KEY_F (19), CK_MenuLastSelectedCmd, "" },
|
||||
{ KEY_F (20), CK_QuietQuitCmd, "" },
|
||||
{ XCTRL ('@'), CK_SingleDirsizeCmd, "" },
|
||||
@ -664,7 +666,7 @@ const global_key_map_t default_main_map[] = {
|
||||
{ 0, 0, "" }
|
||||
};
|
||||
|
||||
const global_key_map_t default_main_x_map[] = {
|
||||
const global_keymap_t default_main_x_map[] = {
|
||||
{ XCTRL ('c'), CK_QuitCmd, "" },
|
||||
{ 'd', CK_CompareDirsCmd, "" },
|
||||
#ifdef USE_VFS
|
||||
@ -691,7 +693,7 @@ const global_key_map_t default_main_x_map[] = {
|
||||
{ 0, 0, "" }
|
||||
};
|
||||
|
||||
const global_key_map_t default_input_keymap[] = {
|
||||
const global_keymap_t default_input_keymap[] = {
|
||||
/* Motion */
|
||||
{ XCTRL ('a'), CK_InputBol, "" },
|
||||
{ KEY_HOME, CK_InputBol, "" },
|
||||
@ -735,7 +737,7 @@ const global_key_map_t default_input_keymap[] = {
|
||||
|
||||
|
||||
int
|
||||
lookup_action (char *keyname)
|
||||
lookup_action (const char *keyname)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -749,11 +751,9 @@ lookup_action (char *keyname)
|
||||
void
|
||||
keymap_add (GArray *keymap, int key, int cmd, const char *caption)
|
||||
{
|
||||
global_key_map_t new_bind, *map;
|
||||
|
||||
map = &(g_array_index (keymap, global_key_map_t, 0));
|
||||
|
||||
if (key != 0 && cmd != 0) {
|
||||
global_keymap_t new_bind;
|
||||
|
||||
new_bind.key = key;
|
||||
new_bind.command = cmd;
|
||||
g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
|
||||
@ -762,7 +762,7 @@ keymap_add (GArray *keymap, int key, int cmd, const char *caption)
|
||||
}
|
||||
|
||||
void
|
||||
keybind_cmd_bind (GArray *keymap, char *keybind, int action)
|
||||
keybind_cmd_bind (GArray *keymap, const char *keybind, int action)
|
||||
{
|
||||
char *caption = NULL;
|
||||
int key;
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
typedef struct name_key_map_t {
|
||||
typedef struct name_keymap_t {
|
||||
const char *name;
|
||||
int val;
|
||||
} name_key_map_t;
|
||||
} name_keymap_t;
|
||||
|
||||
typedef struct key_config_t {
|
||||
time_t mtime; /* mtime at the moment we read config file */
|
||||
@ -18,33 +18,35 @@ typedef struct key_config_t {
|
||||
|
||||
/* The global keymaps are of this type */
|
||||
#define KEYMAP_SHORTCUT_LENGTH 32 /* FIXME: is 32 bytes enough for shortcut? */
|
||||
typedef struct global_key_map_t {
|
||||
typedef struct global_keymap_t {
|
||||
long key;
|
||||
long command;
|
||||
char caption[KEYMAP_SHORTCUT_LENGTH];
|
||||
} global_key_map_t;
|
||||
} global_keymap_t;
|
||||
|
||||
int lookup_action (char *keyname);
|
||||
void keybind_cmd_bind(GArray *keymap, char *keybind, int action);
|
||||
|
||||
#endif /* MC_KEYBIND_H */
|
||||
int lookup_action (const char *keyname);
|
||||
void keybind_cmd_bind (GArray *keymap, const char *keybind, int action);
|
||||
|
||||
/* viewer/actions_cmd.c */
|
||||
extern const global_key_map_t default_viewer_keymap[];
|
||||
extern const global_key_map_t default_viewer_hex_keymap[];
|
||||
extern const global_keymap_t default_viewer_keymap[];
|
||||
extern const global_keymap_t default_viewer_hex_keymap[];
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
/* ../edit/editkey.c */
|
||||
extern const global_key_map_t default_editor_keymap[];
|
||||
extern const global_key_map_t default_editor_x_keymap[];
|
||||
extern const global_keymap_t default_editor_keymap[];
|
||||
extern const global_keymap_t default_editor_x_keymap[];
|
||||
#endif
|
||||
|
||||
/* screen.c */
|
||||
extern const global_key_map_t default_panel_keymap[];
|
||||
extern const global_keymap_t default_panel_keymap[];
|
||||
|
||||
/* widget.c */
|
||||
extern const global_key_map_t default_input_keymap[];
|
||||
extern const global_keymap_t default_input_keymap[];
|
||||
|
||||
/* main.c */
|
||||
extern const global_key_map_t default_main_map[];
|
||||
extern const global_key_map_t default_main_x_map[];
|
||||
extern const global_keymap_t default_main_map[];
|
||||
extern const global_keymap_t default_main_x_map[];
|
||||
|
||||
extern const global_key_map_t default_input_keymap[];
|
||||
extern const global_keymap_t default_input_keymap[];
|
||||
|
||||
#endif /* MC_KEYBIND_H */
|
||||
|
16
src/main.c
16
src/main.c
@ -101,7 +101,7 @@
|
||||
#include "../vfs/gc.h"
|
||||
#endif
|
||||
|
||||
#include "keybind.h" /* type global_key_map_t */
|
||||
#include "keybind.h" /* type global_keymap_t */
|
||||
|
||||
/* When the modes are active, left_panel, right_panel and tree_panel */
|
||||
/* Point to a proper data structure. You should check with the functions */
|
||||
@ -305,7 +305,9 @@ mc_main_error_quark (void)
|
||||
return g_quark_from_static_string (PACKAGE);
|
||||
}
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
GArray *editor_keymap = NULL;
|
||||
#endif
|
||||
GArray *viewer_keymap = NULL;
|
||||
GArray *viewer_hex_keymap = NULL;
|
||||
GArray *main_keymap = NULL;
|
||||
@ -313,8 +315,8 @@ GArray *main_x_keymap = NULL;
|
||||
GArray *panel_keymap = NULL;
|
||||
GArray *input_keymap = NULL;
|
||||
|
||||
const global_key_map_t *main_map;
|
||||
const global_key_map_t *main_x_map;
|
||||
const global_keymap_t *main_map;
|
||||
const global_keymap_t *main_x_map;
|
||||
|
||||
/* Save current stat of directories to avoid reloading the panels */
|
||||
/* when no modifications have taken place */
|
||||
@ -1846,23 +1848,23 @@ do_nc (void)
|
||||
main_map = default_main_map;
|
||||
|
||||
if (main_keymap && main_keymap->len > 0)
|
||||
main_map = (global_key_map_t *) main_keymap->data;
|
||||
main_map = (global_keymap_t *) main_keymap->data;
|
||||
|
||||
main_x_map = default_main_x_map;
|
||||
|
||||
if (main_x_keymap && main_x_keymap->len > 0)
|
||||
main_x_map = (global_key_map_t *) main_x_keymap->data;
|
||||
main_x_map = (global_keymap_t *) main_x_keymap->data;
|
||||
|
||||
panel_map = default_panel_keymap;
|
||||
|
||||
if (panel_keymap && panel_keymap->len > 0) {
|
||||
panel_map = (global_key_map_t *) panel_keymap->data;
|
||||
panel_map = (global_keymap_t *) panel_keymap->data;
|
||||
}
|
||||
|
||||
input_map = default_input_keymap;
|
||||
|
||||
if (input_keymap && input_keymap->len > 0)
|
||||
input_map = (global_key_map_t *) input_keymap->data;
|
||||
input_map = (global_keymap_t *) input_keymap->data;
|
||||
|
||||
/* Check if we were invoked as an editor or file viewer */
|
||||
if (!mc_maybe_editor_or_viewer ()) {
|
||||
|
@ -75,7 +75,9 @@ extern int is_right; /* If the selected menu was the right */
|
||||
#define MENU_PANEL_IDX (is_right ? 1 : 0)
|
||||
#define SELECTED_IS_PANEL (get_display_type (is_right ? 1 : 0) == view_listing)
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
extern GArray *editor_keymap;
|
||||
#endif
|
||||
extern GArray *viewer_keymap;
|
||||
extern GArray *viewer_hex_keymap;
|
||||
extern GArray *main_keymap;
|
||||
@ -83,10 +85,12 @@ extern GArray *main_x_keymap;
|
||||
extern GArray *panel_keymap;
|
||||
extern GArray *input_keymap;
|
||||
|
||||
extern const global_key_map_t *panel_map;
|
||||
extern const global_key_map_t *input_map;
|
||||
extern const global_keymap_t *panel_map;
|
||||
extern const global_keymap_t *input_map;
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
void do_update_prompt (void);
|
||||
#endif
|
||||
|
||||
enum cd_enum {
|
||||
cd_parse_command,
|
||||
|
@ -61,7 +61,7 @@
|
||||
#include "selcodepage.h" /* select_charset () */
|
||||
#include "charsets.h" /* get_codepage_id () */
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "keybind.h" /* global_key_map_t */
|
||||
#include "keybind.h" /* global_keymap_t */
|
||||
|
||||
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
|
||||
|
||||
@ -107,7 +107,7 @@ int filetype_mode = 1;
|
||||
/* The hook list for the select file function */
|
||||
Hook *select_file_hook = 0;
|
||||
|
||||
const global_key_map_t *panel_map;
|
||||
const global_keymap_t *panel_map;
|
||||
|
||||
static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm);
|
||||
static int panel_event (Gpm_Event *event, void *);
|
||||
|
16
src/setup.c
16
src/setup.c
@ -965,25 +965,27 @@ load_keymap_defs (void)
|
||||
|
||||
if (mc_global_keymap != NULL)
|
||||
{
|
||||
editor_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
#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);
|
||||
#endif
|
||||
|
||||
viewer_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
viewer_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
||||
load_keymap_from_section ("viewer", viewer_keymap, mc_global_keymap);
|
||||
|
||||
viewer_hex_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
viewer_hex_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
||||
load_keymap_from_section ("viewer:hex", viewer_hex_keymap, mc_global_keymap);
|
||||
|
||||
main_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
main_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
||||
load_keymap_from_section ("main", main_keymap, mc_global_keymap);
|
||||
|
||||
main_x_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
main_x_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
||||
load_keymap_from_section ("main:xmap", main_x_keymap, mc_global_keymap);
|
||||
|
||||
panel_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
panel_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
||||
load_keymap_from_section ("panel", panel_keymap, mc_global_keymap);
|
||||
|
||||
input_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
input_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
||||
load_keymap_from_section ("input", input_keymap, mc_global_keymap);
|
||||
|
||||
mc_config_deinit(mc_global_keymap);
|
||||
|
@ -63,7 +63,7 @@
|
||||
#include "../src/cmd.h"
|
||||
#include "../src/execute.h"
|
||||
#include "../src/help.h"
|
||||
#include "../src/keybind.h" /* global_key_map_t */
|
||||
#include "../src/keybind.h"
|
||||
#include "../src/cmddef.h" /* CK_ cmd name const */
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "../src/widget.h"
|
||||
#include "../src/search/search.h"
|
||||
#include "../src/keybind.h" /* global_key_map_t */
|
||||
#include "../src/keybind.h" /* global_keymap_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants ********************/
|
||||
|
||||
@ -168,8 +168,8 @@ typedef struct mcview_struct {
|
||||
GIConv converter;
|
||||
|
||||
/* keymaps */
|
||||
const global_key_map_t *plain_map;
|
||||
const global_key_map_t *hex_map;
|
||||
const global_keymap_t *plain_map;
|
||||
const global_keymap_t *hex_map;
|
||||
|
||||
/* handle of search engine */
|
||||
mc_search_t *search;
|
||||
|
@ -172,11 +172,11 @@ mcview_set_keymap (mcview_t * view)
|
||||
{
|
||||
view->plain_map = default_viewer_keymap;
|
||||
if (viewer_keymap && viewer_keymap->len > 0)
|
||||
view->plain_map = (global_key_map_t *) viewer_keymap->data;
|
||||
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_key_map_t *) viewer_hex_keymap->data;
|
||||
view->hex_map = (global_keymap_t *) viewer_hex_keymap->data;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -55,10 +55,10 @@
|
||||
#include "strutil.h"
|
||||
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "keybind.h" /* global_key_map_t */
|
||||
#include "keybind.h" /* global_keymap_t */
|
||||
#include "fileloc.h"
|
||||
|
||||
const global_key_map_t *input_map;
|
||||
const global_keymap_t *input_map;
|
||||
|
||||
static void
|
||||
widget_selectcolor (Widget *w, gboolean focused, gboolean hotkey)
|
||||
|
Loading…
Reference in New Issue
Block a user