added new parameter mcview_eof into ini-file
[free-mc.git] / src / keybind.c
blobe6e605f6187d933f961fae2318af8a438d87d6eb
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 "global.h"
39 #include "cmddef.h" /* CK_ cmd name const */
40 #include "tty/win.h"
41 #include "tty/key.h" /* KEY_M_ */
42 #include "tty/tty.h" /* keys */
43 #include "wtools.h"
44 #include "strutil.h"
46 #include "keybind.h"
48 static name_keymap_t command_names[] = {
49 #ifdef USE_INTERNAL_EDIT
50 { "EditNoCommand", CK_Ignore_Key },
51 { "EditIgnoreKey", CK_Ignore_Key },
52 { "EditBackSpace", CK_BackSpace },
53 { "EditDelete", CK_Delete },
54 { "EditEnter", CK_Enter },
55 { "EditPageUp", CK_Page_Up },
56 { "EditPageDown", CK_Page_Down },
57 { "EditLeft", CK_Left },
58 { "EditRight", CK_Right },
59 { "EditWordLeft", CK_Word_Left },
60 { "EditWordRight", CK_Word_Right },
61 { "EditUp", CK_Up },
62 { "EditDown", CK_Down },
63 { "EditHome", CK_Home },
64 { "EditEnd", CK_End },
65 { "EditTab", CK_Tab },
66 { "EditUndo", CK_Undo },
67 { "EditBeginningOfText", CK_Beginning_Of_Text },
68 { "EditEndOfText", CK_End_Of_Text },
69 { "EditScrollUp", CK_Scroll_Up },
70 { "EditScrollDown", CK_Scroll_Down },
71 { "EditReturn", CK_Return },
72 { "EditBeginPage", CK_Begin_Page },
73 { "EditEndPage", CK_End_Page },
74 { "EditDeleteWordLeft", CK_Delete_Word_Left },
75 { "EditDeleteWordRight", CK_Delete_Word_Right },
76 { "EditParagraphUp", CK_Paragraph_Up },
77 { "EditParagraphDown", CK_Paragraph_Down },
78 { "EditMenu", CK_Menu },
79 { "EditSave", CK_Save },
80 { "EditLoad", CK_Load },
81 { "EditNew", CK_New },
82 { "EditSaveas", CK_Save_As },
83 { "EditMark", CK_Mark },
84 { "EditCopy", CK_Copy },
85 { "EditMove", CK_Move },
86 { "EditRemove", CK_Remove },
87 { "EditUnmark", CK_Unmark },
88 { "EditSaveBlock", CK_Save_Block },
89 { "EditColumnMark", CK_Column_Mark },
90 { "EditFind", CK_Find },
91 { "EditFindAgain", CK_Find_Again },
92 { "EditReplace", CK_Replace },
93 { "EditReplaceAgain", CK_Replace_Again },
94 { "EditCompleteWord", CK_Complete_Word },
95 #if 0
96 { "EditDebugStart", CK_Debug_Start },
97 { "EditDebugStop", CK_Debug_Stop },
98 { "EditDebugToggleBreak", CK_Debug_Toggle_Break },
99 { "EditDebugClear", CK_Debug_Clear },
100 { "EditDebugNext", CK_Debug_Next },
101 { "EditDebugStep", CK_Debug_Step },
102 { "EditDebugBackTrace", CK_Debug_Back_Trace },
103 { "EditDebugContinue", CK_Debug_Continue },
104 { "EditDebugEnterCommand", CK_Debug_Enter_Command },
105 { "EditDebugUntilCurser", CK_Debug_Until_Curser },
106 #endif
107 { "EditInsertFile", CK_Insert_File },
108 { "EditQuit", CK_Quit },
109 { "EditToggleInsert", CK_Toggle_Insert },
110 { "EditHelp", CK_Help },
111 { "EditDate", CK_Date },
112 { "EditRefresh", CK_Refresh },
113 { "EditGoto", CK_Goto },
114 { "EditDeleteLine", CK_Delete_Line },
115 { "EditDeleteToLineEnd", CK_Delete_To_Line_End },
116 { "EditDeleteToLineBegin", CK_Delete_To_Line_Begin },
117 { "EditManPage", CK_Man_Page },
118 { "EditSort", CK_Sort },
119 { "EditMail", CK_Mail },
120 { "EditCancel", CK_Cancel },
121 { "EditComplete", CK_Complete },
122 { "EditParagraphFormat", CK_Paragraph_Format },
123 { "EditUtil", CK_Util },
124 { "EditTypeLoadPython", CK_Type_Load_Python },
125 { "EditFindFile", CK_Find_File },
126 { "EditCtags", CK_Ctags },
127 { "EditMatchBracket", CK_Match_Bracket },
128 { "EditTerminal", CK_Terminal },
129 { "EditTerminalApp", CK_Terminal_App },
130 { "EditExtCmd", CK_ExtCmd },
131 { "EditUserMenu", CK_User_Menu },
132 { "EditBeginRecordMacro", CK_Begin_Record_Macro },
133 { "EditEndRecordMacro", CK_End_Record_Macro },
134 { "EditDeleteMacro", CK_Delete_Macro },
135 { "EditToggleBookmark", CK_Toggle_Bookmark },
136 { "EditFlushBookmarks", CK_Flush_Bookmarks },
137 { "EditNextBookmark", CK_Next_Bookmark },
138 { "EditPrevBookmark", CK_Prev_Bookmark },
139 { "EditPageUpHighlight", CK_Page_Up_Highlight },
140 { "EditPageDownHighlight", CK_Page_Down_Highlight },
141 { "EditLeftHighlight", CK_Left_Highlight },
142 { "EditRightHighlight", CK_Right_Highlight },
143 { "EditWordLeftHighlight", CK_Word_Left_Highlight },
144 { "EditWordRightHighlight", CK_Word_Right_Highlight },
145 { "EditUpHighlight", CK_Up_Highlight },
146 { "EditDownHighlight", CK_Down_Highlight },
147 { "EditHomeHighlight", CK_Home_Highlight },
148 { "EditEndHighlight", CK_End_Highlight },
149 { "EditBeginningOfTextHighlight", CK_Beginning_Of_Text_Highlight },
150 { "EditEndOfTextHighlight", CK_End_Of_Text_Highlight },
151 { "EditBeginPageHighlight", CK_Begin_Page_Highlight },
152 { "EditEndPageHighlight", CK_End_Page_Highlight },
153 { "EditScrollUpHighlight", CK_Scroll_Up_Highlight },
154 { "EditScrollDownHighlight", CK_Scroll_Down_Highlight },
155 { "EditParagraphUpHighlight", CK_Paragraph_Up_Highlight },
156 { "EditParagraphDownHighlight", CK_Paragraph_Down_Highlight },
158 { "EditPageUpAltHighlight", CK_Page_Up_Alt_Highlight },
159 { "EditPageDownAltHighlight", CK_Page_Down_Alt_Highlight },
160 { "EditLeftAltHighlight", CK_Left_Alt_Highlight },
161 { "EditRightAltHighlight", CK_Right_Alt_Highlight },
162 { "EditWordLeftAltHighlight", CK_Word_Left_Alt_Highlight },
163 { "EditWordRightAltHighlight", CK_Word_Right_Alt_Highlight },
164 { "EditUpAltHighlight", CK_Up_Alt_Highlight },
165 { "EditDownAltHighlight", CK_Down_Alt_Highlight },
166 { "EditHomeAltHighlight", CK_Home_Alt_Highlight },
167 { "EditEndAltHighlight", CK_End_Alt_Highlight },
168 { "EditBeginningOfTextAltHighlight", CK_Beginning_Of_Text_Alt_Highlight },
169 { "EditEndOfTextAltHighlight", CK_End_Of_Text_Alt_Highlight },
170 { "EditBeginPageAltHighlight", CK_Begin_Page_Alt_Highlight },
171 { "EditEndPageAltHighlight", CK_End_Page_Alt_Highlight },
172 { "EditScrollUpAltHighlight", CK_Scroll_Up_Alt_Highlight },
173 { "EditScrollDownAltHighlight", CK_Scroll_Down_Alt_Highlight },
174 { "EditParagraphUpAltHighlight", CK_Paragraph_Up_Alt_Highlight },
175 { "EditParagraphDownAltHighlight", CK_Paragraph_Down_Alt_Highlight },
177 { "EditShiftBlockLeft", CK_Shift_Block_Left },
178 { "EditShiftBlockRight", CK_Shift_Block_Right },
180 { "EditXStore", CK_XStore },
181 { "EditXCut", CK_XCut },
182 { "EditXPaste", CK_XPaste },
183 { "EditSelectionHistory", CK_Selection_History },
184 { "EditShell", CK_Shell },
185 { "EditInsertLiteral", CK_Insert_Literal },
186 { "EditExecuteMacro", CK_Execute_Macro },
187 { "EditBeginOrEndMacro", CK_Begin_End_Macro },
188 { "EditExtMode", CK_Ext_Mode },
189 { "EditToggleLineState", CK_Toggle_Line_State },
190 { "EditToggleTabTWS", CK_Toggle_Tab_TWS },
191 { "EditToggleSyntax", CK_Toggle_Syntax },
192 { "EditToggleShowMargin", CK_Toggle_Show_Margin },
193 { "EditFindDefinition", CK_Find_Definition },
194 { "EditLoadPrevFile", CK_Load_Prev_File },
195 { "EditLoadNextFile", CK_Load_Next_File },
196 { "EditOptions", CK_Edit_Options },
197 { "EditSaveMode", CK_Edit_Save_Mode },
198 { "EditChooseSyntax", CK_Choose_Syntax },
199 { "EditAbout", CK_About },
201 #if 0
202 { "EditFocusNext", CK_Focus_Next },
203 { "EditFocusPrev", CK_Focus_Prev },
204 { "EditHeightInc", CK_Height_Inc },
205 { "EditHeightDec", CK_Height_Dec },
206 { "EditMake", CK_Make },
207 { "EditErrorNext", CK_Error_Next },
208 { "EditErrorPrev", CK_Error_Prev },
209 #endif
211 #if 0
212 { "EditSaveDesktop", CK_Save_Desktop },
213 { "EditNewWindow", CK_New_Window },
214 { "EditCycle", CK_Cycle },
215 { "EditSaveAndQuit", CK_Save_And_Quit },
216 { "EditRunAnother", CK_Run_Another },
217 { "EditCheckSaveAndQuit", CK_Check_Save_And_Quit },
218 { "EditMaximize", CK_Maximize },
219 #endif
221 #endif /* USE_INTERNAL_EDIT */
223 /* viewer */
224 { "ViewHelp", CK_ViewHelp },
225 { "ViewToggleWrapMode", CK_ViewToggleWrapMode },
226 { "ViewToggleHexEditMode", CK_ViewToggleHexEditMode },
227 { "ViewQuit", CK_ViewQuit },
228 { "ViewToggleHexMode", CK_ViewToggleHexMode },
229 { "ViewGoto", CK_ViewGoto },
230 { "ViewHexEditSave", CK_ViewHexEditSave },
231 { "ViewSearch", CK_ViewSearch },
232 { "ViewToggleMagicMode", CK_ViewToggleMagicMode },
233 { "ViewToggleNroffMode", CK_ViewToggleNroffMode },
234 { "ViewContinueSearch", CK_ViewContinueSearch },
235 { "ViewGotoBookmark", CK_ViewGotoBookmark },
236 { "ViewNewBookmark", CK_ViewNewBookmark },
237 { "ViewMoveUp", CK_ViewMoveUp },
238 { "ViewMoveDown", CK_ViewMoveDown },
239 { "ViewMoveLeft", CK_ViewMoveLeft },
240 { "ViewMoveRight", CK_ViewMoveRight },
241 { "ViewMovePgDn", CK_ViewMovePgDn },
242 { "ViewMovePgUp", CK_ViewMovePgUp },
243 { "ViewMoveHalfPgDn", CK_ViewMoveHalfPgDn },
244 { "ViewMoveHalfPgUp", CK_ViewMoveHalfPgUp },
245 { "ViewMoveToBol", CK_ViewMoveToBol },
246 { "ViewMoveToEol", CK_ViewMoveToEol },
247 { "ViewNextFile", CK_ViewNextFile },
248 { "ViewPrevFile", CK_ViewPrevFile },
249 { "ViewToggleRuler", CK_ViewToggleRuler },
250 { "ViewToggleHexNavMode", CK_ViewToggleHexNavMode },
252 /* help */
253 { "HelpHelp", CK_HelpHelp },
254 { "HelpIndex", CK_HelpIndex },
255 { "HelpBack", CK_HelpBack },
256 { "HelpQuit", CK_HelpQuit },
257 { "HelpMoveUp", CK_HelpMoveUp },
258 { "HelpMoveDown", CK_HelpMoveDown },
259 { "HelpSelectLink", CK_HelpSelectLink },
260 { "HelpNextLink", CK_HelpNextLink },
261 { "HelpPrevLink", CK_HelpPrevLink },
262 { "HelpNextNode", CK_HelpNextNode },
263 { "HelpPrevNode", CK_HelpPrevNode },
265 /* tree */
266 { "TreeHelp", CK_TreeHelp },
267 { "TreeForget", CK_TreeForget },
268 { "TreeToggleNav", CK_TreeToggleNav },
269 { "TreeCopy", CK_TreeCopy },
270 { "TreeMove", CK_TreeMove },
271 { "TreeMake", CK_TreeMake },
272 { "TreeMoveUp", CK_TreeMoveUp },
273 { "TreeMoveDown", CK_TreeMoveDown },
274 { "TreeMoveLeft", CK_TreeMoveLeft },
275 { "TreeMoveRight", CK_TreeMoveRight },
276 { "TreeMoveHome", CK_TreeMoveHome },
277 { "TreeMoveEnd", CK_TreeMoveEnd },
278 { "TreeMovePgUp", CK_TreeMovePgUp },
279 { "TreeMovePgDn", CK_TreeMovePgDn },
280 { "TreeOpen", CK_TreeOpen },
281 { "TreeRescan", CK_TreeRescan },
282 { "TreeStartSearch", CK_TreeStartSearch },
283 { "TreeRemove", CK_TreeRemove },
285 /* main commands */
286 { "CmdHelp", CK_HelpCmd },
287 { "CmdMenu", CK_MenuCmd },
288 { "CmdChmod", CK_ChmodCmd },
289 { "CmdMenuLastSelected", CK_MenuLastSelectedCmd },
290 { "CmdSingleDirsize", CK_SingleDirsizeCmd },
291 { "CmdCopyCurrentPathname", CK_CopyCurrentPathname },
292 { "CmdCopyOtherPathname", CK_CopyOtherPathname },
293 { "CmdSuspend", CK_SuspendCmd },
294 { "CmdToggleListing", CK_ToggleListingCmd },
295 { "CmdChownAdvanced", CK_ChownAdvancedCmd },
296 { "CmdChown", CK_ChownCmd },
297 { "CmdCompareDirs", CK_CompareDirsCmd },
298 { "CmdConfigureBox", CK_ConfigureBox },
299 { "CmdConfigureVfs", CK_ConfigureVfs },
300 { "CmdConfirmBox", CK_ConfirmBox },
301 { "CmdCopy", CK_CopyCmd },
302 { "CmdDelete", CK_DeleteCmd },
303 { "CmdDirsizes", CK_DirsizesCmd },
304 { "CmdDisplayBitsBox", CK_DisplayBitsBox },
305 { "CmdEdit", CK_EditCmd },
306 { "CmdEditExtFile", CK_EditExtFileCmd },
307 { "CmdEditFhlFile", CK_EditFhlFileCmd },
308 { "CmdEditMcMenu", CK_EditMcMenuCmd },
309 { "CmdEditSymlink", CK_EditSymlinkCmd },
310 { "CmdEditSyntax", CK_EditSyntaxCmd },
311 { "CmdEditUserMenu", CK_EditUserMenuCmd },
312 { "CmdExternalPanelize", CK_ExternalPanelize },
313 { "CmdFilter", CK_FilterCmd },
314 { "CmdFilteredView", CK_FilteredViewCmd },
315 { "CmdFind", CK_FindCmd },
316 #ifdef USE_NETCODE
317 { "CmdFishlink", CK_FishlinkCmd },
318 { "CmdFtplink", CK_FtplinkCmd },
319 #endif
320 { "CmdHistory", CK_HistoryCmd },
321 { "CmdInfo", CK_InfoCmd },
322 #ifdef WITH_BACKGROUND
323 { "CmdJobs", CK_JobsCmd },
324 #endif
325 { "CmdLayout", CK_LayoutCmd },
326 { "CmdLearnKeys", CK_LearnKeys },
327 { "CmdLink", CK_LinkCmd },
328 { "CmdListing", CK_ListingCmd },
329 #ifdef LISTMODE_EDITOR
330 { "CmdListmodeCmd", CK_ListmodeCmd }.
331 #endif
332 { "CmdMkdir", CK_MkdirCmd },
333 #if defined (USE_NETCODE) && defined (ENABLE_VFS_MCFS)
334 { "CmdNetlink", CK_NetlinkCmd },
335 #endif
336 { "CmdQuickCd", CK_QuickCdCmd },
337 { "CmdQuickChdir", CK_QuickChdirCmd },
338 { "CmdQuickView", CK_QuickViewCmd },
339 { "CmdQuietQuit", CK_QuietQuitCmd },
340 { "CmdRename", CK_RenameCmd },
341 { "CmdReread", CK_RereadCmd },
342 { "CmdReselectVfs", CK_ReselectVfs },
343 { "CmdReverseSelection", CK_ReverseSelectionCmd },
344 { "CmdSaveSetup", CK_SaveSetupCmd },
345 { "CmdSelect", CK_SelectCmd },
346 #if defined (USE_NETCODE) && defined (ENABLE_VFS_SMB)
347 { "CmdSmblinkCmd", CK_SmblinkCmd },
348 #endif /* USE_NETCODE || ENABLE_VFS_SMB */
349 { "CmdSwapPanel", CK_SwapCmd },
350 { "CmdSymlink", CK_SymlinkCmd },
351 { "CmdTree", CK_TreeCmd },
352 { "CmdTreeBox", CK_TreeBoxCmd },
353 #ifdef USE_EXT2FSLIB
354 { "CmdUndelete", CK_UndeleteCmd },
355 #endif
356 { "CmdUnselect", CK_UnselectCmd },
357 { "CmdUserMenu", CK_UserMenuCmd },
358 { "CmdUserFileMenu", CK_UserFileMenuCmd },
359 { "CmdView", CK_ViewCmd },
360 { "CmdViewFile", CK_ViewFileCmd },
361 { "CmdCopyCurrentReadlink", CK_CopyCurrentReadlink },
362 { "CmdCopyOtherReadlink", CK_CopyOtherReadlink },
363 { "CmdAddHotlist", CK_AddHotlist },
364 { "CmdQuit", CK_QuitCmd },
365 { "CmdCopyCurrentTagged", CK_CopyCurrentTagged },
366 { "CmdCopyOtherTagged", CK_CopyOtherTagged },
367 { "CmdToggleShowHidden", CK_ToggleShowHidden },
369 /* panel */
370 { "PanelChdirOtherPanel", CK_PanelChdirOtherPanel },
371 { "PanelChdirToReadlink", CK_PanelChdirToReadlink },
372 { "PanelCopyLocal", CK_PanelCmdCopyLocal },
373 { "PanelDeleteLocal", CK_PanelCmdDeleteLocal },
374 { "PanelDoEnter", CK_PanelCmdDoEnter },
375 { "PanelEditNew", CK_PanelCmdEditNew },
376 { "PanelRenameLocal", CK_PanelCmdRenameLocal },
377 { "PanelReverseSelection", CK_PanelCmdReverseSelection },
378 { "PanelSelect", CK_PanelCmdSelect },
379 { "PanelUnselect", CK_PanelCmdUnselect },
380 { "PanelViewSimple", CK_PanelCmdViewSimple },
381 { "PanelCtrlNextPage", CK_PanelCtrlNextPage },
382 { "PanelCtrlPrevPage", CK_PanelCtrlPrevPage },
383 { "PanelDirectoryHistoryList", CK_PanelDirectoryHistoryList },
384 { "PanelDirectoryHistoryNext", CK_PanelDirectoryHistoryNext },
385 { "PanelDirectoryHistoryPrev", CK_PanelDirectoryHistoryPrev },
386 { "PanelGotoBottomFile", CK_PanelGotoBottomFile },
387 { "PanelGotoMiddleFile", CK_PanelGotoMiddleFile },
388 { "PanelGotoTopFile", CK_PanelGotoTopFile },
389 { "PanelMarkFile", CK_PanelMarkFile },
390 { "PanelMoveUp", CK_PanelMoveUp },
391 { "PanelMoveDown", CK_PanelMoveDown },
392 { "PanelMoveLeft", CK_PanelMoveLeft },
393 { "PanelMoveRight", CK_PanelMoveRight },
394 { "PanelMoveEnd", CK_PanelMoveEnd },
395 { "PanelMoveHome", CK_PanelMoveHome },
396 { "PanelNextPage", CK_PanelNextPage },
397 { "PanelPrevPage", CK_PanelPrevPage },
398 #ifdef HAVE_CHARSET
399 { "PanelSetPanelEncoding", CK_PanelSetPanelEncoding },
400 #endif
401 { "PanelStartSearch", CK_PanelStartSearch },
402 { "PanelSyncOtherPanel", CK_PanelSyncOtherPanel },
403 { "PanelToggleSortOrderNext", CK_PanelToggleSortOrderNext },
404 { "PanelToggleSortOrderPrev", CK_PanelToggleSortOrderPrev },
405 { "PanelSelectSortOrder", CK_PanelSelectSortOrder },
406 { "PanelReverseSort", CK_PanelReverseSort },
407 { "PanelSortOrderByName", CK_PanelSortOrderByName },
408 { "PanelSortOrderByExt", CK_PanelSortOrderByExt },
409 { "PanelSortOrderBySize", CK_PanelSortOrderBySize },
410 { "PanelSortOrderByMTime", CK_PanelSortOrderByMTime },
412 /* input line */
413 { "InputBol", CK_InputBol },
414 { "InputEol", CK_InputEol },
415 { "InputMoveLeft", CK_InputMoveLeft },
416 { "InputWordLeft", CK_InputWordLeft },
417 { "InputBackwardChar", CK_InputBackwardChar },
418 { "InputBackwardWord", CK_InputBackwardWord },
419 { "InputMoveRight", CK_InputMoveRight },
420 { "InputWordRight", CK_InputWordRight },
421 { "InputForwardChar", CK_InputForwardChar },
422 { "InputForwardWord", CK_InputForwardWord },
423 { "InputBackwardDelete", CK_InputBackwardDelete },
424 { "InputDeleteChar", CK_InputDeleteChar },
425 { "InputKillWord", CK_InputKillWord },
426 { "InputBackwardKillWord", CK_InputBackwardKillWord },
427 { "InputSetMark", CK_InputSetMark },
428 { "InputKillRegion", CK_InputKillRegion },
429 { "InputYank", CK_InputYank },
430 { "InputKillLine", CK_InputKillLine },
431 { "InputHistoryPrev", CK_InputHistoryPrev },
432 { "InputHistoryNext", CK_InputHistoryNext },
433 { "InputHistoryShow", CK_InputHistoryShow },
434 { "InputComplete", CK_InputComplete },
435 { "InputXStore", CK_InputKillSave },
436 { "InputXPaste", CK_InputPaste },
437 { "InputClearLine", CK_InputClearLine },
439 /* common */
440 { "ExtMap1", CK_StartExtMap1 },
441 { "ExtMap2", CK_StartExtMap2 },
442 { "ShowCommandLine", CK_ShowCommandLine },
443 { "SelectCodepage", CK_SelectCodepage },
445 { NULL, CK_Ignore_Key }
448 static const size_t num_command_names = sizeof (command_names) /
449 sizeof (command_names[0]) - 1;
451 /*** global variables ****************************************************************************/
453 /* viewer/actions_cmd.c */
454 const global_keymap_t default_viewer_keymap[] = {
455 { KEY_F (1), CK_ViewHelp, "F1" },
456 { KEY_F (2), CK_ViewToggleWrapMode, "F2" },
457 { KEY_F (3), CK_ViewQuit, "F3" },
458 { KEY_F (4), CK_ViewToggleHexMode, "F4" },
459 { KEY_F (5), CK_ViewGoto, "F5" },
460 { KEY_F (7), CK_ViewSearch, "F7" },
461 { KEY_F (8), CK_ViewToggleMagicMode, "F8" },
462 { KEY_F (9), CK_ViewToggleNroffMode, "F9" },
463 { KEY_F (10), CK_ViewQuit, "F10" },
465 { '?', CK_ViewSearch, "?" },
466 { '/', CK_ViewSearch, "/" },
467 { XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
468 { XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
469 { KEY_F (17), CK_ViewContinueSearch, "S-F7" },
470 { 'n', CK_ViewContinueSearch, "n" },
471 { ALT ('r'), CK_ViewToggleRuler, "M-r" },
473 { XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
474 { XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
476 { 'h', CK_ViewMoveLeft, "h" },
477 { KEY_LEFT, CK_ViewMoveLeft, "Left" },
479 { 'l', CK_ViewMoveRight, "l" },
480 { KEY_RIGHT, CK_ViewMoveRight, "Right" },
482 { 'k', CK_ViewMoveUp, "k" },
483 { 'y', CK_ViewMoveUp, "y" },
484 { KEY_IC, CK_ViewMoveUp, "Insert" },
485 { KEY_UP, CK_ViewMoveUp, "Up" },
487 { 'j', CK_ViewMoveDown, "j" },
488 { 'e', CK_ViewMoveDown, "e" },
489 { KEY_DOWN, CK_ViewMoveDown, "Down" },
490 { KEY_DC, CK_ViewMoveDown, "Delete" },
492 { ' ', CK_ViewMovePgDn, "Space" },
493 { 'f', CK_ViewMovePgDn, "f" },
494 { KEY_NPAGE, CK_ViewMovePgDn, "PgDn" },
496 { 'b', CK_ViewMovePgUp, "b" },
497 { KEY_PPAGE, CK_ViewMovePgUp, "PgUp" },
499 { 'd', CK_ViewMoveHalfPgDn, "d" },
500 { 'u', CK_ViewMoveHalfPgUp, "u" },
502 { 'm', CK_ViewGotoBookmark, "m" },
503 { 'r', CK_ViewNewBookmark, "r" },
505 { XCTRL ('f'), CK_ViewNextFile, "C-f" },
506 { XCTRL ('b'), CK_ViewPrevFile, "C-b" },
508 { 'q', CK_ViewQuit, "q" },
509 { XCTRL ('g'), CK_ViewQuit, "C-g" },
510 { ESC_CHAR, CK_ViewQuit, "Esc" },
512 { ALT ('e'), CK_SelectCodepage, "M-e" },
513 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
515 { 0, CK_Ignore_Key, "" }
518 const global_keymap_t default_viewer_hex_keymap[] = {
519 { KEY_F (1), CK_ViewHelp, "F1" },
520 { KEY_F (2), CK_ViewToggleHexEditMode, "F2" },
521 { KEY_F (3), CK_ViewQuit, "F3" },
522 { KEY_F (4), CK_ViewToggleHexMode, "F4" },
523 { KEY_F (5), CK_ViewGoto, "F5" },
524 { KEY_F (6), CK_ViewHexEditSave, "F6" },
525 { KEY_F (7), CK_ViewSearch, "F7" },
526 { KEY_F (8), CK_ViewToggleMagicMode, "F8" },
527 { KEY_F (9), CK_ViewToggleNroffMode, "F9" },
528 { KEY_F (10), CK_ViewQuit, "F10" },
530 { '?', CK_ViewSearch, "?" },
531 { '/', CK_ViewSearch, "/" },
532 { XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
533 { XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
534 { KEY_F (17), CK_ViewContinueSearch, "S-F7" },
535 { 'n', CK_ViewContinueSearch, "n" },
537 { '\t', CK_ViewToggleHexNavMode, "Tab" },
538 { XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
539 { XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
541 { 'b', CK_ViewMoveLeft, "b" },
542 { KEY_LEFT, CK_ViewMoveLeft, "Left" },
544 { 'f', CK_ViewMoveRight, "f" },
545 { KEY_RIGHT, CK_ViewMoveRight, "Right" },
547 { 'k', CK_ViewMoveUp, "k" },
548 { 'y', CK_ViewMoveUp, "y" },
549 { KEY_UP, CK_ViewMoveUp, "Up" },
551 { 'j', CK_ViewMoveDown, "j" },
552 { KEY_DOWN, CK_ViewMoveDown, "Down" },
553 { KEY_DC, CK_ViewMoveDown, "Delete" },
555 { 'q', CK_ViewQuit, "q" },
556 { XCTRL ('g'), CK_ViewQuit, "C-g" },
557 { ESC_CHAR, CK_ViewQuit, "Esc" },
559 { ALT ('e'), CK_SelectCodepage, "M-e" },
560 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
562 { 0, CK_Ignore_Key, "" }
565 #ifdef USE_INTERNAL_EDIT
566 /* ../edit/editkeys.c */
567 const global_keymap_t default_editor_keymap[] = {
568 { '\n', CK_Enter, "Enter" },
569 { '\t', CK_Tab, "Tab" },
571 { KEY_F (1), CK_Help, "F1" },
572 { KEY_F (2), CK_Save, "F2" },
573 { KEY_F (3), CK_Mark, "F3" },
574 { KEY_F (4), CK_Replace, "F4" },
575 { KEY_F (5), CK_Copy, "F5" },
576 { KEY_F (6), CK_Move, "F6" },
577 { KEY_F (7), CK_Find, "F7" },
578 { KEY_F (8), CK_Remove, "F8" },
579 { KEY_F (9), CK_Menu, "F9" },
580 { KEY_F (10), CK_Quit, "F10" },
581 /* edit user menu */
582 { KEY_F (11), CK_User_Menu, "S-F1" },
583 { KEY_F (12), CK_Save_As, "S-F2" },
584 { KEY_F (13), CK_Column_Mark, "S-F3" },
585 { KEY_F (14), CK_Replace_Again, "S-F4" },
586 { KEY_F (15), CK_Insert_File, "S-F5" },
587 { KEY_F (17), CK_Find_Again, "S-F7" },
588 /* C formatter */
589 { KEY_F (19), CK_Pipe_Block (0), "S-F9" },
591 { ESC_CHAR, CK_Quit, "Esc" },
592 { KEY_BACKSPACE, CK_BackSpace, "BackSpace" },
593 { KEY_DC, CK_Delete, "Delete" },
594 { KEY_DOWN, CK_Down, "Down" },
595 { KEY_END, CK_End, "End" },
596 { KEY_HOME, CK_Home, "Home" },
597 { KEY_IC, CK_Toggle_Insert, "Insert" },
598 { KEY_LEFT, CK_Left, "Left" },
599 { KEY_NPAGE, CK_Page_Down, "PgDn" },
600 { KEY_PPAGE, CK_Page_Up, "PgUp" },
601 { KEY_RIGHT, CK_Right, "Right" },
602 { KEY_UP, CK_Up, "Up" },
604 /* Ctrl */
605 { KEY_M_CTRL | (KEY_F (2)), CK_Save_As, "C-F2" },
606 { KEY_M_CTRL | (KEY_F (4)), CK_Replace_Again, "C-F4" },
607 { KEY_M_CTRL | (KEY_F (7)), CK_Find_Again, "C-F7" },
608 { KEY_M_CTRL | KEY_BACKSPACE, CK_Undo, "C-BackSpace" },
609 { KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text, "C-PgDn" },
610 { KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text, "C-PgUp" },
611 { KEY_M_CTRL | KEY_HOME, CK_Beginning_Of_Text, "C-Home" },
612 { KEY_M_CTRL | KEY_END, CK_End_Of_Text, "C-End" },
613 { KEY_M_CTRL | KEY_UP, CK_Scroll_Up, "C-Up" },
614 { KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down, "C-Down" },
615 { KEY_M_CTRL | KEY_LEFT, CK_Word_Left, "C-Left" },
616 { KEY_M_CTRL | KEY_RIGHT, CK_Word_Right, "C-Right" },
617 { KEY_M_CTRL | KEY_IC, CK_XStore, "C-Insert" },
618 { KEY_M_CTRL | KEY_DC, CK_Remove, "C-Delete" },
620 { XCTRL ('n'), CK_New, "C-n" },
621 { XCTRL ('k'), CK_Delete_To_Line_End, "C-k" },
622 { XCTRL ('l'), CK_Refresh, "C-l" },
623 { XCTRL ('o'), CK_Shell, "C-o" },
624 { XCTRL ('s'), CK_Toggle_Syntax, "C-s" },
625 { XCTRL ('u'), CK_Undo, "C-u" },
626 { ALT ('e'), CK_SelectCodepage, "M-e" },
627 { XCTRL ('q'), CK_Insert_Literal, "C-q" },
628 { XCTRL ('r'), CK_Begin_End_Macro, "C-r" },
629 { XCTRL ('r'), CK_Begin_Record_Macro, "C-r" },
630 { XCTRL ('r'), CK_End_Record_Macro, "C-r" },
631 { XCTRL ('a'), CK_Execute_Macro, "C-a" },
633 /* Shift */
634 { KEY_M_SHIFT | KEY_NPAGE, CK_Page_Down_Highlight, "S-PgDn" },
635 { KEY_M_SHIFT | KEY_PPAGE, CK_Page_Up_Highlight, "S-PgUp" },
636 { KEY_M_SHIFT | KEY_LEFT, CK_Left_Highlight, "S-Left" },
637 { KEY_M_SHIFT | KEY_RIGHT, CK_Right_Highlight, "S-Right" },
638 { KEY_M_SHIFT | KEY_UP, CK_Up_Highlight, "S-Up" },
639 { KEY_M_SHIFT | KEY_DOWN, CK_Down_Highlight, "S-Down" },
640 { KEY_M_SHIFT | KEY_HOME, CK_Home_Highlight, "S-Home" },
641 { KEY_M_SHIFT | KEY_END, CK_End_Highlight, "S-End" },
642 { KEY_M_SHIFT | KEY_IC, CK_XPaste, "S-Insert" },
643 { KEY_M_SHIFT | KEY_DC, CK_XCut, "S-Delete" },
644 /* useful for pasting multiline text */
645 { KEY_M_SHIFT | '\n', CK_Return, "S-Enter" },
647 /* Ctrl + Shift */
648 { KEY_M_SHIFT | KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text_Highlight, "C-S-PgDn" },
649 { KEY_M_SHIFT | KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text_Highlight, "C-S-PgUp" },
650 { KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, CK_Word_Left_Highlight, "C-S-Left" },
651 { KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, CK_Word_Right_Highlight, "C-S-Right" },
652 { KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, CK_Scroll_Up_Highlight, "C-S-Up" },
653 { KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down_Highlight, "C-S-Down" },
655 /* Alt */
656 { KEY_M_ALT | KEY_NPAGE, CK_Page_Down_Alt_Highlight, "M-PgDn" },
657 { KEY_M_ALT | KEY_PPAGE, CK_Page_Up_Alt_Highlight, "M-PgUp" },
658 { KEY_M_ALT | KEY_LEFT, CK_Left_Alt_Highlight, "M-Left" },
659 { KEY_M_ALT | KEY_RIGHT, CK_Right_Alt_Highlight, "M-Right" },
660 { KEY_M_ALT | KEY_UP, CK_Up_Alt_Highlight, "M-Up" },
661 { KEY_M_ALT | KEY_DOWN, CK_Down_Alt_Highlight, "M-Down" },
662 { KEY_M_ALT | KEY_HOME, CK_Home_Highlight, "M-Home" },
663 { KEY_M_ALT | KEY_END, CK_End_Alt_Highlight, "M-End" },
665 { ALT ('\n'), CK_Find_Definition, "M-Enter" },
666 { ALT ('\t'), CK_Complete_Word, "M-Tab" },
667 { ALT ('l'), CK_Goto, "M-l" },
668 { ALT ('L'), CK_Goto, "M-L" },
669 { ALT ('p'), CK_Paragraph_Format, "M-p" },
670 { ALT ('t'), CK_Sort, "M-t" },
671 { ALT ('u'), CK_ExtCmd, "M-u" },
672 { ALT ('<'), CK_Beginning_Of_Text, "M-<" },
673 { ALT ('>'), CK_End_Of_Text, "M->" },
674 { ALT ('-'), CK_Load_Prev_File, "M--" },
675 { ALT ('+'), CK_Load_Next_File, "M-+" },
676 { ALT ('d'), CK_Delete_Word_Right, "M-d" },
677 { ALT (KEY_BACKSPACE), CK_Delete_Word_Left, "M-BackSpace" },
678 { ALT ('n'), CK_Toggle_Line_State, "M-n" },
679 { ALT ('_'), CK_Toggle_Tab_TWS, "M-_" },
680 { ALT ('k'), CK_Toggle_Bookmark, "M-k" },
681 { ALT ('i'), CK_Prev_Bookmark, "M-i" },
682 { ALT ('j'), CK_Next_Bookmark, "M-j" },
683 { ALT ('o'), CK_Flush_Bookmarks, "M-o" },
685 { XCTRL ('x'), CK_Ext_Mode, "C-x" },
687 { 0, CK_Ignore_Key, "" }
690 /* emacs keyboard layout emulation */
691 const global_keymap_t default_editor_x_keymap[] = {
692 { 'k', CK_New, "k"},
693 { 'e', CK_Execute_Macro, "e"},
694 { 0, CK_Ignore_Key, "" }
696 #endif /* USE_INTERNAL_EDIT */
698 /* tree */
699 const global_keymap_t default_tree_keymap[] = {
700 { KEY_F (1), CK_TreeHelp, "F1"},
701 { KEY_F (2), CK_TreeRescan, "F2" },
702 { KEY_F (3), CK_TreeForget, "F3" },
703 { KEY_F (4), CK_TreeToggleNav, "F4" },
704 { KEY_F (5), CK_TreeCopy, "F5" },
705 { KEY_F (6), CK_TreeMove, "F6" },
706 #if 0
707 { KEY_F (7), CK_TreeMake, "F7" },
708 #endif
709 { KEY_F (8), CK_TreeRemove, "F8" },
710 { KEY_UP, CK_TreeMoveUp, "Up" },
711 { XCTRL ('p'), CK_TreeMoveUp, "C-p" },
712 { KEY_DOWN, CK_TreeMoveDown, "Down" },
713 { XCTRL ('n'), CK_TreeMoveDown, "C-n" },
714 { KEY_LEFT, CK_TreeMoveLeft, "Left" },
715 { KEY_RIGHT, CK_TreeMoveRight, "Right" },
716 { KEY_HOME, CK_TreeMoveHome, "Home" },
717 { ALT ('<'), CK_TreeMoveHome, "M-<" },
718 { KEY_END, CK_TreeMoveEnd , "End" },
719 { ALT ('>'), CK_TreeMoveEnd , "M->" },
720 { KEY_PPAGE, CK_TreeMovePgUp, "PgUp" },
721 { ALT ('v'), CK_TreeMovePgUp, "M-v" },
722 { KEY_NPAGE, CK_TreeMovePgDn, "PnDn" },
723 { XCTRL ('v'), CK_TreeMovePgDn, "C-v" },
724 { '\n', CK_TreeOpen, "Enter" },
725 { KEY_ENTER, CK_TreeOpen, "Enter" },
726 { XCTRL ('r'), CK_TreeRescan, "C-r" },
727 { XCTRL ('s'), CK_TreeStartSearch, "C-s" },
728 { ALT ('s'), CK_TreeStartSearch, "M-s" },
729 { KEY_DC, CK_TreeRemove, "Delete" },
730 { 0, CK_Ignore_Key, ""}
733 /* help */
734 const global_keymap_t default_help_keymap[] = {
735 { KEY_F (1), CK_HelpHelp, "F1" },
736 { KEY_F (2), CK_HelpIndex, "F2" },
737 { KEY_F (3), CK_HelpBack, "F3" },
738 { KEY_F (10), CK_HelpQuit, "F10" },
739 { KEY_LEFT, CK_HelpBack, "Left" },
740 { 'l', CK_HelpBack, "l" },
741 { KEY_DOWN, CK_HelpMoveDown, "Down" },
742 { KEY_UP, CK_HelpMoveUp, "Up" },
743 { KEY_RIGHT, CK_HelpSelectLink, "Right" },
744 { KEY_ENTER, CK_HelpSelectLink, "Enter" },
745 { '\n', CK_HelpSelectLink, "Enter" },
746 { '\t', CK_HelpNextLink, "Tab" },
747 { ALT ('\t'), CK_HelpPrevLink, "M-Tab" },
748 { 'n', CK_HelpNextNode, "n" },
749 { 'p', CK_HelpPrevNode, "p" },
750 { ESC_CHAR, CK_HelpQuit, "Esc" },
751 { XCTRL ('g'), CK_HelpQuit, "C-g" },
752 { 0, CK_Ignore_Key, "" }
755 /* screen.c */
756 const global_keymap_t default_panel_keymap[] = {
757 { ALT ('o'), CK_PanelChdirOtherPanel, "M-o" },
758 { ALT ('l'), CK_PanelChdirToReadlink, "M-l" },
759 { KEY_F (15), CK_PanelCmdCopyLocal, "S-F5" },
760 { KEY_F (18), CK_PanelCmdDeleteLocal, "S-F8" },
761 { KEY_ENTER, CK_PanelCmdDoEnter, "Enter" },
762 { '\n', CK_PanelCmdDoEnter, "Enter" },
763 { KEY_F (14), CK_PanelCmdEditNew, "S-F4" },
764 { KEY_F (16), CK_PanelCmdRenameLocal, "S-F6" },
765 { ALT ('*'), CK_PanelCmdReverseSelection, "M-*" },
766 { KEY_KP_ADD, CK_PanelCmdSelect, "M-+" },
767 { KEY_KP_SUBTRACT, CK_PanelCmdUnselect, "M--" },
768 { KEY_F (13), CK_PanelCmdViewSimple, "S-F3" },
769 { KEY_M_CTRL | KEY_NPAGE, CK_PanelCtrlNextPage, "C-PgDn" },
770 { KEY_M_CTRL | KEY_PPAGE, CK_PanelCtrlPrevPage, "C-PgUp" },
771 { ALT ('H'), CK_PanelDirectoryHistoryList, "M-H" },
772 { ALT ('u'), CK_PanelDirectoryHistoryNext, "M-u" },
773 { ALT ('y'), CK_PanelDirectoryHistoryPrev, "M-y" },
774 { ALT ('j'), CK_PanelGotoBottomFile, "M-j" },
775 { ALT ('r'), CK_PanelGotoMiddleFile, "M-r" },
776 { ALT ('g'), CK_PanelGotoTopFile, "M-g" },
777 { KEY_IC, CK_PanelMarkFile, "Insert" },
778 { KEY_UP, CK_PanelMoveUp, "Up" },
779 { KEY_DOWN, CK_PanelMoveDown, "Down" },
780 { KEY_LEFT, CK_PanelMoveLeft, "Left" },
781 { KEY_RIGHT, CK_PanelMoveRight, "Right" },
782 { KEY_END, CK_PanelMoveEnd, "End" },
783 { KEY_HOME, CK_PanelMoveHome, "Home" },
784 { KEY_A1, CK_PanelMoveHome, "Home" },
785 { KEY_NPAGE, CK_PanelNextPage, "PgDn" },
786 { KEY_PPAGE, CK_PanelPrevPage, "PgUp" },
787 { ALT ('e'), CK_PanelSetPanelEncoding, "M-e" },
788 { XCTRL ('s'), CK_PanelStartSearch, "C-s" },
789 { ALT ('s'), CK_PanelStartSearch, "M-s" },
790 { ALT ('i'), CK_PanelSyncOtherPanel, "M-i" },
791 { 0, CK_Ignore_Key , "" }
794 /* main.c */
795 const global_keymap_t default_main_map[] = {
796 { KEY_F (1), CK_HelpCmd, "F1" },
797 { KEY_F (2), CK_UserMenuCmd, "F2" },
798 { KEY_F (3), CK_ViewCmd, "F3" },
799 { KEY_F (4), CK_EditCmd, "F4" },
800 { KEY_F (5), CK_CopyCmd, "F5" },
801 { KEY_F (6), CK_RenameCmd, "F6" },
802 { KEY_F (7), CK_MkdirCmd, "F7" },
803 { KEY_F (8), CK_DeleteCmd, "F8" },
804 { KEY_F (9), CK_MenuCmd, "F9" },
805 { KEY_F (10), CK_QuitCmd, "F10" },
806 { KEY_F (13), CK_ViewFileCmd, "S-F3" },
807 { KEY_F (19), CK_MenuLastSelectedCmd, "S-F9" },
808 { KEY_F (20), CK_QuietQuitCmd, "S-10" },
809 { ALT ('h'), CK_HistoryCmd, "M-h" },
810 { XCTRL ('@'), CK_SingleDirsizeCmd, "C-Space" },
811 /* Copy useful information to the command line */
812 { ALT ('a'), CK_CopyCurrentPathname, "M-a" },
813 { ALT ('A'), CK_CopyOtherPathname, "M-A" },
814 { ALT ('c'), CK_QuickCdCmd, "M-c" },
815 /* To access the directory hotlist */
816 { XCTRL ('\\'), CK_QuickChdirCmd, "C-\\" },
817 /* Suspend */
818 { XCTRL ('z'), CK_SuspendCmd, "C-z" },
819 /* The filtered view command */
820 { ALT ('!'), CK_FilteredViewCmd, "M-!" },
821 /* Find file */
822 { ALT ('?'), CK_FindCmd, "M-?" },
823 /* Panel refresh */
824 { XCTRL ('r'), CK_RereadCmd, "C-r" },
825 /* Toggle listing between long, user defined and full formats */
826 { ALT ('t'), CK_ToggleListingCmd, "M-t" },
827 /* Swap panels */
828 { XCTRL ('u'), CK_SwapCmd, "C-u" },
829 /* View output */
830 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
831 { ALT ('.'), CK_ToggleShowHidden, "M-." },
832 { XCTRL ('x'), CK_StartExtMap1, "C-x" },
833 /* Select/unselect group */
834 { KEY_KP_ADD, CK_SelectCmd, "+" },
835 { KEY_KP_SUBTRACT, CK_UnselectCmd, "-" },
836 { ALT ('*'), CK_ReverseSelectionCmd, "*" },
837 { 0, CK_Ignore_Key, "" }
840 const global_keymap_t default_main_x_map[] = {
841 { 'd', CK_CompareDirsCmd, "d" },
842 #ifdef ENABLE_VFS
843 { 'a', CK_ReselectVfs, "a"},
844 #endif /* ENABLE_VFS */
845 { 'p', CK_CopyCurrentPathname, "p" },
846 { XCTRL ('p'), CK_CopyOtherPathname, "C-p" },
847 { 't', CK_CopyCurrentTagged, "t" },
848 { XCTRL ('t'), CK_CopyOtherTagged, "C-t" },
849 { 'c', CK_ChmodCmd, "c" },
850 { 'o', CK_ChownCmd, "o" },
851 { 'r', CK_CopyCurrentReadlink, "r" },
852 { XCTRL ('r'), CK_CopyOtherReadlink, "C-r" },
853 { 'l', CK_LinkCmd, "l" },
854 { 's', CK_SymlinkCmd, "s" },
855 { XCTRL ('s'), CK_EditSymlinkCmd, "C-s" },
856 { 'i', CK_InfoCmd, "i" },
857 { 'q', CK_QuickViewCmd, "q" },
858 { 'h', CK_AddHotlist, "h" },
859 { '!', CK_ExternalPanelize, "!" },
860 #ifdef WITH_BACKGROUND
861 { 'j', CK_JobsCmd, "j" },
862 #endif /* WITH_BACKGROUND */
863 { 0, CK_Ignore_Key, "" }
866 const global_keymap_t default_input_keymap[] = {
867 /* Motion */
868 { XCTRL ('a'), CK_InputBol, "C-a" },
869 { KEY_HOME, CK_InputBol, "Home" },
870 { KEY_A1, CK_InputBol, "Home" },
871 { ALT ('<'), CK_InputBol, "M-<" },
872 { XCTRL ('e'), CK_InputEol, "C-e" },
873 { KEY_END, CK_InputEol, "End" },
874 { KEY_C1, CK_InputEol, "End" },
875 { ALT ('>'), CK_InputEol, "M->" },
876 { KEY_LEFT, CK_InputMoveLeft, "Left" },
877 { KEY_M_CTRL | KEY_LEFT, CK_InputWordLeft, "C-Left" },
878 { KEY_RIGHT, CK_InputMoveRight, "Right" },
879 { KEY_M_CTRL | KEY_RIGHT, CK_InputWordRight, "C-Right" },
881 { XCTRL ('b'), CK_InputBackwardChar, "C-b" },
882 { ALT ('b'), CK_InputBackwardWord, "M-b" },
883 { XCTRL ('f'), CK_InputForwardChar, "C-f" },
884 { ALT ('f'), CK_InputForwardWord, "M-f" },
886 /* Editing */
887 { KEY_BACKSPACE, CK_InputBackwardDelete, "BackSpace" },
888 { KEY_DC, CK_InputDeleteChar, "Delete" },
889 { ALT ('d'), CK_InputKillWord, "M-d" },
890 { ALT (KEY_BACKSPACE), CK_InputBackwardKillWord, "M-BackSpace" },
892 /* Region manipulation */
893 { XCTRL ('w'), CK_InputKillRegion, "C-w" },
894 { ALT ('w'), CK_InputKillSave, "M-w" },
895 { XCTRL ('y'), CK_InputYank, "C-y" },
896 { XCTRL ('k'), CK_InputKillLine, "C-k" },
898 /* History */
899 { ALT ('p'), CK_InputHistoryPrev, "M-p" },
900 { ALT ('n'), CK_InputHistoryNext, "M-n" },
901 { ALT ('h'), CK_InputHistoryShow, "M-h" },
903 /* Completion */
904 { ALT ('\t'), CK_InputComplete, "M-tab" },
906 { 0, CK_Ignore_Key, "" }
909 static int
910 name_keymap_comparator (const void *p1, const void *p2)
912 const name_keymap_t *m1 = (const name_keymap_t *) p1;
913 const name_keymap_t *m2 = (const name_keymap_t *) p2;
915 return str_casecmp (m1->name, m2->name);
918 static inline void
919 sort_command_names (void)
921 static gboolean has_been_sorted = FALSE;
923 if (!has_been_sorted) {
924 qsort (command_names, num_command_names,
925 sizeof (command_names[0]), &name_keymap_comparator);
926 has_been_sorted = TRUE;
930 static void
931 keymap_add (GArray *keymap, long key, unsigned long cmd, const char *caption)
933 if (key != 0 && cmd != CK_Ignore_Key) {
934 global_keymap_t new_bind;
936 new_bind.key = key;
937 new_bind.command = cmd;
938 g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
939 g_array_append_val (keymap, new_bind);
943 void
944 keybind_cmd_bind (GArray *keymap, const char *keybind, unsigned long action)
946 char *caption = NULL;
947 long key;
949 key = lookup_key (keybind, &caption);
950 keymap_add (keymap, key, action, caption);
951 g_free (caption);
954 unsigned long
955 lookup_action (const char *keyname)
957 const name_keymap_t key = { keyname, 0 };
958 name_keymap_t *res;
960 sort_command_names ();
962 res = bsearch (&key, command_names, num_command_names,
963 sizeof (command_names[0]), name_keymap_comparator);
965 return (res != NULL) ? res->val : CK_Ignore_Key;
968 const char *
969 lookup_keymap_shortcut (const global_keymap_t *keymap, unsigned long action)
971 size_t i;
973 for (i = 0; keymap[i].key != 0; i++)
974 if (keymap[i].command == action)
975 return (keymap[i].caption[0] != '\0') ? keymap[i].caption : NULL;
977 return NULL;
980 unsigned long
981 lookup_keymap_command (const global_keymap_t *keymap, long key)
983 size_t i;
985 for (i = 0; keymap[i].key != 0; i++)
986 if (keymap[i].key == key)
987 return keymap[i].command;
989 return CK_Ignore_Key;