2 Default values for keybinding engine
4 Copyright (C) 2009, 2010, 2011
5 The 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 */
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
*input_keymap
= NULL
;
42 GArray
*listbox_keymap
= NULL
;
43 GArray
*tree_keymap
= NULL
;
44 GArray
*help_keymap
= NULL
;
45 #ifdef USE_INTERNAL_EDIT
46 GArray
*editor_keymap
= NULL
;
47 GArray
*editor_x_keymap
= NULL
;
49 GArray
*viewer_keymap
= NULL
;
50 GArray
*viewer_hex_keymap
= NULL
;
52 GArray
*diff_keymap
= NULL
;
55 const global_keymap_t
*main_map
= NULL
;
56 const global_keymap_t
*main_x_map
= NULL
;
57 const global_keymap_t
*panel_map
= NULL
;
58 const global_keymap_t
*tree_map
= NULL
;
59 const global_keymap_t
*help_map
= NULL
;
61 #ifdef USE_INTERNAL_EDIT
62 const global_keymap_t
*editor_map
= NULL
;
63 const global_keymap_t
*editor_x_map
= NULL
;
65 const global_keymap_t
*viewer_map
= NULL
;
66 const global_keymap_t
*viewer_hex_map
= NULL
;
68 const global_keymap_t
*diff_map
= NULL
;
71 /*** file scope macro definitions ****************************************************************/
73 /*** file scope type declarations ****************************************************************/
75 /* default keymaps in ini (key=value) format */
76 typedef struct global_keymap_ini_t
80 } global_keymap_ini_t
;
82 /*** file scope variables ************************************************************************/
85 static const global_keymap_ini_t default_main_keymap
[] = {
97 {"MenuLastSelected", "f19"},
100 {"DirSize", "ctrl-space"},
101 /* Copy useful information to the command line */
102 {"PutCurrentPath", "alt-a"},
103 {"PutOtherPath", "alt-shift-a"},
104 {"CdQuick", "alt-c"},
105 /* To access the directory hotlist */
106 {"HotList", "ctrl-backspace"},
108 {"Suspend", "ctrl-z"},
109 /* The filtered view command */
110 {"ViewFiltered", "alt-exclamation"},
112 {"Find", "alt-question"},
114 {"Reread", "ctrl-r"},
115 /* Switch listing between long, user defined and full formats */
116 {"PanelListingSwitch", "alt-t"},
120 {"SplitEqual", "alt-equal"},
121 {"SplitMore", "alt-shift-right"},
122 {"SplitLess", "alt-shift-left"},
125 {"ShowHidden", "alt-dot"},
126 {"SplitVertHoriz", "alt-comma"},
127 {"ExtendedKeyMap", "ctrl-x"},
128 /* Select/unselect group */
129 {"Select", "kpplus"},
130 {"Unselect", "kpminus"},
131 {"SelectInvert", "kpasterisk"},
132 /* List of screens */
133 {"ScreenList", "alt-prime"},
137 static const global_keymap_ini_t default_main_x_keymap
[] = {
138 {"CompareDirs", "d"},
140 {"CompareFiles", "ctrl-d"},
141 #endif /* USE_DIFF_VIEW */
144 #endif /* ENABLE_VFS */
145 {"PutCurrentPath", "p"},
146 {"PutOtherPath", "ctrl-p"},
147 {"PutCurrentTagged", "t"},
148 {"PutOtherTagged", "ctrl-t"},
151 {"PutCurrentLink", "r"},
152 {"PutOtherLink", "ctrl-r"},
154 {"LinkSymbolic", "s"},
155 {"LinkSymbolicRelative", "v"},
156 {"LinkSymbolicEdit", "ctrl-s"},
158 {"PanelQuickView", "q"},
160 #ifdef ENABLE_BACKGROUND
162 #endif /* ENABLE_BACKGROUND */
163 {"ExternalPanelize", "!"},
168 static const global_keymap_ini_t default_panel_keymap
[] = {
169 {"PanelOtherCd", "alt-o"},
170 {"PanelOtherCdLink", "alt-l"},
171 {"CopySingle", "f15"},
172 {"DeleteSingle", "f18"},
175 {"MoveSingle", "f16"},
176 {"SelectInvert", "alt-asterisk"},
177 {"Select", "alt-plus"},
178 {"Unselect", "alt-minus"},
180 {"CdChild", "ctrl-pgdn"},
181 {"CdParent", "ctrl-pgup"},
182 {"History", "alt-shift-h"},
183 {"HistoryNext", "alt-u"},
184 {"HistoryPrev", "alt-y"},
185 {"BottomOnScreen", "alt-j"},
186 {"MiddleOnScreen", "alt-r"},
187 {"TopOnScreen", "alt-g"},
188 {"Mark", "insert; ctrl-t"},
189 {"MarkDown", "shift-down"},
190 {"MarkUp", "shift-up"},
191 {"Up", "up; ctrl-p"},
192 {"Down", "down; ctrl-n"},
195 {"Top", "alt-lt; home; a1"},
196 {"Bottom", "alt-gt; end; c1"},
197 {"PageDown", "pgdn; ctrl-v"},
198 {"PageUp", "pgup; alt-v"},
200 {"SelectCodepage", "alt-e"},
202 {"Search", "ctrl-s; alt-s"},
203 {"PanelOtherSync", "alt-i"},
208 static const global_keymap_ini_t default_dialog_keymap
[] = {
210 {"Cancel", "f10; esc; ctrl-g"},
212 {"Down", "down; right"},
214 {"Left", "up; left"},
215 {"Right", "down; right"},
218 {"Suspend", "ctrl-z"},
219 {"Refresh", "ctrl-l"},
220 {"ScreenList", "alt-prime"},
221 {"ScreenNext", "alt-rbrace"},
222 {"ScreenPrev", "alt-lbrace"},
227 static const global_keymap_ini_t default_input_keymap
[] = {
229 {"Home", "ctrl-a; alt-lt; home; a1"},
230 {"End", "ctrl-e; alt-gt; end; c1"},
231 {"Left", "left; alt-left; ctrl-b"},
232 {"Right", "right; alt-right; ctrl-f"},
233 {"WordLeft", "ctrl-left; alt-b"},
234 {"WordRight", "ctrl-right; alt-f"},
236 {"MarkLeft", "shift-left"},
237 {"MarkRight", "shift-right"},
238 {"MarkToWordBegin", "ctrl-shift-left"},
239 {"MarkToWordEnd", "ctrl-shift-right"},
240 {"MarkToHome", "shift-home"},
241 {"MarkToEnd", "shift-end"},
243 {"Backspace", "backspace; ctrl-h"},
244 {"Delete", "delete; ctrl-d"},
245 {"DeleteToWordEnd", "alt-d"},
246 {"DeleteToWordBegin", "alt-backspace"},
247 /* Region manipulation */
248 {"Remove", "ctrl-w"},
251 {"DeleteToEnd", "ctrl-k"},
253 {"History", "alt-h"},
254 {"HistoryPrev", "alt-p; ctrl-down"},
255 {"HistoryNext", "alt-n; ctrl-up"},
257 {"Complete", "alt-tab"},
262 static const global_keymap_ini_t default_listbox_keymap
[] = {
263 {"Up", "up; ctrl-p"},
264 {"Down", "down; ctrl-n"},
265 {"Top", "home; alt-lt; a1"},
266 {"Bottom", "end; alt-gt; c1"},
267 {"PageUp", "pgup; alt-v"},
268 {"PageDown", "pgdn; ctrl-v"},
269 {"Delete", "delete; d"},
270 {"Clear", "shift-delete; shift-d"},
275 static const global_keymap_ini_t default_tree_keymap
[] = {
277 {"Rescan = f2; ctrl-r"},
279 {"ToggleNavigation = f4"},
285 {"Delete", "f8; delete"},
286 {"Up", "up; ctrl-p"},
287 {"Down", "down; ctrl-n"},
290 {"Top", "home; alt-lt; a1"},
291 {"Bottom", "end; alt-gt; c1"},
292 {"PageUp", "pgup; alt-v"},
293 {"PageDown", "pgdn; ctrl-v"},
295 {"Search", "ctrl-s; alt-s"},
300 static const global_keymap_ini_t default_help_keymap
[] = {
303 {"Back", "f3; left; l"},
304 {"Quit", "f10; esc"},
305 {"Up", "up; ctrl-p"},
306 {"Down", "down; ctrl-n"},
307 {"PageDown", "f; space; pgdn; ctrl-v"},
308 {"PageUp", "b; pgup; alt-v; backspace"},
309 {"HalfPageDown", "d"},
311 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
312 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
313 {"Enter", "right; enter"},
315 {"LinkPrev", "alt-tab"},
321 #ifdef USE_INTERNAL_EDIT
322 static const global_keymap_ini_t default_editor_keymap
[] = {
324 {"Return", "shift-enter"}, /* useful for pasting multiline text */
326 {"BackSpace", "backspace; ctrl-h"},
327 {"Delete", "delete; ctrl-d"},
335 {"PageDown", "pgdn"},
336 {"WordLeft", "ctrl-left; ctrl-z"},
337 {"WordRight", "ctrl-right; ctrl-x"},
338 {"InsertOverwrite", "insert"},
346 {"Remove", "f8; ctrl-delete"},
348 {"Quit", "f10; esc"},
350 {"SaveAs", "f12; ctrl-f2"},
351 {"MarkColumn", "f13"},
352 {"ReplaceContinue", "f14; ctrl-f4"},
353 {"InsertFile", "f15"},
354 {"SearchContinue", "f17; ctrl-f7"},
355 {"EditNew", "ctrl-n"},
356 {"DeleteToWordBegin", "alt-backspace"},
357 {"DeleteToWordEnd", "alt-d"},
358 {"DeleteLine", "ctrl-y"},
359 {"DeleteToEnd", "ctrl-k"},
360 {"Undo", "ctrl-u; ctrl-backspace"},
363 {"SelectCodepage", "alt-e"},
365 {"Goto", "alt-l; alt-shift-l"},
366 {"Refresh", "ctrl-l"},
368 {"Top", "ctrl-home; ctrl-pgup; alt-lt"},
369 {"Bottom", "ctrl-end; ctrl-pgdn; alt-gt"},
370 {"TopOnScreen", "ctrl-pgup"},
371 {"BottomOnScreen", "ctrl-pgdn"},
372 {"ScrollUp", "ctrl-up"},
373 {"ScrollDown", "ctrl-down"},
374 {"Store", "ctrl-insert"},
375 {"Paste", "shift-insert"},
376 {"Cut", "shift-delete"},
377 {"BlockSave", "ctrl-f"},
378 {"MarkLeft", "shift-left"},
379 {"MarkRight", "shift-right"},
380 {"MarkUp", "shift-up"},
381 {"MarkDown", "shift-down"},
382 {"MarkPageUp", "shift-pgup"},
383 {"MarkPageDown", "shift-pgdn"},
384 {"MarkToWordBegin", "ctrl-shift-left"},
385 {"MarkToWordEnd", "ctrl-shift-right"},
386 {"MarkToHome", "shift-home"},
387 {"MarkToEnd", "shift-end"},
388 {"MarkToFileBegin", "ctrl-shift-home"},
389 {"MarkToFileEnd", "ctrl-shift-end"},
390 {"MarkToPageBegin", "ctrl-shift-pgup"},
391 {"MarkToPageEnd", "ctrl-shift-pgdn"},
392 {"MarkScrollUp", "ctrl-shift-up"},
393 {"MarkScrollDown", "ctrl-shift-down"},
394 {"MarkColumnLeft", "alt-left"},
395 {"MarkColumnRight", "alt-right"},
396 {"MarkColumnUp", "alt-up"},
397 {"MarkColumnDown", "alt-down"},
398 {"MarkColumnPageUp", "alt-pgup"},
399 {"MarkColumnPageDown", "alt-pgdn"},
400 {"InsertLiteral", "ctrl-q"},
401 {"Complete", "alt-tab"},
402 {"MatchBracket", "alt-b"},
403 {"ParagraphFormat", "alt-p"},
404 {"Bookmark", "alt-k"},
405 {"BookmarkFlush", "alt-o"},
406 {"BookmarkNext", "alt-j"},
407 {"BookmarkPrev", "alt-i"},
408 {"MacroStartStopRecord", "ctrl-r"},
409 {"MacroExecute", "ctrl-a"},
410 {"ShowNumbers", "alt-n"},
411 {"ShowTabTws", "alt-underline"},
412 {"SyntaxOnOff", "ctrl-s"},
413 {"Find", "alt-enter"},
414 {"FilePrev", "alt-minus"},
415 {"FileNext", "alt-plus"},
418 {"ExternalCommand", "alt-u"},
419 {"ExtendedKeyMap", "ctrl-x"},
423 /* emacs keyboard layout emulation */
424 static const global_keymap_ini_t default_editor_x_keymap
[] = {
427 #endif /* USE_INTERNAL_EDIT */
430 static const global_keymap_ini_t default_viewer_keymap
[] = {
433 {"Quit", "f3; f10; q; esc"},
437 {"SearchContinue", "f17; n"},
443 {"Right", "l; right"},
444 {"LeftQuick", "ctrl-left"},
445 {"RightQuick", "ctrl-right"},
446 {"Up", "k; y; insert; up; ctrl-p"},
447 {"Down", "j; e; delete; down; enter; ctrl-n"},
448 {"PageDown", "f; space; pgdn; ctrl-v"},
449 {"PageUp", "b; pgup; alt-v; backspace"},
450 {"HalfPageDown", "d"},
452 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
453 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
454 {"BookmarkGoto", "m"},
456 {"FileNext", "ctrl-f"},
457 {"FilePrev", "ctrl-b"},
459 {"SelectCodepage", "alt-e"},
463 {"SearchForward", "slash"},
464 {"SearchBackward", "question"},
465 {"SearchForwardContinue", "ctrl-s"},
466 {"SearchBackwardContinue", "ctrl-r"},
471 static const global_keymap_ini_t default_viewer_hex_keymap
[] = {
473 {"HexEditMode", "f2"},
474 {"Quit", "f3; f10; q; esc"},
479 {"SearchContinue", "f17; n"},
482 {"ToggleNavigation", "tab"},
483 {"Home", "ctrl-a; home"},
484 {"End", "ctrl-e; end"},
486 {"Right", "f; right"},
488 {"Down", "j; delete; down"},
489 {"PageDown", "pgdn; ctrl-v"},
490 {"PageUp", "pgup; alt-v"},
491 {"Top", "ctrl-home; ctrl-pgup; a1; alt-lt; g"},
492 {"Bottom", "ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
494 {"SelectCodepage", "alt-e"},
497 {"SearchForward", "slash"},
498 {"SearchBackward", "question"},
499 {"SearchForwardContinue", "ctrl-s"},
500 {"SearchBackwardContinue", "ctrl-r"},
506 static const global_keymap_ini_t default_diff_keymap
[] = {
507 {"ShowSymbols", "alt-s; s"},
508 {"ShowNumbers", "alt-n; l"},
510 {"SplitEqual", "equal"},
519 {"HunkNext", "n; enter; space"},
520 {"HunkPrev", "p; backspace"},
521 {"Goto", "g; shift-g"},
524 {"EditOther", "f14"},
527 {"SearchContinue", "f17"},
529 {"Top", "ctrl-home"},
530 {"Bottom", "ctrl-end"},
533 {"LeftQuick", "ctrl-left"},
534 {"RightQuick", "ctrl-right"},
537 {"PageDown", "pgdn"},
542 {"Quit", "f10; q; shift-q; esc"},
544 {"SelectCodepage", "alt-e"},
551 /*** file scope macro definitions ****************************************************************/
553 /*** file scope type declarations ****************************************************************/
555 /*** file scope variables ************************************************************************/
557 /*** file scope functions ************************************************************************/
558 /* --------------------------------------------------------------------------------------------- */
561 create_default_keymap_section (mc_config_t
* keymap
, const char *section
,
562 const global_keymap_ini_t
* k
)
566 for (i
= 0; k
[i
].key
!= NULL
; i
++)
567 mc_config_set_string_raw (keymap
, section
, k
[i
].key
, k
[i
].value
);
570 /* --------------------------------------------------------------------------------------------- */
571 /*** public functions ****************************************************************************/
572 /* --------------------------------------------------------------------------------------------- */
575 create_default_keymap (void)
579 keymap
= mc_config_init (NULL
);
581 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN
, default_main_keymap
);
582 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN_EXT
, default_main_x_keymap
);
583 create_default_keymap_section (keymap
, KEYMAP_SECTION_PANEL
, default_panel_keymap
);
584 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIALOG
, default_dialog_keymap
);
585 create_default_keymap_section (keymap
, KEYMAP_SECTION_INPUT
, default_input_keymap
);
586 create_default_keymap_section (keymap
, KEYMAP_SECTION_LISTBOX
, default_listbox_keymap
);
587 create_default_keymap_section (keymap
, KEYMAP_SECTION_TREE
, default_tree_keymap
);
588 create_default_keymap_section (keymap
, KEYMAP_SECTION_HELP
, default_help_keymap
);
589 #ifdef USE_INTERNAL_EDIT
590 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR
, default_editor_keymap
);
591 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR_EXT
, default_editor_x_keymap
);
593 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER
, default_viewer_keymap
);
594 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER_HEX
, default_viewer_hex_keymap
);
596 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIFFVIEWER
, default_diff_keymap
);