initial step to do mark in inpun fields
[midnight-commander/osp/pkrayzel.git] / src / keybind.c
blob1479d8594e222829d38bd0e4b28c0811984a12b0
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_LayoutBox },
359 { "CmdLearnKeys", CK_LearnKeys },
360 { "CmdLink", CK_LinkCmd },
361 { "CmdChangeListing", CK_ChangeListingCmd },
362 { "CmdListing", CK_ListingCmd },
363 #ifdef LISTMODE_EDITOR
364 { "CmdListmodeCmd", CK_ListmodeCmd }.
365 #endif
366 { "CmdMkdir", CK_MkdirCmd },
367 #if defined (USE_NETCODE) && defined (ENABLE_VFS_MCFS)
368 { "CmdNetlink", CK_NetlinkCmd },
369 #endif
370 { "CmdPanelOptions", CK_PanelOptionsBox },
371 { "CmdQuickCd", CK_QuickCdCmd },
372 { "CmdQuickChdir", CK_QuickChdirCmd },
373 { "CmdQuickView", CK_QuickViewCmd },
374 { "CmdQuietQuit", CK_QuietQuitCmd },
375 { "CmdRelativeSymlink", CK_RelativeSymlinkCmd },
376 { "CmdRename", CK_RenameCmd },
377 { "CmdReread", CK_RereadCmd },
378 { "CmdReselectVfs", CK_ReselectVfs },
379 { "CmdReverseSelection", CK_ReverseSelectionCmd },
380 { "CmdSaveSetup", CK_SaveSetupCmd },
381 { "CmdSelect", CK_SelectCmd },
382 #if defined (USE_NETCODE) && defined (ENABLE_VFS_SMB)
383 { "CmdSmblinkCmd", CK_SmblinkCmd },
384 #endif /* USE_NETCODE || ENABLE_VFS_SMB */
385 { "CmdSwapPanel", CK_SwapCmd },
386 { "CmdSymlink", CK_SymlinkCmd },
387 { "CmdTree", CK_TreeCmd },
388 { "CmdTreeBox", CK_TreeBoxCmd },
389 #ifdef USE_EXT2FSLIB
390 { "CmdUndelete", CK_UndeleteCmd },
391 #endif
392 { "CmdUnselect", CK_UnselectCmd },
393 { "CmdUserMenu", CK_UserMenuCmd },
394 { "CmdUserFileMenu", CK_UserFileMenuCmd },
395 { "CmdView", CK_ViewCmd },
396 { "CmdViewFile", CK_ViewFileCmd },
397 { "CmdCopyCurrentReadlink", CK_CopyCurrentReadlink },
398 { "CmdCopyOtherReadlink", CK_CopyOtherReadlink },
399 { "CmdAddHotlist", CK_AddHotlist },
400 { "CmdQuit", CK_QuitCmd },
401 { "CmdCopyCurrentTagged", CK_CopyCurrentTagged },
402 { "CmdCopyOtherTagged", CK_CopyOtherTagged },
403 { "CmdToggleShowHidden", CK_ToggleShowHidden },
404 { "CmdTogglePanelsSplit", CK_TogglePanelsSplit },
405 #ifdef USE_DIFF_VIEW
406 { "CmdDiffView", CK_DiffViewCmd},
407 #endif
409 /* panel */
410 { "PanelChdirOtherPanel", CK_PanelChdirOtherPanel },
411 { "PanelChdirToReadlink", CK_PanelChdirToReadlink },
412 { "PanelCopyLocal", CK_PanelCmdCopyLocal },
413 { "PanelDeleteLocal", CK_PanelCmdDeleteLocal },
414 { "PanelDoEnter", CK_PanelCmdDoEnter },
415 { "PanelEditNew", CK_PanelCmdEditNew },
416 { "PanelRenameLocal", CK_PanelCmdRenameLocal },
417 { "PanelReverseSelection", CK_PanelCmdReverseSelection },
418 { "PanelSelect", CK_PanelCmdSelect },
419 { "PanelUnselect", CK_PanelCmdUnselect },
420 { "PanelViewSimple", CK_PanelCmdViewSimple },
421 { "PanelCtrlNextPage", CK_PanelCtrlNextPage },
422 { "PanelCtrlPrevPage", CK_PanelCtrlPrevPage },
423 { "PanelDirectoryHistoryList", CK_PanelDirectoryHistoryList },
424 { "PanelDirectoryHistoryNext", CK_PanelDirectoryHistoryNext },
425 { "PanelDirectoryHistoryPrev", CK_PanelDirectoryHistoryPrev },
426 { "PanelGotoBottomFile", CK_PanelGotoBottomFile },
427 { "PanelGotoMiddleFile", CK_PanelGotoMiddleFile },
428 { "PanelGotoTopFile", CK_PanelGotoTopFile },
429 { "PanelMarkFile", CK_PanelMarkFile },
430 { "PanelMarkFileDown", CK_PanelMarkFileDown },
431 { "PanelMarkFileUp", CK_PanelMarkFileUp },
432 { "PanelMoveUp", CK_PanelMoveUp },
433 { "PanelMoveDown", CK_PanelMoveDown },
434 { "PanelMoveLeft", CK_PanelMoveLeft },
435 { "PanelMoveRight", CK_PanelMoveRight },
436 { "PanelMoveEnd", CK_PanelMoveEnd },
437 { "PanelMoveHome", CK_PanelMoveHome },
438 { "PanelNextPage", CK_PanelNextPage },
439 { "PanelPrevPage", CK_PanelPrevPage },
440 #ifdef HAVE_CHARSET
441 { "PanelSetPanelEncoding", CK_PanelSetPanelEncoding },
442 #endif
443 { "PanelStartSearch", CK_PanelStartSearch },
444 { "PanelSyncOtherPanel", CK_PanelSyncOtherPanel },
445 { "PanelToggleSortOrderNext", CK_PanelToggleSortOrderNext },
446 { "PanelToggleSortOrderPrev", CK_PanelToggleSortOrderPrev },
447 { "PanelSelectSortOrder", CK_PanelSelectSortOrder },
448 { "PanelReverseSort", CK_PanelReverseSort },
449 { "PanelSortOrderByName", CK_PanelSortOrderByName },
450 { "PanelSortOrderByExt", CK_PanelSortOrderByExt },
451 { "PanelSortOrderBySize", CK_PanelSortOrderBySize },
452 { "PanelSortOrderByMTime", CK_PanelSortOrderByMTime },
454 /* input line */
455 { "InputBol", CK_InputBol },
456 { "InputEol", CK_InputEol },
457 { "InputMoveLeft", CK_InputMoveLeft },
458 { "InputWordLeft", CK_InputWordLeft },
459 { "InputBackwardChar", CK_InputBackwardChar },
460 { "InputBackwardWord", CK_InputBackwardWord },
461 { "InputMoveRight", CK_InputMoveRight },
462 { "InputWordRight", CK_InputWordRight },
463 { "InputForwardChar", CK_InputForwardChar },
464 { "InputForwardWord", CK_InputForwardWord },
465 { "InputBackwardDelete", CK_InputBackwardDelete },
466 { "InputDeleteChar", CK_InputDeleteChar },
467 { "InputKillWord", CK_InputKillWord },
468 { "InputBackwardKillWord", CK_InputBackwardKillWord },
469 { "InputSetMark", CK_InputSetMark },
470 { "InputKillRegion", CK_InputKillRegion },
471 { "InputYank", CK_InputYank },
472 { "InputKillLine", CK_InputKillLine },
473 { "InputHistoryPrev", CK_InputHistoryPrev },
474 { "InputHistoryNext", CK_InputHistoryNext },
475 { "InputHistoryShow", CK_InputHistoryShow },
476 { "InputComplete", CK_InputComplete },
477 { "InputXStore", CK_InputKillSave },
478 { "InputXPaste", CK_InputPaste },
479 { "InputClearLine", CK_InputClearLine },
480 { "InputLeftHighlight", CK_InputLeftHighlight },
481 { "InputRightHighlight", CK_InputRightHighlight},
482 { "InputWordLeftHighlight", CK_InputWordLeftHighlight},
483 { "InputWordRightHighlight", CK_InputWordRightHighlight},
484 { "InputBolHighlight", CK_InputBolHighlight},
485 { "InputEolHighlight", CK_InputEolHighlight},
487 /* common */
488 { "ExtMap1", CK_StartExtMap1 },
489 { "ExtMap2", CK_StartExtMap2 },
490 { "ShowCommandLine", CK_ShowCommandLine },
491 { "SelectCodepage", CK_SelectCodepage },
493 /* dialog */
494 { "DialogOK", CK_DialogOK },
495 { "DialogCancel", CK_DialogCancel },
496 { "DialogPrevItem", CK_DialogPrevItem },
497 { "DialogNextItem", CK_DialogNextItem },
498 { "DialogHelp", CK_DialogHelp },
499 { "DialogSuspend", CK_DialogSuspend },
500 { "DialogRefresh", CK_DialogRefresh },
502 /* diff viewer */
503 { "DiffDisplaySymbols", CK_DiffDisplaySymbols},
504 { "DiffDisplayNumbers", CK_DiffDisplayNumbers},
505 { "DiffFull", CK_DiffFull},
506 { "DiffEqual", CK_DiffEqual},
507 { "DiffSplitMore", CK_DiffSplitMore},
508 { "DiffSplitLess", CK_DiffSplitLess},
509 { "DiffShowDiff", CK_DiffShowDiff},
510 { "DiffSetTab2", CK_DiffSetTab2},
511 { "DiffSetTab3", CK_DiffSetTab3},
512 { "DiffSetTab4", CK_DiffSetTab4},
513 { "DiffSetTab8", CK_DiffSetTab8},
514 { "DiffSwapPanel", CK_DiffSwapPanel},
515 { "DiffRedo", CK_DiffRedo},
516 { "DiffNextHunk", CK_DiffNextHunk},
517 { "DiffPrevHunk", CK_DiffPrevHunk},
518 { "DiffGoto", CK_DiffGoto},
519 { "DiffEditCurrent", CK_DiffEditCurrent},
520 { "DiffEditOther", CK_DiffEditOther},
521 { "DiffSearch", CK_DiffSearch},
522 { "DiffContinueSearch", CK_DiffContinueSearch},
523 { "DiffEOF", CK_DiffEOF},
524 { "DiffBOF", CK_DiffBOF},
525 { "DiffDown", CK_DiffDown},
526 { "DiffUp", CK_DiffUp},
527 { "DiffLeft", CK_DiffLeft},
528 { "DiffRight", CK_DiffRight},
529 { "DiffPageDown", CK_DiffPageDown},
530 { "DiffPageUp", CK_DiffPageUp},
531 { "DiffHome", CK_DiffHome},
532 { "DiffEnd", CK_DiffEnd},
533 { "DiffQuit", CK_DiffQuit},
534 { "DiffHelp", CK_DiffHelp},
535 { "SelectCodepage", CK_SelectCodepage},
536 { "DiffMergeCurrentHunk", CK_DiffMergeCurrentHunk},
537 { "DiffSave", CK_DiffSave},
538 { "DiffOptions", CK_DiffOptions},
540 { NULL, CK_Ignore_Key }
543 static const size_t num_command_names = sizeof (command_names) /
544 sizeof (command_names[0]) - 1;
546 /*** global variables ****************************************************************************/
548 /* viewer/actions_cmd.c */
549 const global_keymap_t default_viewer_keymap[] = {
550 { KEY_F (1), CK_ViewHelp, "F1" },
551 { KEY_F (2), CK_ViewToggleWrapMode, "F2" },
552 { KEY_F (3), CK_ViewQuit, "F3" },
553 { KEY_F (4), CK_ViewToggleHexMode, "F4" },
554 { KEY_F (5), CK_ViewGoto, "F5" },
555 { KEY_F (7), CK_ViewSearch, "F7" },
556 { KEY_F (8), CK_ViewToggleMagicMode, "F8" },
557 { KEY_F (9), CK_ViewToggleNroffMode, "F9" },
558 { KEY_F (10), CK_ViewQuit, "F10" },
560 { '?', CK_ViewSearch, "?" },
561 { '/', CK_ViewSearch, "/" },
562 { XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
563 { XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
564 { KEY_F (17), CK_ViewContinueSearch, "S-F7" },
565 { 'n', CK_ViewContinueSearch, "n" },
566 { ALT ('r'), CK_ViewToggleRuler, "M-r" },
568 { XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
569 { XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
571 { 'h', CK_ViewMoveLeft, "h" },
572 { KEY_LEFT, CK_ViewMoveLeft, "Left" },
574 { 'l', CK_ViewMoveRight, "l" },
575 { KEY_RIGHT, CK_ViewMoveRight, "Right" },
577 { 'k', CK_ViewMoveUp, "k" },
578 { 'y', CK_ViewMoveUp, "y" },
579 { KEY_IC, CK_ViewMoveUp, "Insert" },
580 { KEY_UP, CK_ViewMoveUp, "Up" },
582 { 'j', CK_ViewMoveDown, "j" },
583 { 'e', CK_ViewMoveDown, "e" },
584 { KEY_DOWN, CK_ViewMoveDown, "Down" },
585 { KEY_DC, CK_ViewMoveDown, "Delete" },
587 { ' ', CK_ViewMovePgDn, "Space" },
588 { 'f', CK_ViewMovePgDn, "f" },
589 { KEY_NPAGE, CK_ViewMovePgDn, "PgDn" },
591 { 'b', CK_ViewMovePgUp, "b" },
592 { KEY_PPAGE, CK_ViewMovePgUp, "PgUp" },
594 { 'd', CK_ViewMoveHalfPgDn, "d" },
595 { 'u', CK_ViewMoveHalfPgUp, "u" },
597 { 'm', CK_ViewGotoBookmark, "m" },
598 { 'r', CK_ViewNewBookmark, "r" },
600 { XCTRL ('f'), CK_ViewNextFile, "C-f" },
601 { XCTRL ('b'), CK_ViewPrevFile, "C-b" },
603 { 'q', CK_ViewQuit, "q" },
604 { XCTRL ('g'), CK_ViewQuit, "C-g" },
605 { ESC_CHAR, CK_ViewQuit, "Esc" },
607 { ALT ('e'), CK_SelectCodepage, "M-e" },
608 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
610 { 0, CK_Ignore_Key, "" }
613 const global_keymap_t default_viewer_hex_keymap[] = {
614 { KEY_F (1), CK_ViewHelp, "F1" },
615 { KEY_F (2), CK_ViewToggleHexEditMode, "F2" },
616 { KEY_F (3), CK_ViewQuit, "F3" },
617 { KEY_F (4), CK_ViewToggleHexMode, "F4" },
618 { KEY_F (5), CK_ViewGoto, "F5" },
619 { KEY_F (6), CK_ViewHexEditSave, "F6" },
620 { KEY_F (7), CK_ViewSearch, "F7" },
621 { KEY_F (8), CK_ViewToggleMagicMode, "F8" },
622 { KEY_F (9), CK_ViewToggleNroffMode, "F9" },
623 { KEY_F (10), CK_ViewQuit, "F10" },
625 { '?', CK_ViewSearch, "?" },
626 { '/', CK_ViewSearch, "/" },
627 { XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
628 { XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
629 { KEY_F (17), CK_ViewContinueSearch, "S-F7" },
630 { 'n', CK_ViewContinueSearch, "n" },
632 { '\t', CK_ViewToggleHexNavMode, "Tab" },
633 { XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
634 { XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
636 { 'b', CK_ViewMoveLeft, "b" },
637 { KEY_LEFT, CK_ViewMoveLeft, "Left" },
639 { 'f', CK_ViewMoveRight, "f" },
640 { KEY_RIGHT, CK_ViewMoveRight, "Right" },
642 { 'k', CK_ViewMoveUp, "k" },
643 { 'y', CK_ViewMoveUp, "y" },
644 { KEY_UP, CK_ViewMoveUp, "Up" },
646 { 'j', CK_ViewMoveDown, "j" },
647 { KEY_DOWN, CK_ViewMoveDown, "Down" },
648 { KEY_DC, CK_ViewMoveDown, "Delete" },
650 { 'q', CK_ViewQuit, "q" },
651 { XCTRL ('g'), CK_ViewQuit, "C-g" },
652 { ESC_CHAR, CK_ViewQuit, "Esc" },
654 { ALT ('e'), CK_SelectCodepage, "M-e" },
655 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
657 { 0, CK_Ignore_Key, "" }
660 #ifdef USE_INTERNAL_EDIT
661 /* ../edit/editkeys.c */
662 const global_keymap_t default_editor_keymap[] = {
663 { '\n', CK_Enter, "Enter" },
664 { '\t', CK_Tab, "Tab" },
666 { KEY_F (1), CK_Help, "F1" },
667 { KEY_F (2), CK_Save, "F2" },
668 { KEY_F (3), CK_Mark, "F3" },
669 { KEY_F (4), CK_Replace, "F4" },
670 { KEY_F (5), CK_Copy, "F5" },
671 { KEY_F (6), CK_Move, "F6" },
672 { KEY_F (7), CK_Find, "F7" },
673 { KEY_F (8), CK_Remove, "F8" },
674 { KEY_F (9), CK_Menu, "F9" },
675 { KEY_F (10), CK_Quit, "F10" },
676 /* edit user menu */
677 { KEY_F (11), CK_User_Menu, "S-F1" },
678 { KEY_F (12), CK_Save_As, "S-F2" },
679 { KEY_F (13), CK_Column_Mark, "S-F3" },
680 { KEY_F (14), CK_Replace_Again, "S-F4" },
681 { KEY_F (15), CK_Insert_File, "S-F5" },
682 { KEY_F (17), CK_Find_Again, "S-F7" },
683 /* C formatter */
684 { KEY_F (19), CK_Pipe_Block (0), "S-F9" },
686 { ESC_CHAR, CK_Quit, "Esc" },
687 { KEY_BACKSPACE, CK_BackSpace, "BackSpace" },
688 { KEY_DC, CK_Delete, "Delete" },
689 { KEY_DOWN, CK_Down, "Down" },
690 { KEY_END, CK_End, "End" },
691 { KEY_HOME, CK_Home, "Home" },
692 { KEY_IC, CK_Toggle_Insert, "Insert" },
693 { KEY_LEFT, CK_Left, "Left" },
694 { KEY_NPAGE, CK_Page_Down, "PgDn" },
695 { KEY_PPAGE, CK_Page_Up, "PgUp" },
696 { KEY_RIGHT, CK_Right, "Right" },
697 { KEY_UP, CK_Up, "Up" },
699 /* Ctrl */
700 { KEY_M_CTRL | (KEY_F (2)), CK_Save_As, "C-F2" },
701 { KEY_M_CTRL | (KEY_F (4)), CK_Replace_Again, "C-F4" },
702 { KEY_M_CTRL | (KEY_F (7)), CK_Find_Again, "C-F7" },
703 { KEY_M_CTRL | KEY_BACKSPACE, CK_Undo, "C-BackSpace" },
704 { KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text, "C-PgDn" },
705 { KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text, "C-PgUp" },
706 { KEY_M_CTRL | KEY_HOME, CK_Beginning_Of_Text, "C-Home" },
707 { KEY_M_CTRL | KEY_END, CK_End_Of_Text, "C-End" },
708 { KEY_M_CTRL | KEY_UP, CK_Scroll_Up, "C-Up" },
709 { KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down, "C-Down" },
710 { KEY_M_CTRL | KEY_LEFT, CK_Word_Left, "C-Left" },
711 { KEY_M_CTRL | KEY_RIGHT, CK_Word_Right, "C-Right" },
712 { KEY_M_CTRL | KEY_IC, CK_XStore, "C-Insert" },
713 { KEY_M_CTRL | KEY_DC, CK_Remove, "C-Delete" },
715 { XCTRL ('n'), CK_New, "C-n" },
716 { XCTRL ('k'), CK_Delete_To_Line_End, "C-k" },
717 { XCTRL ('l'), CK_Refresh, "C-l" },
718 { XCTRL ('o'), CK_Shell, "C-o" },
719 { XCTRL ('s'), CK_Toggle_Syntax, "C-s" },
720 { XCTRL ('u'), CK_Undo, "C-u" },
721 { ALT ('e'), CK_SelectCodepage, "M-e" },
722 { XCTRL ('q'), CK_Insert_Literal, "C-q" },
723 { XCTRL ('r'), CK_Begin_End_Macro, "C-r" },
724 { XCTRL ('r'), CK_Begin_Record_Macro, "C-r" },
725 { XCTRL ('r'), CK_End_Record_Macro, "C-r" },
726 { XCTRL ('a'), CK_Execute_Macro, "C-a" },
728 /* Shift */
729 { KEY_M_SHIFT | KEY_NPAGE, CK_Page_Down_Highlight, "S-PgDn" },
730 { KEY_M_SHIFT | KEY_PPAGE, CK_Page_Up_Highlight, "S-PgUp" },
731 { KEY_M_SHIFT | KEY_LEFT, CK_Left_Highlight, "S-Left" },
732 { KEY_M_SHIFT | KEY_RIGHT, CK_Right_Highlight, "S-Right" },
733 { KEY_M_SHIFT | KEY_UP, CK_Up_Highlight, "S-Up" },
734 { KEY_M_SHIFT | KEY_DOWN, CK_Down_Highlight, "S-Down" },
735 { KEY_M_SHIFT | KEY_HOME, CK_Home_Highlight, "S-Home" },
736 { KEY_M_SHIFT | KEY_END, CK_End_Highlight, "S-End" },
737 { KEY_M_SHIFT | KEY_IC, CK_XPaste, "S-Insert" },
738 { KEY_M_SHIFT | KEY_DC, CK_XCut, "S-Delete" },
739 /* useful for pasting multiline text */
740 { KEY_M_SHIFT | '\n', CK_Return, "S-Enter" },
742 /* Ctrl + Shift */
743 { KEY_M_SHIFT | KEY_M_CTRL | KEY_NPAGE, CK_End_Of_Text_Highlight, "C-S-PgDn" },
744 { KEY_M_SHIFT | KEY_M_CTRL | KEY_PPAGE, CK_Beginning_Of_Text_Highlight, "C-S-PgUp" },
745 { KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, CK_Word_Left_Highlight, "C-S-Left" },
746 { KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, CK_Word_Right_Highlight, "C-S-Right" },
747 { KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, CK_Scroll_Up_Highlight, "C-S-Up" },
748 { KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, CK_Scroll_Down_Highlight, "C-S-Down" },
750 /* Alt */
751 { KEY_M_ALT | KEY_NPAGE, CK_Page_Down_Alt_Highlight, "M-PgDn" },
752 { KEY_M_ALT | KEY_PPAGE, CK_Page_Up_Alt_Highlight, "M-PgUp" },
753 { KEY_M_ALT | KEY_LEFT, CK_Left_Alt_Highlight, "M-Left" },
754 { KEY_M_ALT | KEY_RIGHT, CK_Right_Alt_Highlight, "M-Right" },
755 { KEY_M_ALT | KEY_UP, CK_Up_Alt_Highlight, "M-Up" },
756 { KEY_M_ALT | KEY_DOWN, CK_Down_Alt_Highlight, "M-Down" },
757 { KEY_M_ALT | KEY_HOME, CK_Home_Highlight, "M-Home" },
758 { KEY_M_ALT | KEY_END, CK_End_Alt_Highlight, "M-End" },
760 { ALT ('\n'), CK_Find_Definition, "M-Enter" },
761 { ALT ('\t'), CK_Complete_Word, "M-Tab" },
762 { ALT ('l'), CK_Goto, "M-l" },
763 { ALT ('L'), CK_Goto, "M-L" },
764 { ALT ('p'), CK_Paragraph_Format, "M-p" },
765 { ALT ('t'), CK_Sort, "M-t" },
766 { ALT ('u'), CK_ExtCmd, "M-u" },
767 { ALT ('<'), CK_Beginning_Of_Text, "M-<" },
768 { ALT ('>'), CK_End_Of_Text, "M->" },
769 { ALT ('-'), CK_Load_Prev_File, "M--" },
770 { ALT ('+'), CK_Load_Next_File, "M-+" },
771 { ALT ('d'), CK_Delete_Word_Right, "M-d" },
772 { ALT (KEY_BACKSPACE), CK_Delete_Word_Left, "M-BackSpace" },
773 { ALT ('n'), CK_Toggle_Line_State, "M-n" },
774 { ALT ('_'), CK_Toggle_Tab_TWS, "M-_" },
775 { ALT ('k'), CK_Toggle_Bookmark, "M-k" },
776 { ALT ('i'), CK_Prev_Bookmark, "M-i" },
777 { ALT ('j'), CK_Next_Bookmark, "M-j" },
778 { ALT ('o'), CK_Flush_Bookmarks, "M-o" },
780 { XCTRL ('x'), CK_Ext_Mode, "C-x" },
782 { 0, CK_Ignore_Key, "" }
785 /* emacs keyboard layout emulation */
786 const global_keymap_t default_editor_x_keymap[] = {
787 { 'k', CK_New, "k"},
788 { 'e', CK_Execute_Macro, "e"},
789 { 0, CK_Ignore_Key, "" }
791 #endif /* USE_INTERNAL_EDIT */
793 /* dialog */
794 const global_keymap_t default_dialog_keymap[] = {
795 { '\n', CK_DialogOK, "Enter" },
796 { KEY_ENTER, CK_DialogOK, "Enter" },
797 { ESC_CHAR, CK_DialogCancel, "Esc" },
798 { XCTRL('g'), CK_DialogCancel, "C-g" },
799 { KEY_F (10), CK_DialogCancel, "F10" },
800 { KEY_LEFT, CK_DialogPrevItem, "Left" },
801 { KEY_UP, CK_DialogPrevItem, "Up" },
802 { KEY_RIGHT, CK_DialogNextItem, "Right" },
803 { KEY_DOWN, CK_DialogNextItem, "Down" },
804 { KEY_F(1), CK_DialogHelp, "F1" },
805 { XCTRL('z'), CK_DialogSuspend, "C-z" },
806 { XCTRL('l'), CK_DialogRefresh, "C-l" },
807 { 0, CK_Ignore_Key, "" }
810 /* tree */
811 const global_keymap_t default_tree_keymap[] = {
812 { KEY_F (1), CK_TreeHelp, "F1"},
813 { KEY_F (2), CK_TreeRescan, "F2" },
814 { KEY_F (3), CK_TreeForget, "F3" },
815 { KEY_F (4), CK_TreeToggleNav, "F4" },
816 { KEY_F (5), CK_TreeCopy, "F5" },
817 { KEY_F (6), CK_TreeMove, "F6" },
818 #if 0
819 { KEY_F (7), CK_TreeMake, "F7" },
820 #endif
821 { KEY_F (8), CK_TreeRemove, "F8" },
822 { KEY_UP, CK_TreeMoveUp, "Up" },
823 { XCTRL ('p'), CK_TreeMoveUp, "C-p" },
824 { KEY_DOWN, CK_TreeMoveDown, "Down" },
825 { XCTRL ('n'), CK_TreeMoveDown, "C-n" },
826 { KEY_LEFT, CK_TreeMoveLeft, "Left" },
827 { KEY_RIGHT, CK_TreeMoveRight, "Right" },
828 { KEY_HOME, CK_TreeMoveHome, "Home" },
829 { ALT ('<'), CK_TreeMoveHome, "M-<" },
830 { KEY_END, CK_TreeMoveEnd , "End" },
831 { ALT ('>'), CK_TreeMoveEnd , "M->" },
832 { KEY_PPAGE, CK_TreeMovePgUp, "PgUp" },
833 { ALT ('v'), CK_TreeMovePgUp, "M-v" },
834 { KEY_NPAGE, CK_TreeMovePgDn, "PnDn" },
835 { XCTRL ('v'), CK_TreeMovePgDn, "C-v" },
836 { '\n', CK_TreeOpen, "Enter" },
837 { KEY_ENTER, CK_TreeOpen, "Enter" },
838 { XCTRL ('r'), CK_TreeRescan, "C-r" },
839 { XCTRL ('s'), CK_TreeStartSearch, "C-s" },
840 { ALT ('s'), CK_TreeStartSearch, "M-s" },
841 { KEY_DC, CK_TreeRemove, "Delete" },
842 { 0, CK_Ignore_Key, ""}
845 /* help */
846 const global_keymap_t default_help_keymap[] = {
847 { KEY_F (1), CK_HelpHelp, "F1" },
848 { KEY_F (2), CK_HelpIndex, "F2" },
849 { KEY_F (3), CK_HelpBack, "F3" },
850 { KEY_F (10), CK_HelpQuit, "F10" },
851 { KEY_LEFT, CK_HelpBack, "Left" },
852 { 'l', CK_HelpBack, "l" },
853 { KEY_DOWN, CK_HelpMoveDown, "Down" },
854 { KEY_UP, CK_HelpMoveUp, "Up" },
855 { KEY_RIGHT, CK_HelpSelectLink, "Right" },
856 { KEY_ENTER, CK_HelpSelectLink, "Enter" },
857 { '\n', CK_HelpSelectLink, "Enter" },
858 { '\t', CK_HelpNextLink, "Tab" },
859 { ALT ('\t'), CK_HelpPrevLink, "M-Tab" },
860 { 'n', CK_HelpNextNode, "n" },
861 { 'p', CK_HelpPrevNode, "p" },
862 { ESC_CHAR, CK_HelpQuit, "Esc" },
863 { XCTRL ('g'), CK_HelpQuit, "C-g" },
864 { 0, CK_Ignore_Key, "" }
867 /* screen.c */
868 const global_keymap_t default_panel_keymap[] = {
869 { ALT ('o'), CK_PanelChdirOtherPanel, "M-o" },
870 { ALT ('l'), CK_PanelChdirToReadlink, "M-l" },
871 { KEY_F (15), CK_PanelCmdCopyLocal, "S-F5" },
872 { KEY_F (18), CK_PanelCmdDeleteLocal, "S-F8" },
873 { KEY_ENTER, CK_PanelCmdDoEnter, "Enter" },
874 { '\n', CK_PanelCmdDoEnter, "Enter" },
875 { KEY_F (14), CK_PanelCmdEditNew, "S-F4" },
876 { KEY_F (16), CK_PanelCmdRenameLocal, "S-F6" },
877 { ALT ('*'), CK_PanelCmdReverseSelection, "M-*" },
878 { KEY_KP_ADD, CK_PanelCmdSelect, "M-+" },
879 { KEY_KP_SUBTRACT, CK_PanelCmdUnselect, "M--" },
880 { KEY_F (13), CK_PanelCmdViewSimple, "S-F3" },
881 { KEY_M_CTRL | KEY_NPAGE, CK_PanelCtrlNextPage, "C-PgDn" },
882 { KEY_M_CTRL | KEY_PPAGE, CK_PanelCtrlPrevPage, "C-PgUp" },
883 { ALT ('H'), CK_PanelDirectoryHistoryList, "M-H" },
884 { ALT ('u'), CK_PanelDirectoryHistoryNext, "M-u" },
885 { ALT ('y'), CK_PanelDirectoryHistoryPrev, "M-y" },
886 { ALT ('j'), CK_PanelGotoBottomFile, "M-j" },
887 { ALT ('r'), CK_PanelGotoMiddleFile, "M-r" },
888 { ALT ('g'), CK_PanelGotoTopFile, "M-g" },
889 { KEY_IC, CK_PanelMarkFile, "Insert" },
890 { KEY_UP, CK_PanelMoveUp, "Up" },
891 { KEY_DOWN, CK_PanelMoveDown, "Down" },
892 { KEY_LEFT, CK_PanelMoveLeft, "Left" },
893 { KEY_RIGHT, CK_PanelMoveRight, "Right" },
894 { KEY_END, CK_PanelMoveEnd, "End" },
895 { KEY_HOME, CK_PanelMoveHome, "Home" },
896 { KEY_A1, CK_PanelMoveHome, "Home" },
897 { KEY_NPAGE, CK_PanelNextPage, "PgDn" },
898 { KEY_PPAGE, CK_PanelPrevPage, "PgUp" },
899 { ALT ('e'), CK_PanelSetPanelEncoding, "M-e" },
900 { XCTRL ('s'), CK_PanelStartSearch, "C-s" },
901 { ALT ('s'), CK_PanelStartSearch, "M-s" },
902 { ALT ('i'), CK_PanelSyncOtherPanel, "M-i" },
903 { 0, CK_Ignore_Key , "" }
906 /* main.c */
907 const global_keymap_t default_main_map[] = {
908 { KEY_F (1), CK_HelpCmd, "F1" },
909 { KEY_F (2), CK_UserMenuCmd, "F2" },
910 { KEY_F (3), CK_ViewCmd, "F3" },
911 { KEY_F (4), CK_EditCmd, "F4" },
912 { KEY_F (5), CK_CopyCmd, "F5" },
913 { KEY_F (6), CK_RenameCmd, "F6" },
914 { KEY_F (7), CK_MkdirCmd, "F7" },
915 { KEY_F (8), CK_DeleteCmd, "F8" },
916 { KEY_F (9), CK_MenuCmd, "F9" },
917 { KEY_F (10), CK_QuitCmd, "F10" },
918 { KEY_F (13), CK_ViewFileCmd, "S-F3" },
919 { KEY_F (19), CK_MenuLastSelectedCmd, "S-F9" },
920 { KEY_F (20), CK_QuietQuitCmd, "S-10" },
921 { ALT ('h'), CK_HistoryCmd, "M-h" },
922 { XCTRL ('@'), CK_SingleDirsizeCmd, "C-Space" },
923 /* Copy useful information to the command line */
924 { ALT ('a'), CK_CopyCurrentPathname, "M-a" },
925 { ALT ('A'), CK_CopyOtherPathname, "M-A" },
926 { ALT ('c'), CK_QuickCdCmd, "M-c" },
927 /* To access the directory hotlist */
928 { XCTRL ('\\'), CK_QuickChdirCmd, "C-\\" },
929 /* Suspend */
930 { XCTRL ('z'), CK_SuspendCmd, "C-z" },
931 /* The filtered view command */
932 { ALT ('!'), CK_FilteredViewCmd, "M-!" },
933 /* Find file */
934 { ALT ('?'), CK_FindCmd, "M-?" },
935 /* Panel refresh */
936 { XCTRL ('r'), CK_RereadCmd, "C-r" },
937 /* Toggle listing between long, user defined and full formats */
938 { ALT ('t'), CK_ToggleListingCmd, "M-t" },
939 /* Swap panels */
940 { XCTRL ('u'), CK_SwapCmd, "C-u" },
941 /* View output */
942 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
943 { ALT ('.'), CK_ToggleShowHidden, "M-." },
944 { ALT (','), CK_TogglePanelsSplit, "M-," },
945 { XCTRL ('x'), CK_StartExtMap1, "C-x" },
946 /* Select/unselect group */
947 { KEY_KP_ADD, CK_SelectCmd, "+" },
948 { KEY_KP_SUBTRACT, CK_UnselectCmd, "-" },
949 { ALT ('*'), CK_ReverseSelectionCmd, "*" },
950 { 0, CK_Ignore_Key, "" }
953 const global_keymap_t default_main_x_map[] = {
954 { 'd', CK_CompareDirsCmd, "d" },
955 #ifdef ENABLE_VFS
956 { 'a', CK_ReselectVfs, "a"},
957 #endif /* ENABLE_VFS */
958 { 'p', CK_CopyCurrentPathname, "p" },
959 { XCTRL ('p'), CK_CopyOtherPathname, "C-p" },
960 { 't', CK_CopyCurrentTagged, "t" },
961 { XCTRL ('t'), CK_CopyOtherTagged, "C-t" },
962 { 'c', CK_ChmodCmd, "c" },
963 { 'o', CK_ChownCmd, "o" },
964 { 'r', CK_CopyCurrentReadlink, "r" },
965 { XCTRL ('r'), CK_CopyOtherReadlink, "C-r" },
966 { 'l', CK_LinkCmd, "l" },
967 { 's', CK_SymlinkCmd, "s" },
968 { 'v', CK_RelativeSymlinkCmd, "v" },
969 { XCTRL ('s'), CK_EditSymlinkCmd, "C-s" },
970 { 'i', CK_InfoCmd, "i" },
971 { 'q', CK_QuickViewCmd, "q" },
972 { 'h', CK_AddHotlist, "h" },
973 { '!', CK_ExternalPanelize, "!" },
974 #ifdef WITH_BACKGROUND
975 { 'j', CK_JobsCmd, "j" },
976 #endif /* WITH_BACKGROUND */
977 { 0, CK_Ignore_Key, "" }
980 const global_keymap_t default_input_keymap[] = {
981 /* Motion */
982 { XCTRL ('a'), CK_InputBol, "C-a" },
983 { KEY_HOME, CK_InputBol, "Home" },
984 { KEY_A1, CK_InputBol, "Home" },
985 { ALT ('<'), CK_InputBol, "M-<" },
986 { XCTRL ('e'), CK_InputEol, "C-e" },
987 { KEY_END, CK_InputEol, "End" },
988 { KEY_C1, CK_InputEol, "End" },
989 { ALT ('>'), CK_InputEol, "M->" },
990 { KEY_LEFT, CK_InputMoveLeft, "Left" },
991 { KEY_M_CTRL | KEY_LEFT, CK_InputWordLeft, "C-Left" },
992 { KEY_RIGHT, CK_InputMoveRight, "Right" },
993 { KEY_M_CTRL | KEY_RIGHT, CK_InputWordRight, "C-Right" },
995 { XCTRL ('b'), CK_InputBackwardChar, "C-b" },
996 { ALT ('b'), CK_InputBackwardWord, "M-b" },
997 { XCTRL ('f'), CK_InputForwardChar, "C-f" },
998 { ALT ('f'), CK_InputForwardWord, "M-f" },
1000 /* Editing */
1001 { KEY_BACKSPACE, CK_InputBackwardDelete, "BackSpace" },
1002 { KEY_DC, CK_InputDeleteChar, "Delete" },
1003 { ALT ('d'), CK_InputKillWord, "M-d" },
1004 { ALT (KEY_BACKSPACE), CK_InputBackwardKillWord, "M-BackSpace" },
1006 /* Region manipulation */
1007 { XCTRL ('w'), CK_InputKillRegion, "C-w" },
1008 { ALT ('w'), CK_InputKillSave, "M-w" },
1009 { XCTRL ('y'), CK_InputYank, "C-y" },
1010 { XCTRL ('k'), CK_InputKillLine, "C-k" },
1012 /* History */
1013 { ALT ('p'), CK_InputHistoryPrev, "M-p" },
1014 { ALT ('n'), CK_InputHistoryNext, "M-n" },
1015 { ALT ('h'), CK_InputHistoryShow, "M-h" },
1017 /* Completion */
1018 { ALT ('\t'), CK_InputComplete, "M-tab" },
1020 { 0, CK_Ignore_Key, "" }
1023 /* diff viewer */
1024 const global_keymap_t default_diff_keymap[] = {
1026 { 's', CK_DiffDisplaySymbols, "s" },
1027 { 'l', CK_DiffDisplayNumbers, "l" },
1028 { 'f', CK_DiffFull, "f" },
1029 { '=', CK_DiffEqual, "=" },
1030 { '>', CK_DiffSplitMore, ">" },
1031 { '<', CK_DiffSplitLess, "<" },
1032 { '2', CK_DiffSetTab2, "2" },
1033 { '3', CK_DiffSetTab3, "3" },
1034 { '4', CK_DiffSetTab4, "4" },
1035 { '8', CK_DiffSetTab8, "8" },
1036 { XCTRL ('u'), CK_DiffSwapPanel, "C-u" },
1037 { XCTRL ('r'), CK_DiffRedo, "C-r" },
1038 { XCTRL ('o'), CK_ShowCommandLine, "C-o" },
1039 { 'n', CK_DiffNextHunk, "n" },
1040 { 'p', CK_DiffPrevHunk, "p" },
1041 { 'g', CK_DiffGoto, "g" },
1042 { 'G', CK_DiffGoto, "G" },
1043 { KEY_M_CTRL | KEY_HOME, CK_DiffBOF, "C-Home" },
1044 { KEY_M_CTRL | KEY_END, CK_DiffEOF, "C-End" },
1045 { KEY_DOWN, CK_DiffDown, "Down" },
1046 { KEY_UP, CK_DiffUp, "Up" },
1047 { KEY_M_CTRL | KEY_LEFT, CK_DiffQuickLeft, "C-Left" },
1048 { KEY_M_CTRL | KEY_RIGHT, CK_DiffQuickRight, "C-Right" },
1049 { KEY_LEFT, CK_DiffLeft, "Left" },
1050 { KEY_RIGHT, CK_DiffRight, "Right" },
1051 { KEY_NPAGE, CK_DiffPageDown, "Down" },
1052 { KEY_PPAGE, CK_DiffPageUp, "Up" },
1053 { KEY_HOME, CK_DiffHome, "Home" },
1054 { KEY_END, CK_DiffEnd, "End" },
1055 { 'q', CK_DiffQuit, "q" },
1056 { 'Q', CK_DiffQuit, "Q" },
1057 { XCTRL ('g'), CK_DiffQuit, "C-g" },
1058 { ESC_CHAR, CK_DiffQuit, "Esc" },
1060 { KEY_F (1), CK_DiffHelp, "F1" },
1061 { KEY_F (4), CK_DiffEditCurrent, "F4" },
1062 { KEY_F (5), CK_DiffMergeCurrentHunk, "F5" },
1063 { KEY_F (7), CK_DiffSearch, "F7" },
1064 { KEY_F (17), CK_DiffContinueSearch, "S-F7" },
1065 { KEY_F (9), CK_DiffOptions, "F9" },
1066 { KEY_F (10), CK_DiffQuit, "F10" },
1067 { KEY_F (14), CK_DiffEditOther, "S-F4" },
1069 { 0, CK_Ignore_Key, "" }
1072 static int
1073 name_keymap_comparator (const void *p1, const void *p2)
1075 const name_keymap_t *m1 = (const name_keymap_t *) p1;
1076 const name_keymap_t *m2 = (const name_keymap_t *) p2;
1078 return str_casecmp (m1->name, m2->name);
1081 static inline void
1082 sort_command_names (void)
1084 static gboolean has_been_sorted = FALSE;
1086 if (!has_been_sorted) {
1087 qsort (command_names, num_command_names,
1088 sizeof (command_names[0]), &name_keymap_comparator);
1089 has_been_sorted = TRUE;
1093 static void
1094 keymap_add (GArray *keymap, long key, unsigned long cmd, const char *caption)
1096 if (key != 0 && cmd != CK_Ignore_Key) {
1097 global_keymap_t new_bind;
1099 new_bind.key = key;
1100 new_bind.command = cmd;
1101 g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
1102 g_array_append_val (keymap, new_bind);
1106 void
1107 keybind_cmd_bind (GArray *keymap, const char *keybind, unsigned long action)
1109 char *caption = NULL;
1110 long key;
1112 key = lookup_key (keybind, &caption);
1113 keymap_add (keymap, key, action, caption);
1114 g_free (caption);
1117 unsigned long
1118 lookup_action (const char *name)
1120 const name_keymap_t key = { name, 0 };
1121 name_keymap_t *res;
1123 sort_command_names ();
1125 res = bsearch (&key, command_names, num_command_names,
1126 sizeof (command_names[0]), name_keymap_comparator);
1128 return (res != NULL) ? res->val : CK_Ignore_Key;
1131 const char *
1132 lookup_keymap_shortcut (const global_keymap_t *keymap, unsigned long action)
1134 size_t i;
1136 for (i = 0; keymap[i].key != 0; i++)
1137 if (keymap[i].command == action)
1138 return (keymap[i].caption[0] != '\0') ? keymap[i].caption : NULL;
1140 return NULL;
1143 unsigned long
1144 lookup_keymap_command (const global_keymap_t *keymap, long key)
1146 size_t i;
1148 for (i = 0; keymap[i].key != 0; i++)
1149 if (keymap[i].key == key)
1150 return keymap[i].command;
1152 return CK_Ignore_Key;