Removed hardcoded hotkeys in dialog.c Replaced keymap's initialization from main...
[pantumic.git] / src / keybind.c
blobc9a32fd6b52e65e1f8a785f683288f7606347871
1 /*
2 Copyright (C) 2009 The Free Software Foundation, Inc.
4 Written by: 2005 Vitja Makarov
5 2009 Ilia Maslakov
7 This file is part of the Midnight Commander.
9 The Midnight Commander is free software; you can redistribute it
10 and/or modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
14 The Midnight Commander is distributed in the hope that it will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
16 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 MA 02110-1301, USA.
25 #include <config.h>
27 #include <ctype.h>
28 #include <errno.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <unistd.h>
37 #include "lib/global.h"
38 #include "lib/tty/win.h"
39 #include "lib/tty/key.h" /* KEY_M_ */
40 #include "lib/tty/tty.h" /* keys */
41 #include "lib/strutil.h"
43 #include "cmddef.h" /* CK_ cmd name const */
44 #include "wtools.h"
45 #include "keybind.h"
47 #ifdef USE_INTERNAL_EDIT
48 GArray *editor_keymap = NULL;
49 GArray *editor_x_keymap = NULL;
51 const global_keymap_t *editor_map;
52 const global_keymap_t *editor_x_map;
53 #endif
55 GArray *main_keymap = NULL;
56 GArray *main_x_keymap = NULL;
57 GArray *viewer_keymap = NULL;
58 GArray *viewer_hex_keymap = NULL;
59 GArray *panel_keymap = NULL;
60 GArray *input_keymap = NULL;
61 GArray *tree_keymap = NULL;
62 GArray *help_keymap = NULL;
63 GArray *dialog_keymap = NULL;
65 #ifdef USE_DIFF_VIEW
66 GArray *diff_keymap = NULL;
68 const global_keymap_t *diff_map;
69 #endif
71 const global_keymap_t *main_map;
72 const global_keymap_t *main_x_map;
73 const global_keymap_t *panel_map;
74 const global_keymap_t *input_map;
75 const global_keymap_t *tree_map;
76 const global_keymap_t *help_map;
77 const global_keymap_t *dialog_map;
79 static name_keymap_t command_names[] = {
80 #ifdef USE_INTERNAL_EDIT
81 { "EditNoCommand", CK_Ignore_Key },
82 { "EditIgnoreKey", CK_Ignore_Key },
83 { "EditBackSpace", CK_BackSpace },
84 { "EditDelete", CK_Delete },
85 { "EditEnter", CK_Enter },
86 { "EditPageUp", CK_Page_Up },
87 { "EditPageDown", CK_Page_Down },
88 { "EditLeft", CK_Left },
89 { "EditRight", CK_Right },
90 { "EditWordLeft", CK_Word_Left },
91 { "EditWordRight", CK_Word_Right },
92 { "EditUp", CK_Up },
93 { "EditDown", CK_Down },
94 { "EditHome", CK_Home },
95 { "EditEnd", CK_End },
96 { "EditTab", CK_Tab },
97 { "EditUndo", CK_Undo },
98 { "EditBeginningOfText", CK_Beginning_Of_Text },
99 { "EditEndOfText", CK_End_Of_Text },
100 { "EditScrollUp", CK_Scroll_Up },
101 { "EditScrollDown", CK_Scroll_Down },
102 { "EditReturn", CK_Return },
103 { "EditBeginPage", CK_Begin_Page },
104 { "EditEndPage", CK_End_Page },
105 { "EditDeleteWordLeft", CK_Delete_Word_Left },
106 { "EditDeleteWordRight", CK_Delete_Word_Right },
107 { "EditParagraphUp", CK_Paragraph_Up },
108 { "EditParagraphDown", CK_Paragraph_Down },
109 { "EditMenu", CK_Menu },
110 { "EditSave", CK_Save },
111 { "EditLoad", CK_Load },
112 { "EditNew", CK_New },
113 { "EditSaveas", CK_Save_As },
114 { "EditMark", CK_Mark },
115 { "EditCopy", CK_Copy },
116 { "EditMove", CK_Move },
117 { "EditRemove", CK_Remove },
118 { "EditMarkAll", CK_Mark_All },
119 { "EditUnmark", CK_Unmark },
120 { "EditSaveBlock", CK_Save_Block },
121 { "EditColumnMark", CK_Column_Mark },
122 { "EditFind", CK_Find },
123 { "EditFindAgain", CK_Find_Again },
124 { "EditReplace", CK_Replace },
125 { "EditReplaceAgain", CK_Replace_Again },
126 { "EditCompleteWord", CK_Complete_Word },
128 #if 0
129 { "EditDebugStart", CK_Debug_Start },
130 { "EditDebugStop", CK_Debug_Stop },
131 { "EditDebugToggleBreak", CK_Debug_Toggle_Break },
132 { "EditDebugClear", CK_Debug_Clear },
133 { "EditDebugNext", CK_Debug_Next },
134 { "EditDebugStep", CK_Debug_Step },
135 { "EditDebugBackTrace", CK_Debug_Back_Trace },
136 { "EditDebugContinue", CK_Debug_Continue },
137 { "EditDebugEnterCommand", CK_Debug_Enter_Command },
138 { "EditDebugUntilCurser", CK_Debug_Until_Curser },
139 #endif
140 { "EditInsertFile", CK_Insert_File },
141 { "EditQuit", CK_Quit },
142 { "EditToggleInsert", CK_Toggle_Insert },
143 { "EditHelp", CK_Help },
144 { "EditDate", CK_Date },
145 { "EditRefresh", CK_Refresh },
146 { "EditGoto", CK_Goto },
147 { "EditDeleteLine", CK_Delete_Line },
148 { "EditDeleteToLineEnd", CK_Delete_To_Line_End },
149 { "EditDeleteToLineBegin", CK_Delete_To_Line_Begin },
150 { "EditManPage", CK_Man_Page },
151 { "EditSort", CK_Sort },
152 { "EditMail", CK_Mail },
153 { "EditCancel", CK_Cancel },
154 { "EditComplete", CK_Complete },
155 { "EditParagraphFormat", CK_Paragraph_Format },
156 { "EditUtil", CK_Util },
157 { "EditTypeLoadPython", CK_Type_Load_Python },
158 { "EditFindFile", CK_Find_File },
159 { "EditCtags", CK_Ctags },
160 { "EditMatchBracket", CK_Match_Bracket },
161 { "EditTerminal", CK_Terminal },
162 { "EditTerminalApp", CK_Terminal_App },
163 { "EditExtCmd", CK_ExtCmd },
164 { "EditUserMenu", CK_User_Menu },
165 { "EditBeginRecordMacro", CK_Begin_Record_Macro },
166 { "EditEndRecordMacro", CK_End_Record_Macro },
167 { "EditDeleteMacro", CK_Delete_Macro },
168 { "EditToggleBookmark", CK_Toggle_Bookmark },
169 { "EditFlushBookmarks", CK_Flush_Bookmarks },
170 { "EditNextBookmark", CK_Next_Bookmark },
171 { "EditPrevBookmark", CK_Prev_Bookmark },
172 { "EditPageUpHighlight", CK_Page_Up_Highlight },
173 { "EditPageDownHighlight", CK_Page_Down_Highlight },
174 { "EditLeftHighlight", CK_Left_Highlight },
175 { "EditRightHighlight", CK_Right_Highlight },
176 { "EditWordLeftHighlight", CK_Word_Left_Highlight },
177 { "EditWordRightHighlight", CK_Word_Right_Highlight },
178 { "EditUpHighlight", CK_Up_Highlight },
179 { "EditDownHighlight", CK_Down_Highlight },
180 { "EditHomeHighlight", CK_Home_Highlight },
181 { "EditEndHighlight", CK_End_Highlight },
182 { "EditBeginningOfTextHighlight", CK_Beginning_Of_Text_Highlight },
183 { "EditEndOfTextHighlight", CK_End_Of_Text_Highlight },
184 { "EditBeginPageHighlight", CK_Begin_Page_Highlight },
185 { "EditEndPageHighlight", CK_End_Page_Highlight },
186 { "EditScrollUpHighlight", CK_Scroll_Up_Highlight },
187 { "EditScrollDownHighlight", CK_Scroll_Down_Highlight },
188 { "EditParagraphUpHighlight", CK_Paragraph_Up_Highlight },
189 { "EditParagraphDownHighlight", CK_Paragraph_Down_Highlight },
191 { "EditPageUpAltHighlight", CK_Page_Up_Alt_Highlight },
192 { "EditPageDownAltHighlight", CK_Page_Down_Alt_Highlight },
193 { "EditLeftAltHighlight", CK_Left_Alt_Highlight },
194 { "EditRightAltHighlight", CK_Right_Alt_Highlight },
195 { "EditWordLeftAltHighlight", CK_Word_Left_Alt_Highlight },
196 { "EditWordRightAltHighlight", CK_Word_Right_Alt_Highlight },
197 { "EditUpAltHighlight", CK_Up_Alt_Highlight },
198 { "EditDownAltHighlight", CK_Down_Alt_Highlight },
199 { "EditHomeAltHighlight", CK_Home_Alt_Highlight },
200 { "EditEndAltHighlight", CK_End_Alt_Highlight },
201 { "EditBeginningOfTextAltHighlight", CK_Beginning_Of_Text_Alt_Highlight },
202 { "EditEndOfTextAltHighlight", CK_End_Of_Text_Alt_Highlight },
203 { "EditBeginPageAltHighlight", CK_Begin_Page_Alt_Highlight },
204 { "EditEndPageAltHighlight", CK_End_Page_Alt_Highlight },
205 { "EditScrollUpAltHighlight", CK_Scroll_Up_Alt_Highlight },
206 { "EditScrollDownAltHighlight", CK_Scroll_Down_Alt_Highlight },
207 { "EditParagraphUpAltHighlight", CK_Paragraph_Up_Alt_Highlight },
208 { "EditParagraphDownAltHighlight", CK_Paragraph_Down_Alt_Highlight },
210 { "EditShiftBlockLeft", CK_Shift_Block_Left },
211 { "EditShiftBlockRight", CK_Shift_Block_Right },
213 { "EditXStore", CK_XStore },
214 { "EditXCut", CK_XCut },
215 { "EditXPaste", CK_XPaste },
216 { "EditSelectionHistory", CK_Selection_History },
217 { "EditShell", CK_Shell },
218 { "EditInsertLiteral", CK_Insert_Literal },
219 { "EditExecuteMacro", CK_Execute_Macro },
220 { "EditBeginOrEndMacro", CK_Begin_End_Macro },
221 { "EditExtMode", CK_Ext_Mode },
222 { "EditToggleLineState", CK_Toggle_Line_State },
223 { "EditToggleTabTWS", CK_Toggle_Tab_TWS },
224 { "EditToggleSyntax", CK_Toggle_Syntax },
225 { "EditToggleShowMargin", CK_Toggle_Show_Margin },
226 { "EditFindDefinition", CK_Find_Definition },
227 { "EditLoadPrevFile", CK_Load_Prev_File },
228 { "EditLoadNextFile", CK_Load_Next_File },
229 { "EditOptions", CK_Edit_Options },
230 { "EditSaveMode", CK_Edit_Save_Mode },
231 { "EditChooseSyntax", CK_Choose_Syntax },
232 { "EditAbout", CK_About },
234 #if 0
235 { "EditFocusNext", CK_Focus_Next },
236 { "EditFocusPrev", CK_Focus_Prev },
237 { "EditHeightInc", CK_Height_Inc },
238 { "EditHeightDec", CK_Height_Dec },
239 { "EditMake", CK_Make },
240 { "EditErrorNext", CK_Error_Next },
241 { "EditErrorPrev", CK_Error_Prev },
242 #endif
244 #if 0
245 { "EditSaveDesktop", CK_Save_Desktop },
246 { "EditNewWindow", CK_New_Window },
247 { "EditCycle", CK_Cycle },
248 { "EditSaveAndQuit", CK_Save_And_Quit },
249 { "EditRunAnother", CK_Run_Another },
250 { "EditCheckSaveAndQuit", CK_Check_Save_And_Quit },
251 { "EditMaximize", CK_Maximize },
252 #endif
254 #endif /* USE_INTERNAL_EDIT */
256 /* viewer */
257 { "ViewHelp", CK_ViewHelp },
258 { "ViewToggleWrapMode", CK_ViewToggleWrapMode },
259 { "ViewToggleHexEditMode", CK_ViewToggleHexEditMode },
260 { "ViewQuit", CK_ViewQuit },
261 { "ViewToggleHexMode", CK_ViewToggleHexMode },
262 { "ViewGoto", CK_ViewGoto },
263 { "ViewHexEditSave", CK_ViewHexEditSave },
264 { "ViewSearch", CK_ViewSearch },
265 { "ViewToggleMagicMode", CK_ViewToggleMagicMode },
266 { "ViewToggleNroffMode", CK_ViewToggleNroffMode },
267 { "ViewContinueSearch", CK_ViewContinueSearch },
268 { "ViewGotoBookmark", CK_ViewGotoBookmark },
269 { "ViewNewBookmark", CK_ViewNewBookmark },
270 { "ViewMoveUp", CK_ViewMoveUp },
271 { "ViewMoveDown", CK_ViewMoveDown },
272 { "ViewMoveLeft", CK_ViewMoveLeft },
273 { "ViewMoveRight", CK_ViewMoveRight },
274 { "ViewMovePgDn", CK_ViewMovePgDn },
275 { "ViewMovePgUp", CK_ViewMovePgUp },
276 { "ViewMoveHalfPgDn", CK_ViewMoveHalfPgDn },
277 { "ViewMoveHalfPgUp", CK_ViewMoveHalfPgUp },
278 { "ViewMoveToBol", CK_ViewMoveToBol },
279 { "ViewMoveToEol", CK_ViewMoveToEol },
280 { "ViewNextFile", CK_ViewNextFile },
281 { "ViewPrevFile", CK_ViewPrevFile },
282 { "ViewToggleRuler", CK_ViewToggleRuler },
283 { "ViewToggleHexNavMode", CK_ViewToggleHexNavMode },
285 /* help */
286 { "HelpHelp", CK_HelpHelp },
287 { "HelpIndex", CK_HelpIndex },
288 { "HelpBack", CK_HelpBack },
289 { "HelpQuit", CK_HelpQuit },
290 { "HelpMoveUp", CK_HelpMoveUp },
291 { "HelpMoveDown", CK_HelpMoveDown },
292 { "HelpSelectLink", CK_HelpSelectLink },
293 { "HelpNextLink", CK_HelpNextLink },
294 { "HelpPrevLink", CK_HelpPrevLink },
295 { "HelpNextNode", CK_HelpNextNode },
296 { "HelpPrevNode", CK_HelpPrevNode },
298 /* tree */
299 { "TreeHelp", CK_TreeHelp },
300 { "TreeForget", CK_TreeForget },
301 { "TreeToggleNav", CK_TreeToggleNav },
302 { "TreeCopy", CK_TreeCopy },
303 { "TreeMove", CK_TreeMove },
304 { "TreeMake", CK_TreeMake },
305 { "TreeMoveUp", CK_TreeMoveUp },
306 { "TreeMoveDown", CK_TreeMoveDown },
307 { "TreeMoveLeft", CK_TreeMoveLeft },
308 { "TreeMoveRight", CK_TreeMoveRight },
309 { "TreeMoveHome", CK_TreeMoveHome },
310 { "TreeMoveEnd", CK_TreeMoveEnd },
311 { "TreeMovePgUp", CK_TreeMovePgUp },
312 { "TreeMovePgDn", CK_TreeMovePgDn },
313 { "TreeOpen", CK_TreeOpen },
314 { "TreeRescan", CK_TreeRescan },
315 { "TreeStartSearch", CK_TreeStartSearch },
316 { "TreeRemove", CK_TreeRemove },
318 /* main commands */
319 { "CmdHelp", CK_HelpCmd },
320 { "CmdMenu", CK_MenuCmd },
321 { "CmdChmod", CK_ChmodCmd },
322 { "CmdMenuLastSelected", CK_MenuLastSelectedCmd },
323 { "CmdSingleDirsize", CK_SingleDirsizeCmd },
324 { "CmdCopyCurrentPathname", CK_CopyCurrentPathname },
325 { "CmdCopyOtherPathname", CK_CopyOtherPathname },
326 { "CmdSuspend", CK_SuspendCmd },
327 { "CmdToggleListing", CK_ToggleListingCmd },
328 { "CmdChownAdvanced", CK_ChownAdvancedCmd },
329 { "CmdChown", CK_ChownCmd },
330 { "CmdCompareDirs", CK_CompareDirsCmd },
331 { "CmdConfigureBox", CK_ConfigureBox },
332 { "CmdConfigureVfs", CK_ConfigureVfs },
333 { "CmdConfirmBox", CK_ConfirmBox },
334 { "CmdCopy", CK_CopyCmd },
335 { "CmdDelete", CK_DeleteCmd },
336 { "CmdDirsizes", CK_DirsizesCmd },
337 { "CmdDisplayBitsBox", CK_DisplayBitsBox },
338 { "CmdEdit", CK_EditCmd },
339 { "CmdEditExtFile", CK_EditExtFileCmd },
340 { "CmdEditFhlFile", CK_EditFhlFileCmd },
341 { "CmdEditMcMenu", CK_EditMcMenuCmd },
342 { "CmdEditSymlink", CK_EditSymlinkCmd },
343 { "CmdEditSyntax", CK_EditSyntaxCmd },
344 { "CmdEditUserMenu", CK_EditUserMenuCmd },
345 { "CmdExternalPanelize", CK_ExternalPanelize },
346 { "CmdFilter", CK_FilterCmd },
347 { "CmdFilteredView", CK_FilteredViewCmd },
348 { "CmdFind", CK_FindCmd },
349 #ifdef USE_NETCODE
350 { "CmdFishlink", CK_FishlinkCmd },
351 { "CmdFtplink", CK_FtplinkCmd },
352 #endif
353 { "CmdHistory", CK_HistoryCmd },
354 { "CmdInfo", CK_InfoCmd },
355 #ifdef WITH_BACKGROUND
356 { "CmdJobs", CK_JobsCmd },
357 #endif
358 { "CmdLayout", CK_LayoutCmd },
359 { "CmdLearnKeys", CK_LearnKeys },
360 { "CmdLink", CK_LinkCmd },
361 { "CmdListing", CK_ListingCmd },
362 #ifdef LISTMODE_EDITOR
363 { "CmdListmodeCmd", CK_ListmodeCmd }.
364 #endif
365 { "CmdMkdir", CK_MkdirCmd },
366 #if defined (USE_NETCODE) && defined (ENABLE_VFS_MCFS)
367 { "CmdNetlink", CK_NetlinkCmd },
368 #endif
369 { "CmdQuickCd", CK_QuickCdCmd },
370 { "CmdQuickChdir", CK_QuickChdirCmd },
371 { "CmdQuickView", CK_QuickViewCmd },
372 { "CmdQuietQuit", CK_QuietQuitCmd },
373 { "CmdRename", CK_RenameCmd },
374 { "CmdReread", CK_RereadCmd },
375 { "CmdReselectVfs", CK_ReselectVfs },
376 { "CmdReverseSelection", CK_ReverseSelectionCmd },
377 { "CmdSaveSetup", CK_SaveSetupCmd },
378 { "CmdSelect", CK_SelectCmd },
379 #if defined (USE_NETCODE) && defined (ENABLE_VFS_SMB)
380 { "CmdSmblinkCmd", CK_SmblinkCmd },
381 #endif /* USE_NETCODE || ENABLE_VFS_SMB */
382 { "CmdSwapPanel", CK_SwapCmd },
383 { "CmdSymlink", CK_SymlinkCmd },
384 { "CmdTree", CK_TreeCmd },
385 { "CmdTreeBox", CK_TreeBoxCmd },
386 #ifdef USE_EXT2FSLIB
387 { "CmdUndelete", CK_UndeleteCmd },
388 #endif
389 { "CmdUnselect", CK_UnselectCmd },
390 { "CmdUserMenu", CK_UserMenuCmd },
391 { "CmdUserFileMenu", CK_UserFileMenuCmd },
392 { "CmdView", CK_ViewCmd },
393 { "CmdViewFile", CK_ViewFileCmd },
394 { "CmdCopyCurrentReadlink", CK_CopyCurrentReadlink },
395 { "CmdCopyOtherReadlink", CK_CopyOtherReadlink },
396 { "CmdAddHotlist", CK_AddHotlist },
397 { "CmdQuit", CK_QuitCmd },
398 { "CmdCopyCurrentTagged", CK_CopyCurrentTagged },
399 { "CmdCopyOtherTagged", CK_CopyOtherTagged },
400 { "CmdToggleShowHidden", CK_ToggleShowHidden },
401 { "CmdTogglePanelsSplit", CK_TogglePanelsSplit },
402 #ifdef USE_DIFF_VIEW
403 { "CmdDiffView", CK_DiffViewCmd},
404 #endif
406 /* panel */
407 { "PanelChdirOtherPanel", CK_PanelChdirOtherPanel },
408 { "PanelChdirToReadlink", CK_PanelChdirToReadlink },
409 { "PanelCopyLocal", CK_PanelCmdCopyLocal },
410 { "PanelDeleteLocal", CK_PanelCmdDeleteLocal },
411 { "PanelDoEnter", CK_PanelCmdDoEnter },
412 { "PanelEditNew", CK_PanelCmdEditNew },
413 { "PanelRenameLocal", CK_PanelCmdRenameLocal },
414 { "PanelReverseSelection", CK_PanelCmdReverseSelection },
415 { "PanelSelect", CK_PanelCmdSelect },
416 { "PanelUnselect", CK_PanelCmdUnselect },
417 { "PanelViewSimple", CK_PanelCmdViewSimple },
418 { "PanelCtrlNextPage", CK_PanelCtrlNextPage },
419 { "PanelCtrlPrevPage", CK_PanelCtrlPrevPage },
420 { "PanelDirectoryHistoryList", CK_PanelDirectoryHistoryList },
421 { "PanelDirectoryHistoryNext", CK_PanelDirectoryHistoryNext },
422 { "PanelDirectoryHistoryPrev", CK_PanelDirectoryHistoryPrev },
423 { "PanelGotoBottomFile", CK_PanelGotoBottomFile },
424 { "PanelGotoMiddleFile", CK_PanelGotoMiddleFile },
425 { "PanelGotoTopFile", CK_PanelGotoTopFile },
426 { "PanelMarkFile", CK_PanelMarkFile },
427 { "PanelMoveUp", CK_PanelMoveUp },
428 { "PanelMoveDown", CK_PanelMoveDown },
429 { "PanelMoveLeft", CK_PanelMoveLeft },
430 { "PanelMoveRight", CK_PanelMoveRight },
431 { "PanelMoveEnd", CK_PanelMoveEnd },
432 { "PanelMoveHome", CK_PanelMoveHome },
433 { "PanelNextPage", CK_PanelNextPage },
434 { "PanelPrevPage", CK_PanelPrevPage },
435 #ifdef HAVE_CHARSET
436 { "PanelSetPanelEncoding", CK_PanelSetPanelEncoding },
437 #endif
438 { "PanelStartSearch", CK_PanelStartSearch },
439 { "PanelSyncOtherPanel", CK_PanelSyncOtherPanel },
440 { "PanelToggleSortOrderNext", CK_PanelToggleSortOrderNext },
441 { "PanelToggleSortOrderPrev", CK_PanelToggleSortOrderPrev },
442 { "PanelSelectSortOrder", CK_PanelSelectSortOrder },
443 { "PanelReverseSort", CK_PanelReverseSort },
444 { "PanelSortOrderByName", CK_PanelSortOrderByName },
445 { "PanelSortOrderByExt", CK_PanelSortOrderByExt },
446 { "PanelSortOrderBySize", CK_PanelSortOrderBySize },
447 { "PanelSortOrderByMTime", CK_PanelSortOrderByMTime },
449 /* input line */
450 { "InputBol", CK_InputBol },
451 { "InputEol", CK_InputEol },
452 { "InputMoveLeft", CK_InputMoveLeft },
453 { "InputWordLeft", CK_InputWordLeft },
454 { "InputBackwardChar", CK_InputBackwardChar },
455 { "InputBackwardWord", CK_InputBackwardWord },
456 { "InputMoveRight", CK_InputMoveRight },
457 { "InputWordRight", CK_InputWordRight },
458 { "InputForwardChar", CK_InputForwardChar },
459 { "InputForwardWord", CK_InputForwardWord },
460 { "InputBackwardDelete", CK_InputBackwardDelete },
461 { "InputDeleteChar", CK_InputDeleteChar },
462 { "InputKillWord", CK_InputKillWord },
463 { "InputBackwardKillWord", CK_InputBackwardKillWord },
464 { "InputSetMark", CK_InputSetMark },
465 { "InputKillRegion", CK_InputKillRegion },
466 { "InputYank", CK_InputYank },
467 { "InputKillLine", CK_InputKillLine },
468 { "InputHistoryPrev", CK_InputHistoryPrev },
469 { "InputHistoryNext", CK_InputHistoryNext },
470 { "InputHistoryShow", CK_InputHistoryShow },
471 { "InputComplete", CK_InputComplete },
472 { "InputXStore", CK_InputKillSave },
473 { "InputXPaste", CK_InputPaste },
474 { "InputClearLine", CK_InputClearLine },
476 /* common */
477 { "ExtMap1", CK_StartExtMap1 },
478 { "ExtMap2", CK_StartExtMap2 },
479 { "ShowCommandLine", CK_ShowCommandLine },
480 { "SelectCodepage", CK_SelectCodepage },
482 /* dialog */
483 { "DialogOK", CK_DialogOK },
484 { "DialogCancel", CK_DialogCancel },
485 { "DialogPrevItem", CK_DialogPrevItem },
486 { "DialogNextItem", CK_DialogNextItem },
487 { "DialogHelp", CK_DialogHelp },
488 { "DialogSuspend", CK_DialogSuspend },
489 { "DialogRefresh", CK_DialogRefresh },
491 /* diff viewer */
492 { "DiffDisplaySymbols", CK_DiffDisplaySymbols},
493 { "DiffDisplayNumbers", CK_DiffDisplayNumbers},
494 { "DiffFull", CK_DiffFull},
495 { "DiffEqual", CK_DiffEqual},
496 { "DiffSplitMore", CK_DiffSplitMore},
497 { "DiffSplitLess", CK_DiffSplitLess},
498 { "DiffShowDiff", CK_DiffShowDiff},
499 { "DiffSetTab2", CK_DiffSetTab2},
500 { "DiffSetTab3", CK_DiffSetTab3},
501 { "DiffSetTab4", CK_DiffSetTab4},
502 { "DiffSetTab8", CK_DiffSetTab8},
503 { "DiffSwapPanel", CK_DiffSwapPanel},
504 { "DiffRedo", CK_DiffRedo},
505 { "DiffNextHunk", CK_DiffNextHunk},
506 { "DiffPrevHunk", CK_DiffPrevHunk},
507 { "DiffGoto", CK_DiffGoto},
508 { "DiffEditCurrent", CK_DiffEditCurrent},
509 { "DiffEditOther", CK_DiffEditOther},
510 { "DiffSearch", CK_DiffSearch},
511 { "DiffContinueSearch", CK_DiffContinueSearch},
512 { "DiffEOF", CK_DiffEOF},
513 { "DiffBOF", CK_DiffBOF},
514 { "DiffDown", CK_DiffDown},
515 { "DiffUp", CK_DiffUp},
516 { "DiffLeft", CK_DiffLeft},
517 { "DiffRight", CK_DiffRight},
518 { "DiffPageDown", CK_DiffPageDown},
519 { "DiffPageUp", CK_DiffPageUp},
520 { "DiffHome", CK_DiffHome},
521 { "DiffEnd", CK_DiffEnd},
522 { "DiffQuit", CK_DiffQuit},
523 { "DiffHelp", CK_DiffHelp},
524 { "SelectCodepage", CK_SelectCodepage},
525 { "DiffMergeCurrentHunk", CK_DiffMergeCurrentHunk},
526 { "DiffSave", CK_DiffSave},
527 { "DiffOptions", CK_DiffOptions},
529 { NULL, CK_Ignore_Key }
532 static const size_t num_command_names = sizeof (command_names) /
533 sizeof (command_names[0]) - 1;
535 /*** global variables ****************************************************************************/
537 /* viewer/actions_cmd.c */
538 const global_keymap_t default_viewer_keymap[] = {
539 { KEY_F (1), CK_ViewHelp, "F1" },
540 { KEY_F (2), CK_ViewToggleWrapMode, "F2" },
541 { KEY_F (3), CK_ViewQuit, "F3" },
542 { KEY_F (4), CK_ViewToggleHexMode, "F4" },
543 { KEY_F (5), CK_ViewGoto, "F5" },
544 { KEY_F (7), CK_ViewSearch, "F7" },
545 { KEY_F (8), CK_ViewToggleMagicMode, "F8" },
546 { KEY_F (9), CK_ViewToggleNroffMode, "F9" },
547 { KEY_F (10), CK_ViewQuit, "F10" },
549 { '?', CK_ViewSearch, "?" },
550 { '/', CK_ViewSearch, "/" },
551 { XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
552 { XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
553 { KEY_F (17), CK_ViewContinueSearch, "S-F7" },
554 { 'n', CK_ViewContinueSearch, "n" },
555 { ALT ('r'), CK_ViewToggleRuler, "M-r" },
557 { XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
558 { XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
560 { 'h', CK_ViewMoveLeft, "h" },
561 { KEY_LEFT, CK_ViewMoveLeft, "Left" },
563 { 'l', CK_ViewMoveRight, "l" },
564 { KEY_RIGHT, CK_ViewMoveRight, "Right" },
566 { 'k', CK_ViewMoveUp, "k" },
567 { 'y', CK_ViewMoveUp, "y" },
568 { KEY_IC, CK_ViewMoveUp, "Insert" },
569 { KEY_UP, CK_ViewMoveUp, "Up" },
571 { 'j', CK_ViewMoveDown, "j" },
572 { 'e', CK_ViewMoveDown, "e" },
573 { KEY_DOWN, CK_ViewMoveDown, "Down" },
574 { KEY_DC, CK_ViewMoveDown, "Delete" },
576 { ' ', CK_ViewMovePgDn, "Space" },
577 { 'f', CK_ViewMovePgDn, "f" },
578 { KEY_NPAGE, CK_ViewMovePgDn, "PgDn" },
580 { 'b', CK_ViewMovePgUp, "b" },
581 { KEY_PPAGE, CK_ViewMovePgUp, "PgUp" },
583 { 'd', CK_ViewMoveHalfPgDn, "d" },
584 { 'u', CK_ViewMoveHalfPgUp, "u" },
586 { 'm', CK_ViewGotoBookmark, "m" },
587 { 'r', CK_ViewNewBookmark, "r" },
589 { XCTRL ('f'), CK_ViewNextFile, "C-f" },
590 { XCTRL ('b'), CK_ViewPrevFile, "C-b" },
592 { 'q', CK_ViewQuit, "q" },
593 { XCTRL ('g'), CK_ViewQuit, "C-g" },
594 { ESC_CHAR, CK_ViewQuit, "Esc" },
596 { ALT ('e'), CK_SelectCodepage, "M-e" },
597 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
599 { 0, CK_Ignore_Key, "" }
602 const global_keymap_t default_viewer_hex_keymap[] = {
603 { KEY_F (1), CK_ViewHelp, "F1" },
604 { KEY_F (2), CK_ViewToggleHexEditMode, "F2" },
605 { KEY_F (3), CK_ViewQuit, "F3" },
606 { KEY_F (4), CK_ViewToggleHexMode, "F4" },
607 { KEY_F (5), CK_ViewGoto, "F5" },
608 { KEY_F (6), CK_ViewHexEditSave, "F6" },
609 { KEY_F (7), CK_ViewSearch, "F7" },
610 { KEY_F (8), CK_ViewToggleMagicMode, "F8" },
611 { KEY_F (9), CK_ViewToggleNroffMode, "F9" },
612 { KEY_F (10), CK_ViewQuit, "F10" },
614 { '?', CK_ViewSearch, "?" },
615 { '/', CK_ViewSearch, "/" },
616 { XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
617 { XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
618 { KEY_F (17), CK_ViewContinueSearch, "S-F7" },
619 { 'n', CK_ViewContinueSearch, "n" },
621 { '\t', CK_ViewToggleHexNavMode, "Tab" },
622 { XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
623 { XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
625 { 'b', CK_ViewMoveLeft, "b" },
626 { KEY_LEFT, CK_ViewMoveLeft, "Left" },
628 { 'f', CK_ViewMoveRight, "f" },
629 { KEY_RIGHT, CK_ViewMoveRight, "Right" },
631 { 'k', CK_ViewMoveUp, "k" },
632 { 'y', CK_ViewMoveUp, "y" },
633 { KEY_UP, CK_ViewMoveUp, "Up" },
635 { 'j', CK_ViewMoveDown, "j" },
636 { KEY_DOWN, CK_ViewMoveDown, "Down" },
637 { KEY_DC, CK_ViewMoveDown, "Delete" },
639 { 'q', CK_ViewQuit, "q" },
640 { XCTRL ('g'), CK_ViewQuit, "C-g" },
641 { ESC_CHAR, CK_ViewQuit, "Esc" },
643 { ALT ('e'), CK_SelectCodepage, "M-e" },
644 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
646 { 0, CK_Ignore_Key, "" }
649 #ifdef USE_INTERNAL_EDIT
650 /* ../edit/editkeys.c */
651 const global_keymap_t default_editor_keymap[] = {
652 { '\n', CK_Enter, "Enter" },
653 { '\t', CK_Tab, "Tab" },
655 { KEY_F (1), CK_Help, "F1" },
656 { KEY_F (2), CK_Save, "F2" },
657 { KEY_F (3), CK_Mark, "F3" },
658 { KEY_F (4), CK_Replace, "F4" },
659 { KEY_F (5), CK_Copy, "F5" },
660 { KEY_F (6), CK_Move, "F6" },
661 { KEY_F (7), CK_Find, "F7" },
662 { KEY_F (8), CK_Remove, "F8" },
663 { KEY_F (9), CK_Menu, "F9" },
664 { KEY_F (10), CK_Quit, "F10" },
665 /* edit user menu */
666 { KEY_F (11), CK_User_Menu, "S-F1" },
667 { KEY_F (12), CK_Save_As, "S-F2" },
668 { KEY_F (13), CK_Column_Mark, "S-F3" },
669 { KEY_F (14), CK_Replace_Again, "S-F4" },
670 { KEY_F (15), CK_Insert_File, "S-F5" },
671 { KEY_F (17), CK_Find_Again, "S-F7" },
672 /* C formatter */
673 { KEY_F (19), CK_Pipe_Block (0), "S-F9" },
675 { ESC_CHAR, CK_Quit, "Esc" },
676 { KEY_BACKSPACE, CK_BackSpace, "BackSpace" },
677 { KEY_DC, CK_Delete, "Delete" },
678 { KEY_DOWN, CK_Down, "Down" },
679 { KEY_END, CK_End, "End" },
680 { KEY_HOME, CK_Home, "Home" },
681 { KEY_IC, CK_Toggle_Insert, "Insert" },
682 { KEY_LEFT, CK_Left, "Left" },
683 { KEY_NPAGE, CK_Page_Down, "PgDn" },
684 { KEY_PPAGE, CK_Page_Up, "PgUp" },
685 { KEY_RIGHT, CK_Right, "Right" },
686 { KEY_UP, CK_Up, "Up" },
688 /* Ctrl */
689 { KEY_M_CTRL | (KEY_F (2)), CK_Save_As, "C-F2" },
690 { KEY_M_CTRL | (KEY_F (4)), CK_Replace_Again, "C-F4" },
691 { KEY_M_CTRL | (KEY_F (7)), CK_Find_Again, "C-F7" },
692 { KEY_M_CTRL | KEY_BACKSPACE, CK_Undo, "C-BackSpace" },
693 { KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text, "C-PgDn" },
694 { KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text, "C-PgUp" },
695 { KEY_M_CTRL | KEY_HOME, CK_Beginning_Of_Text, "C-Home" },
696 { KEY_M_CTRL | KEY_END, CK_End_Of_Text, "C-End" },
697 { KEY_M_CTRL | KEY_UP, CK_Scroll_Up, "C-Up" },
698 { KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down, "C-Down" },
699 { KEY_M_CTRL | KEY_LEFT, CK_Word_Left, "C-Left" },
700 { KEY_M_CTRL | KEY_RIGHT, CK_Word_Right, "C-Right" },
701 { KEY_M_CTRL | KEY_IC, CK_XStore, "C-Insert" },
702 { KEY_M_CTRL | KEY_DC, CK_Remove, "C-Delete" },
704 { XCTRL ('n'), CK_New, "C-n" },
705 { XCTRL ('k'), CK_Delete_To_Line_End, "C-k" },
706 { XCTRL ('l'), CK_Refresh, "C-l" },
707 { XCTRL ('o'), CK_Shell, "C-o" },
708 { XCTRL ('s'), CK_Toggle_Syntax, "C-s" },
709 { XCTRL ('u'), CK_Undo, "C-u" },
710 { ALT ('e'), CK_SelectCodepage, "M-e" },
711 { XCTRL ('q'), CK_Insert_Literal, "C-q" },
712 { XCTRL ('r'), CK_Begin_End_Macro, "C-r" },
713 { XCTRL ('r'), CK_Begin_Record_Macro, "C-r" },
714 { XCTRL ('r'), CK_End_Record_Macro, "C-r" },
715 { XCTRL ('a'), CK_Execute_Macro, "C-a" },
717 /* Shift */
718 { KEY_M_SHIFT | KEY_NPAGE, CK_Page_Down_Highlight, "S-PgDn" },
719 { KEY_M_SHIFT | KEY_PPAGE, CK_Page_Up_Highlight, "S-PgUp" },
720 { KEY_M_SHIFT | KEY_LEFT, CK_Left_Highlight, "S-Left" },
721 { KEY_M_SHIFT | KEY_RIGHT, CK_Right_Highlight, "S-Right" },
722 { KEY_M_SHIFT | KEY_UP, CK_Up_Highlight, "S-Up" },
723 { KEY_M_SHIFT | KEY_DOWN, CK_Down_Highlight, "S-Down" },
724 { KEY_M_SHIFT | KEY_HOME, CK_Home_Highlight, "S-Home" },
725 { KEY_M_SHIFT | KEY_END, CK_End_Highlight, "S-End" },
726 { KEY_M_SHIFT | KEY_IC, CK_XPaste, "S-Insert" },
727 { KEY_M_SHIFT | KEY_DC, CK_XCut, "S-Delete" },
728 /* useful for pasting multiline text */
729 { KEY_M_SHIFT | '\n', CK_Return, "S-Enter" },
731 /* Ctrl + Shift */
732 { KEY_M_SHIFT | KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text_Highlight, "C-S-PgDn" },
733 { KEY_M_SHIFT | KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text_Highlight, "C-S-PgUp" },
734 { KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, CK_Word_Left_Highlight, "C-S-Left" },
735 { KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, CK_Word_Right_Highlight, "C-S-Right" },
736 { KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, CK_Scroll_Up_Highlight, "C-S-Up" },
737 { KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down_Highlight, "C-S-Down" },
739 /* Alt */
740 { KEY_M_ALT | KEY_NPAGE, CK_Page_Down_Alt_Highlight, "M-PgDn" },
741 { KEY_M_ALT | KEY_PPAGE, CK_Page_Up_Alt_Highlight, "M-PgUp" },
742 { KEY_M_ALT | KEY_LEFT, CK_Left_Alt_Highlight, "M-Left" },
743 { KEY_M_ALT | KEY_RIGHT, CK_Right_Alt_Highlight, "M-Right" },
744 { KEY_M_ALT | KEY_UP, CK_Up_Alt_Highlight, "M-Up" },
745 { KEY_M_ALT | KEY_DOWN, CK_Down_Alt_Highlight, "M-Down" },
746 { KEY_M_ALT | KEY_HOME, CK_Home_Highlight, "M-Home" },
747 { KEY_M_ALT | KEY_END, CK_End_Alt_Highlight, "M-End" },
749 { ALT ('\n'), CK_Find_Definition, "M-Enter" },
750 { ALT ('\t'), CK_Complete_Word, "M-Tab" },
751 { ALT ('l'), CK_Goto, "M-l" },
752 { ALT ('L'), CK_Goto, "M-L" },
753 { ALT ('p'), CK_Paragraph_Format, "M-p" },
754 { ALT ('t'), CK_Sort, "M-t" },
755 { ALT ('u'), CK_ExtCmd, "M-u" },
756 { ALT ('<'), CK_Beginning_Of_Text, "M-<" },
757 { ALT ('>'), CK_End_Of_Text, "M->" },
758 { ALT ('-'), CK_Load_Prev_File, "M--" },
759 { ALT ('+'), CK_Load_Next_File, "M-+" },
760 { ALT ('d'), CK_Delete_Word_Right, "M-d" },
761 { ALT (KEY_BACKSPACE), CK_Delete_Word_Left, "M-BackSpace" },
762 { ALT ('n'), CK_Toggle_Line_State, "M-n" },
763 { ALT ('_'), CK_Toggle_Tab_TWS, "M-_" },
764 { ALT ('k'), CK_Toggle_Bookmark, "M-k" },
765 { ALT ('i'), CK_Prev_Bookmark, "M-i" },
766 { ALT ('j'), CK_Next_Bookmark, "M-j" },
767 { ALT ('o'), CK_Flush_Bookmarks, "M-o" },
769 { XCTRL ('x'), CK_Ext_Mode, "C-x" },
771 { 0, CK_Ignore_Key, "" }
774 /* emacs keyboard layout emulation */
775 const global_keymap_t default_editor_x_keymap[] = {
776 { 'k', CK_New, "k"},
777 { 'e', CK_Execute_Macro, "e"},
778 { 0, CK_Ignore_Key, "" }
780 #endif /* USE_INTERNAL_EDIT */
782 /* dialog */
783 const global_keymap_t default_dialog_keymap[] = {
784 { '\n', CK_DialogOK, "Enter" },
785 { KEY_ENTER, CK_DialogOK, "Enter" },
786 { ESC_CHAR, CK_DialogCancel, "Esc" },
787 { XCTRL('g'), CK_DialogCancel, "C-g" },
788 { KEY_F (10), CK_DialogCancel, "F10" },
789 { KEY_LEFT, CK_DialogPrevItem, "Left" },
790 { KEY_UP, CK_DialogPrevItem, "Up" },
791 { KEY_RIGHT, CK_DialogNextItem, "Right" },
792 { KEY_DOWN, CK_DialogNextItem, "Down" },
793 { KEY_F(1), CK_DialogHelp, "F1" },
794 { XCTRL('z'), CK_DialogSuspend, "C-z" },
795 { XCTRL('l'), CK_DialogRefresh, "C-l" },
796 { 0, CK_Ignore_Key, "" }
799 /* tree */
800 const global_keymap_t default_tree_keymap[] = {
801 { KEY_F (1), CK_TreeHelp, "F1"},
802 { KEY_F (2), CK_TreeRescan, "F2" },
803 { KEY_F (3), CK_TreeForget, "F3" },
804 { KEY_F (4), CK_TreeToggleNav, "F4" },
805 { KEY_F (5), CK_TreeCopy, "F5" },
806 { KEY_F (6), CK_TreeMove, "F6" },
807 #if 0
808 { KEY_F (7), CK_TreeMake, "F7" },
809 #endif
810 { KEY_F (8), CK_TreeRemove, "F8" },
811 { KEY_UP, CK_TreeMoveUp, "Up" },
812 { XCTRL ('p'), CK_TreeMoveUp, "C-p" },
813 { KEY_DOWN, CK_TreeMoveDown, "Down" },
814 { XCTRL ('n'), CK_TreeMoveDown, "C-n" },
815 { KEY_LEFT, CK_TreeMoveLeft, "Left" },
816 { KEY_RIGHT, CK_TreeMoveRight, "Right" },
817 { KEY_HOME, CK_TreeMoveHome, "Home" },
818 { ALT ('<'), CK_TreeMoveHome, "M-<" },
819 { KEY_END, CK_TreeMoveEnd , "End" },
820 { ALT ('>'), CK_TreeMoveEnd , "M->" },
821 { KEY_PPAGE, CK_TreeMovePgUp, "PgUp" },
822 { ALT ('v'), CK_TreeMovePgUp, "M-v" },
823 { KEY_NPAGE, CK_TreeMovePgDn, "PnDn" },
824 { XCTRL ('v'), CK_TreeMovePgDn, "C-v" },
825 { '\n', CK_TreeOpen, "Enter" },
826 { KEY_ENTER, CK_TreeOpen, "Enter" },
827 { XCTRL ('r'), CK_TreeRescan, "C-r" },
828 { XCTRL ('s'), CK_TreeStartSearch, "C-s" },
829 { ALT ('s'), CK_TreeStartSearch, "M-s" },
830 { KEY_DC, CK_TreeRemove, "Delete" },
831 { 0, CK_Ignore_Key, ""}
834 /* help */
835 const global_keymap_t default_help_keymap[] = {
836 { KEY_F (1), CK_HelpHelp, "F1" },
837 { KEY_F (2), CK_HelpIndex, "F2" },
838 { KEY_F (3), CK_HelpBack, "F3" },
839 { KEY_F (10), CK_HelpQuit, "F10" },
840 { KEY_LEFT, CK_HelpBack, "Left" },
841 { 'l', CK_HelpBack, "l" },
842 { KEY_DOWN, CK_HelpMoveDown, "Down" },
843 { KEY_UP, CK_HelpMoveUp, "Up" },
844 { KEY_RIGHT, CK_HelpSelectLink, "Right" },
845 { KEY_ENTER, CK_HelpSelectLink, "Enter" },
846 { '\n', CK_HelpSelectLink, "Enter" },
847 { '\t', CK_HelpNextLink, "Tab" },
848 { ALT ('\t'), CK_HelpPrevLink, "M-Tab" },
849 { 'n', CK_HelpNextNode, "n" },
850 { 'p', CK_HelpPrevNode, "p" },
851 { ESC_CHAR, CK_HelpQuit, "Esc" },
852 { XCTRL ('g'), CK_HelpQuit, "C-g" },
853 { 0, CK_Ignore_Key, "" }
856 /* screen.c */
857 const global_keymap_t default_panel_keymap[] = {
858 { ALT ('o'), CK_PanelChdirOtherPanel, "M-o" },
859 { ALT ('l'), CK_PanelChdirToReadlink, "M-l" },
860 { KEY_F (15), CK_PanelCmdCopyLocal, "S-F5" },
861 { KEY_F (18), CK_PanelCmdDeleteLocal, "S-F8" },
862 { KEY_ENTER, CK_PanelCmdDoEnter, "Enter" },
863 { '\n', CK_PanelCmdDoEnter, "Enter" },
864 { KEY_F (14), CK_PanelCmdEditNew, "S-F4" },
865 { KEY_F (16), CK_PanelCmdRenameLocal, "S-F6" },
866 { ALT ('*'), CK_PanelCmdReverseSelection, "M-*" },
867 { KEY_KP_ADD, CK_PanelCmdSelect, "M-+" },
868 { KEY_KP_SUBTRACT, CK_PanelCmdUnselect, "M--" },
869 { KEY_F (13), CK_PanelCmdViewSimple, "S-F3" },
870 { KEY_M_CTRL | KEY_NPAGE, CK_PanelCtrlNextPage, "C-PgDn" },
871 { KEY_M_CTRL | KEY_PPAGE, CK_PanelCtrlPrevPage, "C-PgUp" },
872 { ALT ('H'), CK_PanelDirectoryHistoryList, "M-H" },
873 { ALT ('u'), CK_PanelDirectoryHistoryNext, "M-u" },
874 { ALT ('y'), CK_PanelDirectoryHistoryPrev, "M-y" },
875 { ALT ('j'), CK_PanelGotoBottomFile, "M-j" },
876 { ALT ('r'), CK_PanelGotoMiddleFile, "M-r" },
877 { ALT ('g'), CK_PanelGotoTopFile, "M-g" },
878 { KEY_IC, CK_PanelMarkFile, "Insert" },
879 { KEY_UP, CK_PanelMoveUp, "Up" },
880 { KEY_DOWN, CK_PanelMoveDown, "Down" },
881 { KEY_LEFT, CK_PanelMoveLeft, "Left" },
882 { KEY_RIGHT, CK_PanelMoveRight, "Right" },
883 { KEY_END, CK_PanelMoveEnd, "End" },
884 { KEY_HOME, CK_PanelMoveHome, "Home" },
885 { KEY_A1, CK_PanelMoveHome, "Home" },
886 { KEY_NPAGE, CK_PanelNextPage, "PgDn" },
887 { KEY_PPAGE, CK_PanelPrevPage, "PgUp" },
888 { ALT ('e'), CK_PanelSetPanelEncoding, "M-e" },
889 { XCTRL ('s'), CK_PanelStartSearch, "C-s" },
890 { ALT ('s'), CK_PanelStartSearch, "M-s" },
891 { ALT ('i'), CK_PanelSyncOtherPanel, "M-i" },
892 { 0, CK_Ignore_Key , "" }
895 /* main.c */
896 const global_keymap_t default_main_map[] = {
897 { KEY_F (1), CK_HelpCmd, "F1" },
898 { KEY_F (2), CK_UserMenuCmd, "F2" },
899 { KEY_F (3), CK_ViewCmd, "F3" },
900 { KEY_F (4), CK_EditCmd, "F4" },
901 { KEY_F (5), CK_CopyCmd, "F5" },
902 { KEY_F (6), CK_RenameCmd, "F6" },
903 { KEY_F (7), CK_MkdirCmd, "F7" },
904 { KEY_F (8), CK_DeleteCmd, "F8" },
905 { KEY_F (9), CK_MenuCmd, "F9" },
906 { KEY_F (10), CK_QuitCmd, "F10" },
907 { KEY_F (13), CK_ViewFileCmd, "S-F3" },
908 { KEY_F (19), CK_MenuLastSelectedCmd, "S-F9" },
909 { KEY_F (20), CK_QuietQuitCmd, "S-10" },
910 { ALT ('h'), CK_HistoryCmd, "M-h" },
911 { XCTRL ('@'), CK_SingleDirsizeCmd, "C-Space" },
912 /* Copy useful information to the command line */
913 { ALT ('a'), CK_CopyCurrentPathname, "M-a" },
914 { ALT ('A'), CK_CopyOtherPathname, "M-A" },
915 { ALT ('c'), CK_QuickCdCmd, "M-c" },
916 /* To access the directory hotlist */
917 { XCTRL ('\\'), CK_QuickChdirCmd, "C-\\" },
918 /* Suspend */
919 { XCTRL ('z'), CK_SuspendCmd, "C-z" },
920 /* The filtered view command */
921 { ALT ('!'), CK_FilteredViewCmd, "M-!" },
922 /* Find file */
923 { ALT ('?'), CK_FindCmd, "M-?" },
924 /* Panel refresh */
925 { XCTRL ('r'), CK_RereadCmd, "C-r" },
926 /* Toggle listing between long, user defined and full formats */
927 { ALT ('t'), CK_ToggleListingCmd, "M-t" },
928 /* Swap panels */
929 { XCTRL ('u'), CK_SwapCmd, "C-u" },
930 /* View output */
931 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
932 { ALT ('.'), CK_ToggleShowHidden, "M-." },
933 { ALT (','), CK_TogglePanelsSplit, "M-," },
934 { XCTRL ('x'), CK_StartExtMap1, "C-x" },
935 /* Select/unselect group */
936 { KEY_KP_ADD, CK_SelectCmd, "+" },
937 { KEY_KP_SUBTRACT, CK_UnselectCmd, "-" },
938 { ALT ('*'), CK_ReverseSelectionCmd, "*" },
939 { 0, CK_Ignore_Key, "" }
942 const global_keymap_t default_main_x_map[] = {
943 { 'd', CK_CompareDirsCmd, "d" },
944 #ifdef ENABLE_VFS
945 { 'a', CK_ReselectVfs, "a"},
946 #endif /* ENABLE_VFS */
947 { 'p', CK_CopyCurrentPathname, "p" },
948 { XCTRL ('p'), CK_CopyOtherPathname, "C-p" },
949 { 't', CK_CopyCurrentTagged, "t" },
950 { XCTRL ('t'), CK_CopyOtherTagged, "C-t" },
951 { 'c', CK_ChmodCmd, "c" },
952 { 'o', CK_ChownCmd, "o" },
953 { 'r', CK_CopyCurrentReadlink, "r" },
954 { XCTRL ('r'), CK_CopyOtherReadlink, "C-r" },
955 { 'l', CK_LinkCmd, "l" },
956 { 's', CK_SymlinkCmd, "s" },
957 { XCTRL ('s'), CK_EditSymlinkCmd, "C-s" },
958 { 'i', CK_InfoCmd, "i" },
959 { 'q', CK_QuickViewCmd, "q" },
960 { 'h', CK_AddHotlist, "h" },
961 { '!', CK_ExternalPanelize, "!" },
962 #ifdef WITH_BACKGROUND
963 { 'j', CK_JobsCmd, "j" },
964 #endif /* WITH_BACKGROUND */
965 { 0, CK_Ignore_Key, "" }
968 const global_keymap_t default_input_keymap[] = {
969 /* Motion */
970 { XCTRL ('a'), CK_InputBol, "C-a" },
971 { KEY_HOME, CK_InputBol, "Home" },
972 { KEY_A1, CK_InputBol, "Home" },
973 { ALT ('<'), CK_InputBol, "M-<" },
974 { XCTRL ('e'), CK_InputEol, "C-e" },
975 { KEY_END, CK_InputEol, "End" },
976 { KEY_C1, CK_InputEol, "End" },
977 { ALT ('>'), CK_InputEol, "M->" },
978 { KEY_LEFT, CK_InputMoveLeft, "Left" },
979 { KEY_M_CTRL | KEY_LEFT, CK_InputWordLeft, "C-Left" },
980 { KEY_RIGHT, CK_InputMoveRight, "Right" },
981 { KEY_M_CTRL | KEY_RIGHT, CK_InputWordRight, "C-Right" },
983 { XCTRL ('b'), CK_InputBackwardChar, "C-b" },
984 { ALT ('b'), CK_InputBackwardWord, "M-b" },
985 { XCTRL ('f'), CK_InputForwardChar, "C-f" },
986 { ALT ('f'), CK_InputForwardWord, "M-f" },
988 /* Editing */
989 { KEY_BACKSPACE, CK_InputBackwardDelete, "BackSpace" },
990 { KEY_DC, CK_InputDeleteChar, "Delete" },
991 { ALT ('d'), CK_InputKillWord, "M-d" },
992 { ALT (KEY_BACKSPACE), CK_InputBackwardKillWord, "M-BackSpace" },
994 /* Region manipulation */
995 { XCTRL ('w'), CK_InputKillRegion, "C-w" },
996 { ALT ('w'), CK_InputKillSave, "M-w" },
997 { XCTRL ('y'), CK_InputYank, "C-y" },
998 { XCTRL ('k'), CK_InputKillLine, "C-k" },
1000 /* History */
1001 { ALT ('p'), CK_InputHistoryPrev, "M-p" },
1002 { ALT ('n'), CK_InputHistoryNext, "M-n" },
1003 { ALT ('h'), CK_InputHistoryShow, "M-h" },
1005 /* Completion */
1006 { ALT ('\t'), CK_InputComplete, "M-tab" },
1008 { 0, CK_Ignore_Key, "" }
1011 /* diff viewer */
1012 const global_keymap_t default_diff_keymap[] = {
1014 { 's', CK_DiffDisplaySymbols, "s" },
1015 { 'l', CK_DiffDisplayNumbers, "l" },
1016 { 'f', CK_DiffFull, "f" },
1017 { '=', CK_DiffEqual, "=" },
1018 { '>', CK_DiffSplitMore, ">" },
1019 { '<', CK_DiffSplitLess, "<" },
1020 { '2', CK_DiffSetTab2, "2" },
1021 { '3', CK_DiffSetTab3, "3" },
1022 { '4', CK_DiffSetTab4, "4" },
1023 { '8', CK_DiffSetTab8, "8" },
1024 { XCTRL ('u'), CK_DiffSwapPanel, "C-u" },
1025 { XCTRL ('r'), CK_DiffRedo, "C-r" },
1026 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
1027 { 'n', CK_DiffNextHunk, "n" },
1028 { 'p', CK_DiffPrevHunk, "p" },
1029 { 'g', CK_DiffGoto, "g" },
1030 { 'G', CK_DiffGoto, "G" },
1031 { KEY_M_CTRL | KEY_HOME, CK_DiffBOF, "C-Home" },
1032 { KEY_M_CTRL | KEY_END, CK_DiffEOF, "C-End" },
1033 { KEY_DOWN, CK_DiffDown, "Down" },
1034 { KEY_UP, CK_DiffUp, "Up" },
1035 { KEY_M_CTRL | KEY_LEFT, CK_DiffQuickLeft, "C-Left" },
1036 { KEY_M_CTRL | KEY_RIGHT, CK_DiffQuickRight, "C-Right" },
1037 { KEY_LEFT, CK_DiffLeft, "Left" },
1038 { KEY_RIGHT, CK_DiffRight, "Right" },
1039 { KEY_NPAGE, CK_DiffPageDown, "Down" },
1040 { KEY_PPAGE, CK_DiffPageUp, "Up" },
1041 { KEY_HOME, CK_DiffHome, "Home" },
1042 { KEY_END, CK_DiffEnd, "End" },
1043 { 'q', CK_DiffQuit, "q" },
1044 { 'Q', CK_DiffQuit, "Q" },
1045 { XCTRL ('g'), CK_DiffQuit, "C-g" },
1046 { ESC_CHAR, CK_DiffQuit, "Esc" },
1048 { KEY_F (1), CK_DiffHelp, "F1" },
1049 { KEY_F (4), CK_DiffEditCurrent, "F4" },
1050 { KEY_F (5), CK_DiffMergeCurrentHunk, "F5" },
1051 { KEY_F (7), CK_DiffSearch, "F7" },
1052 { KEY_F (17), CK_DiffContinueSearch, "S-F7" },
1053 { KEY_F (9), CK_DiffOptions, "F9" },
1054 { KEY_F (10), CK_DiffQuit, "F10" },
1055 { KEY_F (14), CK_DiffEditOther, "S-F4" },
1057 { 0, CK_Ignore_Key, "" }
1060 static int
1061 name_keymap_comparator (const void *p1, const void *p2)
1063 const name_keymap_t *m1 = (const name_keymap_t *) p1;
1064 const name_keymap_t *m2 = (const name_keymap_t *) p2;
1066 return str_casecmp (m1->name, m2->name);
1069 static inline void
1070 sort_command_names (void)
1072 static gboolean has_been_sorted = FALSE;
1074 if (!has_been_sorted) {
1075 qsort (command_names, num_command_names,
1076 sizeof (command_names[0]), &name_keymap_comparator);
1077 has_been_sorted = TRUE;
1081 static void
1082 keymap_add (GArray *keymap, long key, unsigned long cmd, const char *caption)
1084 if (key != 0 && cmd != CK_Ignore_Key) {
1085 global_keymap_t new_bind;
1087 new_bind.key = key;
1088 new_bind.command = cmd;
1089 g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
1090 g_array_append_val (keymap, new_bind);
1094 void
1095 keybind_cmd_bind (GArray *keymap, const char *keybind, unsigned long action)
1097 char *caption = NULL;
1098 long key;
1100 key = lookup_key (keybind, &caption);
1101 keymap_add (keymap, key, action, caption);
1102 g_free (caption);
1105 unsigned long
1106 lookup_action (const char *name)
1108 const name_keymap_t key = { name, 0 };
1109 name_keymap_t *res;
1111 sort_command_names ();
1113 res = bsearch (&key, command_names, num_command_names,
1114 sizeof (command_names[0]), name_keymap_comparator);
1116 return (res != NULL) ? res->val : CK_Ignore_Key;
1119 const char *
1120 lookup_keymap_shortcut (const global_keymap_t *keymap, unsigned long action)
1122 size_t i;
1124 for (i = 0; keymap[i].key != 0; i++)
1125 if (keymap[i].command == action)
1126 return (keymap[i].caption[0] != '\0') ? keymap[i].caption : NULL;
1128 return NULL;
1131 unsigned long
1132 lookup_keymap_command (const global_keymap_t *keymap, long key)
1134 size_t i;
1136 for (i = 0; keymap[i].key != 0; i++)
1137 if (keymap[i].key == key)
1138 return keymap[i].command;
1140 return CK_Ignore_Key;