From 87102cc7e8435b57674933934dcfaf171750bc23 Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Mon, 28 Sep 2009 20:25:46 +0000 Subject: [PATCH] fix: main.c keys handler add more keys into mc.keymap fix: CK_SingleDirsizeCmd event add default keys (alt-'.', alt-'+') mc.keymap Signed-off-by: Ilia Maslakov Added alt-shift-h hotkey Add some documentation about keymap file. Replace some symbols into names '.' to 'dot', '?' to question, etc. Signed-off-by: Slava Zanko --- doc/man/mc.1.in | 60 ++++++++++++++++++++++++++++++++++++++++++++++++- doc/man/ru/mc.1.in | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- edit/edit.c | 4 +--- misc/mc.keymap | 28 +++++++++++------------ src/cmddef.h | 2 +- src/keybind.c | 5 +++-- src/keybind.h | 2 +- src/main.c | 10 +++++++-- src/tty/key.c | 19 ++++++++++++++++ 9 files changed, 170 insertions(+), 26 deletions(-) diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in index 00b247e53..a04668e1b 100644 --- a/doc/man/mc.1.in +++ b/doc/man/mc.1.in @@ -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 . means hold the Shift key down while typing . .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 \ +or +.BR \-\-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: diff --git a/doc/man/ru/mc.1.in b/doc/man/ru/mc.1.in index 1bd0719ad..1ee295a87 100644 --- a/doc/man/ru/mc.1.in +++ b/doc/man/ru/mc.1.in @@ -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 " Разные команды" Имеется несколько действий, ассоциированных с некоторыми комбинациями diff --git a/edit/edit.c b/edit/edit.c index 51eabac6b..a8e9a640c 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -723,10 +723,8 @@ static void edit_set_keymap (WEdit *edit) { edit->user_map = default_editor_keymap; - if (editor_keymap && editor_keymap->len > 0) { + if (editor_keymap && editor_keymap->len > 0) edit->user_map = (global_key_map_t *) editor_keymap->data; - mc_log ("edit->user_map"); - } } diff --git a/misc/mc.keymap b/misc/mc.keymap index 40c9cd06a..95664b62c 100644 --- a/misc/mc.keymap +++ b/misc/mc.keymap @@ -156,7 +156,7 @@ ViewMoveUp = k; y; up ViewMoveDown = j; delete; down [viewer] -ViewSearch = ?; /; f7 +ViewSearch = question; slash; f7 ViewContinueSearch = ctrl-r; ctrl-s; f17 ViewMoveToBol = home ViewMoveToEol = end @@ -180,18 +180,19 @@ ViewToggleRuler = alt-r [main] CmdMenuLastSelected = f19 CmdQuietQuit = f20 -CmdSingleDirsize = ctrl-@ +CmdSingleDirsize = ctrl-space CmdCopyCurrentPathname = alt-a CmdCopyOtherPathname = alt-A CmdQuickCd = alt-c -CmdQuickChdir = ctrl-\\ +CmdQuickChdir = ctrl-backslash CmdSuspend = ctrl-z -CmdFilteredView = alt-! -CmdFind = alt-? +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] @@ -214,12 +215,12 @@ PanelEditNew = F14 PanelCopyLocal = F15 PanelRenameLocal = F16 PanelDeleteLocal = F18 -PanelReverseSelection = alt-* -PanelSelect = plus -PanelUnselect = minus +PanelReverseSelection = alt-asterisk +PanelSelect = alt-plus +PanelUnselect = alt-minus PanelCtrlNextPage = ctrl-pgdn PanelCtrlPrevPage = ctrl-pgup -PanelDirectoryHistoryList = alt-H +PanelDirectoryHistoryList = alt-shift-h PanelDirectoryHistoryNext = alt-u PanelDirectoryHistoryPrev = alt-y PanelGotoBottomFile = alt-j @@ -227,15 +228,14 @@ PanelGotoMiddleFile = alt-r PanelSyncOtherPanel = alt-i PanelGotoTopFile = alt-g PanelSetPanelEncoding = ctrl-t -PanelMoveHome = home -PanelMoveEnd = end - +PanelMoveHome = alt-lt; home +PanelMoveEnd = alt-gt; end [panel:xmap] [input] -InputBol = ctrl-a; alt-<; home -InputEol = ctrl-e; alt->; end +InputBol = ctrl-a; alt-lt; home +InputEol = ctrl-e; alt-gt; end InputMoveLeft = left; alt-left InputWordLeft = ctrl-left InputBackwardChar = ctrl-b diff --git a/src/cmddef.h b/src/cmddef.h index 999e20472..ca2223682 100644 --- a/src/cmddef.h +++ b/src/cmddef.h @@ -304,7 +304,7 @@ #define CK_AddHotlist 7062 #define CK_QuitCmd 7064 #define CK_CopyOtherTarget 7065 -#define CK_CopyOthertReadlink 7066 +#define CK_ToggleShowHidden 7066 /* panels */ #define CK_PanelChdirOtherPanel 8001 diff --git a/src/keybind.c b/src/keybind.c index f362f586f..2cc21bfc9 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -274,12 +274,12 @@ static const name_key_map_t command_names[] = { { "CmdUserFileMenu", CK_UserFileMenuCmd }, { "CmdView", CK_ViewCmd }, { "CmdViewFile", CK_ViewFileCmd }, - { "CmdCmdCopyCurrentReadlink", CK_CopyCurrentReadlink }, + { "CmdCopyCurrentReadlink", CK_CopyCurrentReadlink }, { "CmdCopyOtherReadlink", CK_CopyOtherReadlink }, { "CmdAddHotlist", CK_AddHotlist }, { "CmdQuit", CK_QuitCmd }, { "CmdCopyOtherTarget", CK_CopyOtherTarget }, - { "CmdCopyOthertReadlink", CK_CopyOthertReadlink }, + { "CmdToggleShowHidden", CK_ToggleShowHidden }, /* panel */ { "PanelChdirOtherPanel", CK_PanelChdirOtherPanel }, @@ -611,6 +611,7 @@ const global_key_map_t default_main_map[] = { {XCTRL ('u'), CK_SwapCmd}, /* View output */ {XCTRL ('o'), CK_ShowCommandLine}, + {ALT ('.'), CK_ToggleShowHidden}, {XCTRL ('x'), CK_StartExtMap1 }, { 0, 0 } }; diff --git a/src/keybind.h b/src/keybind.h index 5bb65d4c4..540f49d15 100644 --- a/src/keybind.h +++ b/src/keybind.h @@ -47,4 +47,4 @@ extern const global_key_map_t default_input_keymap[]; extern const global_key_map_t default_main_map[]; extern const global_key_map_t default_main_x_map[]; -const global_key_map_t default_input_keymap[]; +extern const global_key_map_t default_input_keymap[]; diff --git a/src/main.c b/src/main.c index db62c231a..69403de02 100644 --- a/src/main.c +++ b/src/main.c @@ -1215,7 +1215,7 @@ midnight_execute_cmd(int command) quiet_quit_cmd (); break; case CK_SingleDirsizeCmd: - single_dirsize_cmd (); + smart_dirsize_cmd (); break; case CK_CopyCurrentPathname: copy_current_pathname (); @@ -1251,10 +1251,13 @@ midnight_execute_cmd(int command) 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 (); @@ -1265,7 +1268,7 @@ midnight_execute_cmd(int command) case CK_CopyCurrentReadlink: copy_current_readlink (); break; - case CK_CopyOthertReadlink: + case CK_CopyOtherReadlink: copy_other_readlink (); break; case CK_ChmodCmd: @@ -1300,6 +1303,9 @@ midnight_execute_cmd(int command) jobs_cmd (); break; #endif + case CK_ToggleShowHidden: + toggle_show_hidden (); + break; case CK_StartExtMap1: ctl_x_cmd (); break; diff --git a/src/tty/key.c b/src/tty/key.c index 74dccf9c4..edc033ed7 100644 --- a/src/tty/key.c +++ b/src/tty/key.c @@ -152,12 +152,31 @@ key_code_name_t key_name_conv_tab[] = { {(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")}, -- 2.11.4.GIT