2 Default values for keybinding engine
4 Copyright (C) 2009-2020
5 Free Software Foundation, Inc.
9 Ilia Maslakov <il.smind@gmail.com>, 2009, 2010
10 Andrew Borodin <aborodin@vmail.ru>, 2010, 2011
12 This file is part of the Midnight Commander.
14 The Midnight Commander is free software: you can redistribute it
15 and/or modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation, either version 3 of the License,
17 or (at your option) any later version.
19 The Midnight Commander is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include "lib/global.h"
31 #include "lib/widget.h" /* dialog_map, input_map, listbox_map, menu_map, radio_map */
33 #include "keybind-defaults.h"
35 /*** global variables ****************************************************************************/
37 GArray
*main_keymap
= NULL
;
38 GArray
*main_x_keymap
= NULL
;
39 GArray
*panel_keymap
= NULL
;
40 GArray
*dialog_keymap
= NULL
;
41 GArray
*menu_keymap
= NULL
;
42 GArray
*input_keymap
= NULL
;
43 GArray
*listbox_keymap
= NULL
;
44 GArray
*radio_keymap
= NULL
;
45 GArray
*tree_keymap
= NULL
;
46 GArray
*help_keymap
= NULL
;
47 #ifdef ENABLE_EXT2FS_ATTR
48 GArray
*chattr_keymap
= NULL
;
50 #ifdef USE_INTERNAL_EDIT
51 GArray
*editor_keymap
= NULL
;
52 GArray
*editor_x_keymap
= NULL
;
54 GArray
*viewer_keymap
= NULL
;
55 GArray
*viewer_hex_keymap
= NULL
;
57 GArray
*diff_keymap
= NULL
;
60 const global_keymap_t
*main_map
= NULL
;
61 const global_keymap_t
*main_x_map
= NULL
;
62 const global_keymap_t
*panel_map
= NULL
;
63 const global_keymap_t
*tree_map
= NULL
;
64 const global_keymap_t
*help_map
= NULL
;
65 #ifdef ENABLE_EXT2FS_ATTR
66 const global_keymap_t
*chattr_map
= NULL
;
68 #ifdef USE_INTERNAL_EDIT
69 const global_keymap_t
*editor_map
= NULL
;
70 const global_keymap_t
*editor_x_map
= NULL
;
72 const global_keymap_t
*viewer_map
= NULL
;
73 const global_keymap_t
*viewer_hex_map
= NULL
;
75 const global_keymap_t
*diff_map
= NULL
;
78 /*** file scope macro definitions ****************************************************************/
80 /*** file scope type declarations ****************************************************************/
82 /* default keymaps in ini (key=value) format */
83 typedef struct global_keymap_ini_t
87 } global_keymap_ini_t
;
89 /*** file scope variables ************************************************************************/
92 static const global_keymap_ini_t default_main_keymap
[] = {
93 {"ChangePanel", "tab"},
104 {"MenuLastSelected", "f19"},
105 {"QuitQuiet", "f20"},
106 {"History", "alt-h"},
107 {"EditorViewerHistory", "alt-shift-e"},
108 {"DirSize", "ctrl-space"},
109 /* Copy useful information to the command line */
110 {"PutCurrentPath", "alt-a"},
111 {"PutOtherPath", "alt-shift-a"},
112 {"PutCurrentSelected", "alt-enter; ctrl-enter"},
113 {"PutCurrentFullSelected", "ctrl-shift-enter"},
114 {"CdQuick", "alt-c"},
115 /* To access the directory hotlist */
116 {"HotList", "ctrl-backslash"},
118 {"Suspend", "ctrl-z"},
119 /* The filtered view command */
120 {"ViewFiltered", "alt-exclamation"},
122 {"Find", "alt-question"},
124 {"Reread", "ctrl-r"},
125 /* Switch listing between long, user defined and full formats */
129 {"SplitEqual", "alt-equal"},
130 {"SplitMore", "alt-shift-right"},
131 {"SplitLess", "alt-shift-left"},
134 {"ShowHidden", "alt-dot"},
135 {"SplitVertHoriz", "alt-comma"},
136 {"ExtendedKeyMap", "ctrl-x"},
137 /* Select/unselect group */
138 {"Select", "kpplus"},
139 {"Unselect", "kpminus"},
140 {"SelectInvert", "kpasterisk"},
141 /* List of screens */
142 {"ScreenList", "alt-prime"},
146 static const global_keymap_ini_t default_main_x_keymap
[] = {
147 {"CompareDirs", "d"},
149 {"CompareFiles", "ctrl-d"},
150 #endif /* USE_DIFF_VIEW */
153 #endif /* ENABLE_VFS */
154 {"PutCurrentPath", "p"},
155 {"PutOtherPath", "ctrl-p"},
156 {"PutCurrentTagged", "t"},
157 {"PutOtherTagged", "ctrl-t"},
160 #ifdef ENABLE_EXT2FS_ATTR
161 {"ChangeAttributes", "e"},
162 #endif /* ENABLE_EXT2FS_ATTR */
163 {"PutCurrentLink", "r"},
164 {"PutOtherLink", "ctrl-r"},
166 {"LinkSymbolic", "s"},
167 {"LinkSymbolicRelative", "v"},
168 {"LinkSymbolicEdit", "ctrl-s"},
170 {"PanelQuickView", "q"},
172 #ifdef ENABLE_BACKGROUND
174 #endif /* ENABLE_BACKGROUND */
175 {"ExternalPanelize", "!"},
180 static const global_keymap_ini_t default_panel_keymap
[] = {
181 {"CycleListingFormat", "alt-t"},
182 {"PanelOtherCd", "alt-o"},
183 {"PanelOtherCdLink", "alt-l"},
184 {"CopySingle", "f15"},
185 {"DeleteSingle", "f18"},
188 {"MoveSingle", "f16"},
189 {"SelectInvert", "alt-asterisk"},
190 {"Select", "alt-plus"},
191 {"Unselect", "alt-minus"},
193 {"CdChild", "ctrl-pgdn"},
194 {"CdParent", "ctrl-pgup"},
195 {"History", "alt-shift-h"},
196 {"HistoryNext", "alt-u"},
197 {"HistoryPrev", "alt-y"},
198 {"BottomOnScreen", "alt-j"},
199 {"MiddleOnScreen", "alt-r"},
200 {"TopOnScreen", "alt-g"},
201 {"Mark", "insert; ctrl-t"},
202 {"MarkDown", "shift-down"},
203 {"MarkUp", "shift-up"},
204 {"Up", "up; ctrl-p"},
205 {"Down", "down; ctrl-n"},
208 {"Top", "alt-lt; home; a1"},
209 {"Bottom", "alt-gt; end; c1"},
210 {"PageDown", "pgdn; ctrl-v"},
211 {"PageUp", "pgup; alt-v"},
213 {"SelectCodepage", "alt-e"},
215 {"Search", "ctrl-s; alt-s"},
216 {"PanelOtherSync", "alt-i"},
221 static const global_keymap_ini_t default_dialog_keymap
[] = {
223 {"Cancel", "f10; esc; ctrl-g"},
225 {"Down", "down; right"},
227 {"Left", "up; left"},
228 {"Right", "down; right"},
231 {"Suspend", "ctrl-z"},
232 {"Refresh", "ctrl-l"},
233 {"ScreenList", "alt-prime"},
234 {"ScreenNext", "alt-rbrace"},
235 {"ScreenPrev", "alt-lbrace"},
240 static const global_keymap_ini_t default_menu_keymap
[] = {
242 {"Left", "left; ctrl-b"},
243 {"Right", "right; ctrl-f"},
244 {"Up", "up; ctrl-p"},
245 {"Down", "down; ctrl-n"},
246 {"Home", "home; alt-lt; ctrl-a"},
247 {"End", "end; alt-gt; ctrl-e"},
249 {"Quit", "f10; ctrl-g; esc"},
254 static const global_keymap_ini_t default_input_keymap
[] = {
256 {"Home", "ctrl-a; alt-lt; home; a1"},
257 {"End", "ctrl-e; alt-gt; end; c1"},
258 {"Left", "left; alt-left; ctrl-b"},
259 {"Right", "right; alt-right; ctrl-f"},
260 {"WordLeft", "ctrl-left; alt-b"},
261 {"WordRight", "ctrl-right; alt-f"},
263 {"MarkLeft", "shift-left"},
264 {"MarkRight", "shift-right"},
265 {"MarkToWordBegin", "ctrl-shift-left"},
266 {"MarkToWordEnd", "ctrl-shift-right"},
267 {"MarkToHome", "shift-home"},
268 {"MarkToEnd", "shift-end"},
270 {"Backspace", "backspace; ctrl-h"},
271 {"Delete", "delete; ctrl-d"},
272 {"DeleteToWordEnd", "alt-d"},
273 {"DeleteToWordBegin", "alt-backspace"},
274 /* Region manipulation */
275 {"Remove", "ctrl-w"},
278 {"DeleteToEnd", "ctrl-k"},
280 {"History", "alt-h"},
281 {"HistoryPrev", "alt-p; ctrl-down"},
282 {"HistoryNext", "alt-n; ctrl-up"},
284 {"Complete", "alt-tab"},
289 static const global_keymap_ini_t default_listbox_keymap
[] = {
290 {"Up", "up; ctrl-p"},
291 {"Down", "down; ctrl-n"},
292 {"Top", "home; alt-lt; a1"},
293 {"Bottom", "end; alt-gt; c1"},
294 {"PageUp", "pgup; alt-v"},
295 {"PageDown", "pgdn; ctrl-v"},
296 {"Delete", "delete; d"},
297 {"Clear", "shift-delete; shift-d"},
305 static const global_keymap_ini_t default_radio_keymap
[] = {
306 {"Up", "up; ctrl-p"},
307 {"Down", "down; ctrl-n"},
308 {"Top", "home; alt-lt; a1"},
309 {"Bottom", "end; alt-gt; c1"},
315 static const global_keymap_ini_t default_tree_keymap
[] = {
317 {"Rescan", "f2; ctrl-r"},
319 {"ToggleNavigation", "f4"},
325 {"Delete", "f8; delete"},
326 {"Up", "up; ctrl-p"},
327 {"Down", "down; ctrl-n"},
330 {"Top", "home; alt-lt; a1"},
331 {"Bottom", "end; alt-gt; c1"},
332 {"PageUp", "pgup; alt-v"},
333 {"PageDown", "pgdn; ctrl-v"},
335 {"Search", "ctrl-s; alt-s"},
340 static const global_keymap_ini_t default_help_keymap
[] = {
343 {"Back", "f3; left; l"},
344 {"Quit", "f10; esc"},
345 {"Up", "up; ctrl-p"},
346 {"Down", "down; ctrl-n"},
347 {"PageDown", "f; space; pgdn; ctrl-v"},
348 {"PageUp", "b; pgup; alt-v; backspace"},
349 {"HalfPageDown", "d"},
351 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
352 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
353 {"Enter", "right; enter"},
355 {"LinkPrev", "alt-tab"},
361 #ifdef ENABLE_EXT2FS_ATTR
363 static const global_keymap_ini_t default_chattr_keymap
[] = {
364 {"Up", "up; left; ctrl-p"},
365 {"Down", "down; right; ctrl-n"},
366 {"Top", "home; alt-lt; a1"},
367 {"Bottom", "end; alt-gt; c1"},
368 {"PageUp", "pgup; alt-v"},
369 {"PageDown", "pgdn; ctrl-v"},
370 {"Mark", "t; shift-t"},
371 {"MarkAndDown", "insert"},
374 #endif /* ENABLE_EXT2FS_ATTR */
376 #ifdef USE_INTERNAL_EDIT
377 static const global_keymap_ini_t default_editor_keymap
[] = {
379 {"Return", "shift-enter; ctrl-enter; ctrl-shift-enter"}, /* useful for pasting multiline text */
380 {"Tab", "tab; shift-tab; ctrl-tab; ctrl-shift-tab"}, /* ditto */
381 {"BackSpace", "backspace; ctrl-h"},
382 {"Delete", "delete; ctrl-d"},
390 {"PageDown", "pgdn"},
391 {"WordLeft", "ctrl-left; ctrl-z"},
392 {"WordRight", "ctrl-right; ctrl-x"},
393 {"InsertOverwrite", "insert"},
401 {"Remove", "f8; ctrl-delete"},
403 {"Quit", "f10; esc"},
405 {"SaveAs", "f12; ctrl-f2"},
406 {"MarkColumn", "f13"},
407 {"ReplaceContinue", "f14; ctrl-f4"},
408 {"InsertFile", "f15"},
409 {"SearchContinue", "f17; ctrl-f7"},
410 {"EditNew", "ctrl-n"},
411 {"DeleteToWordBegin", "alt-backspace"},
412 {"DeleteToWordEnd", "alt-d"},
413 {"DeleteLine", "ctrl-y"},
414 {"DeleteToEnd", "ctrl-k"},
415 {"Undo", "ctrl-u; ctrl-backspace"},
418 {"SelectCodepage", "alt-e"},
420 {"Goto", "alt-l; alt-shift-l"},
421 {"Refresh", "ctrl-l"},
423 {"Top", "ctrl-home; ctrl-pgup; alt-lt"},
424 {"Bottom", "ctrl-end; ctrl-pgdn; alt-gt"},
425 {"TopOnScreen", "ctrl-pgup"},
426 {"BottomOnScreen", "ctrl-pgdn"},
427 {"ScrollUp", "ctrl-up"},
428 {"ScrollDown", "ctrl-down"},
429 {"Store", "ctrl-insert"},
430 {"Paste", "shift-insert"},
431 {"Cut", "shift-delete"},
432 {"BlockSave", "ctrl-f"},
433 {"MarkLeft", "shift-left"},
434 {"MarkRight", "shift-right"},
435 {"MarkUp", "shift-up"},
436 {"MarkDown", "shift-down"},
437 {"MarkPageUp", "shift-pgup"},
438 {"MarkPageDown", "shift-pgdn"},
439 {"MarkToWordBegin", "ctrl-shift-left"},
440 {"MarkToWordEnd", "ctrl-shift-right"},
441 {"MarkToHome", "shift-home"},
442 {"MarkToEnd", "shift-end"},
443 {"MarkToFileBegin", "ctrl-shift-home"},
444 {"MarkToFileEnd", "ctrl-shift-end"},
445 {"MarkToPageBegin", "ctrl-shift-pgup"},
446 {"MarkToPageEnd", "ctrl-shift-pgdn"},
447 {"MarkScrollUp", "ctrl-shift-up"},
448 {"MarkScrollDown", "ctrl-shift-down"},
449 {"MarkColumnLeft", "alt-left"},
450 {"MarkColumnRight", "alt-right"},
451 {"MarkColumnUp", "alt-up"},
452 {"MarkColumnDown", "alt-down"},
453 {"MarkColumnPageUp", "alt-pgup"},
454 {"MarkColumnPageDown", "alt-pgdn"},
455 {"InsertLiteral", "ctrl-q"},
456 {"Complete", "alt-tab"},
457 {"MatchBracket", "alt-b"},
458 {"ParagraphFormat", "alt-p"},
459 {"Bookmark", "alt-k"},
460 {"BookmarkFlush", "alt-o"},
461 {"BookmarkNext", "alt-j"},
462 {"BookmarkPrev", "alt-i"},
463 {"MacroStartStopRecord", "ctrl-r"},
464 {"MacroExecute", "ctrl-a"},
465 {"ShowNumbers", "alt-n"},
466 {"ShowTabTws", "alt-underline"},
467 {"SyntaxOnOff", "ctrl-s"},
468 {"Find", "alt-enter"},
469 {"FilePrev", "alt-minus"},
470 {"FileNext", "alt-plus"},
473 {"ExternalCommand", "alt-u"},
475 {"SpellCheckCurrentWord", "ctrl-p"},
477 {"ExtendedKeyMap", "ctrl-x"},
481 /* emacs keyboard layout emulation */
482 static const global_keymap_ini_t default_editor_x_keymap
[] = {
485 #endif /* USE_INTERNAL_EDIT */
488 static const global_keymap_ini_t default_viewer_keymap
[] = {
491 {"Quit", "f3; f10; q; esc"},
495 {"SearchContinue", "f17; n"},
501 {"Right", "l; right"},
502 {"LeftQuick", "ctrl-left"},
503 {"RightQuick", "ctrl-right"},
504 {"Up", "k; y; insert; up; ctrl-p"},
505 {"Down", "j; e; delete; down; enter; ctrl-n"},
506 {"PageDown", "f; space; pgdn; ctrl-v"},
507 {"PageUp", "b; pgup; alt-v; backspace"},
508 {"HalfPageDown", "d"},
510 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
511 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
512 {"BookmarkGoto", "m"},
514 {"FileNext", "ctrl-f"},
515 {"FilePrev", "ctrl-b"},
517 {"SelectCodepage", "alt-e"},
521 {"SearchForward", "slash"},
522 {"SearchBackward", "question"},
523 {"SearchForwardContinue", "ctrl-s"},
524 {"SearchBackwardContinue", "ctrl-r"},
525 {"SearchOppositeContinue", "shift-n"},
526 {"History", "alt-shift-e"},
531 static const global_keymap_ini_t default_viewer_hex_keymap
[] = {
533 {"HexEditMode", "f2"},
534 {"Quit", "f3; f10; q; esc"},
539 {"SearchContinue", "f17; n"},
542 {"ToggleNavigation", "tab"},
543 {"Home", "ctrl-a; home"},
544 {"End", "ctrl-e; end"},
546 {"Right", "f; right"},
548 {"Down", "j; delete; down"},
549 {"PageDown", "pgdn; ctrl-v"},
550 {"PageUp", "pgup; alt-v"},
551 {"Top", "ctrl-home; ctrl-pgup; a1; alt-lt; g"},
552 {"Bottom", "ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
554 {"SelectCodepage", "alt-e"},
557 {"SearchForward", "slash"},
558 {"SearchBackward", "question"},
559 {"SearchForwardContinue", "ctrl-s"},
560 {"SearchBackwardContinue", "ctrl-r"},
561 {"SearchOppositeContinue", "shift-n"},
562 {"History", "alt-shift-e"},
568 static const global_keymap_ini_t default_diff_keymap
[] = {
569 {"ShowSymbols", "alt-s; s"},
570 {"ShowNumbers", "alt-n; l"},
572 {"SplitEqual", "equal"},
581 {"HunkNext", "n; enter; space"},
582 {"HunkPrev", "p; backspace"},
583 {"Goto", "g; shift-g"},
586 {"EditOther", "f14"},
588 {"MergeOther", "f15"},
590 {"SearchContinue", "f17"},
592 {"Top", "ctrl-home"},
593 {"Bottom", "ctrl-end"},
596 {"LeftQuick", "ctrl-left"},
597 {"RightQuick", "ctrl-right"},
600 {"PageDown", "pgdn"},
605 {"Quit", "f10; q; shift-q; esc"},
607 {"SelectCodepage", "alt-e"},
614 /*** file scope macro definitions ****************************************************************/
616 /*** file scope type declarations ****************************************************************/
618 /*** file scope variables ************************************************************************/
620 /*** file scope functions ************************************************************************/
621 /* --------------------------------------------------------------------------------------------- */
624 create_default_keymap_section (mc_config_t
* keymap
, const char *section
,
625 const global_keymap_ini_t
* k
)
629 for (i
= 0; k
[i
].key
!= NULL
; i
++)
630 mc_config_set_string_raw (keymap
, section
, k
[i
].key
, k
[i
].value
);
633 /* --------------------------------------------------------------------------------------------- */
634 /*** public functions ****************************************************************************/
635 /* --------------------------------------------------------------------------------------------- */
638 create_default_keymap (void)
642 keymap
= mc_config_init (NULL
, TRUE
);
644 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN
, default_main_keymap
);
645 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN_EXT
, default_main_x_keymap
);
646 create_default_keymap_section (keymap
, KEYMAP_SECTION_PANEL
, default_panel_keymap
);
647 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIALOG
, default_dialog_keymap
);
648 create_default_keymap_section (keymap
, KEYMAP_SECTION_MENU
, default_menu_keymap
);
649 create_default_keymap_section (keymap
, KEYMAP_SECTION_INPUT
, default_input_keymap
);
650 create_default_keymap_section (keymap
, KEYMAP_SECTION_LISTBOX
, default_listbox_keymap
);
651 create_default_keymap_section (keymap
, KEYMAP_SECTION_RADIO
, default_radio_keymap
);
652 create_default_keymap_section (keymap
, KEYMAP_SECTION_TREE
, default_tree_keymap
);
653 create_default_keymap_section (keymap
, KEYMAP_SECTION_HELP
, default_help_keymap
);
654 #ifdef ENABLE_EXT2FS_ATTR
655 create_default_keymap_section (keymap
, KEYMAP_SECTION_HELP
, default_chattr_keymap
);
657 #ifdef USE_INTERNAL_EDIT
658 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR
, default_editor_keymap
);
659 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR_EXT
, default_editor_x_keymap
);
661 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER
, default_viewer_keymap
);
662 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER_HEX
, default_viewer_hex_keymap
);
664 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIFFVIEWER
, default_diff_keymap
);