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
[] = {
96 {"MenuLastSelected", "f19"},
99 {"DirSize", "ctrl-space"},
100 /* Copy useful information to the command line */
101 {"PutCurrentPath", "alt-a"},
102 {"PutOtherPath", "alt-shift-a"},
103 {"CdQuick", "alt-c"},
104 /* To access the directory hotlist */
105 {"HotList", "ctrl-backspace"},
107 {"Suspend", "ctrl-z"},
108 /* The filtered view command */
109 {"ViewFiltered", "alt-exclamation"},
111 {"Find", "alt-question"},
113 {"Reread", "ctrl-r"},
114 /* Switch listing between long, user defined and full formats */
115 {"PanelListingSwitch", "alt-t"},
120 {"ShowHidden", "alt-dot"},
121 {"SplitVertHoriz", "alt-comma"},
122 {"ExtendedKeyMap", "ctrl-x"},
123 /* Select/unselect group */
124 {"Select", "kpplus"},
125 {"Unselect", "kpminus"},
126 {"SelectInvert", "kpasterisk"},
127 /* List of screens */
128 {"ScreenList", "alt-prime"},
132 static const global_keymap_ini_t default_main_x_keymap
[] = {
133 {"CompareDirs", "d"},
135 {"CompareFiles", "ctrl-d"},
136 #endif /* USE_DIFF_VIEW */
139 #endif /* ENABLE_VFS */
140 {"PutCurrentPath", "p"},
141 {"PutOtherPath", "ctrl-p"},
142 {"PutCurrentTagged", "t"},
143 {"PutOtherTagged", "ctrl-t"},
146 {"PutCurrentLink", "r"},
147 {"PutOtherLink", "ctrl-r"},
149 {"LinkSymbolic", "s"},
150 {"LinkSymbolicRelative", "v"},
151 {"LinkSymbolicEdit", "ctrl-s"},
153 {"PanelQuickView", "q"},
155 #ifdef ENABLE_BACKGROUND
157 #endif /* ENABLE_BACKGROUND */
158 {"ExternalPanelize", "!"},
163 static const global_keymap_ini_t default_panel_keymap
[] = {
164 {"PanelOtherCd", "alt-o"},
165 {"PanelOtherCdLink", "alt-l"},
166 {"CopySingle", "f15"},
167 {"DeleteSingle", "f18"},
170 {"MoveSingle", "f16"},
171 {"SelectInvert", "alt-asterisk"},
172 {"Select", "alt-plus"},
173 {"Unselect", "alt-minus"},
175 {"CdChild", "ctrl-pgdn"},
176 {"CdParent", "ctrl-pgup"},
177 {"History", "alt-shift-h"},
178 {"HistoryNext", "alt-u"},
179 {"HistoryPrev", "alt-y"},
180 {"BottomOnScreen", "alt-j"},
181 {"MiddleOnScreen", "alt-r"},
182 {"TopOnScreen", "alt-g"},
183 {"Mark", "insert; ctrl-t"},
184 {"MarkDown", "shift-down"},
185 {"MarkUp", "shift-up"},
186 {"Up", "up; ctrl-p"},
187 {"Down", "down; ctrl-n"},
190 {"Top", "alt-lt; home; a1"},
191 {"Bottom", "alt-gt; end; c1"},
192 {"PageDown", "pgdn; ctrl-v"},
193 {"PageUp", "pgup; alt-v"},
195 {"SelectCodepage", "alt-e"},
197 {"Search", "ctrl-s; alt-s"},
198 {"PanelOtherSync", "alt-i"},
203 static const global_keymap_ini_t default_dialog_keymap
[] = {
205 {"Cancel", "f10; esc; ctrl-g"},
207 {"Down", "down; right"},
209 {"Left", "up; left"},
210 {"Right", "down; right"},
213 {"Suspend", "ctrl-z"},
214 {"Refresh", "ctrl-l"},
215 {"ScreenList", "alt-prime"},
216 {"ScreenNext", "alt-rbrace"},
217 {"ScreenPrev", "alt-lbrace"},
222 static const global_keymap_ini_t default_input_keymap
[] = {
224 {"Home", "ctrl-a; alt-lt; home; a1"},
225 {"End", "ctrl-e; alt-gt; end; c1"},
226 {"Left", "left; alt-left; ctrl-b"},
227 {"Right", "right; alt-right; ctrl-f"},
228 {"WordLeft", "ctrl-left; alt-b"},
229 {"WordRight", "ctrl-right; alt-f"},
231 {"MarkLeft", "shift-left"},
232 {"MarkRight", "shift-right"},
233 {"MarkToWordBegin", "ctrl-shift-left"},
234 {"MarkToWordEnd", "ctrl-shift-right"},
235 {"MarkToHome", "shift-home"},
236 {"MarkToEnd", "shift-end"},
238 {"Backspace", "backspace; ctrl-h"},
239 {"Delete", "delete; ctrl-d"},
240 {"DeleteToWordEnd", "alt-d"},
241 {"DeleteToWordBegin", "alt-backspace"},
242 /* Region manipulation */
243 {"Remove", "ctrl-w"},
246 {"DeleteToEnd", "ctrl-k"},
248 {"History", "alt-h"},
249 {"HistoryPrev", "alt-p; ctrl-down"},
250 {"HistoryNext", "alt-n; ctrl-up"},
252 {"Complete", "alt-tab"},
257 static const global_keymap_ini_t default_listbox_keymap
[] = {
258 {"Up", "up; ctrl-p"},
259 {"Down", "down; ctrl-n"},
260 {"Top", "home; alt-lt; a1"},
261 {"Bottom", "end; alt-gt; c1"},
262 {"PageUp", "pgup; alt-v"},
263 {"PageDown", "pgdn; ctrl-v"},
264 {"Delete", "delete; d"},
265 {"Clear", "shift-delete; shift-d"},
270 static const global_keymap_ini_t default_tree_keymap
[] = {
272 {"Rescan = f2; ctrl-r"},
274 {"ToggleNavigation = f4"},
280 {"Delete", "f8; delete"},
281 {"Up", "up; ctrl-p"},
282 {"Down", "down; ctrl-n"},
285 {"Top", "home; alt-lt; a1"},
286 {"Bottom", "end; alt-gt; c1"},
287 {"PageUp", "pgup; alt-v"},
288 {"PageDown", "pgdn; ctrl-v"},
290 {"Search", "ctrl-s; alt-s"},
295 static const global_keymap_ini_t default_help_keymap
[] = {
298 {"Back", "f3; left; l"},
299 {"Quit", "f10; esc"},
300 {"Up", "up; ctrl-p"},
301 {"Down", "down; ctrl-n"},
302 {"PageDown", "f; space; pgdn; ctrl-v"},
303 {"PageUp", "b; pgup; alt-v; backspace"},
304 {"HalfPageDown", "d"},
306 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
307 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
308 {"Enter", "right; enter"},
310 {"LinkPrev", "alt-tab"},
316 #ifdef USE_INTERNAL_EDIT
317 static const global_keymap_ini_t default_editor_keymap
[] = {
319 {"Return", "shift-enter"}, /* useful for pasting multiline text */
321 {"BackSpace", "backspace; ctrl-h"},
322 {"Delete", "delete; ctrl-d"},
330 {"PageDown", "pgdn"},
331 {"WordLeft", "ctrl-left; ctrl-z"},
332 {"WordRight", "ctrl-right; ctrl-x"},
333 {"InsertOverwrite", "insert"},
341 {"Remove", "f8; ctrl-delete"},
343 {"Quit", "f10; esc"},
345 {"SaveAs", "f12; ctrl-f2"},
346 {"MarkColumn", "f13"},
347 {"ReplaceContinue", "f14; ctrl-f4"},
348 {"InsertFile", "f15"},
349 {"SearchContinue", "f17; ctrl-f7"},
350 {"EditNew", "ctrl-n"},
351 {"DeleteToWordBegin", "alt-backspace"},
352 {"DeleteToWordEnd", "alt-d"},
353 {"DeleteLine", "ctrl-y"},
354 {"DeleteToEnd", "ctrl-k"},
355 {"Undo", "ctrl-u; ctrl-backspace"},
358 {"SelectCodepage", "alt-e"},
360 {"Goto", "alt-l; alt-shift-l"},
361 {"Refresh", "ctrl-l"},
363 {"Top", "ctrl-home; ctrl-pgup; alt-lt"},
364 {"Bottom", "ctrl-end; ctrl-pgdn; alt-gt"},
365 {"TopOnScreen", "ctrl-pgup"},
366 {"BottomOnScreen", "ctrl-pgdn"},
367 {"ScrollUp", "ctrl-up"},
368 {"ScrollDown", "ctrl-down"},
369 {"Store", "ctrl-insert"},
370 {"Paste", "shift-insert"},
371 {"Cut", "shift-delete"},
372 {"BlockSave", "ctrl-f"},
373 {"MarkLeft", "shift-left"},
374 {"MarkRight", "shift-right"},
375 {"MarkUp", "shift-up"},
376 {"MarkDown", "shift-down"},
377 {"MarkPageUp", "shift-pgup"},
378 {"MarkPageDown", "shift-pgdn"},
379 {"MarkToWordBegin", "ctrl-shift-left"},
380 {"MarkToWordEnd", "ctrl-shift-right"},
381 {"MarkToHome", "shift-home"},
382 {"MarkToEnd", "shift-end"},
383 {"MarkToFileBegin", "ctrl-shift-home"},
384 {"MarkToFileEnd", "ctrl-shift-end"},
385 {"MarkToPageBegin", "ctrl-shift-pgup"},
386 {"MarkToPageEnd", "ctrl-shift-pgdn"},
387 {"MarkScrollUp", "ctrl-shift-up"},
388 {"MarkScrollDown", "ctrl-shift-down"},
389 {"MarkColumnLeft", "alt-left"},
390 {"MarkColumnRight", "alt-right"},
391 {"MarkColumnUp", "alt-up"},
392 {"MarkColumnDown", "alt-down"},
393 {"MarkColumnPageUp", "alt-pgup"},
394 {"MarkColumnPageDown", "alt-pgdn"},
395 {"InsertLiteral", "ctrl-q"},
396 {"Complete", "alt-tab"},
397 {"MatchBracket", "alt-b"},
398 {"ParagraphFormat", "alt-p"},
399 {"Bookmark", "alt-k"},
400 {"BookmarkFlush", "alt-o"},
401 {"BookmarkNext", "alt-j"},
402 {"BookmarkPrev", "alt-i"},
403 {"MacroStartStopRecord", "ctrl-r"},
404 {"MacroExecute", "ctrl-a"},
405 {"ShowNumbers", "alt-n"},
406 {"ShowTabTws", "alt-underline"},
407 {"SyntaxOnOff", "ctrl-s"},
408 {"Find", "alt-enter"},
409 {"FilePrev", "alt-minus"},
410 {"FileNext", "alt-plus"},
413 {"ExternalCommand", "alt-u"},
414 {"ExtendedKeyMap", "ctrl-x"},
418 /* emacs keyboard layout emulation */
419 static const global_keymap_ini_t default_editor_x_keymap
[] = {
422 #endif /* USE_INTERNAL_EDIT */
425 static const global_keymap_ini_t default_viewer_keymap
[] = {
428 {"Quit", "f3; f10; q; esc"},
432 {"SearchContinue", "f17; n"},
438 {"Right", "l; right"},
439 {"LeftQuick", "ctrl-left"},
440 {"RightQuick", "ctrl-right"},
441 {"Up", "k; y; insert; up; ctrl-p"},
442 {"Down", "j; e; delete; down; enter; ctrl-n"},
443 {"PageDown", "f; space; pgdn; ctrl-v"},
444 {"PageUp", "b; pgup; alt-v; backspace"},
445 {"HalfPageDown", "d"},
447 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
448 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
449 {"BookmarkGoto", "m"},
451 {"FileNext", "ctrl-f"},
452 {"FilePrev", "ctrl-b"},
454 {"SelectCodepage", "alt-e"},
458 {"SearchForward", "slash"},
459 {"SearchBackward", "question"},
460 {"SearchForwardContinue", "ctrl-s"},
461 {"SearchBackwardContinue", "ctrl-r"},
466 static const global_keymap_ini_t default_viewer_hex_keymap
[] = {
468 {"HexEditMode", "f2"},
469 {"Quit", "f3; f10; q; esc"},
474 {"SearchContinue", "f17; n"},
477 {"ToggleNavigation", "tab"},
478 {"Home", "ctrl-a; home"},
479 {"End", "ctrl-e; end"},
481 {"Right", "f; right"},
483 {"Down", "j; delete; down"},
484 {"PageDown", "pgdn; ctrl-v"},
485 {"PageUp", "pgup; alt-v"},
486 {"Top", "ctrl-home; ctrl-pgup; a1; alt-lt; g"},
487 {"Bottom", "ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
489 {"SelectCodepage", "alt-e"},
492 {"SearchForward", "slash"},
493 {"SearchBackward", "question"},
494 {"SearchForwardContinue", "ctrl-s"},
495 {"SearchBackwardContinue", "ctrl-r"},
501 static const global_keymap_ini_t default_diff_keymap
[] = {
502 {"ShowSymbols", "alt-s; s"},
503 {"ShowNumbers", "alt-n; l"},
505 {"SplitEqual", "equal"},
514 {"HunkNext", "n; enter; space"},
515 {"HunkPrev", "p; backspace"},
516 {"Goto", "g; shift-g"},
519 {"EditOther", "f14"},
522 {"SearchContinue", "f17"},
524 {"Top", "ctrl-home"},
525 {"Bottom", "ctrl-end"},
528 {"LeftQuick", "ctrl-left"},
529 {"RightQuick", "ctrl-right"},
532 {"PageDown", "pgdn"},
537 {"Quit", "f10; q; shift-q; esc"},
539 {"SelectCodepage", "alt-e"},
546 /*** file scope macro definitions ****************************************************************/
548 /*** file scope type declarations ****************************************************************/
550 /*** file scope variables ************************************************************************/
552 /*** file scope functions ************************************************************************/
553 /* --------------------------------------------------------------------------------------------- */
556 create_default_keymap_section (mc_config_t
* keymap
, const char *section
,
557 const global_keymap_ini_t
* k
)
561 for (i
= 0; k
[i
].key
!= NULL
; i
++)
562 mc_config_set_string_raw (keymap
, section
, k
[i
].key
, k
[i
].value
);
565 /* --------------------------------------------------------------------------------------------- */
566 /*** public functions ****************************************************************************/
567 /* --------------------------------------------------------------------------------------------- */
570 create_default_keymap (void)
574 keymap
= mc_config_init (NULL
, TRUE
);
576 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN
, default_main_keymap
);
577 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN_EXT
, default_main_x_keymap
);
578 create_default_keymap_section (keymap
, KEYMAP_SECTION_PANEL
, default_panel_keymap
);
579 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIALOG
, default_dialog_keymap
);
580 create_default_keymap_section (keymap
, KEYMAP_SECTION_INPUT
, default_input_keymap
);
581 create_default_keymap_section (keymap
, KEYMAP_SECTION_LISTBOX
, default_listbox_keymap
);
582 create_default_keymap_section (keymap
, KEYMAP_SECTION_TREE
, default_tree_keymap
);
583 create_default_keymap_section (keymap
, KEYMAP_SECTION_HELP
, default_help_keymap
);
584 #ifdef USE_INTERNAL_EDIT
585 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR
, default_editor_keymap
);
586 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR_EXT
, default_editor_x_keymap
);
588 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER
, default_viewer_keymap
);
589 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER_HEX
, default_viewer_hex_keymap
);
591 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIFFVIEWER
, default_diff_keymap
);