mirror of https://github.com/MidnightCommander/mc
Merge branch '212_redefine_hotkeys'
* 212_redefine_hotkeys: (26 commits) remove unused struct. fix: main.c keys handler fix: default_input_keymap, remove incorrect entry add alt+arrows action and descriptions into mc.keymap fix: movement in Lynx navigation mode Fix hotkey parser for handle shift+<letter> hotkeys. Fixed parsing of hotkeys. Now will read: Fix memory leak in function lookup_key() Added new WIDGET_COMMAND message. Some minor optimization. Add some default hotkeys Add some forgotten hotkeys. Add more event handlers for actions Rename widget_* functions and variables into input_* functions and variables. Rename Widget* events into Input* events. Show hotkeys as 'alt-s' instread of 'alt s'. add more commands into mc.keymap refactoring editor keybindings Added mc.keymap into spec file little cosmetic refactoring ...
This commit is contained in:
commit
cc979394d3
|
@ -147,6 +147,7 @@ rm -rf $RPM_BUILD_ROOT
|
|||
%config(noreplace) %{_sysconfdir}/mc/mc.menu
|
||||
%config(noreplace) %{_sysconfdir}/mc/extfs/extfs.ini
|
||||
%config(noreplace) %{_sysconfdir}/mc/extfs/sfs.ini
|
||||
%config(noreplace) %{_sysconfdir}/mc/mc.keymap
|
||||
|
||||
%dir %{_datadir}/mc
|
||||
%{_datadir}/mc/*
|
||||
|
|
|
@ -3294,8 +3294,8 @@ También se pueden usar
|
|||
Por ejemplo:
|
||||
|
||||
.nf
|
||||
ctrl alt right=\\e[[1;6C
|
||||
ctrl alt left=\\e[[1;6D
|
||||
ctrl-alt-right=\\e[[1;6C
|
||||
ctrl-alt-left=\\e[[1;6D
|
||||
.fi
|
||||
|
||||
.PP
|
||||
|
|
|
@ -59,6 +59,9 @@ Display the compiled\-in search paths for Midnight Commander files.
|
|||
Reset softkeys to their default from the termcap/terminfo
|
||||
database. Only useful on HP terminals when the function keys don't work.
|
||||
.TP
|
||||
.I \-K файл
|
||||
Specify a name of keymap file in the command line.
|
||||
.TP
|
||||
.I \-l file, \-\-ftplog=file
|
||||
Save the ftpfs dialog with the server in file.
|
||||
.TP
|
||||
|
@ -268,7 +271,16 @@ release it, then type the character <chr>.
|
|||
means hold the Shift key down while typing <chr>.
|
||||
.PP
|
||||
All input lines in the Midnight Commander use an approximation to
|
||||
the GNU Emacs editor's key bindings.
|
||||
the GNU Emacs editor's key bindings (default).
|
||||
.PP
|
||||
You may redefine key bindings. See
|
||||
.\"LINK2"
|
||||
.I redefine hotkey bindings
|
||||
.\"Keys_redefine"
|
||||
.PP
|
||||
for more info. All other key bindings (described in this manual) relative
|
||||
to default behavior.
|
||||
|
||||
.PP
|
||||
There are many sections which tell about the keys. The following are
|
||||
the most important.
|
||||
|
@ -304,6 +316,52 @@ Input Line Keys
|
|||
.\"Input Line Keys"
|
||||
are used for editing input lines. This means both the command line and
|
||||
the input lines in the query dialogs.
|
||||
|
||||
.\"NODE " Keys_redefine"
|
||||
.SH " Redefine hotkey bindings"
|
||||
Hotkey bindings may be readed from external file (keymap\-file).
|
||||
A keymap\-file is searched on the following algorithm (to the first one found):
|
||||
.IP
|
||||
.br
|
||||
1) command line option
|
||||
.BR \-K
|
||||
.BR \<keymap\>
|
||||
or
|
||||
.BR \-\-keymap=\<keymap\>
|
||||
.br
|
||||
2) Environment variable
|
||||
.BR MC_KEYMAP
|
||||
.br
|
||||
3) In config file parameter
|
||||
.BR keymap
|
||||
in section
|
||||
.BR \[Midhight
|
||||
.BR Commander\]
|
||||
.br
|
||||
4) File
|
||||
.BR ~/.mc/mc.keymap
|
||||
.br
|
||||
5) File
|
||||
.BR /etc/mc/mc.keymap
|
||||
.br
|
||||
6) File
|
||||
.BR @prefix@/share/mc/mc.keymap
|
||||
|
||||
.PP
|
||||
Command line option, environment variable and parameter in config file may
|
||||
contain the absolute path to the keymap\-file (with the extension \.keymap
|
||||
or without it). Search of keymap\-file will occur in (to the first one found):
|
||||
.IP
|
||||
1)
|
||||
.BR ~/.mc/
|
||||
.br
|
||||
2)
|
||||
.BR /etc/mc/
|
||||
.br
|
||||
3)
|
||||
.BR @prefix@/share/mc/
|
||||
.br
|
||||
|
||||
.\"NODE " Miscellaneous Keys"
|
||||
.SH " Miscellaneous Keys"
|
||||
Here are some keys which don't fall into any of the other categories:
|
||||
|
@ -3696,8 +3754,8 @@ Also now you can use
|
|||
For example:
|
||||
|
||||
.nf
|
||||
ctrl alt right=\\e[[1;6C
|
||||
ctrl alt left=\\e[[1;6D
|
||||
ctrl-alt-right=\\e[[1;6C
|
||||
ctrl-alt-left=\\e[[1;6D
|
||||
.fi
|
||||
|
||||
.PP
|
||||
|
|
|
@ -72,6 +72,10 @@ UNIX\-подобных операционных системах.
|
|||
termcap/terminfo. Этот ключ используется только на терминалах HP, где
|
||||
функциональные клавиши не работают.
|
||||
.TP
|
||||
.I \-K файл
|
||||
Задаёт файл клавиатурных команд для переопределения привязки хоткеев
|
||||
к действиям.
|
||||
.TP
|
||||
.I \-l файл
|
||||
Сохранить диалог с ftp\-сервером, а также отладочную информацию smbfs в
|
||||
файл file.
|
||||
|
@ -259,8 +263,18 @@ Control и, удерживая ее, нажмите (коротким щелчк
|
|||
S\-<символ> означает, что нужно держать в нажатом состоянии клавишу Shift
|
||||
во время удара по клавише <символ>.
|
||||
.PP
|
||||
Все строки ввода в Midnight Commander поддерживают соглашения об
|
||||
использовании "горячих" клавиш, принятые в редакторе GNU Emacs.
|
||||
Все строки ввода в Midnight Commander по умолчанию поддерживают соглашения
|
||||
об использовании "горячих" клавиш, принятые в редакторе GNU Emacs.
|
||||
.PP
|
||||
Вы можете переопределить клавиатурные привязки хоткеев к командам, как
|
||||
это описано в разделе
|
||||
.\"LINK2"
|
||||
.I переопределение клавиатурных команд
|
||||
.\"Keys_redefine"
|
||||
.PP
|
||||
Все последующие описания клавиатурных команд относятся к поведению по
|
||||
умолчанию.
|
||||
|
||||
.PP
|
||||
Описания клавиатурных команд даются в нескольких разделах помощи.
|
||||
Наиболее важными являются следующие разделы:
|
||||
|
@ -299,6 +313,54 @@ S\-<символ> означает, что нужно держать в нажа
|
|||
.\"Input Line Keys"
|
||||
используются как при редактировании командной строки, так и других строк
|
||||
ввода, появляющихся в различных запросах программы.
|
||||
|
||||
.\"NODE " Keys_redefine"
|
||||
.SH " Переопределение клавиатурных команд"
|
||||
Клавиатурные команды могут быть прочитаны из внешнего файла.
|
||||
Поиск файла клавиатурных команд производится по следующему алгоритму
|
||||
(до первого нахождения файла):
|
||||
.IP
|
||||
.br
|
||||
1) параметр командной строки
|
||||
.BR \-K
|
||||
.BR \<файл\>
|
||||
или
|
||||
.BR \-\-keymap=\<файл\>
|
||||
.br
|
||||
2) Переменная окружения
|
||||
.BR MC_KEYMAP
|
||||
.br
|
||||
3) В конфигурационном файле параметр
|
||||
.BR keymap
|
||||
в секции
|
||||
.BR \[Midhight
|
||||
.BR Commander\]
|
||||
.br
|
||||
4) Файл
|
||||
.BR ~/.mc/mc.keymap
|
||||
.br
|
||||
5) Файл
|
||||
.BR /etc/mc/mc.keymap
|
||||
.br
|
||||
6) Файл
|
||||
.BR @prefix@/share/mc/mc.keymap
|
||||
|
||||
.PP
|
||||
Параметры в трёх первых случаях могут содержать абсолютный путь к файлу
|
||||
клавиатурных команд либо просто название схемы привязки (с расширением
|
||||
\.keymap либо без него). В данном случае поиск файла клавиатурных команд
|
||||
будет происходить по следующим каталогам (до первого нахождения):
|
||||
.IP
|
||||
1)
|
||||
.BR ~/.mc/
|
||||
.br
|
||||
2)
|
||||
.BR /etc/mc/
|
||||
.br
|
||||
3)
|
||||
.BR @prefix@/share/mc/
|
||||
.br
|
||||
|
||||
.\"NODE " Miscellaneous Keys"
|
||||
.SH " Разные команды"
|
||||
Имеется несколько действий, ассоциированных с некоторыми комбинациями
|
||||
|
|
|
@ -9,7 +9,7 @@ endif
|
|||
libedit_a_SOURCES = \
|
||||
bookmark.c edit.c editcmd.c editwidget.c editdraw.c editkeys.c \
|
||||
editmenu.c editoptions.c editcmddef.h edit-impl.h edit.h edit-widget.h \
|
||||
editlock.c editlock.h syntax.c usermap.h usermap.c wordproc.c \
|
||||
editlock.c editlock.h syntax.c wordproc.c \
|
||||
choosesyntax.c etags.c etags.h editcmd_dialogs.c editcmd_dialogs.h
|
||||
|
||||
EXTRA_DIST =
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "../src/search/search.h" /* mc_search_t */
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "../src/keybind.h"
|
||||
|
||||
|
||||
#define MAX_MACRO_LENGTH 1024
|
||||
#define N_LINE_CACHES 32
|
||||
|
@ -32,11 +34,6 @@ struct syntax_rule {
|
|||
unsigned char border;
|
||||
};
|
||||
|
||||
typedef struct edit_key_map_type {
|
||||
long key;
|
||||
long command;
|
||||
} edit_key_map_type;
|
||||
|
||||
struct WEdit {
|
||||
Widget widget;
|
||||
|
||||
|
@ -132,9 +129,9 @@ struct WEdit {
|
|||
struct macro macro[MAX_MACRO_LENGTH];
|
||||
|
||||
/* user map stuff */
|
||||
const edit_key_map_type *user_map;
|
||||
const edit_key_map_type *ext_map;
|
||||
GIConv converter;
|
||||
const global_key_map_t *user_map;
|
||||
const global_key_map_t *ext_map;
|
||||
|
||||
/* line break */
|
||||
LineBreaks lb;
|
||||
|
|
16
edit/edit.c
16
edit/edit.c
|
@ -44,8 +44,7 @@
|
|||
#include "edit-impl.h"
|
||||
#include "editlock.h"
|
||||
#include "edit-widget.h"
|
||||
#include "editcmddef.h"
|
||||
#include "usermap.h"
|
||||
#include "../src/cmddef.h"
|
||||
|
||||
#include "../src/tty/color.h" /* EDITOR_NORMAL_COLOR */
|
||||
#include "../src/tty/tty.h" /* attrset() */
|
||||
|
@ -720,6 +719,15 @@ edit_purge_widget (WEdit *edit)
|
|||
edit->macro_i = -1; /* not recording a macro */
|
||||
}
|
||||
|
||||
static void
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
#define space_width 1
|
||||
|
||||
/*
|
||||
|
@ -829,7 +837,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
|
|||
edit_move_to_line (edit, line - 1);
|
||||
}
|
||||
|
||||
edit_load_user_map(edit);
|
||||
edit_set_keymap (edit);
|
||||
|
||||
return edit;
|
||||
}
|
||||
|
@ -3113,7 +3121,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
|
|||
case CK_Shell:
|
||||
view_other_cmd ();
|
||||
break;
|
||||
case CK_Select_Codepage:
|
||||
case CK_SelectCodepage:
|
||||
edit_select_codepage_cmd (edit);
|
||||
break;
|
||||
case CK_Insert_Literal:
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
#include "../edit/edit-impl.h"
|
||||
#include "../edit/edit.h"
|
||||
#include "../edit/editlock.h"
|
||||
#include "../edit/editcmddef.h"
|
||||
#include "../src/cmddef.h"
|
||||
#include "../edit/edit-widget.h"
|
||||
#include "../edit/editcmd_dialogs.h"
|
||||
#include "../edit/etags.h"
|
||||
|
|
|
@ -44,10 +44,10 @@
|
|||
#include "edit-impl.h"
|
||||
#include "edit-widget.h" /* edit->macro_i */
|
||||
#include "editcmd_dialogs.h"
|
||||
#include "editcmddef.h" /* list of commands */
|
||||
|
||||
#include "../src/tty/tty.h" /* keys */
|
||||
#include "../src/tty/key.h" /* KEY_M_SHIFT */
|
||||
#include "../src/cmddef.h" /* list of commands */
|
||||
|
||||
#include "../src/charsets.h" /* convert_from_input_c() */
|
||||
#include "../src/main.h" /* display_codepage */
|
||||
|
@ -57,7 +57,7 @@
|
|||
* Ordinary translations. Note that the keys listed first take priority
|
||||
* when the key is assigned to more than one command.
|
||||
*/
|
||||
static const edit_key_map_type cooledit_key_map[] = {
|
||||
static const global_key_map_t cooledit_key_map[] = {
|
||||
{ ALT ('b'), CK_Match_Bracket },
|
||||
{ ALT ('m'), CK_Mail },
|
||||
{ XCTRL ('f'), CK_Save_Block },
|
||||
|
@ -69,7 +69,7 @@ static const edit_key_map_type cooledit_key_map[] = {
|
|||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const edit_key_map_type emacs_key_map[] = {
|
||||
static const global_key_map_t emacs_key_map[] = {
|
||||
{ ALT ('$'), CK_Pipe_Block (1) }, /* spell check */
|
||||
{ ALT ('b'), CK_Word_Left },
|
||||
{ ALT ('f'), CK_Word_Right },
|
||||
|
@ -90,7 +90,7 @@ static const edit_key_map_type emacs_key_map[] = {
|
|||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const edit_key_map_type common_key_map[] = {
|
||||
static const global_key_map_t common_key_map[] = {
|
||||
{ '\n', CK_Enter },
|
||||
{ '\t', CK_Tab },
|
||||
|
||||
|
@ -132,7 +132,7 @@ static const edit_key_map_type common_key_map[] = {
|
|||
{ XCTRL ('o'), CK_Shell },
|
||||
{ XCTRL ('s'), CK_Toggle_Syntax },
|
||||
{ XCTRL ('u'), CK_Undo },
|
||||
{ XCTRL ('t'), CK_Select_Codepage },
|
||||
{ XCTRL ('t'), CK_SelectCodepage },
|
||||
{ XCTRL ('q'), CK_Insert_Literal },
|
||||
{ XCTRL ('a'), CK_Execute_Macro },
|
||||
{ XCTRL ('r'), CK_Begin_End_Macro },
|
||||
|
@ -207,7 +207,7 @@ static const edit_key_map_type common_key_map[] = {
|
|||
|
||||
/*
|
||||
* Translate the keycode into either 'command' or 'char_for_insertion'.
|
||||
* 'command' is one of the editor commands from editcmddef.h.
|
||||
* 'command' is one of the editor commands from cmddef.h.
|
||||
*/
|
||||
int
|
||||
edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
||||
|
@ -218,56 +218,6 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||
int extmod = 0;
|
||||
int c;
|
||||
|
||||
const edit_key_map_type *key_map = NULL;
|
||||
switch (edit_key_emulation) {
|
||||
case EDIT_KEY_EMULATION_NORMAL:
|
||||
key_map = cooledit_key_map;
|
||||
break;
|
||||
case EDIT_KEY_EMULATION_EMACS:
|
||||
key_map = emacs_key_map;
|
||||
if (x_key == XCTRL ('x')) {
|
||||
int ext_key;
|
||||
ext_key =
|
||||
editcmd_dialog_raw_key_query (" Ctrl-X ", _(" Emacs key: "), 0);
|
||||
switch (ext_key) {
|
||||
case 's':
|
||||
command = CK_Save;
|
||||
goto fin;
|
||||
case 'x':
|
||||
command = CK_Exit;
|
||||
goto fin;
|
||||
case 'k':
|
||||
command = CK_New;
|
||||
goto fin;
|
||||
case 'e':
|
||||
command =
|
||||
CK_Macro (editcmd_dialog_raw_key_query
|
||||
(_(" Execute Macro "),
|
||||
_(" Press macro hotkey: "), 1));
|
||||
if (command == CK_Macro (0))
|
||||
command = CK_Insert_Char;
|
||||
goto fin;
|
||||
}
|
||||
goto fin;
|
||||
}
|
||||
break;
|
||||
|
||||
case EDIT_KEY_EMULATION_USER:
|
||||
if (edit->user_map != NULL) {
|
||||
if (edit->extmod && edit->ext_map != NULL) {
|
||||
key_map = edit->ext_map;
|
||||
extmod = 1;
|
||||
} else {
|
||||
key_map = edit->user_map;
|
||||
}
|
||||
edit->extmod = 0;
|
||||
} else {
|
||||
key_map = edit->user_map = cooledit_key_map;
|
||||
}
|
||||
break;
|
||||
}
|
||||
assert (key_map != NULL);
|
||||
|
||||
/* an ordinary insertable character */
|
||||
if (x_key < 256 && !extmod) {
|
||||
#ifdef HAVE_CHARSET
|
||||
|
@ -292,7 +242,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||
}
|
||||
#ifdef HAVE_CHARSET
|
||||
} else {
|
||||
c = convert_from_input_c (x_key);
|
||||
c = convert_from_input_c (x_key);
|
||||
if (is_printable (c)) {
|
||||
char_for_insertion = convert_from_8bit_to_utf_c2((unsigned char) x_key);
|
||||
goto fin;
|
||||
|
@ -347,34 +297,12 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||
}
|
||||
|
||||
/* Commands specific to the key emulation */
|
||||
for (i = 0; key_map[i].key != 0 && key_map[i].key != x_key; i++)
|
||||
continue;
|
||||
if (key_map[i].key != 0) {
|
||||
command = key_map[i].command;
|
||||
goto fin;
|
||||
for (i = 0; edit->user_map[i].key != 0; i++) {
|
||||
if (x_key == edit->user_map[i].key) {
|
||||
command = edit->user_map[i].command;
|
||||
}
|
||||
}
|
||||
|
||||
/* Commands common for the key emulations */
|
||||
key_map = common_key_map;
|
||||
for (i = 0; key_map[i].key != 0 && key_map[i].key != x_key; i++)
|
||||
continue;
|
||||
if (key_map[i].key != 0) {
|
||||
command = key_map[i].command;
|
||||
goto fin;
|
||||
}
|
||||
|
||||
/* Function still not found for this key, so try macros */
|
||||
/* This allows the same macro to be
|
||||
enabled by either eg "ALT('f')" or "XCTRL('f')" or "XCTRL('a'), 'f'" */
|
||||
|
||||
if (x_key & ALT (0)) { /* is an alt key ? */
|
||||
command = CK_Macro (x_key - ALT (0));
|
||||
goto fin;
|
||||
}
|
||||
if (x_key < ' ') { /* is a ctrl key ? */
|
||||
command = CK_Macro (x_key);
|
||||
goto fin;
|
||||
}
|
||||
fin:
|
||||
|
||||
*cmd = command;
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
#include "../src/main.h" /* drop_menus */
|
||||
#include "../src/learn.h" /* learn_keys */
|
||||
|
||||
#include "edit-widget.h"
|
||||
#include "../src/cmddef.h"
|
||||
|
||||
static void
|
||||
menu_cmd (int command)
|
||||
{
|
||||
|
@ -224,7 +227,7 @@ menu_replace_cmd (void)
|
|||
static void
|
||||
menu_select_codepage_cmd (void)
|
||||
{
|
||||
menu_cmd (CK_Select_Codepage);
|
||||
menu_cmd (CK_SelectCodepage);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "../src/global.h"
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "usermap.h"
|
||||
#include "../src/dialog.h" /* B_CANCEL */
|
||||
#include "../src/wtools.h" /* QuickDialog */
|
||||
|
||||
|
@ -177,6 +176,4 @@ edit_options_dialog (void)
|
|||
/* Load or unload syntax rules if the option has changed */
|
||||
if (option_syntax_highlighting != old_syntax_hl)
|
||||
edit_load_syntax (wedit, NULL, option_syntax_type);
|
||||
/* Load usermap if it's needed */
|
||||
edit_load_user_map (wedit);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#include "edit-impl.h"
|
||||
#include "edit-widget.h"
|
||||
#include "editcmddef.h" /* list of commands */
|
||||
#include "../src/cmddef.h" /* list of commands */
|
||||
#include "usermap.h"
|
||||
|
||||
#include "../src/wtools.h"
|
||||
|
@ -333,10 +333,10 @@ split_line(char *str)
|
|||
static void
|
||||
keymap_add(GArray *keymap, int key, int cmd)
|
||||
{
|
||||
edit_key_map_type new_one, *map;
|
||||
global_key_map_t new_one, *map;
|
||||
guint i;
|
||||
|
||||
map = &(g_array_index(keymap, edit_key_map_type, 0));
|
||||
map = &(g_array_index(keymap, global_key_map_t, 0));
|
||||
for (i = 0; i < keymap->len; i++) {
|
||||
if (map[i].key == key) {
|
||||
map[i].command = cmd;
|
||||
|
@ -583,8 +583,8 @@ load_user_keymap(config_t *cfg, const char *file)
|
|||
{0, 0}
|
||||
};
|
||||
|
||||
cfg->keymap = g_array_new(TRUE, FALSE, sizeof(edit_key_map_type));
|
||||
cfg->ext_keymap = g_array_new(TRUE, FALSE, sizeof(edit_key_map_type));
|
||||
cfg->keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
cfg->ext_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
|
||||
if (!parse_file(cfg, file, cmd)) {
|
||||
return FALSE;
|
||||
|
@ -629,8 +629,8 @@ edit_load_user_map(WEdit *edit)
|
|||
}
|
||||
}
|
||||
|
||||
edit->user_map = (edit_key_map_type *) cfg.keymap->data;
|
||||
edit->ext_map = (edit_key_map_type *) cfg.ext_keymap->data;
|
||||
edit->user_map = (global_key_map_t *) cfg.keymap->data;
|
||||
edit->ext_map = (global_key_map_t *) cfg.ext_keymap->data;
|
||||
memcpy(edit->labels, cfg.labels, sizeof(edit->labels));
|
||||
|
||||
g_free(file);
|
||||
|
|
|
@ -14,6 +14,7 @@ LIBFILES_CONST = \
|
|||
edit.spell.rc \
|
||||
mc.lib \
|
||||
filehighlight.ini \
|
||||
mc.keymap \
|
||||
mc.menu
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
[editor]
|
||||
|
||||
EditXStore = ctrl-g
|
||||
EditXPaste = ctrl-v
|
||||
EditXCut = ctrl-x
|
||||
|
||||
EditDeleteLine = ctrl-y
|
||||
EditDeleteToLineEnd = ctrl-k
|
||||
EditDeleteToLineBegin =
|
||||
|
||||
EditLeft = left
|
||||
EditRight = right
|
||||
EditUp = up
|
||||
EditDown = down
|
||||
EditEnter = enter
|
||||
EditBackSpace = backspace
|
||||
EditDelete = delete
|
||||
EditPageUp = pgup
|
||||
EditPageDown = pgdn
|
||||
EditWordLeft = ctrl-left
|
||||
EditWordRight = ctrl-right
|
||||
EditHome = home
|
||||
EditEnd = end
|
||||
EditTab = tab
|
||||
EditUndo = alt-backspace
|
||||
EditBeginningOfText = ctrl-shift-pgup
|
||||
EditEndOfText = ctrl-shift-pgdn
|
||||
EditScrollUp = ctrl-up
|
||||
EditScrollDown = ctrl-down
|
||||
EditReturn = shift-enter
|
||||
EditBeginPage =
|
||||
EditEndPage =
|
||||
EditDeleteWordLeft = alt-f
|
||||
EditDeleteWordRight = alt-d
|
||||
EditParagraphUp =
|
||||
EditParagraphDown =
|
||||
EditSave = f2
|
||||
EditLoad =
|
||||
EditNew =
|
||||
EditSaveas = f12
|
||||
EditMark = f3
|
||||
EditCopy = f5
|
||||
EditMove = f6
|
||||
EditRemove = f8
|
||||
EditUnmark =
|
||||
EditFind = f7
|
||||
|
||||
EditPageUpHighlight = shift-pgup
|
||||
EditPageDownHighlight = shift-pgdn
|
||||
EditLeftHighlight = shift-left
|
||||
EditRightHighlight = shift-right
|
||||
EditWordLeftHighlight = ctrl-shift-left
|
||||
EditWordRightHighlight = ctrl-shift-right
|
||||
EditUpHighlight = shift-up
|
||||
EditDownHighlight = shift-down
|
||||
EditHomeHighlight = shift-home
|
||||
EditEndHighlight = shift-end
|
||||
EditBeginningOfTextHighlight = ctrl-shift-home
|
||||
EditEndOfTextHighlight = ctrl-shift-end
|
||||
EditBeginPageHighlight = ctrl-shift-pgup
|
||||
EditEndPageHighlight = ctrl-shift-pgdn
|
||||
EditScrollUpHighlight =
|
||||
EditScrollDownHighlight =
|
||||
EditParagraphUpHighlight =
|
||||
EditParagraphDownHighlight =
|
||||
|
||||
EditPageUpAltHighlight = alt-pgup
|
||||
EditPageDownAltHighlight = alt-pgdn
|
||||
EditLeftAltHighlight = alt-left
|
||||
EditRightAltHighlight = alt-right
|
||||
EditWordLeftAltHighlight = ctrl-alt-left
|
||||
EditWordRightAltHighlight = ctrl-alt-right
|
||||
EditUpAltHighlight = alt-up
|
||||
EditDownAltHighlight = alt-down
|
||||
EditHomeAltHighlight = alt-home
|
||||
EditEndAltHighlight = alt-end
|
||||
EditBeginningOfTextAltHighlight = ctrl-alt-home
|
||||
EditEndOfTextHighlight = ctrl-alt-end
|
||||
EditBeginPageHighlight = ctrl-alt-pgup
|
||||
EditEndPageAltHighlight = ctrl-alt-pgdn
|
||||
EditScrollUpAltHighlight =
|
||||
EditScrollDownAltHighlight =
|
||||
EditParagraphUpAltHighlight =
|
||||
EditParagraphDownAltHighlight =
|
||||
|
||||
EditSaveBlock = ctrl-f
|
||||
EditColumnMark = f13
|
||||
EditFindAgain = f17
|
||||
EditReplace = f4
|
||||
EditReplaceAgain = f14
|
||||
EditCompleteWord = alt-tab
|
||||
EditDebugStart =
|
||||
EditDebugStop =
|
||||
EditDebugToggleBreak =
|
||||
EditDebugClear =
|
||||
EditDebugNext =
|
||||
EditDebugStep =
|
||||
EditDebugBackTrace =
|
||||
EditDebugContinue =
|
||||
EditDebugEnterCommand =
|
||||
EditDebugUntilCurser =
|
||||
EditInsertFile = f15
|
||||
EditExit = f10
|
||||
EditToggleInsert = ins
|
||||
EditHelp = f1
|
||||
EditDate =
|
||||
EditRefresh = ctrl-l
|
||||
EditGoto = alt-l
|
||||
EditManPage =
|
||||
EditSort = alt-t
|
||||
EditMail =
|
||||
EditCancel =
|
||||
EditComplete =
|
||||
|
||||
EditParagraphFormat = alt-p
|
||||
EditUtil =
|
||||
EditTypeLoadPython =
|
||||
EditFindFile =
|
||||
EditCtags =
|
||||
EditMatchBracket = alt-b
|
||||
EditTerminal =
|
||||
EditTerminalApp =
|
||||
EditExtCmd = alt-u
|
||||
EditUserMenu = f11
|
||||
EditSaveDesktop =
|
||||
EditNewWindow =
|
||||
EditCycle =
|
||||
EditMenu = f9
|
||||
EditSaveAndQuit =
|
||||
EditRunAnother =
|
||||
EditCheckSaveAndQuit =
|
||||
EditMaximize =
|
||||
EditDeleteMacro =
|
||||
EditToggleBookmark = alt-k
|
||||
EditFlushBookmarks = alt-o
|
||||
EditNextBookmark = alt-j
|
||||
EditPrevBookmark = alt-i
|
||||
|
||||
EditSelectionHistory =
|
||||
EditShell = ctrl-o
|
||||
EditInsertLiteral = ctrl-q
|
||||
EditExecuteMacro = ctrl-a
|
||||
EditBeginorEndMacro = ctrl-r
|
||||
EditBeginRecordMacro =
|
||||
EditEndRecordMacro =
|
||||
EditToggleLineState = alt-n
|
||||
|
||||
|
||||
[viewer:hex]
|
||||
HexViewToggleNavigationMode = tab
|
||||
ViewMoveToBol = ctrl-a; home
|
||||
ViewMoveToEol = ctrl-e; end
|
||||
ViewMoveLeft = b; left
|
||||
ViewMoveRight = f; right
|
||||
ViewMoveUp = k; y; up
|
||||
ViewMoveDown = j; delete; down
|
||||
|
||||
[viewer]
|
||||
ViewSearch = question; slash; f7
|
||||
ViewContinueSearch = ctrl-r; ctrl-s; f17
|
||||
ViewMoveToBol = home
|
||||
ViewMoveToEol = end
|
||||
ViewMoveLeft = h; left
|
||||
ViewMoveRight = l; right
|
||||
ViewMoveUp = k; y; insert; up
|
||||
ViewMoveDown = j; e; delete; down
|
||||
ViewMovePgDn = f; space; pgdn
|
||||
ViewMovePgUp = b; pgup
|
||||
ViewMoveHalfPgDn = d
|
||||
ViewMoveHalfPgUp = u
|
||||
ViewGotoBookmark = m
|
||||
ViewNewBookmark = r
|
||||
ViewNextFile = ctrl-f
|
||||
ViewPrevFile = ctrl-b
|
||||
ViewQuit = q; esc
|
||||
SelectCodepage = ctrl-t
|
||||
ShowCommandLine = ctrl-o
|
||||
ViewToggleRuler = alt-r
|
||||
|
||||
[main]
|
||||
CmdMenuLastSelected = f19
|
||||
CmdQuietQuit = f20
|
||||
CmdSingleDirsize = ctrl-space
|
||||
CmdCopyCurrentPathname = alt-a
|
||||
CmdCopyOtherPathname = alt-A
|
||||
CmdQuickCd = alt-c
|
||||
CmdQuickChdir = ctrl-backslash
|
||||
CmdSuspend = ctrl-z
|
||||
CmdFilteredView = alt-exclamation
|
||||
CmdFind = alt-question
|
||||
CmdReread = ctrl-r
|
||||
CmdToggleListing = alt-t
|
||||
CmdSwapPanel = ctrl-u
|
||||
ShowCommandLine = ctrl-o
|
||||
CmdToggleShowHidden = alt-dot
|
||||
|
||||
ExtMap1 = ctrl-x
|
||||
[main:xmap]
|
||||
|
||||
|
||||
[panel]
|
||||
PanelStartSearch = ctrl-s; alt-s
|
||||
PanelMarkFile = ins
|
||||
PanelMoveDown = down; ctrl-n
|
||||
PanelMoveUp = up; ctrl-p
|
||||
PanelMoveLeft = left
|
||||
PanelMoveRight = right
|
||||
PanelPrevPage = pgup; alt-v
|
||||
PanelNextPage = pgdn; ctrl-v
|
||||
PanelDoEnter = enter
|
||||
PanelChdirOtherPanel = alt-o
|
||||
PanelChdirToReadlink = alt-l
|
||||
PanelViewSimple = shift-F3
|
||||
PanelEditNew = F14
|
||||
PanelCopyLocal = F15
|
||||
PanelRenameLocal = F16
|
||||
PanelDeleteLocal = F18
|
||||
PanelReverseSelection = alt-asterisk
|
||||
PanelSelect = alt-plus
|
||||
PanelUnselect = alt-minus
|
||||
PanelCtrlNextPage = ctrl-pgdn
|
||||
PanelCtrlPrevPage = ctrl-pgup
|
||||
PanelDirectoryHistoryList = alt-shift-h
|
||||
PanelDirectoryHistoryNext = alt-u
|
||||
PanelDirectoryHistoryPrev = alt-y
|
||||
PanelGotoBottomFile = alt-j
|
||||
PanelGotoMiddleFile = alt-r
|
||||
PanelSyncOtherPanel = alt-i
|
||||
PanelGotoTopFile = alt-g
|
||||
PanelSetPanelEncoding = ctrl-t
|
||||
PanelMoveHome = alt-lt; home
|
||||
PanelMoveEnd = alt-gt; end
|
||||
|
||||
[panel:xmap]
|
||||
|
||||
[input]
|
||||
InputBol = ctrl-a; alt-lt; home
|
||||
InputEol = ctrl-e; alt-gt; end
|
||||
InputMoveLeft = left; alt-left
|
||||
InputWordLeft = ctrl-left
|
||||
InputBackwardChar = ctrl-b
|
||||
InputBackwardWord = alt-b
|
||||
InputMoveRight = right; alt-right
|
||||
InputWordRight = ctrl-right
|
||||
InputForwardChar = ctrl-f
|
||||
InputForwardWord = alt-f
|
||||
|
||||
InputBackwardDelete = backspace
|
||||
InputDeleteChar = delete
|
||||
InputKillWord = alt-d
|
||||
InputBackwardKillWord = alt-backspace
|
||||
InputSetMark =
|
||||
InputKillRegion = ctrl-w
|
||||
InputKillSave = alt-w
|
||||
InputYank = ctrl-y
|
||||
InputKillLine = ctrl-k
|
||||
InputHistoryPrev = alt-p; ctrl-down
|
||||
InputHistoryNext = alt-n; ctrl-up
|
||||
InputHistoryShow = alt-h
|
||||
InputComplete = alt-tab
|
|
@ -71,6 +71,7 @@ SRCS = args.c args.h achown.c achown.h background.c background.h \
|
|||
user.h util.c util.h utilunix.c vfsdummy.h \
|
||||
widget.c widget.h wtools.c wtools.h unixcompat.h \
|
||||
ecs.h ecs.c \
|
||||
keybind.c keybind.h cmddef.h \
|
||||
strutil.h strutil.c strutilascii.c strutil8bit.c strutilutf8.c \
|
||||
search/search.h strescape.c strescape.h
|
||||
|
||||
|
|
10
src/args.c
10
src/args.c
|
@ -77,6 +77,9 @@ char *mc_args__last_wd_file = NULL;
|
|||
/* when enabled NETCODE, use folowing file as logfile */
|
||||
char *mc_args__netfs_logfile = NULL;
|
||||
|
||||
/* keymap file */
|
||||
char *mc_args__keymap_file = NULL;
|
||||
|
||||
/* Debug level*/
|
||||
int mc_args__debug_level = 0;
|
||||
|
||||
|
@ -219,6 +222,13 @@ static const GOptionEntry argument_terminal_table[] = {
|
|||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
"keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
|
||||
&mc_args__keymap_file,
|
||||
N_("Load definitions of key bindings from specified file"),
|
||||
"<file>"
|
||||
},
|
||||
|
||||
{NULL}
|
||||
};
|
||||
#undef ARGS_TERM_OPTIONS
|
||||
|
|
|
@ -19,6 +19,7 @@ extern char *mc_args__skin;
|
|||
extern gboolean mc_args__version;
|
||||
extern char *mc_args__last_wd_file;
|
||||
extern char *mc_args__netfs_logfile;
|
||||
extern char *mc_args__keymap_file;
|
||||
extern int mc_args__debug_level;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
|
10
src/cmd.c
10
src/cmd.c
|
@ -51,9 +51,10 @@
|
|||
#include "../src/tty/key.h" /* ALT() macro */
|
||||
#include "../src/tty/win.h" /* do_enter_ca_mode() */
|
||||
|
||||
#include "../src/search/search.h"
|
||||
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
#include "../src/search/search.h"
|
||||
#include "../src/viewer/mcviewer.h"
|
||||
#include "../src/filehighlight/fhl.h" /* MC_FHL_INI_FILE */
|
||||
|
||||
#include "cmd.h" /* Our definitions */
|
||||
#include "fileopctx.h"
|
||||
|
@ -79,8 +80,7 @@
|
|||
#include "history.h"
|
||||
#include "strutil.h"
|
||||
#include "dir.h"
|
||||
#include "../src/viewer/mcviewer.h"
|
||||
#include "../src/filehighlight/fhl.h" /* MC_FHL_INI_FILE */
|
||||
#include "cmddef.h" /* CK_InputHistoryShow */
|
||||
|
||||
#ifndef MAP_FILE
|
||||
# define MAP_FILE 0
|
||||
|
@ -888,7 +888,7 @@ void
|
|||
history_cmd (void)
|
||||
{
|
||||
/* show the history of command line widget */
|
||||
send_message (&cmdline->widget, WIDGET_KEY, ALT ('h'));
|
||||
send_message (&cmdline->widget, WIDGET_COMMAND, CK_InputHistoryShow);
|
||||
}
|
||||
|
||||
void swap_cmd (void)
|
||||
|
|
|
@ -0,0 +1,362 @@
|
|||
|
||||
/** \file
|
||||
* \brief Header: editor constants
|
||||
*/
|
||||
|
||||
#ifndef MC_CMD_DEF_H
|
||||
#define MC_CMD_DEF_H
|
||||
|
||||
/** \todo In the distant future, keyboards will be invented with a
|
||||
* separate key for each one of these commands *sigh*
|
||||
*/
|
||||
|
||||
/* special commands */
|
||||
#define CK_Insert_Char -1
|
||||
#define CK_Ignore_Key 0
|
||||
|
||||
/* cursor movements */
|
||||
#define CK_BackSpace 1
|
||||
#define CK_Delete 2
|
||||
#define CK_Enter 3
|
||||
#define CK_Page_Up 4
|
||||
#define CK_Page_Down 5
|
||||
#define CK_Left 6
|
||||
#define CK_Right 7
|
||||
#define CK_Word_Left 8
|
||||
#define CK_Word_Right 9
|
||||
#define CK_Up 10
|
||||
#define CK_Down 11
|
||||
#define CK_Home 12
|
||||
#define CK_End 13
|
||||
#define CK_Tab 14
|
||||
#define CK_Undo 15
|
||||
#define CK_Beginning_Of_Text 16
|
||||
#define CK_End_Of_Text 17
|
||||
#define CK_Scroll_Up 18
|
||||
#define CK_Scroll_Down 19
|
||||
#define CK_Return 20
|
||||
#define CK_Begin_Page 21
|
||||
#define CK_End_Page 22
|
||||
#define CK_Delete_Word_Left 23
|
||||
#define CK_Delete_Word_Right 24
|
||||
#define CK_Paragraph_Up 25
|
||||
#define CK_Paragraph_Down 26
|
||||
|
||||
/* file commands */
|
||||
#define CK_Save 101
|
||||
#define CK_Load 102
|
||||
#define CK_New 103
|
||||
#define CK_Save_As 104
|
||||
#define CK_Load_Prev_File 111
|
||||
#define CK_Load_Next_File 112
|
||||
#define CK_Load_Syntax_File 121
|
||||
#define CK_Load_Menu_File 122
|
||||
|
||||
/* block commands */
|
||||
#define CK_Mark 201
|
||||
#define CK_Copy 202
|
||||
#define CK_Move 203
|
||||
#define CK_Remove 204
|
||||
#define CK_Unmark 206
|
||||
#define CK_Save_Block 207
|
||||
#define CK_Column_Mark 208
|
||||
|
||||
/* search and replace */
|
||||
#define CK_Find 301
|
||||
#define CK_Find_Again 302
|
||||
#define CK_Replace 303
|
||||
#define CK_Replace_Again 304
|
||||
#define CK_Complete_Word 305
|
||||
|
||||
/* debugger commands */
|
||||
#define CK_Debug_Start 350
|
||||
#define CK_Debug_Stop 351
|
||||
#define CK_Debug_Toggle_Break 352
|
||||
#define CK_Debug_Clear 353
|
||||
#define CK_Debug_Next 354
|
||||
#define CK_Debug_Step 355
|
||||
#define CK_Debug_Back_Trace 356
|
||||
#define CK_Debug_Continue 357
|
||||
#define CK_Debug_Enter_Command 358
|
||||
#define CK_Debug_Until_Curser 359
|
||||
|
||||
/* misc */
|
||||
#define CK_Insert_File 401
|
||||
#define CK_Exit 402
|
||||
#define CK_Toggle_Insert 403
|
||||
#define CK_Help 404
|
||||
#define CK_Date 405
|
||||
#define CK_Refresh 406
|
||||
#define CK_Goto 407
|
||||
#define CK_Delete_Line 408
|
||||
#define CK_Delete_To_Line_End 409
|
||||
#define CK_Delete_To_Line_Begin 410
|
||||
#define CK_Man_Page 411
|
||||
#define CK_Sort 412
|
||||
#define CK_Mail 413
|
||||
#define CK_Cancel 414
|
||||
#define CK_Complete 415
|
||||
#define CK_Paragraph_Format 416
|
||||
#define CK_Util 417
|
||||
#define CK_Type_Load_Python 418
|
||||
#define CK_Find_File 419
|
||||
#define CK_Ctags 420
|
||||
#define CK_Match_Bracket 421
|
||||
#define CK_Terminal 422
|
||||
#define CK_Terminal_App 423
|
||||
#define CK_ExtCmd 424
|
||||
#define CK_User_Menu 425
|
||||
#define CK_Find_Definition 426
|
||||
|
||||
/* application control */
|
||||
#define CK_Save_Desktop 451
|
||||
#define CK_New_Window 452
|
||||
#define CK_Cycle 453
|
||||
#define CK_Menu 454
|
||||
#define CK_Save_And_Quit 455
|
||||
#define CK_Run_Another 456
|
||||
#define CK_Check_Save_And_Quit 457
|
||||
#define CK_Maximize 458
|
||||
|
||||
#define CK_Toggle_Tab_TWS 470
|
||||
#define CK_Toggle_Syntax 480
|
||||
#define CK_Toggle_Line_State 490
|
||||
|
||||
/* macro */
|
||||
#define CK_Begin_Record_Macro 501
|
||||
#define CK_End_Record_Macro 502
|
||||
#define CK_Delete_Macro 503
|
||||
|
||||
/* book mark */
|
||||
#define CK_Toggle_Bookmark 550
|
||||
#define CK_Flush_Bookmarks 551
|
||||
#define CK_Next_Bookmark 552
|
||||
#define CK_Prev_Bookmark 553
|
||||
|
||||
/* highlight commands */
|
||||
#define CK_Page_Up_Highlight 604
|
||||
#define CK_Page_Down_Highlight 605
|
||||
#define CK_Left_Highlight 606
|
||||
#define CK_Right_Highlight 607
|
||||
#define CK_Word_Left_Highlight 608
|
||||
#define CK_Word_Right_Highlight 609
|
||||
#define CK_Up_Highlight 610
|
||||
#define CK_Down_Highlight 611
|
||||
#define CK_Home_Highlight 612
|
||||
#define CK_End_Highlight 613
|
||||
#define CK_Beginning_Of_Text_Highlight 614
|
||||
#define CK_End_Of_Text_Highlight 615
|
||||
#define CK_Begin_Page_Highlight 616
|
||||
#define CK_End_Page_Highlight 617
|
||||
#define CK_Scroll_Up_Highlight 618
|
||||
#define CK_Scroll_Down_Highlight 619
|
||||
#define CK_Paragraph_Up_Highlight 620
|
||||
#define CK_Paragraph_Down_Highlight 621
|
||||
|
||||
/* alt highlight commands */
|
||||
#define CK_Page_Up_Alt_Highlight 654
|
||||
#define CK_Page_Down_Alt_Highlight 655
|
||||
#define CK_Left_Alt_Highlight 656
|
||||
#define CK_Right_Alt_Highlight 657
|
||||
#define CK_Word_Left_Alt_Highlight 658
|
||||
#define CK_Word_Right_Alt_Highlight 659
|
||||
#define CK_Up_Alt_Highlight 660
|
||||
#define CK_Down_Alt_Highlight 661
|
||||
#define CK_Home_Alt_Highlight 662
|
||||
#define CK_End_Alt_Highlight 663
|
||||
#define CK_Beginning_Of_Text_Alt_Highlight 664
|
||||
#define CK_End_Of_Text_Alt_Highlight 665
|
||||
#define CK_Begin_Page_Alt_Highlight 666
|
||||
#define CK_End_Page_Alt_Highlight 667
|
||||
#define CK_Scroll_Up_Alt_Highlight 668
|
||||
#define CK_Scroll_Down_Alt_Highlight 669
|
||||
#define CK_Paragraph_Up_Alt_Highlight 670
|
||||
#define CK_Paragraph_Down_Alt_Highlight 671
|
||||
|
||||
/* X clipboard operations */
|
||||
#define CK_XStore 701
|
||||
#define CK_XCut 702
|
||||
#define CK_XPaste 703
|
||||
#define CK_Selection_History 704
|
||||
|
||||
#define CK_Shell 801
|
||||
|
||||
|
||||
/* C-x or similar */
|
||||
#define CK_Ext_Mode 820
|
||||
|
||||
|
||||
#define CK_Insert_Literal 851
|
||||
#define CK_Execute_Macro 852
|
||||
#define CK_Begin_End_Macro 853
|
||||
|
||||
|
||||
/* common */
|
||||
#define CK_ShowCommandLine 2001
|
||||
#define CK_SelectCodepage 2002
|
||||
#define CK_StartExtMap1 2021
|
||||
#define CK_StartExtMap2 2022
|
||||
|
||||
/* text fields*/
|
||||
#define CK_InputBol 4001
|
||||
#define CK_InputEol 4002
|
||||
#define CK_InputMoveLeft 4003
|
||||
#define CK_InputWordLeft 4004
|
||||
#define CK_InputBackwardChar 4005
|
||||
#define CK_InputBackwardWord 4006
|
||||
#define CK_InputMoveRight 4007
|
||||
#define CK_InputWordRight 4008
|
||||
#define CK_InputForwardChar 4009
|
||||
#define CK_InputForwardWord 4010
|
||||
#define CK_InputBackwardDelete 4011
|
||||
#define CK_InputDeleteChar 4012
|
||||
#define CK_InputKillWord 4013
|
||||
#define CK_InputBackwardKillWord 4014
|
||||
#define CK_InputSetMark 4015
|
||||
#define CK_InputKillRegion 4016
|
||||
#define CK_InputKillSave 4017
|
||||
#define CK_InputYank 4018
|
||||
#define CK_InputKillLine 4020
|
||||
#define CK_InputHistoryPrev 4021
|
||||
#define CK_InputHistoryNext 4022
|
||||
#define CK_InputHistoryShow 4023
|
||||
#define CK_InputComplete 4024
|
||||
|
||||
/* Viewer */
|
||||
#define CK_ViewSearch 5001
|
||||
#define CK_ViewContinueSearch 5002
|
||||
#define CK_ViewGotoBookmark 5003
|
||||
#define CK_ViewNewBookmark 5004
|
||||
#define CK_ViewMoveUp 5005
|
||||
#define CK_ViewMoveDown 5006
|
||||
#define CK_ViewMoveLeft 5007
|
||||
#define CK_ViewMoveRight 5008
|
||||
#define CK_ViewMovePgDn 5009
|
||||
#define CK_ViewMovePgUp 5010
|
||||
#define CK_ViewMoveHalfPgDn 5011
|
||||
#define CK_ViewMoveHalfPgUp 5012
|
||||
#define CK_ViewMoveToBol 5013
|
||||
#define CK_ViewMoveToEol 5014
|
||||
#define CK_ViewNextFile 5015
|
||||
#define CK_ViewPrevFile 5016
|
||||
#define CK_ViewToggleRuler 5017
|
||||
#define CK_HexViewToggleNavigationMode 5018
|
||||
#define CK_ViewQuit 5020
|
||||
|
||||
/* main commands */
|
||||
#define CK_ChmodCmd 7001
|
||||
#define CK_ChownAdvancedCmd 7002
|
||||
#define CK_ChownCmd 7003
|
||||
#define CK_CompareDirsCmd 7004
|
||||
#define CK_ConfigureBox 7005
|
||||
#define CK_ConfigureVfs 7006
|
||||
#define CK_ConfirmBox 7007
|
||||
#define CK_CopyCmd 7008
|
||||
#define CK_CopyCurrentPathname 7009
|
||||
#define CK_CopyOtherPathname 7010
|
||||
#define CK_DeleteCmd 7011
|
||||
#define CK_DirsizesCmd 7012
|
||||
#define CK_DisplayBitsBox 7013
|
||||
#define CK_EditCmd 7014
|
||||
#define CK_EditMcMenuCmd 7015
|
||||
#define CK_EditSymlinkCmd 7016
|
||||
#define CK_EditSyntaxCmd 7017
|
||||
#define CK_EditUserMenuCmd 7018
|
||||
#define CK_ExternalPanelize 7020
|
||||
#define CK_FilterCmd 7021
|
||||
#define CK_FilteredViewCmd 7022
|
||||
#define CK_FindCmd 7023
|
||||
#define CK_FishlinkCmd 7024
|
||||
#define CK_FtplinkCmd 7025
|
||||
#define CK_HistoryCmd 7026
|
||||
#define CK_InfoCmd 7027
|
||||
#define CK_JobsCmd 7028
|
||||
#define CK_LayoutCmd 7029
|
||||
#define CK_LearnKeys 7030
|
||||
#define CK_LinkCmd 7031
|
||||
#define CK_ListingCmd 7033
|
||||
#define CK_MenuLastSelectedCmd 7034
|
||||
#define CK_MkdirCmd 7035
|
||||
#define CK_QuickCdCmd 7036
|
||||
#define CK_QuickChdirCmd 7037
|
||||
#define CK_QuickViewCmd 7038
|
||||
#define CK_RenCmd 7039
|
||||
#define CK_RereadCmd 7040
|
||||
#define CK_ReselectVfs 7041
|
||||
#define CK_ReverseSelectionCmd 7043
|
||||
#define CK_SaveSetupCmd 7044
|
||||
#define CK_SelectCmd 7045
|
||||
#define CK_SingleDirsizeCmd 7046
|
||||
#define CK_SuspendCmd 7047
|
||||
#define CK_SwapCmd 7048
|
||||
#define CK_SymlinkCmd 7049
|
||||
#define CK_ToggleListingCmd 7050
|
||||
#define CK_TreeCmd 7051
|
||||
#define CK_UndeleteCmd 7052
|
||||
#define CK_UnselectCmd 7053
|
||||
#define CK_UserFileMenuCmd 7054
|
||||
#define CK_ViewCmd 7055
|
||||
#define CK_ViewFileCmd 7056
|
||||
#define CK_QuietQuitCmd 7058
|
||||
#define CK_CopyCurrentTagged 7059
|
||||
#define CK_CopyCurrentReadlink 7060
|
||||
#define CK_CopyOtherReadlink 7061
|
||||
#define CK_AddHotlist 7062
|
||||
#define CK_QuitCmd 7064
|
||||
#define CK_CopyOtherTarget 7065
|
||||
#define CK_ToggleShowHidden 7066
|
||||
|
||||
/* panels */
|
||||
#define CK_PanelChdirOtherPanel 8001
|
||||
#define CK_PanelChdirToReadlink 8002
|
||||
#define CK_PanelCmdCopyLocal 8003
|
||||
#define CK_PanelCmdDeleteLocal 8004
|
||||
#define CK_PanelCmdDoEnter 8005
|
||||
#define CK_PanelCmdEditNew 8006
|
||||
#define CK_PanelCmdRenameLocal 8007
|
||||
#define CK_PanelCmdReverseSelection 8008
|
||||
#define CK_PanelCmdSelect 8009
|
||||
#define CK_PanelCmdUnselect 8010
|
||||
#define CK_PanelCmdViewSimple 8011
|
||||
#define CK_PanelCtrlNextPage 8012
|
||||
#define CK_PanelCtrlPrevPage 8013
|
||||
#define CK_PanelDirectoryHistoryList 8014
|
||||
#define CK_PanelDirectoryHistoryNext 8015
|
||||
#define CK_PanelDirectoryHistoryPrev 8016
|
||||
#define CK_PanelGotoBottomFile 8017
|
||||
#define CK_PanelGotoMiddleFile 8018
|
||||
#define CK_PanelGotoTopFile 8019
|
||||
#define CK_PanelMarkFile 8020
|
||||
#define CK_PanelMoveDown 8021
|
||||
#define CK_PanelMoveEnd 8022
|
||||
#define CK_PanelMoveHome 8023
|
||||
#define CK_PanelMoveUp 8024
|
||||
#define CK_PanelMoveLeft 8025
|
||||
#define CK_PanelMoveRight 8026
|
||||
#define CK_PanelNextPage 8027
|
||||
#define CK_PanelPrevPage 8028
|
||||
#define CK_PanelSetPanelEncoding 8029
|
||||
#define CK_PanelStartSearch 8030
|
||||
#define CK_PanelSyncOtherPanel 8031
|
||||
|
||||
/*
|
||||
Process a block through a shell command: CK_Pipe_Block(i) executes shell_cmd[i].
|
||||
shell_cmd[i] must process the file ~/cooledit.block and output ~/cooledit.block
|
||||
which is then inserted into the text in place of the original block. shell_cmd[i] must
|
||||
also produce a file homedir/cooledit.error . If this file is not empty an error will
|
||||
have been assumed to have occured, and the block will not be replaced.
|
||||
TODO: bring up a viewer to display the error message instead of inserting
|
||||
it into the text, which is annoying.
|
||||
*/
|
||||
#define CK_Pipe_Block(i) (1000+(i))
|
||||
#define SHELL_COMMANDS_i {"/edit.indent.rc", "/edit.spell.rc", /* and so on */ 0 }
|
||||
#define CK_Macro(i) (2000+(i))
|
||||
#define CK_Last_Macro CK_Macro(0x7FFF)
|
||||
#else
|
||||
|
||||
#define CK_User_Command(i) ((i) | (1 << 16))
|
||||
#define IS_USER_COMMAND(i) ((i) & (1 << 16))
|
||||
#define CK_Macro(i) ((i) | (1 << 17))
|
||||
#define IS_MACRO_COMMAND(i) ((i) & (1 << 17))
|
||||
|
||||
#endif /* MC_CMD_DEF_H */
|
|
@ -41,6 +41,7 @@ typedef enum {
|
|||
WIDGET_DRAW, /* Sent to widget to draw themselves */
|
||||
WIDGET_KEY, /* Sent to widgets on key press */
|
||||
WIDGET_HOTKEY, /* Sent to widget to catch preprocess key */
|
||||
WIDGET_COMMAND, /* Send to widget to handle command */
|
||||
WIDGET_DESTROY, /* Sent to widget at destruction time */
|
||||
WIDGET_CURSOR, /* Sent to widget to position the cursor */
|
||||
WIDGET_IDLE, /* Sent to widgets with options & W_WANT_IDLE*/
|
||||
|
|
|
@ -0,0 +1,718 @@
|
|||
/*
|
||||
Copyright (C) 2009 The Free Software Foundation, Inc.
|
||||
|
||||
Written by: 2005 Vitja Makarov
|
||||
2009 Ilia Maslakov
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "tty/win.h"
|
||||
#include "tty/key.h" /* KEY_M_ */
|
||||
#include "tty/tty.h" /* keys */
|
||||
#include "wtools.h"
|
||||
#include "strutil.h"
|
||||
|
||||
#include "keybind.h"
|
||||
|
||||
static const name_key_map_t command_names[] = {
|
||||
{ "EditNoCommand", CK_Ignore_Key },
|
||||
{ "EditIgnoreKey", CK_Ignore_Key },
|
||||
{ "EditBackSpace", CK_BackSpace },
|
||||
{ "EditDelete", CK_Delete },
|
||||
{ "EditEnter", CK_Enter },
|
||||
{ "EditPageUp", CK_Page_Up },
|
||||
{ "EditPageDown", CK_Page_Down },
|
||||
{ "EditLeft", CK_Left },
|
||||
{ "EditRight", CK_Right },
|
||||
{ "EditWordLeft", CK_Word_Left },
|
||||
{ "EditWordRight", CK_Word_Right },
|
||||
{ "EditUp", CK_Up },
|
||||
{ "EditDown", CK_Down },
|
||||
{ "EditHome", CK_Home },
|
||||
{ "EditEnd", CK_End },
|
||||
{ "EditTab", CK_Tab },
|
||||
{ "EditUndo", CK_Undo },
|
||||
{ "EditBeginningOfText", CK_Beginning_Of_Text },
|
||||
{ "EditEndOfText", CK_End_Of_Text },
|
||||
{ "EditScrollUp", CK_Scroll_Up },
|
||||
{ "EditScrollDown", CK_Scroll_Down },
|
||||
{ "EditReturn", CK_Return },
|
||||
{ "EditBeginPage", CK_Begin_Page },
|
||||
{ "EditEndPage", CK_End_Page },
|
||||
{ "EditDeleteWordLeft", CK_Delete_Word_Left },
|
||||
{ "EditDeleteWordRight", CK_Delete_Word_Right },
|
||||
{ "EditParagraphUp", CK_Paragraph_Up },
|
||||
{ "EditParagraphDown", CK_Paragraph_Down },
|
||||
{ "EditSave", CK_Save },
|
||||
{ "EditLoad", CK_Load },
|
||||
{ "EditNew", CK_New },
|
||||
{ "EditSaveas", CK_Save_As },
|
||||
{ "EditMark", CK_Mark },
|
||||
{ "EditCopy", CK_Copy },
|
||||
{ "EditMove", CK_Move },
|
||||
{ "EditRemove", CK_Remove },
|
||||
{ "EditUnmark", CK_Unmark },
|
||||
{ "EditSaveBlock", CK_Save_Block },
|
||||
{ "EditColumnMark", CK_Column_Mark },
|
||||
{ "EditFind", CK_Find },
|
||||
{ "EditFindAgain", CK_Find_Again },
|
||||
{ "EditReplace", CK_Replace },
|
||||
{ "EditReplaceAgain", CK_Replace_Again },
|
||||
{ "EditCompleteWord", CK_Complete_Word },
|
||||
{ "EditDebugStart", CK_Debug_Start },
|
||||
{ "EditDebugStop", CK_Debug_Stop },
|
||||
{ "EditDebugToggleBreak", CK_Debug_Toggle_Break },
|
||||
{ "EditDebugClear", CK_Debug_Clear },
|
||||
{ "EditDebugNext", CK_Debug_Next },
|
||||
{ "EditDebugStep", CK_Debug_Step },
|
||||
{ "EditDebugBackTrace", CK_Debug_Back_Trace },
|
||||
{ "EditDebugContinue", CK_Debug_Continue },
|
||||
{ "EditDebugEnterCommand", CK_Debug_Enter_Command },
|
||||
{ "EditDebugUntilCurser", CK_Debug_Until_Curser },
|
||||
{ "EditInsertFile", CK_Insert_File },
|
||||
{ "EditExit", CK_Exit },
|
||||
{ "EditToggleInsert", CK_Toggle_Insert },
|
||||
{ "EditHelp", CK_Help },
|
||||
{ "EditDate", CK_Date },
|
||||
{ "EditRefresh", CK_Refresh },
|
||||
{ "EditGoto", CK_Goto },
|
||||
{ "EditDeleteLine", CK_Delete_Line },
|
||||
{ "EditDeleteToLineEnd", CK_Delete_To_Line_End },
|
||||
{ "EditDeleteToLineBegin", CK_Delete_To_Line_Begin },
|
||||
{ "EditManPage", CK_Man_Page },
|
||||
{ "EditSort", CK_Sort },
|
||||
{ "EditMail", CK_Mail },
|
||||
{ "EditCancel", CK_Cancel },
|
||||
{ "EditComplete", CK_Complete },
|
||||
{ "EditParagraphFormat", CK_Paragraph_Format },
|
||||
{ "EditUtil", CK_Util },
|
||||
{ "EditTypeLoadPython", CK_Type_Load_Python },
|
||||
{ "EditFindFile", CK_Find_File },
|
||||
{ "EditCtags", CK_Ctags },
|
||||
{ "EditMatchBracket", CK_Match_Bracket },
|
||||
{ "EditTerminal", CK_Terminal },
|
||||
{ "EditTerminalApp", CK_Terminal_App },
|
||||
{ "EditExtCmd", CK_ExtCmd },
|
||||
{ "EditUserMenu", CK_User_Menu },
|
||||
{ "EditSaveDesktop", CK_Save_Desktop },
|
||||
{ "EditNewWindow", CK_New_Window },
|
||||
{ "EditCycle", CK_Cycle },
|
||||
{ "EditMenu", CK_Menu },
|
||||
{ "EditSaveAndQuit", CK_Save_And_Quit },
|
||||
{ "EditRunAnother", CK_Run_Another },
|
||||
{ "EditCheckSaveAndQuit", CK_Check_Save_And_Quit },
|
||||
{ "EditMaximize", CK_Maximize },
|
||||
{ "EditBeginRecordMacro", CK_Begin_Record_Macro },
|
||||
{ "EditEndRecordMacro", CK_End_Record_Macro },
|
||||
{ "EditDeleteMacro", CK_Delete_Macro },
|
||||
{ "EditToggleBookmark", CK_Toggle_Bookmark },
|
||||
{ "EditFlushBookmarks", CK_Flush_Bookmarks },
|
||||
{ "EditNextBookmark", CK_Next_Bookmark },
|
||||
{ "EditPrevBookmark", CK_Prev_Bookmark },
|
||||
{ "EditPageUpHighlight", CK_Page_Up_Highlight },
|
||||
{ "EditPageDownHighlight", CK_Page_Down_Highlight },
|
||||
{ "EditLeftHighlight", CK_Left_Highlight },
|
||||
{ "EditRightHighlight", CK_Right_Highlight },
|
||||
{ "EditWordLeftHighlight", CK_Word_Left_Highlight },
|
||||
{ "EditWordRightHighlight", CK_Word_Right_Highlight },
|
||||
{ "EditUpHighlight", CK_Up_Highlight },
|
||||
{ "EditDownHighlight", CK_Down_Highlight },
|
||||
{ "EditHomeHighlight", CK_Home_Highlight },
|
||||
{ "EditEndHighlight", CK_End_Highlight },
|
||||
{ "EditBeginningOfTextHighlight", CK_Beginning_Of_Text_Highlight },
|
||||
{ "EditEndOfTextHighlight", CK_End_Of_Text_Highlight },
|
||||
{ "EditBeginPageHighlight", CK_Begin_Page_Highlight },
|
||||
{ "EditEndPageHighlight", CK_End_Page_Highlight },
|
||||
{ "EditScrollUpHighlight", CK_Scroll_Up_Highlight },
|
||||
{ "EditScrollDownHighlight", CK_Scroll_Down_Highlight },
|
||||
{ "EditParagraphUpHighlight", CK_Paragraph_Up_Highlight },
|
||||
{ "EditParagraphDownHighlight", CK_Paragraph_Down_Highlight },
|
||||
|
||||
{ "EditPageUpAltHighlight", CK_Page_Up_Alt_Highlight },
|
||||
{ "EditPageDownAltHighlight", CK_Page_Down_Alt_Highlight },
|
||||
{ "EditLeftAltHighlight", CK_Left_Alt_Highlight },
|
||||
{ "EditRightAltHighlight", CK_Right_Alt_Highlight },
|
||||
{ "EditWordLeftAltHighlight", CK_Word_Left_Alt_Highlight },
|
||||
{ "EditWordRightAltHighlight", CK_Word_Right_Alt_Highlight },
|
||||
{ "EditUpAltHighlight", CK_Up_Alt_Highlight },
|
||||
{ "EditDownAltHighlight", CK_Down_Alt_Highlight },
|
||||
{ "EditHomeAltHighlight", CK_Home_Alt_Highlight },
|
||||
{ "EditEndAltHighlight", CK_End_Alt_Highlight },
|
||||
{ "EditBeginningOfTextAltHighlight", CK_Beginning_Of_Text_Alt_Highlight },
|
||||
{ "EditEndOfTextAltHighlight", CK_End_Of_Text_Alt_Highlight },
|
||||
{ "EditBeginPageAltHighlight", CK_Begin_Page_Alt_Highlight },
|
||||
{ "EditEndPageAltHighlight", CK_End_Page_Alt_Highlight },
|
||||
{ "EditScrollUpAltHighlight", CK_Scroll_Up_Alt_Highlight },
|
||||
{ "EditScrollDownAltHighlight", CK_Scroll_Down_Alt_Highlight },
|
||||
{ "EditParagraphUpAltHighlight", CK_Paragraph_Up_Alt_Highlight },
|
||||
{ "EditParagraphDownAltHighlight", CK_Paragraph_Down_Alt_Highlight },
|
||||
|
||||
{ "EditXStore", CK_XStore },
|
||||
{ "EditXCut", CK_XCut },
|
||||
{ "EditXPaste", CK_XPaste },
|
||||
{ "EditSelectionHistory", CK_Selection_History },
|
||||
{ "EditShell", CK_Shell },
|
||||
{ "EditInsertLiteral", CK_Insert_Literal },
|
||||
{ "EditExecuteMacro", CK_Execute_Macro },
|
||||
{ "EditBeginorEndMacro", CK_Begin_End_Macro },
|
||||
{ "EditExtmode", CK_Ext_Mode },
|
||||
{ "EditToggleLineState", CK_Toggle_Line_State },
|
||||
#if 0
|
||||
{ "EditFocusNext", CK_Focus_Next },
|
||||
{ "EditFocusPrev", CK_Focus_Prev },
|
||||
{ "EditHeightInc", CK_Height_Inc },
|
||||
{ "EditHeightDec", CK_Height_Dec },
|
||||
{ "EditMake", CK_Make },
|
||||
{ "EditErrorNext", CK_Error_Next },
|
||||
{ "EditErrorPrev", CK_Error_Prev },
|
||||
#endif
|
||||
|
||||
/* viewer */
|
||||
{ "ViewSearch", CK_ViewSearch },
|
||||
{ "ViewContinueSearch", CK_ViewContinueSearch },
|
||||
{ "ViewGotoBookmark", CK_ViewGotoBookmark },
|
||||
{ "ViewNewBookmark", CK_ViewNewBookmark },
|
||||
{ "ViewMoveUp", CK_ViewMoveUp },
|
||||
{ "ViewMoveDown", CK_ViewMoveDown },
|
||||
{ "ViewMoveLeft", CK_ViewMoveLeft },
|
||||
{ "ViewMoveRight", CK_ViewMoveRight },
|
||||
{ "ViewMovePgDn", CK_ViewMovePgDn },
|
||||
{ "ViewMovePgUp", CK_ViewMovePgUp },
|
||||
{ "ViewMoveHalfPgDn", CK_ViewMoveHalfPgDn },
|
||||
{ "ViewMoveHalfPgUp", CK_ViewMoveHalfPgUp },
|
||||
{ "ViewMoveToBol", CK_ViewMoveToBol },
|
||||
{ "ViewMoveToEol", CK_ViewMoveToEol },
|
||||
{ "ViewNextFile", CK_ViewNextFile },
|
||||
{ "ViewPrevFile", CK_ViewPrevFile },
|
||||
{ "ViewToggleRuler", CK_ViewToggleRuler },
|
||||
{ "HexViewToggleNavigationMode", CK_HexViewToggleNavigationMode },
|
||||
{ "ViewQuit", CK_ViewQuit },
|
||||
|
||||
/* main commands */
|
||||
{ "CmdChmod", CK_ChmodCmd },
|
||||
{ "CmdMenuLastSelected", CK_MenuLastSelectedCmd },
|
||||
{ "CmdSingleDirsize", CK_SingleDirsizeCmd },
|
||||
{ "CmdCopyCurrentPathname", CK_CopyCurrentPathname },
|
||||
{ "CmdCopyOtherPathname", CK_CopyOtherPathname },
|
||||
{ "CmdSuspend", CK_SuspendCmd },
|
||||
{ "CmdToggleListing", CK_ToggleListingCmd },
|
||||
{ "CmdChownAdvanced", CK_ChownAdvancedCmd },
|
||||
{ "CmdChown", CK_ChownCmd },
|
||||
{ "CmdCompareDirs", CK_CompareDirsCmd },
|
||||
{ "CmdConfigureBox", CK_ConfigureBox },
|
||||
{ "CmdConfigureVfs", CK_ConfigureVfs },
|
||||
{ "CmdConfirmBox", CK_ConfirmBox },
|
||||
{ "CmdCopy", CK_CopyCmd },
|
||||
{ "CmdDelete", CK_DeleteCmd },
|
||||
{ "CmdDirsizes", CK_DirsizesCmd },
|
||||
{ "CmdDisplayBitsBox", CK_DisplayBitsBox },
|
||||
{ "CmdEdit", CK_EditCmd },
|
||||
{ "CmdEditMcMenu", CK_EditMcMenuCmd },
|
||||
{ "CmdEditSymlink", CK_EditSymlinkCmd },
|
||||
{ "CmdEditSyntax", CK_EditSyntaxCmd },
|
||||
{ "CmdEditUserMenu", CK_EditUserMenuCmd },
|
||||
{ "CmdExternalPanelize", CK_ExternalPanelize },
|
||||
{ "CmdFilter", CK_FilterCmd },
|
||||
{ "CmdFilteredView", CK_FilteredViewCmd },
|
||||
{ "CmdFind", CK_FindCmd },
|
||||
{ "CmdFishlink", CK_FishlinkCmd },
|
||||
{ "CmdFtplink", CK_FtplinkCmd },
|
||||
{ "CmdHistory", CK_HistoryCmd },
|
||||
{ "CmdInfo", CK_InfoCmd },
|
||||
{ "CmdJobs", CK_JobsCmd },
|
||||
{ "CmdLayout", CK_LayoutCmd },
|
||||
{ "CmdLearnKeys", CK_LearnKeys },
|
||||
{ "CmdLink", CK_LinkCmd },
|
||||
{ "CmdListing", CK_ListingCmd },
|
||||
{ "CmdMkdir", CK_MkdirCmd },
|
||||
{ "CmdQuickCd", CK_QuickCdCmd },
|
||||
{ "CmdQuickChdir", CK_QuickChdirCmd },
|
||||
{ "CmdQuickView", CK_QuickViewCmd },
|
||||
{ "CmdQuietQuit", CK_QuietQuitCmd },
|
||||
{ "CmdRename", CK_RenCmd },
|
||||
{ "CmdReread", CK_RereadCmd },
|
||||
{ "CmdReselectVfs", CK_ReselectVfs },
|
||||
{ "CmdReverseSelection", CK_ReverseSelectionCmd },
|
||||
{ "CmdSaveSetup", CK_SaveSetupCmd },
|
||||
{ "CmdSelect", CK_SelectCmd },
|
||||
{ "CmdSwapPanel", CK_SwapCmd },
|
||||
{ "CmdSymlink", CK_SymlinkCmd },
|
||||
{ "CmdTree", CK_TreeCmd },
|
||||
{ "CmdUndelete", CK_UndeleteCmd },
|
||||
{ "CmdUnselect", CK_UnselectCmd },
|
||||
{ "CmdUserFileMenu", CK_UserFileMenuCmd },
|
||||
{ "CmdView", CK_ViewCmd },
|
||||
{ "CmdViewFile", CK_ViewFileCmd },
|
||||
{ "CmdCopyCurrentReadlink", CK_CopyCurrentReadlink },
|
||||
{ "CmdCopyOtherReadlink", CK_CopyOtherReadlink },
|
||||
{ "CmdAddHotlist", CK_AddHotlist },
|
||||
{ "CmdQuit", CK_QuitCmd },
|
||||
{ "CmdCopyOtherTarget", CK_CopyOtherTarget },
|
||||
{ "CmdToggleShowHidden", CK_ToggleShowHidden },
|
||||
|
||||
/* panel */
|
||||
{ "PanelChdirOtherPanel", CK_PanelChdirOtherPanel },
|
||||
{ "PanelChdirToReadlink", CK_PanelChdirToReadlink },
|
||||
{ "PanelCopyLocal", CK_PanelCmdCopyLocal },
|
||||
{ "PanelDeleteLocal", CK_PanelCmdDeleteLocal },
|
||||
{ "PanelDoEnter", CK_PanelCmdDoEnter },
|
||||
{ "PanelEditNew", CK_PanelCmdEditNew },
|
||||
{ "PanelRenameLocal", CK_PanelCmdRenameLocal },
|
||||
{ "PanelReverseSelection", CK_PanelCmdReverseSelection },
|
||||
{ "PanelSelect", CK_PanelCmdSelect },
|
||||
{ "PanelUnselect", CK_PanelCmdUnselect },
|
||||
{ "PanelViewSimple", CK_PanelCmdViewSimple },
|
||||
{ "PanelCtrlNextPage", CK_PanelCtrlNextPage },
|
||||
{ "PanelCtrlPrevPage", CK_PanelCtrlPrevPage },
|
||||
{ "PanelDirectoryHistoryList", CK_PanelDirectoryHistoryList },
|
||||
{ "PanelDirectoryHistoryNext", CK_PanelDirectoryHistoryNext },
|
||||
{ "PanelDirectoryHistoryPrev", CK_PanelDirectoryHistoryPrev },
|
||||
{ "PanelGotoBottomFile", CK_PanelGotoBottomFile },
|
||||
{ "PanelGotoMiddleFile", CK_PanelGotoMiddleFile },
|
||||
{ "PanelGotoTopFile", CK_PanelGotoTopFile },
|
||||
{ "PanelMarkFile", CK_PanelMarkFile },
|
||||
{ "PanelMoveUp", CK_PanelMoveUp },
|
||||
{ "PanelMoveDown", CK_PanelMoveDown },
|
||||
{ "PanelMoveLeft", CK_PanelMoveLeft },
|
||||
{ "PanelMoveRight", CK_PanelMoveRight },
|
||||
{ "PanelMoveEnd", CK_PanelMoveEnd },
|
||||
{ "PanelMoveHome", CK_PanelMoveHome },
|
||||
{ "PanelNextPage", CK_PanelNextPage },
|
||||
{ "PanelPrevPage", CK_PanelPrevPage },
|
||||
{ "PanelSetPanelEncoding", CK_PanelSetPanelEncoding },
|
||||
{ "PanelStartSearch", CK_PanelStartSearch },
|
||||
{ "PanelSyncOtherPanel", CK_PanelSyncOtherPanel },
|
||||
|
||||
/* widgets */
|
||||
{ "InputBol", CK_InputBol },
|
||||
{ "InputEol", CK_InputEol },
|
||||
{ "InputMoveLeft", CK_InputMoveLeft },
|
||||
{ "InputWordLeft", CK_InputWordLeft },
|
||||
{ "InputBackwardChar", CK_InputBackwardChar },
|
||||
{ "InputBackwardWord", CK_InputBackwardWord },
|
||||
{ "InputMoveRight", CK_InputMoveRight },
|
||||
{ "InputWordRight", CK_InputWordRight },
|
||||
{ "InputForwardChar", CK_InputForwardChar },
|
||||
{ "InputForwardWord", CK_InputForwardWord },
|
||||
{ "InputBackwardDelete", CK_InputBackwardDelete },
|
||||
{ "InputDeleteChar", CK_InputDeleteChar },
|
||||
{ "InputKillWord", CK_InputKillWord },
|
||||
{ "InputBackwardKillWord", CK_InputBackwardKillWord },
|
||||
{ "InputSetMark", CK_InputSetMark },
|
||||
{ "InputKillRegion", CK_InputKillRegion },
|
||||
{ "InputKillSave", CK_InputKillSave },
|
||||
{ "InputYank", CK_InputYank },
|
||||
{ "InputKillLine", CK_InputKillLine },
|
||||
{ "InputHistoryPrev", CK_InputHistoryPrev },
|
||||
{ "InputHistoryNext", CK_InputHistoryNext },
|
||||
{ "InputHistoryShow", CK_InputHistoryShow },
|
||||
{ "InputComplete", CK_InputComplete },
|
||||
|
||||
/* common */
|
||||
{ "ExtMap1", CK_StartExtMap1 },
|
||||
{ "ExtMap2", CK_StartExtMap2 },
|
||||
{ "ShowCommandLine", CK_ShowCommandLine },
|
||||
{ "SelectCodepage", CK_SelectCodepage },
|
||||
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/* viewer/actions_cmd.c */
|
||||
const global_key_map_t default_viewer_keymap[] = {
|
||||
|
||||
{ '?', CK_ViewSearch },
|
||||
{ '/', CK_ViewSearch },
|
||||
{ XCTRL('r'), CK_ViewContinueSearch },
|
||||
{ XCTRL('s'), CK_ViewContinueSearch },
|
||||
{ KEY_F (17), CK_ViewContinueSearch },
|
||||
{ ALT('r'), CK_ViewToggleRuler },
|
||||
|
||||
{ KEY_HOME, CK_ViewMoveToBol },
|
||||
{ KEY_END, CK_ViewMoveToEol },
|
||||
|
||||
{ 'h', CK_ViewMoveLeft },
|
||||
{ KEY_LEFT, CK_ViewMoveLeft },
|
||||
|
||||
{ 'l', CK_ViewMoveRight },
|
||||
{ KEY_RIGHT, CK_ViewMoveRight },
|
||||
|
||||
{ 'k', CK_ViewMoveUp },
|
||||
{ 'y', CK_ViewMoveUp },
|
||||
{ KEY_IC, CK_ViewMoveUp },
|
||||
{ KEY_UP, CK_ViewMoveUp },
|
||||
|
||||
{ 'j', CK_ViewMoveDown },
|
||||
{ 'e', CK_ViewMoveDown },
|
||||
{ KEY_DOWN, CK_ViewMoveDown },
|
||||
{ KEY_DC, CK_ViewMoveDown },
|
||||
|
||||
{ ' ', CK_ViewMovePgDn },
|
||||
{ 'f', CK_ViewMovePgDn },
|
||||
{ KEY_NPAGE, CK_ViewMovePgDn },
|
||||
|
||||
{ 'b', CK_ViewMovePgUp },
|
||||
{ KEY_PPAGE, CK_ViewMovePgUp },
|
||||
|
||||
{ 'd', CK_ViewMoveHalfPgDn },
|
||||
{ 'u', CK_ViewMoveHalfPgUp },
|
||||
|
||||
{ 'm', CK_ViewGotoBookmark },
|
||||
{ 'r', CK_ViewNewBookmark },
|
||||
|
||||
{ XCTRL ('f'), CK_ViewNextFile },
|
||||
{ XCTRL ('b'), CK_ViewPrevFile },
|
||||
|
||||
{ 'q', CK_ViewQuit },
|
||||
{ XCTRL ('g'), CK_ViewQuit },
|
||||
{ ESC_CHAR, CK_ViewQuit },
|
||||
|
||||
{ XCTRL ('t'), CK_SelectCodepage },
|
||||
{ XCTRL('o'), CK_ShowCommandLine },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
const global_key_map_t default_viewer_hex_keymap[] = {
|
||||
|
||||
{ '\t', CK_HexViewToggleNavigationMode },
|
||||
{ XCTRL ('a'), CK_ViewMoveToBol },
|
||||
{ XCTRL ('e'), CK_ViewMoveToEol },
|
||||
|
||||
{ 'b', CK_ViewMoveLeft },
|
||||
{ KEY_LEFT, CK_ViewMoveLeft },
|
||||
|
||||
{ 'f', CK_ViewMoveRight },
|
||||
{ KEY_RIGHT, CK_ViewMoveRight },
|
||||
|
||||
{ 'k', CK_ViewMoveUp },
|
||||
{ 'y', CK_ViewMoveUp },
|
||||
{ KEY_UP, CK_ViewMoveUp },
|
||||
|
||||
{ 'j', CK_ViewMoveDown },
|
||||
{ KEY_DOWN, CK_ViewMoveDown },
|
||||
{ KEY_DC, CK_ViewMoveDown },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/* ../edit/editkeys.c */
|
||||
const global_key_map_t default_editor_keymap[] = {
|
||||
{ '\n', CK_Enter },
|
||||
{ '\t', CK_Tab },
|
||||
|
||||
{ ESC_CHAR, CK_Exit },
|
||||
{ KEY_BACKSPACE, CK_BackSpace },
|
||||
{ KEY_DC, CK_Delete },
|
||||
{ KEY_DOWN, CK_Down },
|
||||
{ KEY_END, CK_End },
|
||||
{ KEY_HOME, CK_Home },
|
||||
{ KEY_IC, CK_Toggle_Insert },
|
||||
{ KEY_LEFT, CK_Left },
|
||||
{ KEY_NPAGE, CK_Page_Down },
|
||||
{ KEY_PPAGE, CK_Page_Up },
|
||||
{ KEY_RIGHT, CK_Right },
|
||||
{ KEY_UP, CK_Up },
|
||||
|
||||
{ ALT ('\n'), CK_Find_Definition },
|
||||
{ ALT ('\t'), CK_Complete_Word },
|
||||
{ ALT ('l'), CK_Goto },
|
||||
{ ALT ('L'), CK_Goto },
|
||||
{ ALT ('p'), CK_Paragraph_Format },
|
||||
{ ALT ('t'), CK_Sort },
|
||||
{ ALT ('u'), CK_ExtCmd },
|
||||
{ ALT ('<'), CK_Beginning_Of_Text },
|
||||
{ ALT ('>'), CK_End_Of_Text },
|
||||
{ ALT ('-'), CK_Load_Prev_File },
|
||||
{ ALT ('='), CK_Load_Next_File },
|
||||
{ ALT ('d'), CK_Delete_Word_Right },
|
||||
{ ALT (KEY_BACKSPACE), CK_Delete_Word_Left },
|
||||
{ ALT ('n'), CK_Toggle_Line_State },
|
||||
{ ALT ('_'), CK_Toggle_Tab_TWS },
|
||||
{ ALT ('k'), CK_Toggle_Bookmark },
|
||||
{ ALT ('i'), CK_Prev_Bookmark },
|
||||
{ ALT ('j'), CK_Next_Bookmark },
|
||||
{ ALT ('o'), CK_Flush_Bookmarks },
|
||||
|
||||
{ XCTRL ('k'), CK_Delete_To_Line_End },
|
||||
{ XCTRL ('l'), CK_Refresh },
|
||||
{ XCTRL ('o'), CK_Shell },
|
||||
{ XCTRL ('s'), CK_Toggle_Syntax },
|
||||
{ XCTRL ('u'), CK_Undo },
|
||||
{ XCTRL ('t'), CK_SelectCodepage },
|
||||
{ XCTRL ('q'), CK_Insert_Literal },
|
||||
{ XCTRL ('a'), CK_Execute_Macro },
|
||||
{ XCTRL ('r'), CK_Begin_End_Macro },
|
||||
|
||||
{ KEY_F (1), CK_Help },
|
||||
{ KEY_F (2), CK_Save },
|
||||
{ KEY_F (3), CK_Mark },
|
||||
{ KEY_F (4), CK_Replace },
|
||||
{ KEY_F (5), CK_Copy },
|
||||
{ KEY_F (6), CK_Move },
|
||||
{ KEY_F (7), CK_Find },
|
||||
{ KEY_F (8), CK_Remove },
|
||||
{ KEY_F (10), CK_Exit },
|
||||
/* edit user menu */
|
||||
{ KEY_F (11), CK_User_Menu },
|
||||
{ KEY_F (12), CK_Save_As },
|
||||
{ KEY_F (13), CK_Column_Mark },
|
||||
{ KEY_F (14), CK_Replace_Again },
|
||||
{ KEY_F (15), CK_Insert_File },
|
||||
{ KEY_F (17), CK_Find_Again },
|
||||
/* C formatter */
|
||||
{ KEY_F (19), CK_Pipe_Block (0) },
|
||||
|
||||
/* Shift */
|
||||
{ KEY_M_SHIFT | KEY_PPAGE, CK_Page_Up_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_NPAGE, CK_Page_Down_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_LEFT, CK_Left_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_RIGHT, CK_Right_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_UP, CK_Up_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_DOWN, CK_Down_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_HOME, CK_Home_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_END, CK_End_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_IC, CK_XPaste },
|
||||
{ KEY_M_SHIFT | KEY_DC, CK_XCut },
|
||||
/* useful for pasting multiline text */
|
||||
{ KEY_M_SHIFT | '\n', CK_Return },
|
||||
|
||||
/* Alt */
|
||||
{ KEY_M_ALT | KEY_PPAGE, CK_Page_Up_Alt_Highlight },
|
||||
{ KEY_M_ALT | KEY_NPAGE, CK_Page_Down_Alt_Highlight },
|
||||
{ KEY_M_ALT | KEY_LEFT, CK_Left_Alt_Highlight },
|
||||
{ KEY_M_ALT | KEY_RIGHT, CK_Right_Alt_Highlight },
|
||||
{ KEY_M_ALT | KEY_UP, CK_Up_Alt_Highlight },
|
||||
{ KEY_M_ALT | KEY_DOWN, CK_Down_Alt_Highlight },
|
||||
{ KEY_M_ALT | KEY_HOME, CK_Home_Highlight },
|
||||
{ KEY_M_ALT | KEY_END, CK_End_Alt_Highlight },
|
||||
|
||||
/* Ctrl */
|
||||
{ KEY_M_CTRL | (KEY_F (2)), CK_Save_As },
|
||||
{ KEY_M_CTRL | (KEY_F (4)), CK_Replace_Again },
|
||||
{ KEY_M_CTRL | (KEY_F (7)), CK_Find_Again },
|
||||
{ KEY_M_CTRL | KEY_BACKSPACE, CK_Undo },
|
||||
{ KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text },
|
||||
{ KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text },
|
||||
{ KEY_M_CTRL | KEY_HOME, CK_Beginning_Of_Text },
|
||||
{ KEY_M_CTRL | KEY_END, CK_End_Of_Text },
|
||||
{ KEY_M_CTRL | KEY_UP, CK_Scroll_Up },
|
||||
{ KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down },
|
||||
{ KEY_M_CTRL | KEY_LEFT, CK_Word_Left },
|
||||
{ KEY_M_CTRL | KEY_RIGHT, CK_Word_Right },
|
||||
{ KEY_M_CTRL | KEY_IC, CK_XStore },
|
||||
{ KEY_M_CTRL | KEY_DC, CK_Remove },
|
||||
|
||||
/* Ctrl + Shift */
|
||||
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, CK_Word_Left_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, CK_Word_Right_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, CK_Scroll_Up_Highlight },
|
||||
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down_Highlight },
|
||||
|
||||
{ XCTRL ('x'), CK_StartExtMap1 },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/* screen.c */
|
||||
const global_key_map_t default_panel_keymap[] = {
|
||||
|
||||
{ ALT('o'), CK_PanelChdirOtherPanel },
|
||||
{ ALT('l'), CK_PanelChdirToReadlink },
|
||||
{ KEY_F(15), CK_PanelCmdCopyLocal },
|
||||
{ KEY_F(18), CK_PanelCmdDeleteLocal },
|
||||
{ KEY_ENTER, CK_PanelCmdDoEnter },
|
||||
{ '\n', CK_PanelCmdDoEnter },
|
||||
{ KEY_F(14), CK_PanelCmdEditNew },
|
||||
{ KEY_F(16), CK_PanelCmdRenameLocal },
|
||||
{ ALT('*'), CK_PanelCmdReverseSelection },
|
||||
{ KEY_KP_ADD, CK_PanelCmdSelect },
|
||||
{ KEY_KP_SUBTRACT, CK_PanelCmdUnselect },
|
||||
{ KEY_F(13), CK_PanelCmdViewSimple },
|
||||
{ KEY_M_CTRL | KEY_NPAGE, CK_PanelCtrlNextPage },
|
||||
{ KEY_M_CTRL | KEY_PPAGE, CK_PanelCtrlPrevPage },
|
||||
{ ALT('H'), CK_PanelDirectoryHistoryList },
|
||||
{ ALT('u'), CK_PanelDirectoryHistoryNext },
|
||||
{ ALT('y'), CK_PanelDirectoryHistoryPrev },
|
||||
{ ALT('j'), CK_PanelGotoBottomFile },
|
||||
{ ALT('r'), CK_PanelGotoMiddleFile },
|
||||
{ ALT('g'), CK_PanelGotoTopFile },
|
||||
{ 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_A1, CK_PanelMoveHome },
|
||||
{ KEY_NPAGE, CK_PanelNextPage },
|
||||
{ KEY_PPAGE, CK_PanelPrevPage },
|
||||
{ XCTRL('t'), CK_PanelSetPanelEncoding },
|
||||
{ XCTRL('s'), CK_PanelStartSearch },
|
||||
{ ALT('i'), CK_PanelSyncOtherPanel },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/* main.c */
|
||||
const global_key_map_t default_main_map[] = {
|
||||
{KEY_F (19), CK_MenuLastSelectedCmd},
|
||||
{KEY_F (20), CK_QuietQuitCmd},
|
||||
{XCTRL ('@'), CK_SingleDirsizeCmd},
|
||||
/* Copy useful information to the command line */
|
||||
{ALT ('a'), CK_CopyCurrentPathname},
|
||||
{ALT ('A'), CK_CopyOtherPathname},
|
||||
{ALT ('c'), CK_QuickCdCmd},
|
||||
/* To access the directory hotlist */
|
||||
{XCTRL ('\\'), CK_QuickChdirCmd},
|
||||
/* Suspend */
|
||||
{XCTRL ('z'), CK_SuspendCmd},
|
||||
/* The filtered view command */
|
||||
{ALT ('!'), CK_FilteredViewCmd},
|
||||
/* Find file */
|
||||
{ALT ('?'), CK_FindCmd},
|
||||
/* Panel refresh */
|
||||
{XCTRL ('r'), CK_RereadCmd},
|
||||
/* Toggle listing between long, user defined and full formats */
|
||||
{ALT ('t'), CK_ToggleListingCmd},
|
||||
/* Swap panels */
|
||||
{XCTRL ('u'), CK_SwapCmd},
|
||||
/* View output */
|
||||
{XCTRL ('o'), CK_ShowCommandLine},
|
||||
{ALT ('.'), CK_ToggleShowHidden},
|
||||
{XCTRL ('x'), CK_StartExtMap1 },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
const global_key_map_t default_main_x_map[] = {
|
||||
{XCTRL ('c'), CK_QuitCmd},
|
||||
{'d', CK_CompareDirsCmd},
|
||||
#ifdef USE_VFS
|
||||
{'a', CK_ReselectVfs},
|
||||
#endif /* USE_VFS */
|
||||
{'p', CK_CopyCurrentPathname},
|
||||
{XCTRL ('p'), CK_CopyOtherPathname},
|
||||
{'t', CK_CopyCurrentTagged},
|
||||
{XCTRL ('t'), CK_CopyOtherTarget},
|
||||
{'c', CK_ChmodCmd},
|
||||
{'o', CK_ChownCmd},
|
||||
{'r', CK_CopyCurrentReadlink},
|
||||
{XCTRL ('r'), CK_CopyOtherReadlink},
|
||||
{'l', CK_LinkCmd},
|
||||
{'s', CK_SymlinkCmd},
|
||||
{XCTRL ('s'), CK_EditSymlinkCmd},
|
||||
{'i', CK_InfoCmd},
|
||||
{'q', CK_QuickViewCmd},
|
||||
{'h', CK_AddHotlist},
|
||||
{'!', CK_ExternalPanelize},
|
||||
#ifdef WITH_BACKGROUND
|
||||
{'j', CK_JobsCmd},
|
||||
#endif /* WITH_BACKGROUND */
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
const global_key_map_t default_input_keymap[] = {
|
||||
/* Motion */
|
||||
{ XCTRL('a'), CK_InputBol },
|
||||
{ KEY_HOME, CK_InputBol },
|
||||
{ KEY_A1, CK_InputBol },
|
||||
{ ALT ('<'), CK_InputBol },
|
||||
{ XCTRL('e'), CK_InputEol },
|
||||
{ KEY_END, CK_InputEol },
|
||||
{ KEY_C1, CK_InputEol },
|
||||
{ ALT ('>'), CK_InputEol },
|
||||
{ KEY_LEFT, CK_InputMoveLeft },
|
||||
{ KEY_LEFT | KEY_M_CTRL, CK_InputWordLeft },
|
||||
{ KEY_RIGHT, CK_InputMoveRight },
|
||||
{ KEY_RIGHT | KEY_M_CTRL, CK_InputWordRight },
|
||||
|
||||
{ XCTRL('b'), CK_InputBackwardChar },
|
||||
{ ALT('b'), CK_InputBackwardWord },
|
||||
{ XCTRL('f'), CK_InputForwardChar },
|
||||
{ ALT('f'), CK_InputForwardWord },
|
||||
|
||||
/* Editing */
|
||||
{ KEY_BACKSPACE, CK_InputBackwardDelete },
|
||||
{ KEY_DC, CK_InputDeleteChar },
|
||||
{ ALT('d'), CK_InputKillWord },
|
||||
{ ALT(KEY_BACKSPACE), CK_InputBackwardKillWord },
|
||||
|
||||
/* Region manipulation */
|
||||
{ XCTRL('w'), CK_InputKillRegion },
|
||||
{ ALT('w'), CK_InputKillSave },
|
||||
{ XCTRL('y'), CK_InputYank },
|
||||
{ XCTRL('k'), CK_InputKillLine },
|
||||
|
||||
/* History */
|
||||
{ ALT('p'), CK_InputHistoryPrev },
|
||||
{ ALT('n'), CK_InputHistoryNext },
|
||||
{ ALT('h'), CK_InputHistoryShow },
|
||||
|
||||
/* Completion */
|
||||
{ ALT('\t'), CK_InputComplete },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
int lookup_action (char *keyname)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; command_names [i].name; i++){
|
||||
if (!str_casecmp (command_names [i].name, keyname))
|
||||
return command_names [i].val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
keymap_add(GArray *keymap, int key, int cmd)
|
||||
{
|
||||
global_key_map_t new_bind, *map;
|
||||
map = &(g_array_index(keymap, global_key_map_t, 0));
|
||||
|
||||
if (key !=0 && cmd !=0) {
|
||||
new_bind.key = key;
|
||||
new_bind.command = cmd;
|
||||
g_array_append_val(keymap, new_bind);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
keybind_cmd_bind(GArray *keymap, char *keybind, int action)
|
||||
{
|
||||
keymap_add(keymap, lookup_key(keybind), action);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
#ifndef MC_KEYBIND_H
|
||||
#define MC_KEYBIND_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#define GLOBAL_KEYMAP_FILE "mc.keymap"
|
||||
|
||||
typedef struct name_key_map_t {
|
||||
const char *name;
|
||||
int val;
|
||||
} name_key_map_t;
|
||||
|
||||
typedef struct key_config_t {
|
||||
time_t mtime; /* mtime at the moment we read config file */
|
||||
GArray *keymap;
|
||||
GArray *ext_keymap;
|
||||
gchar *labels[10];
|
||||
} key_config_t;
|
||||
|
||||
/* The global keymaps are of this type */
|
||||
typedef struct global_key_map_t {
|
||||
long key;
|
||||
long command;
|
||||
} global_key_map_t;
|
||||
|
||||
int lookup_action (char *keyname);
|
||||
void keybind_cmd_bind(GArray *keymap, char *keybind, int action);
|
||||
|
||||
#endif /* MC_KEYBIND_H */
|
||||
|
||||
/* viewer/actions_cmd.c */
|
||||
extern const global_key_map_t default_viewer_keymap[];
|
||||
extern const global_key_map_t default_viewer_hex_keymap[];
|
||||
|
||||
/* ../edit/editkey.c */
|
||||
extern const global_key_map_t default_editor_keymap[];
|
||||
extern const global_key_map_t default_editor_x_keymap[];
|
||||
|
||||
/* screen.c */
|
||||
extern const global_key_map_t default_panel_keymap[];
|
||||
|
||||
/* widget.c */
|
||||
extern const global_key_map_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_key_map_t default_input_keymap[];
|
332
src/main.c
332
src/main.c
|
@ -77,6 +77,7 @@
|
|||
#include "widget.h"
|
||||
#include "command.h"
|
||||
#include "wtools.h"
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
|
||||
#include "../vfs/vfs.h" /* vfs_translate_url() */
|
||||
|
||||
|
@ -100,6 +101,8 @@
|
|||
#include "../vfs/gc.h"
|
||||
#endif
|
||||
|
||||
#include "keybind.h" /* type global_key_map_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 */
|
||||
/* get_current_type and get_other_type the types of the panels before using */
|
||||
|
@ -301,6 +304,99 @@ mc_main_error_quark (void)
|
|||
return g_quark_from_static_string (PACKAGE);
|
||||
}
|
||||
|
||||
GArray *editor_keymap = NULL;
|
||||
GArray *viewer_keymap = NULL;
|
||||
GArray *viewer_hex_keymap = NULL;
|
||||
GArray *main_keymap = NULL;
|
||||
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;
|
||||
|
||||
static void
|
||||
reload_panelized (WPanel *panel)
|
||||
{
|
||||
int i, j;
|
||||
dir_list *list = &panel->dir;
|
||||
|
||||
if (panel != current_panel)
|
||||
mc_chdir (panel->cwd);
|
||||
|
||||
for (i = 0, j = 0; i < panel->count; i++) {
|
||||
if (list->list[i].f.marked) {
|
||||
/* Unmark the file in advance. In case the following mc_lstat
|
||||
* fails we are done, else we have to mark the file again
|
||||
* (Note: do_file_mark depends on a valid "list->list [i].buf").
|
||||
* IMO that's the best way to update the panel's summary status
|
||||
* -- Norbert
|
||||
*/
|
||||
do_file_mark (panel, i, 0);
|
||||
}
|
||||
if (mc_lstat (list->list[i].fname, &list->list[i].st)) {
|
||||
g_free (list->list[i].fname);
|
||||
continue;
|
||||
}
|
||||
if (list->list[i].f.marked)
|
||||
do_file_mark (panel, i, 1);
|
||||
if (j != i)
|
||||
list->list[j] = list->list[i];
|
||||
j++;
|
||||
}
|
||||
if (j == 0)
|
||||
panel->count = set_zero_dir (list);
|
||||
else
|
||||
panel->count = j;
|
||||
|
||||
if (panel != current_panel)
|
||||
mc_chdir (current_panel->cwd);
|
||||
}
|
||||
|
||||
static void
|
||||
update_one_panel_widget (WPanel *panel, int force_update,
|
||||
const char *current_file)
|
||||
{
|
||||
int free_pointer;
|
||||
char *my_current_file = NULL;
|
||||
|
||||
if (force_update & UP_RELOAD) {
|
||||
panel->is_panelized = 0;
|
||||
mc_setctl (panel->cwd, VFS_SETCTL_FLUSH, 0);
|
||||
memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
|
||||
}
|
||||
|
||||
/* If current_file == -1 (an invalid pointer) then preserve selection */
|
||||
if (current_file == UP_KEEPSEL) {
|
||||
free_pointer = 1;
|
||||
my_current_file = g_strdup (panel->dir.list[panel->selected].fname);
|
||||
current_file = my_current_file;
|
||||
} else
|
||||
free_pointer = 0;
|
||||
|
||||
if (panel->is_panelized)
|
||||
reload_panelized (panel);
|
||||
else
|
||||
panel_reload (panel);
|
||||
|
||||
try_to_select (panel, current_file);
|
||||
panel->dirty = 1;
|
||||
|
||||
if (free_pointer)
|
||||
g_free (my_current_file);
|
||||
}
|
||||
|
||||
static void
|
||||
update_one_panel (int which, int force_update, const char *current_file)
|
||||
{
|
||||
WPanel *panel;
|
||||
|
||||
if (get_display_type (which) != view_listing)
|
||||
return;
|
||||
|
||||
panel = (WPanel *) get_panel_widget (which);
|
||||
update_one_panel_widget (panel, force_update, current_file);
|
||||
}
|
||||
|
||||
/* Save current stat of directories to avoid reloading the panels */
|
||||
/* when no modifications have taken place */
|
||||
|
@ -1093,33 +1189,6 @@ init_labels (void)
|
|||
buttonbar_set_label (midnight_dlg, 10, _("Quit"), quit_cmd);
|
||||
}
|
||||
|
||||
static const key_map ctl_x_map[] = {
|
||||
{XCTRL ('c'), quit_cmd},
|
||||
{'d', compare_dirs_cmd},
|
||||
#ifdef USE_VFS
|
||||
{'a', reselect_vfs},
|
||||
#endif /* USE_VFS */
|
||||
{'p', copy_current_pathname},
|
||||
{XCTRL ('p'), copy_other_pathname},
|
||||
{'t', copy_current_tagged},
|
||||
{XCTRL ('t'), copy_other_tagged},
|
||||
{'c', chmod_cmd},
|
||||
{'o', chown_cmd},
|
||||
{'r', copy_current_readlink},
|
||||
{XCTRL ('r'), copy_other_readlink},
|
||||
{'l', link_cmd},
|
||||
{'s', symlink_cmd},
|
||||
{XCTRL ('s'), edit_symlink_cmd},
|
||||
{'i', info_cmd_no_menu},
|
||||
{'q', quick_cmd_no_menu},
|
||||
{'h', add2hotlist_cmd},
|
||||
{'!', external_panelize},
|
||||
#ifdef WITH_BACKGROUND
|
||||
{'j', jobs_cmd},
|
||||
#endif /* WITH_BACKGROUND */
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static int ctl_x_map_enabled = 0;
|
||||
|
||||
static void
|
||||
|
@ -1133,54 +1202,119 @@ nothing (void)
|
|||
{
|
||||
}
|
||||
|
||||
static const key_map default_map[] = {
|
||||
{KEY_F (19), menu_last_selected_cmd},
|
||||
{KEY_F (20), quiet_quit_cmd},
|
||||
static cb_ret_t
|
||||
midnight_execute_cmd(int command)
|
||||
{
|
||||
cb_ret_t res = MSG_HANDLED;
|
||||
|
||||
{XCTRL ('@'), smart_dirsize_cmd},
|
||||
switch (command) {
|
||||
case CK_MenuLastSelectedCmd:
|
||||
menu_last_selected_cmd ();
|
||||
break;
|
||||
case CK_QuietQuitCmd:
|
||||
quiet_quit_cmd ();
|
||||
break;
|
||||
case CK_SingleDirsizeCmd:
|
||||
smart_dirsize_cmd ();
|
||||
break;
|
||||
case CK_CopyCurrentPathname:
|
||||
copy_current_pathname ();
|
||||
break;
|
||||
case CK_CopyOtherPathname:
|
||||
copy_other_pathname ();
|
||||
break;
|
||||
case CK_QuickCdCmd:
|
||||
quick_cd_cmd ();
|
||||
break;
|
||||
case CK_QuickChdirCmd:
|
||||
quick_chdir_cmd ();
|
||||
break;
|
||||
case CK_SuspendCmd:
|
||||
suspend_cmd ();
|
||||
break;
|
||||
case CK_FilteredViewCmd:
|
||||
filtered_view_cmd ();
|
||||
break;
|
||||
case CK_FindCmd:
|
||||
find_cmd ();
|
||||
break;
|
||||
case CK_RereadCmd:
|
||||
reread_cmd ();
|
||||
break;
|
||||
case CK_ToggleListingCmd:
|
||||
toggle_listing_cmd ();
|
||||
break;
|
||||
case CK_SwapCmd:
|
||||
swap_cmd ();
|
||||
break;
|
||||
case CK_ShowCommandLine:
|
||||
view_other_cmd ();
|
||||
break;
|
||||
case CK_QuitCmd:
|
||||
quit_cmd ();
|
||||
break;
|
||||
case CK_CompareDirsCmd:
|
||||
compare_dirs_cmd ();
|
||||
break;
|
||||
case CK_ReselectVfs:
|
||||
reselect_vfs ();
|
||||
break;
|
||||
case CK_CopyCurrentTagged:
|
||||
copy_current_tagged ();
|
||||
break;
|
||||
case CK_CopyOtherTarget:
|
||||
copy_other_tagged ();
|
||||
break;
|
||||
case CK_CopyCurrentReadlink:
|
||||
copy_current_readlink ();
|
||||
break;
|
||||
case CK_CopyOtherReadlink:
|
||||
copy_other_readlink ();
|
||||
break;
|
||||
case CK_ChmodCmd:
|
||||
chmod_cmd ();
|
||||
break;
|
||||
case CK_ChownCmd:
|
||||
chown_cmd ();
|
||||
break;
|
||||
case CK_LinkCmd:
|
||||
link_cmd () ;
|
||||
break;
|
||||
case CK_SymlinkCmd:
|
||||
symlink_cmd ();
|
||||
break;
|
||||
case CK_EditSymlinkCmd:
|
||||
edit_symlink_cmd ();
|
||||
break;
|
||||
case CK_InfoCmd:
|
||||
info_cmd_no_menu ();
|
||||
break;
|
||||
case CK_QuickViewCmd:
|
||||
quick_cmd_no_menu ();
|
||||
break;
|
||||
case CK_AddHotlist:
|
||||
add2hotlist_cmd ();
|
||||
break;
|
||||
case CK_ExternalPanelize:
|
||||
external_panelize ();
|
||||
break;
|
||||
#ifdef WITH_BACKGROUND
|
||||
case CK_JobsCmd:
|
||||
jobs_cmd ();
|
||||
break;
|
||||
#endif
|
||||
case CK_ToggleShowHidden:
|
||||
toggle_show_hidden ();
|
||||
break;
|
||||
case CK_StartExtMap1:
|
||||
ctl_x_cmd ();
|
||||
break;
|
||||
default:
|
||||
res = MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
/* Copy useful information to the command line */
|
||||
{ALT ('a'), copy_current_pathname},
|
||||
{ALT ('A'), copy_other_pathname},
|
||||
|
||||
{ALT ('c'), quick_cd_cmd},
|
||||
|
||||
/* To access the directory hotlist */
|
||||
{XCTRL ('\\'), quick_chdir_cmd},
|
||||
|
||||
/* Suspend */
|
||||
{XCTRL ('z'), suspend_cmd},
|
||||
|
||||
/* The filtered view command */
|
||||
{ALT ('!'), filtered_view_cmd},
|
||||
|
||||
/* Find file */
|
||||
{ALT ('?'), find_cmd},
|
||||
|
||||
/* Panel refresh */
|
||||
{XCTRL ('r'), reread_cmd},
|
||||
|
||||
/* Toggle listing between long, user defined and full formats */
|
||||
{ALT ('t'), toggle_listing_cmd},
|
||||
|
||||
/* Swap panels */
|
||||
{XCTRL ('u'), swap_cmd},
|
||||
|
||||
/* View output */
|
||||
{XCTRL ('o'), view_other_cmd},
|
||||
|
||||
/* Control-X keybindings */
|
||||
{XCTRL ('x'), ctl_x_cmd},
|
||||
|
||||
/* Show/hide hidden files */
|
||||
{ALT ('.'), toggle_show_hidden},
|
||||
|
||||
/* Trap dlg's exit commands */
|
||||
{ESC_CHAR, nothing},
|
||||
{XCTRL ('c'), nothing},
|
||||
{XCTRL ('g'), nothing},
|
||||
{0, 0},
|
||||
};
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
setup_pre (void)
|
||||
|
@ -1400,11 +1534,9 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
|||
case DLG_KEY:
|
||||
if (ctl_x_map_enabled) {
|
||||
ctl_x_map_enabled = 0;
|
||||
for (i = 0; ctl_x_map[i].key_code; i++)
|
||||
if (parm == ctl_x_map[i].key_code) {
|
||||
(*ctl_x_map[i].fn) ();
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
for (i = 0; main_x_map[i].key; i++)
|
||||
if (parm == main_x_map[i].key)
|
||||
return midnight_execute_cmd (main_x_map[i].command);
|
||||
}
|
||||
|
||||
/* FIXME: should handle all menu shortcuts before this point */
|
||||
|
@ -1494,25 +1626,21 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
|||
|
||||
case DLG_UNHANDLED_KEY:
|
||||
if (command_prompt) {
|
||||
int v;
|
||||
cb_ret_t v;
|
||||
|
||||
v = send_message ((Widget *) cmdline, WIDGET_KEY, parm);
|
||||
if (v)
|
||||
return v;
|
||||
if (v == MSG_HANDLED)
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
if (ctl_x_map_enabled) {
|
||||
ctl_x_map_enabled = 0;
|
||||
for (i = 0; ctl_x_map[i].key_code; i++)
|
||||
if (parm == ctl_x_map[i].key_code) {
|
||||
(*ctl_x_map[i].fn) ();
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
for (i = 0; main_x_map[i].key; i++)
|
||||
if (parm == main_x_map[i].key)
|
||||
return midnight_execute_cmd (main_x_map[i].command);
|
||||
} else {
|
||||
for (i = 0; default_map[i].key_code; i++) {
|
||||
if (parm == default_map[i].key_code) {
|
||||
(*default_map[i].fn) ();
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
for (i = 0; main_map[i].key; i++) {
|
||||
if (parm == main_map[i].key)
|
||||
return midnight_execute_cmd (main_map[i].command);
|
||||
}
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
|
@ -1689,6 +1817,26 @@ do_nc (void)
|
|||
|
||||
/* start check display_codepage and source_codepage */
|
||||
check_codeset();
|
||||
main_map = default_main_map;
|
||||
|
||||
if (main_keymap && main_keymap->len > 0)
|
||||
main_map = (global_key_map_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;
|
||||
|
||||
panel_map = default_panel_keymap;
|
||||
|
||||
if (panel_keymap && panel_keymap->len > 0) {
|
||||
panel_map = (global_key_map_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;
|
||||
|
||||
/* Check if we were invoked as an editor or file viewer */
|
||||
if (!mc_maybe_editor_or_viewer ()) {
|
||||
|
@ -2004,6 +2152,8 @@ main (int argc, char *argv[])
|
|||
/* Removing this from the X code let's us type C-c */
|
||||
load_key_defs ();
|
||||
|
||||
load_keymap_defs ();
|
||||
|
||||
/* Also done after init_subshell, to save any shell init file messages */
|
||||
if (console_flag)
|
||||
handle_console (CONSOLE_SAVE);
|
||||
|
|
17
src/main.h
17
src/main.h
|
@ -6,6 +6,8 @@
|
|||
#ifndef MC_MAIN_H
|
||||
#define MC_MAIN_H
|
||||
|
||||
#include "keybind.h"
|
||||
|
||||
/* Toggling functions */
|
||||
void toggle_fast_reload (void);
|
||||
void toggle_mix_all_files (void);
|
||||
|
@ -72,13 +74,16 @@ 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)
|
||||
|
||||
typedef void (*key_callback) (void);
|
||||
extern GArray *editor_keymap;
|
||||
extern GArray *viewer_keymap;
|
||||
extern GArray *viewer_hex_keymap;
|
||||
extern GArray *main_keymap;
|
||||
extern GArray *main_x_keymap;
|
||||
extern GArray *panel_keymap;
|
||||
extern GArray *input_keymap;
|
||||
|
||||
/* The keymaps are of this type */
|
||||
typedef struct {
|
||||
int key_code;
|
||||
key_callback fn;
|
||||
} key_map;
|
||||
extern const global_key_map_t *panel_map;
|
||||
extern const global_key_map_t *input_map;
|
||||
|
||||
void do_update_prompt (void);
|
||||
|
||||
|
|
190
src/screen.c
190
src/screen.c
|
@ -60,6 +60,8 @@
|
|||
#include "selcodepage.h" /* select_charset () */
|
||||
#include "charsets.h" /* get_codepage_id () */
|
||||
#include "strutil.h"
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "keybind.h" /* global_key_map_t */
|
||||
|
||||
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
|
||||
|
||||
|
@ -105,6 +107,8 @@ int filetype_mode = 1;
|
|||
/* The hook list for the select file function */
|
||||
Hook *select_file_hook = 0;
|
||||
|
||||
const global_key_map_t *panel_map;
|
||||
|
||||
static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm);
|
||||
static int panel_event (Gpm_Event *event, void *);
|
||||
static void paint_frame (WPanel *panel);
|
||||
|
@ -1776,9 +1780,8 @@ move_selection (WPanel *panel, int lines)
|
|||
}
|
||||
|
||||
static cb_ret_t
|
||||
move_left (WPanel *panel, int c_code)
|
||||
move_left (WPanel *panel)
|
||||
{
|
||||
(void) c_code;
|
||||
if (panel->split) {
|
||||
move_selection (panel, -llines (panel));
|
||||
return MSG_HANDLED;
|
||||
|
@ -1787,9 +1790,8 @@ move_left (WPanel *panel, int c_code)
|
|||
}
|
||||
|
||||
static int
|
||||
move_right (WPanel *panel, int c_code)
|
||||
move_right (WPanel *panel)
|
||||
{
|
||||
(void) c_code;
|
||||
if (panel->split) {
|
||||
move_selection (panel, llines (panel));
|
||||
return MSG_HANDLED;
|
||||
|
@ -2273,10 +2275,6 @@ chdir_to_readlink (WPanel *panel)
|
|||
}
|
||||
|
||||
typedef void (*panel_key_callback) (WPanel *);
|
||||
typedef struct {
|
||||
int key_code;
|
||||
panel_key_callback fn;
|
||||
} panel_key_map;
|
||||
|
||||
static void cmd_do_enter(WPanel *wp) { (void) do_enter(wp); }
|
||||
static void cmd_view_simple(WPanel *wp) { (void) wp; view_simple_cmd(); }
|
||||
|
@ -2288,93 +2286,139 @@ static void cmd_select(WPanel *wp) { (void) wp;select_cmd(); }
|
|||
static void cmd_unselect(WPanel *wp) { (void) wp;unselect_cmd(); }
|
||||
static void cmd_reverse_selection(WPanel *wp) { (void) wp;reverse_selection_cmd(); }
|
||||
|
||||
static const panel_key_map panel_keymap [] = {
|
||||
{ KEY_DOWN, move_down },
|
||||
{ KEY_UP, move_up },
|
||||
static cb_ret_t
|
||||
panel_execute_cmd (WPanel *panel, int command)
|
||||
{
|
||||
int res = MSG_HANDLED;
|
||||
|
||||
/* The action button :-) */
|
||||
{ '\n', cmd_do_enter },
|
||||
{ KEY_ENTER, cmd_do_enter },
|
||||
|
||||
{ KEY_IC, mark_file },
|
||||
{ KEY_HOME, move_home },
|
||||
{ KEY_A1, move_home },
|
||||
{ ALT ('<'), move_home },
|
||||
{ KEY_C1, move_end },
|
||||
{ KEY_END, move_end },
|
||||
{ ALT ('>'), move_end },
|
||||
{ KEY_NPAGE, next_page },
|
||||
{ KEY_PPAGE, prev_page },
|
||||
{ KEY_NPAGE | KEY_M_CTRL, ctrl_next_page },
|
||||
{ KEY_PPAGE | KEY_M_CTRL, ctrl_prev_page },
|
||||
|
||||
/* To quickly move in the panel */
|
||||
{ ALT('g'), goto_top_file },
|
||||
{ ALT('r'), goto_middle_file }, /* M-r like emacs */
|
||||
{ ALT('j'), goto_bottom_file },
|
||||
|
||||
/* Emacs-like bindings */
|
||||
{ XCTRL('v'), next_page }, /* C-v like emacs */
|
||||
{ ALT('v'), prev_page }, /* M-v like emacs */
|
||||
{ XCTRL('p'), move_up }, /* C-p like emacs */
|
||||
{ XCTRL('n'), move_down }, /* C-n like emacs */
|
||||
{ XCTRL('s'), start_search }, /* C-s like emacs */
|
||||
{ ALT('s'), start_search }, /* M-s not like emacs */
|
||||
/* { XCTRL('t'), mark_file },*/
|
||||
{ XCTRL('t'), set_panel_encoding },
|
||||
{ ALT('o'), chdir_other_panel },
|
||||
{ ALT('i'), sync_other_panel },
|
||||
{ ALT('l'), chdir_to_readlink },
|
||||
{ ALT('H'), directory_history_list },
|
||||
{ KEY_F(13), cmd_view_simple },
|
||||
{ KEY_F(14), cmd_edit_new },
|
||||
{ KEY_F(15), cmd_copy_local },
|
||||
{ KEY_F(16), cmd_rename_local },
|
||||
{ KEY_F(18), cmd_delete_local },
|
||||
{ ALT('y'), directory_history_prev },
|
||||
{ ALT('u'), directory_history_next },
|
||||
{ ALT('+'), cmd_select },
|
||||
{ KEY_KP_ADD, cmd_select },
|
||||
{ ALT('\\'), cmd_unselect },
|
||||
{ ALT('-'), cmd_unselect },
|
||||
{ KEY_KP_SUBTRACT, cmd_unselect },
|
||||
{ ALT('*'), cmd_reverse_selection },
|
||||
{ KEY_KP_MULTIPLY, cmd_reverse_selection },
|
||||
{ 0, 0 }
|
||||
};
|
||||
switch (command) {
|
||||
case CK_PanelChdirOtherPanel:
|
||||
chdir_other_panel (panel);
|
||||
break;
|
||||
case CK_PanelChdirToReadlink:
|
||||
chdir_to_readlink (panel);
|
||||
break;
|
||||
case CK_PanelCmdCopyLocal:
|
||||
cmd_copy_local (panel);
|
||||
break;
|
||||
case CK_PanelCmdDeleteLocal:
|
||||
cmd_delete_local (panel);
|
||||
break;
|
||||
case CK_PanelCmdDoEnter:
|
||||
cmd_do_enter (panel);
|
||||
break;
|
||||
case CK_PanelCmdViewSimple:
|
||||
cmd_view_simple (panel);
|
||||
break;
|
||||
case CK_PanelCmdEditNew:
|
||||
cmd_edit_new (panel);
|
||||
break;
|
||||
case CK_PanelCmdRenameLocal:
|
||||
cmd_rename_local (panel);
|
||||
break;
|
||||
case CK_PanelCmdReverseSelection:
|
||||
cmd_reverse_selection (panel);
|
||||
break;
|
||||
case CK_PanelCmdSelect:
|
||||
cmd_select (panel);
|
||||
break;
|
||||
case CK_PanelCmdUnselect:
|
||||
cmd_unselect (panel);
|
||||
break;
|
||||
case CK_PanelNextPage:
|
||||
next_page (panel);
|
||||
break;
|
||||
case CK_PanelPrevPage:
|
||||
prev_page (panel);
|
||||
break;
|
||||
case CK_PanelCtrlNextPage:
|
||||
ctrl_next_page (panel);
|
||||
break;
|
||||
case CK_PanelCtrlPrevPage:
|
||||
ctrl_prev_page (panel);
|
||||
break;
|
||||
case CK_PanelDirectoryHistoryList:
|
||||
directory_history_list (panel);
|
||||
break;
|
||||
case CK_PanelDirectoryHistoryNext:
|
||||
directory_history_next (panel);
|
||||
break;
|
||||
case CK_PanelDirectoryHistoryPrev:
|
||||
directory_history_prev (panel);
|
||||
break;
|
||||
case CK_PanelGotoBottomFile:
|
||||
goto_bottom_file (panel);
|
||||
break;
|
||||
case CK_PanelGotoMiddleFile:
|
||||
goto_middle_file (panel);
|
||||
break;
|
||||
case CK_PanelGotoTopFile:
|
||||
goto_top_file (panel);
|
||||
break;
|
||||
case CK_PanelMarkFile:
|
||||
mark_file (panel);
|
||||
break;
|
||||
case CK_PanelMoveUp:
|
||||
move_up (panel);
|
||||
break;
|
||||
case CK_PanelMoveDown:
|
||||
move_down (panel);
|
||||
break;
|
||||
case CK_PanelMoveLeft:
|
||||
res = move_left (panel);
|
||||
break;
|
||||
case CK_PanelMoveRight:
|
||||
res = move_right (panel);
|
||||
break;
|
||||
case CK_PanelMoveEnd:
|
||||
move_end (panel);
|
||||
break;
|
||||
case CK_PanelMoveHome:
|
||||
move_home (panel);
|
||||
break;
|
||||
case CK_PanelSetPanelEncoding:
|
||||
set_panel_encoding (panel);
|
||||
break;
|
||||
case CK_PanelStartSearch:
|
||||
start_search (panel);
|
||||
break;
|
||||
case CK_PanelSyncOtherPanel:
|
||||
sync_other_panel (panel);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static cb_ret_t
|
||||
panel_key (WPanel *panel, int key)
|
||||
{
|
||||
int i;
|
||||
int res, command;
|
||||
|
||||
for (i = 0; panel_keymap[i].key_code; i++) {
|
||||
if (key == panel_keymap[i].key_code) {
|
||||
for (i = 0; panel_map[i].key; i++) {
|
||||
if (key == panel_map[i].key) {
|
||||
int old_searching = panel->searching;
|
||||
|
||||
if (panel_keymap[i].fn != start_search)
|
||||
if (panel_map[i].command != CK_PanelStartSearch)
|
||||
panel->searching = 0;
|
||||
|
||||
(*panel_keymap[i].fn) (panel);
|
||||
command = panel_map[i].command;
|
||||
res = panel_execute_cmd (panel, command);
|
||||
|
||||
if (res == MSG_NOT_HANDLED)
|
||||
return res;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* We do not want to take a key press if nothing can be done with it */
|
||||
/* The command line widget may do something more useful */
|
||||
if (key == KEY_LEFT)
|
||||
return move_left (panel, key);
|
||||
|
||||
if (key == KEY_RIGHT)
|
||||
return move_right (panel, key);
|
||||
|
||||
if (is_abort_char (key)) {
|
||||
panel->searching = 0;
|
||||
display_mini_info (panel);
|
||||
|
|
231
src/setup.c
231
src/setup.c
|
@ -48,6 +48,8 @@
|
|||
#include "menu.h" /* menubar_visible declaration */
|
||||
#include "cmd.h"
|
||||
#include "file.h" /* safe_delete */
|
||||
#include "keybind.h" /* lookup_action */
|
||||
#include "fileloc.h"
|
||||
|
||||
#ifdef USE_VFS
|
||||
#include "../vfs/gc.h"
|
||||
|
@ -551,6 +553,154 @@ setup__move_panels_config_into_separate_file(const char*profile)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
Get name of config file.
|
||||
|
||||
\param subdir
|
||||
if not NULL, then config also search into specified subdir
|
||||
|
||||
\param config_file_name
|
||||
If specified filename is relative, then will search in standart patches.
|
||||
|
||||
\return
|
||||
Newly allocated path to config name or NULL if file not found
|
||||
|
||||
If config_file_name is a relative path, then search config in stantart pathes */
|
||||
static char*
|
||||
load_setup_get_full_config_name(const char *subdir, const char *config_file_name)
|
||||
{
|
||||
/*
|
||||
TODO: IMHO, in future this function must be placed into mc_config module.
|
||||
Also, need to rename stupid mc_home and mc_home_alt to mc_sysconfdir and mc_datadir;
|
||||
home_mc => mc_user_homedir
|
||||
*/
|
||||
char *basename, *ret;
|
||||
|
||||
if (config_file_name == NULL)
|
||||
return NULL;
|
||||
|
||||
if (g_path_is_absolute (config_file_name))
|
||||
return g_strdup(config_file_name);
|
||||
|
||||
|
||||
basename = g_path_get_basename(config_file_name);
|
||||
if (basename == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (subdir)
|
||||
ret = g_build_filename (home_dir, MC_USERCONF_DIR, subdir, basename, NULL);
|
||||
else
|
||||
ret = g_build_filename (home_dir, MC_USERCONF_DIR, basename, NULL);
|
||||
|
||||
if (exist_file(ret)) {
|
||||
g_free(basename);
|
||||
return ret;
|
||||
}
|
||||
g_free(ret);
|
||||
|
||||
|
||||
if (subdir)
|
||||
ret = g_build_filename (mc_home, subdir, basename, NULL);
|
||||
else
|
||||
ret = g_build_filename (mc_home, basename, NULL);
|
||||
|
||||
if (exist_file(ret)) {
|
||||
g_free(basename);
|
||||
return ret;
|
||||
}
|
||||
g_free(ret);
|
||||
|
||||
if (subdir)
|
||||
ret = g_build_filename (mc_home_alt, subdir, basename, NULL);
|
||||
else
|
||||
ret = g_build_filename (mc_home_alt, basename, NULL);
|
||||
|
||||
if (exist_file(ret)) {
|
||||
g_free(basename);
|
||||
return ret;
|
||||
}
|
||||
g_free(ret);
|
||||
g_free(basename);
|
||||
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)
|
||||
{
|
||||
/*
|
||||
TODO: IMHO, in future this function must be placed into mc_config module.
|
||||
*/
|
||||
if (exist_file(fname)) {
|
||||
if (*config)
|
||||
mc_config_read_file( *config, fname);
|
||||
else
|
||||
*config = mc_config_init(fname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static mc_config_t *
|
||||
load_setup_get_keymap_profile_config(void)
|
||||
{
|
||||
/*
|
||||
TODO: IMHO, in future this function must be placed into mc_config module.
|
||||
*/
|
||||
mc_config_t *keymap_config = NULL ;
|
||||
|
||||
char *fname, *fname2;
|
||||
|
||||
/* 1) /usr/share/mc (mc_home_alt) */
|
||||
fname = g_build_filename (mc_home_alt, GLOBAL_KEYMAP_FILE, NULL);
|
||||
load_setup_init_config_from_file( &keymap_config, fname);
|
||||
g_free(fname);
|
||||
|
||||
/* 2) /etc/mc (mc_home) */
|
||||
fname = g_build_filename (mc_home, GLOBAL_KEYMAP_FILE, NULL);
|
||||
load_setup_init_config_from_file( &keymap_config, fname);
|
||||
g_free(fname);
|
||||
|
||||
/* 3) ~/.mc (home_dir?) */
|
||||
fname = g_build_filename (home_dir, MC_USERCONF_DIR, GLOBAL_KEYMAP_FILE, NULL);
|
||||
load_setup_init_config_from_file( &keymap_config, fname);
|
||||
g_free(fname);
|
||||
|
||||
/* 4) main config; [Midnight Commander] -> keymap*/
|
||||
|
||||
fname2 = mc_config_get_string(mc_main_config, CONFIG_APP_SECTION, "keymap" , GLOBAL_KEYMAP_FILE);
|
||||
fname = load_setup_get_full_config_name(NULL, fname2);
|
||||
if (fname)
|
||||
{
|
||||
load_setup_init_config_from_file( &keymap_config, fname);
|
||||
g_free(fname);
|
||||
}
|
||||
g_free(fname2);
|
||||
|
||||
/* 5) getenv("MC_KEYMAP") */
|
||||
fname = load_setup_get_full_config_name(NULL, g_getenv ("MC_KEYMAP"));
|
||||
if (fname)
|
||||
{
|
||||
load_setup_init_config_from_file( &keymap_config, fname);
|
||||
g_free(fname);
|
||||
}
|
||||
|
||||
/* 6) --keymap=<keymap> */
|
||||
fname = load_setup_get_full_config_name(NULL, mc_args__keymap_file);
|
||||
if (fname)
|
||||
{
|
||||
load_setup_init_config_from_file( &keymap_config, fname);
|
||||
g_free(fname);
|
||||
}
|
||||
|
||||
return keymap_config;
|
||||
}
|
||||
|
||||
char *
|
||||
setup_init (void)
|
||||
|
@ -595,11 +745,11 @@ load_setup (void)
|
|||
/* mc.lib is common for all users, but has priority lower than
|
||||
~/.mc/ini. FIXME: it's only used for keys and treestore now */
|
||||
global_profile_name = concat_dir_and_file (mc_home, "mc.lib");
|
||||
|
||||
if (!exist_file(global_profile_name)) {
|
||||
g_free (global_profile_name);
|
||||
global_profile_name = concat_dir_and_file (mc_home_alt, "mc.lib");
|
||||
}
|
||||
|
||||
panels_profile_name = concat_dir_and_file (home_dir, PANELS_PROFILE_NAME);
|
||||
|
||||
mc_main_config = mc_config_init(profile);
|
||||
|
@ -785,3 +935,82 @@ void load_key_defs (void)
|
|||
load_keys_from_section (getenv ("TERM"), mc_main_config);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
load_keymap_from_section (const char *section_name, GArray *keymap, mc_config_t *cfg)
|
||||
{
|
||||
gchar **profile_keys, **keys;
|
||||
gchar **values, **curr_values;
|
||||
char *valcopy, *value;
|
||||
int action;
|
||||
gsize len, values_len;
|
||||
|
||||
if (!section_name)
|
||||
return;
|
||||
|
||||
profile_keys = keys = mc_config_get_keys (cfg, section_name, &len);
|
||||
|
||||
while (*profile_keys) {
|
||||
curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);
|
||||
action = lookup_action (*profile_keys);
|
||||
if (action>0) {
|
||||
if (curr_values){
|
||||
while (*curr_values){
|
||||
valcopy = convert_controls (*curr_values);
|
||||
keybind_cmd_bind (keymap, valcopy, action);
|
||||
g_free (valcopy);
|
||||
curr_values++;
|
||||
}
|
||||
} else {
|
||||
value = mc_config_get_string (cfg, section_name, *profile_keys, "");
|
||||
valcopy = convert_controls (value);
|
||||
//define_sequence (key_code, valcopy, MCKEY_NOACTION);
|
||||
g_free (valcopy);
|
||||
g_free(value);
|
||||
}
|
||||
}
|
||||
profile_keys++;
|
||||
if (values)
|
||||
g_strfreev(values);
|
||||
}
|
||||
g_strfreev(keys);
|
||||
}
|
||||
|
||||
void
|
||||
load_keymap_defs (void)
|
||||
{
|
||||
/*
|
||||
* Load keymap from GLOBAL_KEYMAP_FILE before ~/.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();
|
||||
|
||||
if (mc_global_keymap != NULL)
|
||||
{
|
||||
editor_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
load_keymap_from_section ("editor", editor_keymap, mc_global_keymap);
|
||||
|
||||
viewer_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
load_keymap_from_section ("viewer", viewer_keymap, mc_global_keymap);
|
||||
|
||||
viewer_hex_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_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));
|
||||
load_keymap_from_section ("main", main_keymap, mc_global_keymap);
|
||||
|
||||
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);
|
||||
|
||||
panel_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
load_keymap_from_section ("panel", panel_keymap, mc_global_keymap);
|
||||
|
||||
input_keymap = g_array_new(TRUE, FALSE, sizeof(global_key_map_t));
|
||||
load_keymap_from_section ("input", input_keymap, mc_global_keymap);
|
||||
|
||||
mc_config_deinit(mc_global_keymap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ char *load_anon_passwd (void);
|
|||
void panel_save_setup (struct WPanel *panel, const char *section);
|
||||
void panel_load_setup (struct WPanel *panel, const char *section);
|
||||
void save_panel_types (void);
|
||||
void load_keymap_defs (void);
|
||||
extern char *profile_name;
|
||||
extern char *global_profile_name;
|
||||
|
||||
|
|
|
@ -130,7 +130,8 @@ key_code_name_t key_name_conv_tab[] = {
|
|||
{ALT ('\t'), "complete", N_("Completion/M-tab")},
|
||||
{KEY_KP_ADD, "kpplus", N_("+ on keypad")},
|
||||
{KEY_KP_SUBTRACT, "kpminus", N_("- on keypad")},
|
||||
{KEY_KP_MULTIPLY, "kpasterix", N_("* on keypad")},
|
||||
{(int) '/', "kpslash", N_("Slash on keypad")},
|
||||
{KEY_KP_MULTIPLY, "kpasterisk", N_("* on keypad")},
|
||||
|
||||
/* From here on, these won't be shown in Learn keys (no space) */
|
||||
{KEY_LEFT, "kpleft", N_("Left arrow keypad")},
|
||||
|
@ -144,18 +145,38 @@ key_code_name_t key_name_conv_tab[] = {
|
|||
{KEY_IC, "kpinsert", N_("Insert on keypad")},
|
||||
{KEY_DC, "kpdelete", N_("Delete on keypad")},
|
||||
{(int) '\n', "kpenter", N_("Enter on keypad")},
|
||||
{(int) '\n', "enter", N_("Enter on keypad")},
|
||||
{(int) '\t', "tab", N_("Tab on keypad")},
|
||||
{(int) ' ', "space", N_("Space on keypad")},
|
||||
{(int) '/', "kpslash", N_("Slash on keypad")},
|
||||
{(int) '#', "kpnumlock", N_("NumLock on keypad")},
|
||||
|
||||
/* Alternative label */
|
||||
{KEY_BACKSPACE, "backspace", N_("Backspace key")},
|
||||
{KEY_IC, "insert", N_("Insert key")},
|
||||
{KEY_KP_ADD, "plus", N_("+ on keypad")},
|
||||
{KEY_KP_SUBTRACT, "minus", N_("- on keypad")},
|
||||
{KEY_KP_MULTIPLY, "asterix", N_("* on keypad")},
|
||||
{(int) '+', "plus", N_("Plus")},
|
||||
{(int) '-', "minus", N_("Minus")},
|
||||
{(int) '*', "asterisk", N_("Asterisk")},
|
||||
{(int) '.', "dot", N_("Dot")},
|
||||
{(int) '<', "lt", N_("Less than")},
|
||||
{(int) '>', "gt", N_("Great than")},
|
||||
{(int) '=', "equal", N_("Equal")},
|
||||
{(int) ',', "comma", N_("Comma")},
|
||||
{(int) '\'', "apostrophe", N_("Apostrophe")},
|
||||
{(int) ':', "colon", N_("Colon")},
|
||||
{(int) '!', "exclamation", N_("Exclamation mark")},
|
||||
{(int) '?', "question", N_("Question mark")},
|
||||
{(int) '&', "ampersand", N_("Ampersand")},
|
||||
{(int) '$', "dollar", N_("Dollar sign")},
|
||||
{(int) '"', "quota", N_("Quotation mark")},
|
||||
{(int) '^', "caret", N_("Caret")},
|
||||
{(int) '~', "tilda", N_("Tilda")},
|
||||
{(int) '`', "prime", N_("Prime")},
|
||||
{(int) '_', "underline", N_("Underline")},
|
||||
{(int) '_', "understrike", N_("Understrike")},
|
||||
{(int) '|', "pipe", N_("Pipe")},
|
||||
{(int) '\n', "enter", N_("Enter")},
|
||||
{(int) '\t', "tab", N_("Tab key")},
|
||||
{(int) ' ', "space", N_("Space key")},
|
||||
{(int) '/', "slash", N_("Slash key")},
|
||||
{(int) '\\', "backslash", N_("Backslash key")},
|
||||
{(int) '#', "number", N_("Number sign #")},
|
||||
{(int) '#', "hash", N_("Number sign #")},
|
||||
|
||||
/* meta keys */
|
||||
{KEY_M_CTRL, "control", N_("Ctrl")},
|
||||
|
@ -1232,24 +1253,35 @@ lookup_key (char *keyname)
|
|||
if (keyname == NULL)
|
||||
return 0;
|
||||
|
||||
keys = g_strsplit (keyname, " ", -1);
|
||||
keys = g_strsplit_set (keyname, "-+ ", -1);
|
||||
keys_count = g_strv_length (keys);
|
||||
for (i = keys_count - 1; i >= 0; i--) {
|
||||
if (keys[i] != NULL && keys[i][0] != 0) {
|
||||
g_strstrip(keys[i]);
|
||||
key = lookup_keyname (keys[i]);
|
||||
|
||||
if (key & KEY_M_SHIFT) {
|
||||
if (k < 127) {
|
||||
k = (gchar) g_ascii_toupper ((gchar) k);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (key & KEY_M_CTRL) {
|
||||
if (k < 256)
|
||||
k = XCTRL (k);
|
||||
else
|
||||
k |= key;
|
||||
} else {
|
||||
if (k == -1)
|
||||
if (k == -1) {
|
||||
if (key < 127)
|
||||
key = (gchar) g_ascii_tolower ((gchar) key);
|
||||
k = key;
|
||||
else
|
||||
} else
|
||||
k |= key;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_strfreev (keys);
|
||||
if (k == -1)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -50,16 +50,23 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "../src/tty/tty.h"
|
||||
#include "../src/tty/key.h"
|
||||
|
||||
#include "../src/dialog.h" /* cb_ret_t */
|
||||
#include "../src/panel.h"
|
||||
#include "../src/layout.h"
|
||||
#include "../src/wtools.h"
|
||||
#include "../src/history.h"
|
||||
#include "../src/charsets.h"
|
||||
#include "../src/tty/tty.h"
|
||||
#include "../src/tty/key.h"
|
||||
#include "../src/cmd.h"
|
||||
#include "../src/execute.h"
|
||||
#include "../src/help.h"
|
||||
#include "../src/keybind.h" /* global_key_map_t */
|
||||
#include "../src/cmddef.h" /* CK_ cmd name const */
|
||||
|
||||
|
||||
#include "internal.h"
|
||||
#include "mcviewer.h"
|
||||
|
||||
|
@ -278,160 +285,154 @@ mcview_hook (void *v)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Both views */
|
||||
static cb_ret_t
|
||||
mcview_handle_key (mcview_t * view, int c)
|
||||
mcview_execute_cmd (mcview_t * view, int command, int key)
|
||||
{
|
||||
c = convert_from_input_c (c);
|
||||
int res = MSG_HANDLED;
|
||||
|
||||
if (view->hex_mode) {
|
||||
switch (c) {
|
||||
case '\t':
|
||||
switch (command) {
|
||||
case CK_HexViewToggleNavigationMode:
|
||||
view->hexview_in_text = !view->hexview_in_text;
|
||||
view->dirty++;
|
||||
return MSG_HANDLED;
|
||||
|
||||
case XCTRL ('a'):
|
||||
break;
|
||||
case CK_ViewMoveToBol:
|
||||
mcview_moveto_bol (view);
|
||||
view->dirty++;
|
||||
return MSG_HANDLED;
|
||||
|
||||
case XCTRL ('b'):
|
||||
mcview_move_left (view, 1);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case XCTRL ('e'):
|
||||
break;
|
||||
case CK_ViewMoveToEol:
|
||||
mcview_moveto_eol (view);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case XCTRL ('f'):
|
||||
break;
|
||||
case CK_ViewMoveLeft:
|
||||
mcview_move_left (view, 1);
|
||||
break;
|
||||
case CK_ViewMoveRight:
|
||||
mcview_move_right (view, 1);
|
||||
return MSG_HANDLED;
|
||||
break;
|
||||
default :
|
||||
res = MSG_NOT_HANDLED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (view->hexedit_mode && mcview_handle_editkey (view, c) == MSG_HANDLED)
|
||||
} else {
|
||||
switch (command) {
|
||||
case CK_ViewSearch:
|
||||
view->search_type = MC_SEARCH_T_REGEX;
|
||||
mcview_search_cmd (view);
|
||||
break;
|
||||
/* Continue search */
|
||||
case CK_ViewContinueSearch:
|
||||
mcview_continue_search_cmd (view);
|
||||
break;
|
||||
/* toggle ruler */
|
||||
case CK_ViewToggleRuler:
|
||||
mcview_toggle_ruler_cmd (view);
|
||||
break;
|
||||
case CK_ViewMoveLeft:
|
||||
mcview_move_left (view, 1);
|
||||
break;
|
||||
case CK_ViewMoveRight:
|
||||
mcview_move_right (view, 1);
|
||||
break;
|
||||
case CK_ViewMoveUp:
|
||||
mcview_move_up (view, 1);
|
||||
break;
|
||||
case CK_ViewMoveDown:
|
||||
mcview_move_down (view, 1);
|
||||
break;
|
||||
case CK_ViewMoveHalfPgUp:
|
||||
mcview_move_up (view, (view->data_area.height + 1) / 2);
|
||||
break;
|
||||
case CK_ViewMoveHalfPgDn:
|
||||
mcview_move_down (view, (view->data_area.height + 1) / 2);
|
||||
break;
|
||||
case CK_ViewMovePgUp:
|
||||
mcview_move_up (view, view->data_area.height);
|
||||
break;
|
||||
case CK_ViewMovePgDn:
|
||||
mcview_move_down (view, view->data_area.height);
|
||||
break;
|
||||
case CK_ShowCommandLine:
|
||||
view_other_cmd ();
|
||||
break;
|
||||
/*
|
||||
// Unlike Ctrl-O, run a new shell if the subshell is not running
|
||||
case '!':
|
||||
exec_shell ();
|
||||
return MSG_HANDLED;
|
||||
*/
|
||||
case CK_ViewGotoBookmark:
|
||||
view->marks[view->marker] = view->dpy_start;
|
||||
break;
|
||||
case CK_ViewNewBookmark:
|
||||
view->dpy_start = view->marks[view->marker];
|
||||
view->dirty++;
|
||||
break;
|
||||
case CK_ViewNextFile:
|
||||
/* Use to indicate parent that we want to see the next/previous file */
|
||||
/* Does not work in panel mode */
|
||||
if (!mcview_is_in_panel (view))
|
||||
view->move_dir = 1;
|
||||
break;
|
||||
case CK_ViewPrevFile:
|
||||
/* Use to indicate parent that we want to see the next/previous file */
|
||||
/* Does not work in panel mode */
|
||||
if (!mcview_is_in_panel (view))
|
||||
view->move_dir = -1;
|
||||
break;
|
||||
case CK_ViewQuit:
|
||||
if (mcview_ok_to_quit (view))
|
||||
view->want_to_quit = TRUE;
|
||||
break;
|
||||
case CK_SelectCodepage:
|
||||
mcview_select_encoding (view);
|
||||
view->dirty++;
|
||||
mcview_update (view);
|
||||
break;
|
||||
default :
|
||||
res = MSG_NOT_HANDLED;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (mcview_check_left_right_keys (view, c))
|
||||
|
||||
/* Both views */
|
||||
static cb_ret_t
|
||||
mcview_handle_key (mcview_t * view, int key)
|
||||
{
|
||||
key = convert_from_input_c (key);
|
||||
|
||||
int i;
|
||||
|
||||
if (view->hex_mode) {
|
||||
for (i = 0; view->hex_map[i].key != 0; i++)
|
||||
if ((key == view->hex_map[i].key)
|
||||
&& (mcview_execute_cmd (view, view->hex_map[i].command,
|
||||
key) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
} else {
|
||||
for (i = 0; view->plain_map[i].key != 0; i++)
|
||||
if ((key == view->plain_map[i].key)
|
||||
&& (mcview_execute_cmd (view, view->plain_map[i].command,
|
||||
key) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
if (mcview_check_left_right_keys (view, key))
|
||||
return MSG_HANDLED;
|
||||
|
||||
if (check_movement_keys (c, view->data_area.height + 1, view,
|
||||
if (check_movement_keys (key, view->data_area.height + 1, view,
|
||||
mcview_cmk_move_up, mcview_cmk_move_down,
|
||||
mcview_cmk_moveto_top, mcview_cmk_moveto_bottom))
|
||||
return MSG_HANDLED;
|
||||
|
||||
switch (c) {
|
||||
|
||||
case '?':
|
||||
case '/':
|
||||
view->search_type = MC_SEARCH_T_REGEX;
|
||||
mcview_search_cmd (view);
|
||||
return MSG_HANDLED;
|
||||
break;
|
||||
/* Continue search */
|
||||
case XCTRL ('r'):
|
||||
case XCTRL ('s'):
|
||||
case 'n':
|
||||
case KEY_F (17):
|
||||
mcview_continue_search_cmd (view);
|
||||
return MSG_HANDLED;
|
||||
|
||||
/* toggle ruler */
|
||||
case ALT ('r'):
|
||||
mcview_toggle_ruler_cmd (view);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'h':
|
||||
mcview_move_left (view, 1);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'j':
|
||||
case '\n':
|
||||
case 'e':
|
||||
mcview_move_down (view, 1);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'd':
|
||||
mcview_move_down (view, (view->data_area.height + 1) / 2);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'u':
|
||||
mcview_move_up (view, (view->data_area.height + 1) / 2);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'k':
|
||||
case 'y':
|
||||
mcview_move_up (view, 1);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'l':
|
||||
mcview_move_right (view, 1);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case ' ':
|
||||
case 'f':
|
||||
mcview_move_down (view, view->data_area.height);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case XCTRL ('o'):
|
||||
view_other_cmd ();
|
||||
return MSG_HANDLED;
|
||||
|
||||
/* Unlike Ctrl-O, run a new shell if the subshell is not running. */
|
||||
case '!':
|
||||
exec_shell ();
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'b':
|
||||
mcview_move_up (view, view->data_area.height);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case KEY_IC:
|
||||
mcview_move_up (view, 2);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case KEY_DC:
|
||||
mcview_move_down (view, 2);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'm':
|
||||
view->marks[view->marker] = view->dpy_start;
|
||||
return MSG_HANDLED;
|
||||
|
||||
case 'r':
|
||||
view->dpy_start = view->marks[view->marker];
|
||||
view->dirty++;
|
||||
return MSG_HANDLED;
|
||||
|
||||
/* Use to indicate parent that we want to see the next/previous file */
|
||||
/* Does not work in panel mode */
|
||||
case XCTRL ('f'):
|
||||
case XCTRL ('b'):
|
||||
if (!mcview_is_in_panel (view))
|
||||
view->move_dir = c == XCTRL ('f') ? 1 : -1;
|
||||
/* FALLTHROUGH */
|
||||
case 'q':
|
||||
case XCTRL ('g'):
|
||||
case ESC_CHAR:
|
||||
if (mcview_ok_to_quit (view))
|
||||
view->want_to_quit = TRUE;
|
||||
return MSG_HANDLED;
|
||||
|
||||
case XCTRL ('t'):
|
||||
mcview_select_encoding (view);
|
||||
view->dirty++;
|
||||
mcview_update (view);
|
||||
return MSG_HANDLED;
|
||||
|
||||
#ifdef MC_ENABLE_DEBUGGING_CODE
|
||||
case 't': /* mnemonic: "test" */
|
||||
if (c == 't') { /* mnemonic: "test" */
|
||||
mcview_ccache_dump (view);
|
||||
return MSG_HANDLED;
|
||||
#endif
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
view->marker = c - '0';
|
||||
#endif
|
||||
if (key >= '0' && key <= '9')
|
||||
view->marker = key - '0';
|
||||
|
||||
/* Key not used */
|
||||
return MSG_NOT_HANDLED;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "../src/widget.h"
|
||||
#include "../src/search/search.h"
|
||||
#include "../src/keybind.h" /* global_key_map_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants ********************/
|
||||
|
||||
|
@ -166,6 +167,10 @@ typedef struct mcview_struct {
|
|||
/* converter for translation of text */
|
||||
GIConv converter;
|
||||
|
||||
/* keymaps */
|
||||
const global_key_map_t *plain_map;
|
||||
const global_key_map_t *hex_map;
|
||||
|
||||
/* handle of search engine */
|
||||
mc_search_t *search;
|
||||
gchar *last_search_string;
|
||||
|
@ -192,7 +197,7 @@ typedef struct mcview_nroff_struct {
|
|||
|
||||
/*** declarations of public functions **********************************/
|
||||
|
||||
/* actions_cmd.c: callbacks */
|
||||
/* actions_cmd.c: */
|
||||
cb_ret_t mcview_callback (Widget *, widget_msg_t, int);
|
||||
cb_ret_t mcview_dialog_callback (Dlg_head *, dlg_msg_t, int);
|
||||
void mcview_help_cmd (void);
|
||||
|
|
|
@ -167,6 +167,19 @@ mcview_real_event (Gpm_Event * event, void *x)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
mcview_set_keymap (mcview_t * view)
|
||||
{
|
||||
int i;
|
||||
view->plain_map = default_viewer_keymap;
|
||||
if (viewer_keymap && viewer_keymap->len > 0)
|
||||
view->plain_map = (global_key_map_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;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/*** public functions ****************************************************************************/
|
||||
|
@ -238,6 +251,8 @@ mcview_new (int y, int x, int cols, int lines, int is_panel)
|
|||
if (mcview_default_magic_flag)
|
||||
mcview_toggle_magic_mode (view);
|
||||
|
||||
mcview_set_keymap (view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
223
src/widget.c
223
src/widget.c
|
@ -54,8 +54,13 @@
|
|||
#include "wtools.h"
|
||||
#include "strutil.h"
|
||||
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "keybind.h" /* global_key_map_t */
|
||||
|
||||
#define HISTORY_FILE_NAME ".mc/history"
|
||||
|
||||
const global_key_map_t *input_map;
|
||||
|
||||
static void
|
||||
widget_selectcolor (Widget *w, gboolean focused, gboolean hotkey)
|
||||
{
|
||||
|
@ -1623,72 +1628,6 @@ hist_next (WInput *in)
|
|||
in->need_push = 0;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
int key_code;
|
||||
void (*fn)(WInput *in);
|
||||
} input_map [] = {
|
||||
/* Motion */
|
||||
{ XCTRL('a'), beginning_of_line },
|
||||
{ KEY_HOME, beginning_of_line },
|
||||
{ KEY_A1, beginning_of_line },
|
||||
{ ALT ('<'), beginning_of_line },
|
||||
{ XCTRL('e'), end_of_line },
|
||||
{ KEY_END, end_of_line },
|
||||
{ KEY_C1, end_of_line },
|
||||
{ ALT ('>'), end_of_line },
|
||||
{ KEY_LEFT, key_left },
|
||||
{ KEY_LEFT | KEY_M_CTRL, key_ctrl_left },
|
||||
{ XCTRL('b'), backward_char },
|
||||
{ ALT('b'), backward_word },
|
||||
{ KEY_RIGHT, key_right },
|
||||
{ KEY_RIGHT | KEY_M_CTRL, key_ctrl_right },
|
||||
{ XCTRL('f'), forward_char },
|
||||
{ ALT('f'), forward_word },
|
||||
|
||||
/* Editing */
|
||||
{ KEY_BACKSPACE, backward_delete },
|
||||
{ KEY_DC, delete_char },
|
||||
{ ALT('d'), kill_word },
|
||||
{ ALT(KEY_BACKSPACE), back_kill_word },
|
||||
|
||||
/* Region manipulation */
|
||||
{ 0, set_mark },
|
||||
{ XCTRL('w'), kill_region },
|
||||
{ ALT('w'), kill_save },
|
||||
{ XCTRL('y'), yank },
|
||||
{ XCTRL('k'), kill_line },
|
||||
|
||||
/* History */
|
||||
{ ALT('p'), hist_prev },
|
||||
{ ALT('n'), hist_next },
|
||||
{ ALT('h'), do_show_hist },
|
||||
|
||||
/* Completion */
|
||||
{ ALT('\t'), complete },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/* This function is a test for a special input key used in complete.c */
|
||||
/* Returns 0 if it is not a special key, 1 if it is a non-complete key
|
||||
and 2 if it is a complete key */
|
||||
int
|
||||
is_in_input_map (WInput *in, int c_code)
|
||||
{
|
||||
int i;
|
||||
|
||||
(void) in;
|
||||
|
||||
for (i = 0; input_map [i].fn; i++)
|
||||
if (c_code == input_map [i].key_code) {
|
||||
if (input_map [i].fn == complete)
|
||||
return 2;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
port_region_marked_for_delete (WInput *in)
|
||||
{
|
||||
|
@ -1698,39 +1637,142 @@ port_region_marked_for_delete (WInput *in)
|
|||
in->charpoint = 0;
|
||||
}
|
||||
|
||||
static cb_ret_t
|
||||
input_execute_cmd (WInput *in, int command)
|
||||
{
|
||||
cb_ret_t res = MSG_HANDLED;
|
||||
|
||||
switch (command) {
|
||||
case CK_InputBol:
|
||||
beginning_of_line (in);
|
||||
break;
|
||||
case CK_InputEol:
|
||||
end_of_line (in);
|
||||
break;
|
||||
case CK_InputMoveLeft:
|
||||
key_left (in);
|
||||
break;
|
||||
case CK_InputWordLeft:
|
||||
key_ctrl_left (in);
|
||||
break;
|
||||
case CK_InputMoveRight:
|
||||
key_right (in);
|
||||
break;
|
||||
case CK_InputWordRight:
|
||||
key_ctrl_right (in);
|
||||
break;
|
||||
case CK_InputBackwardChar:
|
||||
backward_char (in);
|
||||
break;
|
||||
case CK_InputBackwardWord:
|
||||
backward_word (in);
|
||||
break;
|
||||
case CK_InputForwardChar:
|
||||
forward_char (in);
|
||||
break;
|
||||
case CK_InputForwardWord:
|
||||
forward_word (in);
|
||||
break;
|
||||
case CK_InputBackwardDelete:
|
||||
backward_delete (in);
|
||||
break;
|
||||
case CK_InputDeleteChar:
|
||||
delete_char (in);
|
||||
break;
|
||||
case CK_InputKillWord:
|
||||
kill_word (in);
|
||||
break;
|
||||
case CK_InputBackwardKillWord:
|
||||
back_kill_word (in);
|
||||
break;
|
||||
case CK_InputSetMark:
|
||||
set_mark (in);
|
||||
break;
|
||||
case CK_InputKillRegion:
|
||||
kill_region (in);
|
||||
break;
|
||||
case CK_InputKillSave:
|
||||
kill_save (in);
|
||||
break;
|
||||
case CK_InputYank:
|
||||
yank (in);
|
||||
break;
|
||||
case CK_InputKillLine:
|
||||
kill_line (in);
|
||||
break;
|
||||
case CK_InputHistoryPrev:
|
||||
hist_prev (in);
|
||||
break;
|
||||
case CK_InputHistoryNext:
|
||||
hist_next (in);
|
||||
break;
|
||||
case CK_InputHistoryShow:
|
||||
do_show_hist (in);
|
||||
break;
|
||||
case CK_InputComplete:
|
||||
complete (in);
|
||||
break;
|
||||
default:
|
||||
res = MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* This function is a test for a special input key used in complete.c */
|
||||
/* Returns 0 if it is not a special key, 1 if it is a non-complete key
|
||||
and 2 if it is a complete key */
|
||||
int
|
||||
is_in_input_map (WInput *in, int key)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; input_map[i].key; i++) {
|
||||
if (key == input_map[i].key) {
|
||||
input_execute_cmd (in, input_map[i].command);
|
||||
if (input_map[i].command == CK_InputComplete)
|
||||
return 2;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
cb_ret_t
|
||||
handle_char (WInput *in, int c_code)
|
||||
handle_char (WInput *in, int key)
|
||||
{
|
||||
cb_ret_t v;
|
||||
int i;
|
||||
|
||||
v = MSG_NOT_HANDLED;
|
||||
|
||||
if (quote){
|
||||
free_completions (in);
|
||||
v = insert_char (in, c_code);
|
||||
update_input (in, 1);
|
||||
quote = 0;
|
||||
return v;
|
||||
if (quote) {
|
||||
free_completions (in);
|
||||
v = insert_char (in, key);
|
||||
update_input (in, 1);
|
||||
quote = 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
for (i = 0; input_map [i].fn; i++){
|
||||
if (c_code == input_map [i].key_code){
|
||||
if (input_map [i].fn != complete)
|
||||
free_completions (in);
|
||||
(*input_map [i].fn)(in);
|
||||
v = MSG_HANDLED;
|
||||
break;
|
||||
}
|
||||
for (i = 0; input_map[i].key; i++) {
|
||||
if (key == input_map[i].key) {
|
||||
if (input_map[i].command != CK_InputComplete) {
|
||||
free_completions (in);
|
||||
input_execute_cmd (in, input_map[i].command);
|
||||
update_input (in, 1);
|
||||
v = MSG_HANDLED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!input_map [i].fn){
|
||||
if (c_code > 255)
|
||||
return MSG_NOT_HANDLED;
|
||||
if (in->first){
|
||||
port_region_marked_for_delete (in);
|
||||
}
|
||||
free_completions (in);
|
||||
v = insert_char (in, c_code);
|
||||
if (input_map[i].command == 0) {
|
||||
if (key > 255)
|
||||
return MSG_NOT_HANDLED;
|
||||
if (in->first)
|
||||
port_region_marked_for_delete (in);
|
||||
free_completions (in);
|
||||
v = insert_char (in, key);
|
||||
}
|
||||
update_input (in, 1);
|
||||
return v;
|
||||
|
@ -1793,6 +1835,9 @@ input_callback (Widget *w, widget_msg_t msg, int parm)
|
|||
|
||||
return handle_char (in, parm);
|
||||
|
||||
case WIDGET_COMMAND:
|
||||
return input_execute_cmd (in, parm);
|
||||
|
||||
case WIDGET_FOCUS:
|
||||
case WIDGET_UNFOCUS:
|
||||
case WIDGET_DRAW:
|
||||
|
|
Loading…
Reference in New Issue