2 Copyright (C) 2009, 2010, 2011 The Free Software Foundation, Inc.
4 Written by: 2005 Vitja Makarov
5 2009, 2010 Ilia Maslakov
6 2010, 2011 Andrew Borodin
8 This file is part of the Midnight Commander.
10 The Midnight Commander is free software; you can redistribute it
11 and/or modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
15 The Midnight Commander is distributed in the hope that it will be
16 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28 #include "lib/global.h"
29 #include "lib/widget.h" /* dialog_map, input_map, listbox_map */
31 #include "keybind-defaults.h"
33 /*** global variables ****************************************************************************/
35 GArray
*main_keymap
= NULL
;
36 GArray
*main_x_keymap
= NULL
;
37 GArray
*panel_keymap
= NULL
;
38 GArray
*dialog_keymap
= NULL
;
39 GArray
*input_keymap
= NULL
;
40 GArray
*listbox_keymap
= NULL
;
41 GArray
*tree_keymap
= NULL
;
42 GArray
*help_keymap
= NULL
;
43 #ifdef USE_INTERNAL_EDIT
44 GArray
*editor_keymap
= NULL
;
45 GArray
*editor_x_keymap
= NULL
;
47 GArray
*viewer_keymap
= NULL
;
48 GArray
*viewer_hex_keymap
= NULL
;
50 GArray
*diff_keymap
= NULL
;
53 const global_keymap_t
*main_map
= NULL
;
54 const global_keymap_t
*main_x_map
= NULL
;
55 const global_keymap_t
*panel_map
= NULL
;
56 const global_keymap_t
*tree_map
= NULL
;
57 const global_keymap_t
*help_map
= NULL
;
59 #ifdef USE_INTERNAL_EDIT
60 const global_keymap_t
*editor_map
= NULL
;
61 const global_keymap_t
*editor_x_map
= NULL
;
63 const global_keymap_t
*viewer_map
= NULL
;
64 const global_keymap_t
*viewer_hex_map
= NULL
;
66 const global_keymap_t
*diff_map
= NULL
;
69 /*** file scope macro definitions ****************************************************************/
71 /*** file scope type declarations ****************************************************************/
73 /* default keymaps in ini (key=value) format */
74 typedef struct global_keymap_ini_t
78 } global_keymap_ini_t
;
80 /*** file scope variables ************************************************************************/
83 static const global_keymap_ini_t default_main_keymap
[] = {
95 {"MenuLastSelected", "f19"},
98 {"DirSize", "ctrl-space"},
99 /* Copy useful information to the command line */
100 {"PutCurrentPath", "alt-a"},
101 {"PutOtherPath", "alt-shift-a"},
102 {"CdQuick", "alt-c"},
103 /* To access the directory hotlist */
104 {"HotList", "ctrl-backspace"},
106 {"Suspend", "ctrl-z"},
107 /* The filtered view command */
108 {"ViewFiltered", "alt-exclamation"},
110 {"Find", "alt-question"},
112 {"Reread", "ctrl-r"},
113 /* Switch listing between long, user defined and full formats */
114 {"PanelListingSwitch", "alt-t"},
119 {"ShowHidden", "alt-dot"},
120 {"SplitVertHoriz", "alt-comma"},
121 {"ExtendedKeyMap", "ctrl-x"},
122 /* Select/unselect group */
123 {"Select", "kpplus"},
124 {"Unselect", "kpminus"},
125 {"SelectInvert", "kpasterisk"},
126 /* List of screens */
127 {"ScreenList", "alt-prime"},
131 static const global_keymap_ini_t default_main_x_keymap
[] = {
132 {"CompareDirs", "d"},
134 {"CompareFiles", "ctrl-d"},
135 #endif /* USE_DIFF_VIEW */
138 #endif /* ENABLE_VFS */
139 {"PutCurrentPath", "p"},
140 {"PutOtherPath", "ctrl-p"},
141 {"PutCurrentTagged", "t"},
142 {"PutOtherTagged", "ctrl-t"},
145 {"PutCurrentLink", "r"},
146 {"PutOtherLink", "ctrl-r"},
148 {"LinkSymbolic", "s"},
149 {"LinkSymbolicRelative", "v"},
150 {"LinkSymbolicEdit", "ctrl-s"},
152 {"PanelQuickView", "q"},
154 #ifdef WITH_BACKGROUND
156 #endif /* WITH_BACKGROUND */
157 {"ExternalPanelize", "!"},
162 static const global_keymap_ini_t default_panel_keymap
[] = {
163 {"PanelOtherCd", "alt-o"},
164 {"PanelOtherCdLink", "alt-l"},
165 {"CopySingle", "f15"},
166 {"DeleteSingle", "f18"},
169 {"MoveSingle", "f16"},
170 {"SelectInvert", "alt-asterisk"},
171 {"Select", "alt-plus"},
172 {"Unselect", "alt-minus"},
174 {"CdChild", "ctrl-pgdn"},
175 {"CdParent", "ctrl-pgup"},
176 {"History", "alt-shift-h"},
177 {"HistoryNext", "alt-u"},
178 {"HistoryPrev", "alt-y"},
179 {"BottomOnScreen", "alt-j"},
180 {"MiddleOnScreen", "alt-r"},
181 {"TopOnScreen", "alt-g"},
182 {"Mark", "insert; ctrl-t"},
183 {"MarkDown", "shift-down"},
184 {"MarkUp", "shift-up"},
185 {"Up", "up; ctrl-p"},
186 {"Down", "down; ctrl-n"},
189 {"Top", "alt-lt; home; a1"},
190 {"Bottom", "alt-gt; end; c1"},
191 {"PageDown", "pgdn; ctrl-v"},
192 {"PageUp", "pgup; alt-v"},
194 {"SelectCodepage", "alt-e"},
196 {"Search", "ctrl-s; alt-s"},
197 {"PanelOtherSync", "alt-i"},
202 static const global_keymap_ini_t default_dialog_keymap
[] = {
204 {"Cancel", "f10; esc; ctrl-g"},
206 {"Down", "down; right"},
208 {"Left", "up; left"},
209 {"Right", "down; right"},
212 {"Suspend", "ctrl-z"},
213 {"Refresh", "ctrl-l"},
214 {"ScreenList", "alt-prime"},
215 {"ScreenNext", "alt-rbrace"},
216 {"ScreenPrev", "alt-lbrace"},
221 static const global_keymap_ini_t default_input_keymap
[] = {
223 {"Home", "ctrl-a; alt-lt; home; a1"},
224 {"End", "ctrl-e; alt-gt; end; c1"},
225 {"Left", "left; alt-left; ctrl-b"},
226 {"Right", "right; alt-right; ctrl-f"},
227 {"WordLeft", "ctrl-left; alt-b"},
228 {"WordRight", "ctrl-right; alt-f"},
230 {"MarkLeft", "shift-left"},
231 {"MarkRight", "shift-right"},
232 {"MarkToWordBegin", "ctrl-shift-left"},
233 {"MarkToWordEnd", "ctrl-shift-right"},
234 {"MarkToHome", "shift-home"},
235 {"MarkToEnd", "shift-end"},
237 {"Backspace", "backspace; ctrl-h"},
238 {"Delete", "delete; ctrl-d"},
239 {"DeleteToWordEnd", "alt-d"},
240 {"DeleteToWordBegin", "alt-backspace"},
241 /* Region manipulation */
242 {"Remove", "ctrl-w"},
245 {"DeleteToEnd", "ctrl-k"},
247 {"History", "alt-h"},
248 {"HistoryPrev", "alt-p; ctrl-down"},
249 {"HistoryNext", "alt-n; ctrl-up"},
251 {"Complete", "alt-tab"},
256 static const global_keymap_ini_t default_listbox_keymap
[] = {
257 {"Up", "up; ctrl-p"},
258 {"Down", "down; ctrl-n"},
259 {"Top", "home; alt-lt; a1"},
260 {"Bottom", "end; alt-gt; c1"},
261 {"PageUp", "pgup; alt-v"},
262 {"PageDown", "pgdn; ctrl-v"},
263 {"Delete", "delete; d"},
264 {"Clear", "shift-delete; shift-d"},
269 static const global_keymap_ini_t default_tree_keymap
[] = {
271 {"Rescan = f2; ctrl-r"},
273 {"ToggleNavigation = f4"},
279 {"Delete", "f8; delete"},
280 {"Up", "up; ctrl-p"},
281 {"Down", "down; ctrl-n"},
284 {"Top", "home; alt-lt; a1"},
285 {"Bottom", "end; alt-gt; c1"},
286 {"PageUp", "pgup; alt-v"},
287 {"PageDown", "pgdn; ctrl-v"},
289 {"Search", "ctrl-s; alt-s"},
294 static const global_keymap_ini_t default_help_keymap
[] = {
297 {"Back", "f3; left; l"},
298 {"Quit", "f10; esc"},
299 {"Up", "up; ctrl-p"},
300 {"Down", "down; ctrl-n"},
301 {"PageDown", "f; space; pgdn; ctrl-v"},
302 {"PageUp", "b; pgup; alt-v; backspace"},
303 {"HalfPageDown", "d"},
305 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
306 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
307 {"Enter", "right; enter"},
309 {"LinkPrev", "alt-tab"},
315 #ifdef USE_INTERNAL_EDIT
316 static const global_keymap_ini_t default_editor_keymap
[] = {
318 {"Return", "shift-enter"}, /* useful for pasting multiline text */
320 {"BackSpace", "backspace; ctrl-h"},
321 {"Delete", "delete; ctrl-d"},
329 {"PageDown", "pgdn"},
330 {"WordLeft", "ctrl-left; ctrl-z"},
331 {"WordRight", "ctrl-right; ctrl-x"},
332 {"InsertOverwrite", "insert"},
340 {"Remove", "f8; ctrl-delete"},
342 {"Quit", "f10; esc"},
344 {"SaveAs", "f12; ctrl-f2"},
345 {"MarkColumn", "f13"},
346 {"ReplaceContinue", "f14; ctrl-f4"},
347 {"InsertFile", "f15"},
348 {"SearchContinue", "f17; ctrl-f7"},
349 {"EditNew", "ctrl-n"},
350 {"DeleteToWordBegin", "alt-backspace"},
351 {"DeleteToWordEnd", "alt-d"},
352 {"DeleteLine", "ctrl-y"},
353 {"DeleteToEnd", "ctrl-k"},
354 {"Undo", "ctrl-u; ctrl-backspace"},
357 {"SelectCodepage", "alt-e"},
359 {"Goto", "alt-l; alt-shift-l"},
360 {"Refresh", "ctrl-l"},
362 {"Top", "ctrl-home; ctrl-pgup; alt-lt"},
363 {"Bottom", "ctrl-end; ctrl-pgdn; alt-gt"},
364 {"TopOnScreen", "ctrl-pgup"},
365 {"BottomOnScreen", "ctrl-pgdn"},
366 {"ScrollUp", "ctrl-up"},
367 {"ScrollDown", "ctrl-down"},
368 {"Store", "ctrl-insert"},
369 {"Paste", "shift-insert"},
370 {"Cut", "shift-delete"},
371 {"BlockSave", "ctrl-f"},
372 {"MarkLeft", "shift-left"},
373 {"MarkRight", "shift-right"},
374 {"MarkUp", "shift-up"},
375 {"MarkDown", "shift-down"},
376 {"MarkPageUp", "shift-pgup"},
377 {"MarkPageDown", "shift-pgdn"},
378 {"MarkToWordBegin", "ctrl-shift-left"},
379 {"MarkToWordEnd", "ctrl-shift-right"},
380 {"MarkToHome", "shift-home"},
381 {"MarkToEnd", "shift-end"},
382 {"MarkToFileBegin", "ctrl-shift-home"},
383 {"MarkToFileEnd", "ctrl-shift-end"},
384 {"MarkToPageBegin", "ctrl-shift-pgup"},
385 {"MarkToPageEnd", "ctrl-shift-pgdn"},
386 {"MarkScrollUp", "ctrl-shift-up"},
387 {"MarkScrollDown", "ctrl-shift-down"},
388 {"MarkColumnLeft", "alt-left"},
389 {"MarkColumnRight", "alt-right"},
390 {"MarkColumnUp", "alt-up"},
391 {"MarkColumnDown", "alt-down"},
392 {"MarkColumnPageUp", "alt-pgup"},
393 {"MarkColumnPageDown", "alt-pgdn"},
394 {"InsertLiteral", "ctrl-q"},
395 {"Complete", "alt-tab"},
396 {"MatchBracket", "alt-b"},
397 {"ParagraphFormat", "alt-p"},
398 {"Bookmark", "alt-k"},
399 {"BookmarkFlush", "alt-o"},
400 {"BookmarkNext", "alt-j"},
401 {"BookmarkPrev", "alt-i"},
402 {"MacroStartStopRecord", "ctrl-r"},
403 {"MacroExecute", "ctrl-a"},
404 {"ShowNumbers", "alt-n"},
405 {"ShowTabTws", "alt-underline"},
406 {"SyntaxOnOff", "ctrl-s"},
407 {"Find", "alt-enter"},
408 {"FilePrev", "alt-minus"},
409 {"FileNext", "alt-plus"},
412 {"ExternalCommand", "alt-u"},
413 {"ExtendedKeyMap", "ctrl-x"},
417 /* emacs keyboard layout emulation */
418 static const global_keymap_ini_t default_editor_x_keymap
[] = {
421 #endif /* USE_INTERNAL_EDIT */
424 static const global_keymap_ini_t default_viewer_keymap
[] = {
427 {"Quit", "f3; f10; q; esc"},
430 {"Search", "f7; question; slash"},
431 {"SearchContinue", "ctrl-r; ctrl-s; f17; n"},
437 {"Right", "l; right"},
438 {"LeftQuick", "ctrl-left"},
439 {"RightQuick", "ctrl-right"},
440 {"Up", "k; y; insert; up; ctrl-p"},
441 {"Down", "j; e; delete; down; enter; ctrl-n"},
442 {"PageDown", "f; space; pgdn; ctrl-v"},
443 {"PageUp", "b; pgup; alt-v; backspace"},
444 {"HalfPageDown", "d"},
446 {"Top", "home; ctrl-home; ctrl-pgup; a1; alt-lt; g"},
447 {"Bottom", "end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
448 {"BookmarkGoto", "m"},
450 {"FileNext", "ctrl-f"},
451 {"FilePrev", "ctrl-b"},
453 {"SelectCodepage", "alt-e"},
461 static const global_keymap_ini_t default_viewer_hex_keymap
[] = {
463 {"HexEditMode", "f2"},
464 {"Quit", "f3; f10; q; esc"},
468 {"Search", "f7; question; slash"},
469 {"SearchContinue", "ctrl-r; ctrl-s; f17; n"},
472 {"ToggleNavigation", "tab"},
473 {"Home", "ctrl-a; home"},
474 {"End", "ctrl-e; end"},
476 {"Right", "f; right"},
478 {"Down", "j; delete; down"},
479 {"PageDown", "pgdn; ctrl-v"},
480 {"PageUp", "pgup; alt-v"},
481 {"Top", "ctrl-home; ctrl-pgup; a1; alt-lt; g"},
482 {"Bottom", "ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g"},
484 {"SelectCodepage", "alt-e"},
492 static const global_keymap_ini_t default_diff_keymap
[] = {
493 {"ShowSymbols", "alt-s; s"},
494 {"ShowNumbers", "alt-n; l"},
496 {"SplitEqual", "equal"},
505 {"HunkNext", "n; enter; space"},
506 {"HunkPrev", "p; backspace"},
507 {"Goto", "g; shift-g"},
510 {"EditOther", "f14"},
513 {"SearchContinue", "f17"},
515 {"Top", "ctrl-home"},
516 {"Bottom", "ctrl-end"},
519 {"LeftQuick", "ctrl-left"},
520 {"RightQuick", "ctrl-right"},
523 {"PageDown", "pgdn"},
528 {"Quit", "f10; q; shift-q; esc"},
530 {"SelectCodepage", "alt-e"},
537 /*** file scope macro definitions ****************************************************************/
539 /*** file scope type declarations ****************************************************************/
541 /*** file scope variables ************************************************************************/
543 /*** file scope functions ************************************************************************/
544 /* --------------------------------------------------------------------------------------------- */
547 create_default_keymap_section (mc_config_t
*keymap
, const char *section
,
548 const global_keymap_ini_t
*k
)
552 for (i
= 0; k
[i
].key
!= NULL
; i
++)
553 mc_config_set_string_raw (keymap
, section
, k
[i
].key
, k
[i
].value
);
556 /* --------------------------------------------------------------------------------------------- */
557 /*** public functions ****************************************************************************/
558 /* --------------------------------------------------------------------------------------------- */
561 create_default_keymap (void)
565 keymap
= mc_config_init (NULL
);
567 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN
, default_main_keymap
);
568 create_default_keymap_section (keymap
, KEYMAP_SECTION_MAIN_EXT
, default_main_x_keymap
);
569 create_default_keymap_section (keymap
, KEYMAP_SECTION_PANEL
, default_panel_keymap
);
570 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIALOG
, default_dialog_keymap
);
571 create_default_keymap_section (keymap
, KEYMAP_SECTION_INPUT
, default_input_keymap
);
572 create_default_keymap_section (keymap
, KEYMAP_SECTION_LISTBOX
, default_listbox_keymap
);
573 create_default_keymap_section (keymap
, KEYMAP_SECTION_TREE
, default_tree_keymap
);
574 create_default_keymap_section (keymap
, KEYMAP_SECTION_HELP
, default_help_keymap
);
575 #ifdef USE_INTERNAL_EDIT
576 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR
, default_editor_keymap
);
577 create_default_keymap_section (keymap
, KEYMAP_SECTION_EDITOR_EXT
, default_editor_x_keymap
);
579 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER
, default_viewer_keymap
);
580 create_default_keymap_section (keymap
, KEYMAP_SECTION_VIEWER_HEX
, default_viewer_hex_keymap
);
582 create_default_keymap_section (keymap
, KEYMAP_SECTION_DIFFVIEWER
, default_diff_keymap
);