mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Add support for multi-hotkeys in editor (like a ctrl-x,t).
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
parent
e5feeea8d9
commit
82b7c4fdee
@ -127,6 +127,7 @@ struct WEdit {
|
|||||||
/* user map stuff */
|
/* user map stuff */
|
||||||
GIConv converter;
|
GIConv converter;
|
||||||
const global_keymap_t *user_map;
|
const global_keymap_t *user_map;
|
||||||
|
const global_keymap_t *user_x_map;
|
||||||
|
|
||||||
/* line break */
|
/* line break */
|
||||||
LineBreaks lb;
|
LineBreaks lb;
|
||||||
|
@ -726,6 +726,9 @@ edit_set_keymap (WEdit *edit)
|
|||||||
edit->user_map = default_editor_keymap;
|
edit->user_map = default_editor_keymap;
|
||||||
if (editor_keymap && editor_keymap->len > 0)
|
if (editor_keymap && editor_keymap->len > 0)
|
||||||
edit->user_map = (global_keymap_t *) editor_keymap->data;
|
edit->user_map = (global_keymap_t *) editor_keymap->data;
|
||||||
|
edit->user_x_map = default_editor_x_keymap;
|
||||||
|
if (editor_x_keymap && editor_x_keymap->len > 0)
|
||||||
|
edit->user_x_map = (global_keymap_t *) editor_x_keymap->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,11 +63,10 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||||||
int command = CK_Insert_Char;
|
int command = CK_Insert_Char;
|
||||||
int char_for_insertion = -1;
|
int char_for_insertion = -1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int extmod = 0;
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
/* an ordinary insertable character */
|
/* an ordinary insertable character */
|
||||||
if (x_key < 256 && !extmod) {
|
if (x_key < 256) {
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
if ( edit->charpoint >= 4 ) {
|
if ( edit->charpoint >= 4 ) {
|
||||||
edit->charpoint = 0;
|
edit->charpoint = 0;
|
||||||
@ -145,12 +144,22 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Commands specific to the key emulation */
|
/* Commands specific to the key emulation */
|
||||||
for (i = 0; edit->user_map[i].key != 0; i++)
|
if (edit->extmod) {
|
||||||
if (x_key == edit->user_map[i].key) {
|
edit->extmod = 0;
|
||||||
command = edit->user_map[i].command;
|
for (i = 0; edit->user_x_map[i].key; i++) {
|
||||||
break;
|
if (x_key == edit->user_x_map[i].key) {
|
||||||
|
command = edit->user_x_map[i].command;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; edit->user_map[i].key != 0; i++) {
|
||||||
|
if (x_key == edit->user_map[i].key) {
|
||||||
|
command = edit->user_map[i].command;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
fin:
|
fin:
|
||||||
*cmd = command;
|
*cmd = command;
|
||||||
*ch = char_for_insertion;
|
*ch = char_for_insertion;
|
||||||
|
@ -594,6 +594,10 @@ const global_keymap_t default_editor_keymap[] = {
|
|||||||
|
|
||||||
{ 0, 0, "" }
|
{ 0, 0, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const global_keymap_t default_editor_x_keymap[] = {
|
||||||
|
{ 0, 0, "" }
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* screen.c */
|
/* screen.c */
|
||||||
|
@ -308,6 +308,7 @@ mc_main_error_quark (void)
|
|||||||
|
|
||||||
#ifdef USE_INTERNAL_EDIT
|
#ifdef USE_INTERNAL_EDIT
|
||||||
GArray *editor_keymap = NULL;
|
GArray *editor_keymap = NULL;
|
||||||
|
GArray *editor_x_keymap = NULL;
|
||||||
#endif
|
#endif
|
||||||
GArray *viewer_keymap = NULL;
|
GArray *viewer_keymap = NULL;
|
||||||
GArray *viewer_hex_keymap = NULL;
|
GArray *viewer_hex_keymap = NULL;
|
||||||
|
@ -77,6 +77,7 @@ extern int is_right; /* If the selected menu was the right */
|
|||||||
|
|
||||||
#ifdef USE_INTERNAL_EDIT
|
#ifdef USE_INTERNAL_EDIT
|
||||||
extern GArray *editor_keymap;
|
extern GArray *editor_keymap;
|
||||||
|
extern GArray *editor_x_keymap;
|
||||||
#endif
|
#endif
|
||||||
extern GArray *viewer_keymap;
|
extern GArray *viewer_keymap;
|
||||||
extern GArray *viewer_hex_keymap;
|
extern GArray *viewer_hex_keymap;
|
||||||
|
18
src/setup.c
18
src/setup.c
@ -966,29 +966,31 @@ load_keymap_defs (void)
|
|||||||
if (mc_global_keymap != NULL)
|
if (mc_global_keymap != NULL)
|
||||||
{
|
{
|
||||||
#ifdef USE_INTERNAL_EDIT
|
#ifdef USE_INTERNAL_EDIT
|
||||||
editor_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
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 ("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);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
viewer_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
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 ("viewer", viewer_keymap, mc_global_keymap);
|
||||||
|
|
||||||
viewer_hex_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_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);
|
load_keymap_from_section ("viewer:hex", viewer_hex_keymap, mc_global_keymap);
|
||||||
|
|
||||||
main_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
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 ("main", main_keymap, mc_global_keymap);
|
||||||
|
|
||||||
main_x_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_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);
|
load_keymap_from_section ("main:xmap", main_x_keymap, mc_global_keymap);
|
||||||
|
|
||||||
panel_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
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 ("panel", panel_keymap, mc_global_keymap);
|
||||||
|
|
||||||
input_keymap = g_array_new(TRUE, FALSE, sizeof (global_keymap_t));
|
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 ("input", input_keymap, mc_global_keymap);
|
||||||
|
|
||||||
mc_config_deinit(mc_global_keymap);
|
mc_config_deinit (mc_global_keymap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user