mirror of https://github.com/MidnightCommander/mc
rework screen.c keymapping
Signed-off-by: Ilia Maslakov <il.smind@google.com>
This commit is contained in:
parent
71b1a8bf99
commit
27545f1745
|
@ -307,7 +307,7 @@ mc_main_error_quark (void)
|
|||
GArray *editor_keymap = NULL;
|
||||
GArray *main_keymap = NULL;
|
||||
GArray *main_x_keymap = NULL;
|
||||
GArray *screen_keymap = NULL;
|
||||
GArray *panel_keymap = NULL;
|
||||
|
||||
const global_key_map_t *main_map;
|
||||
const global_key_map_t *main_x_map;
|
||||
|
@ -1861,6 +1861,13 @@ do_nc (void)
|
|||
if (main_x_keymap && main_x_keymap->len > 0)
|
||||
main_x_map = (global_key_map_t *) main_x_keymap->data;
|
||||
|
||||
panel_map = default_panel_keymap;
|
||||
|
||||
if (panel_keymap && panel_keymap->len > 0) {
|
||||
mc_log ("panel_keymap && panel_keymap->len > 0\n");
|
||||
panel_map = (global_key_map_t *) panel_keymap->data;
|
||||
}
|
||||
|
||||
/* Check if we were invoked as an editor or file viewer */
|
||||
if (!mc_maybe_editor_or_viewer ()) {
|
||||
setup_panels_and_run_mc ();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef MC_MAIN_H
|
||||
#define MC_MAIN_H
|
||||
|
||||
//#include "global.h"
|
||||
#include "keybind.h"
|
||||
|
||||
/* Toggling functions */
|
||||
void toggle_fast_reload (void);
|
||||
|
@ -77,8 +77,10 @@ extern int is_right; /* If the selected menu was the right */
|
|||
extern GArray *editor_keymap;
|
||||
extern GArray *main_keymap;
|
||||
extern GArray *main_x_keymap;
|
||||
extern GArray *screen_keymap;
|
||||
extern GArray *panel_keymap;
|
||||
|
||||
extern const global_key_map_t *panel_map;
|
||||
extern const global_key_map_t default_panel_keymap[];
|
||||
void do_update_prompt (void);
|
||||
|
||||
enum cd_enum {
|
||||
|
|
15
src/screen.c
15
src/screen.c
|
@ -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_keymap;
|
||||
const global_key_map_t *panel_map;
|
||||
|
||||
const global_key_map_t default_panel_keymap[] = {
|
||||
|
||||
|
@ -134,6 +134,8 @@ const global_key_map_t default_panel_keymap[] = {
|
|||
{ KEY_IC, CK_PanelMarkFile },
|
||||
{ KEY_UP, CK_PanelMoveUp },
|
||||
{ KEY_DOWN, CK_PanelMoveDown },
|
||||
{ KEY_LEFT, CK_PanelMoveLeft },
|
||||
{ KEY_RIGHT, CK_PanelMoveRight },
|
||||
{ KEY_END, CK_PanelMoveEnd },
|
||||
{ KEY_HOME, CK_PanelMoveHome },
|
||||
{ KEY_NPAGE, CK_PanelNextPage },
|
||||
|
@ -1142,7 +1144,6 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
|
|||
} else
|
||||
mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
|
||||
|
||||
panel_keymap = default_panel_keymap;
|
||||
strcpy (panel->lwd, ".");
|
||||
|
||||
panel->hist_name = g_strconcat ("Dir Hist ", panel_name, (char *) NULL);
|
||||
|
@ -2429,20 +2430,22 @@ panel_key (WPanel *panel, int key)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; panel_keymap[i].key; i++) {
|
||||
if (key == panel_keymap[i].key) {
|
||||
|
||||
for (i = 0; panel_map[i].key; i++) {
|
||||
if (key == panel_map[i].key) {
|
||||
int old_searching = panel->searching;
|
||||
|
||||
if (panel_keymap[i].command != CK_PanelStartSearch)
|
||||
if (panel_map[i].command != CK_PanelStartSearch)
|
||||
panel->searching = 0;
|
||||
|
||||
screen_execute_cmd (panel, panel_keymap[i].command, key);
|
||||
screen_execute_cmd (panel, panel_map[i].command, key);
|
||||
|
||||
if (panel->searching != old_searching)
|
||||
display_mini_info (panel);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (torben_fj_mode && key == ALT ('h')) {
|
||||
goto_middle_file (panel);
|
||||
return MSG_HANDLED;
|
||||
|
|
|
@ -855,8 +855,8 @@ load_keymap_defs (void)
|
|||
main_x_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
load_keymap_from_section ("main:xmap", main_x_keymap, mc_global_keymap);
|
||||
|
||||
screen_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
load_keymap_from_section ("panel", screen_keymap, mc_global_keymap);
|
||||
panel_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
load_keymap_from_section ("panel", panel_keymap, mc_global_keymap);
|
||||
mc_config_deinit(mc_global_keymap);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue