2 Copyright (C) 2009 The Free Software Foundation, Inc.
4 Written by: 2005 Vitja Makarov
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,
30 #include <sys/types.h>
32 #include "lib/global.h"
33 #include "lib/tty/key.h" /* KEY_M_ */
34 #include "lib/strutil.h" /* str_casecmp() */
35 #include "lib/keybind.h"
37 /*** global variables ****************************************************************************/
39 /*** file scope macro definitions ****************************************************************/
41 /*** file scope type declarations ****************************************************************/
43 /*** file scope variables ************************************************************************/
45 static name_keymap_t command_names
[] = {
46 #ifdef USE_INTERNAL_EDIT
47 {"EditNoCommand", CK_Ignore_Key
},
48 {"EditIgnoreKey", CK_Ignore_Key
},
49 {"EditBackSpace", CK_BackSpace
},
50 {"EditDelete", CK_Delete
},
51 {"EditEnter", CK_Enter
},
52 {"EditPageUp", CK_Page_Up
},
53 {"EditPageDown", CK_Page_Down
},
54 {"EditLeft", CK_Left
},
55 {"EditRight", CK_Right
},
56 {"EditWordLeft", CK_Word_Left
},
57 {"EditWordRight", CK_Word_Right
},
59 {"EditDown", CK_Down
},
60 {"EditHome", CK_Home
},
63 {"EditUndo", CK_Undo
},
64 {"EditRedo", CK_Redo
},
65 {"EditBeginningOfText", CK_Beginning_Of_Text
},
66 {"EditEndOfText", CK_End_Of_Text
},
67 {"EditScrollUp", CK_Scroll_Up
},
68 {"EditScrollDown", CK_Scroll_Down
},
69 {"EditReturn", CK_Return
},
70 {"EditBeginPage", CK_Begin_Page
},
71 {"EditEndPage", CK_End_Page
},
72 {"EditDeleteWordLeft", CK_Delete_Word_Left
},
73 {"EditDeleteWordRight", CK_Delete_Word_Right
},
74 {"EditParagraphUp", CK_Paragraph_Up
},
75 {"EditParagraphDown", CK_Paragraph_Down
},
76 {"EditMenu", CK_Menu
},
77 {"EditSave", CK_Save
},
78 {"EditLoad", CK_Load
},
80 {"EditSaveas", CK_Save_As
},
81 {"EditMark", CK_Mark
},
82 {"EditCopy", CK_Copy
},
83 {"EditMove", CK_Move
},
84 {"EditRemove", CK_Remove
},
85 {"EditMarkAll", CK_Mark_All
},
86 {"EditUnmark", CK_Unmark
},
87 {"EditMarkWord", CK_Mark_Word
},
88 {"EditMarkLine", CK_Mark_Line
},
89 {"EditSaveBlock", CK_Save_Block
},
90 {"EditColumnMark", CK_Column_Mark
},
91 {"EditFind", CK_Find
},
92 {"EditFindAgain", CK_Find_Again
},
93 {"EditReplace", CK_Replace
},
94 {"EditReplaceAgain", CK_Replace_Again
},
95 {"EditCompleteWord", CK_Complete_Word
},
98 {"EditDebugStart", CK_Debug_Start
},
99 {"EditDebugStop", CK_Debug_Stop
},
100 {"EditDebugToggleBreak", CK_Debug_Toggle_Break
},
101 {"EditDebugClear", CK_Debug_Clear
},
102 {"EditDebugNext", CK_Debug_Next
},
103 {"EditDebugStep", CK_Debug_Step
},
104 {"EditDebugBackTrace", CK_Debug_Back_Trace
},
105 {"EditDebugContinue", CK_Debug_Continue
},
106 {"EditDebugEnterCommand", CK_Debug_Enter_Command
},
107 {"EditDebugUntilCurser", CK_Debug_Until_Curser
},
109 {"EditInsertFile", CK_Insert_File
},
110 {"EditQuit", CK_Quit
},
111 {"EditToggleInsert", CK_Toggle_Insert
},
112 {"EditHelp", CK_Help
},
113 {"EditDate", CK_Date
},
114 {"EditRefresh", CK_Refresh
},
115 {"EditGoto", CK_Goto
},
116 {"EditDeleteLine", CK_Delete_Line
},
117 {"EditDeleteToLineEnd", CK_Delete_To_Line_End
},
118 {"EditDeleteToLineBegin", CK_Delete_To_Line_Begin
},
119 {"EditManPage", CK_Man_Page
},
120 {"EditSort", CK_Sort
},
121 {"EditMail", CK_Mail
},
122 {"EditCancel", CK_Cancel
},
123 {"EditComplete", CK_Complete
},
124 {"EditParagraphFormat", CK_Paragraph_Format
},
125 {"EditUtil", CK_Util
},
126 {"EditTypeLoadPython", CK_Type_Load_Python
},
127 {"EditFindFile", CK_Find_File
},
128 {"EditCtags", CK_Ctags
},
129 {"EditMatchBracket", CK_Match_Bracket
},
130 {"EditTerminal", CK_Terminal
},
131 {"EditTerminalApp", CK_Terminal_App
},
132 {"EditExtCmd", CK_ExtCmd
},
133 {"EditUserMenu", CK_User_Menu
},
134 {"EditBeginRecordMacro", CK_Begin_Record_Macro
},
135 {"EditEndRecordMacro", CK_End_Record_Macro
},
136 {"EditDeleteMacro", CK_Delete_Macro
},
137 {"EditToggleBookmark", CK_Toggle_Bookmark
},
138 {"EditFlushBookmarks", CK_Flush_Bookmarks
},
139 {"EditNextBookmark", CK_Next_Bookmark
},
140 {"EditPrevBookmark", CK_Prev_Bookmark
},
141 {"EditPageUpHighlight", CK_Page_Up_Highlight
},
142 {"EditPageDownHighlight", CK_Page_Down_Highlight
},
143 {"EditLeftHighlight", CK_Left_Highlight
},
144 {"EditRightHighlight", CK_Right_Highlight
},
145 {"EditWordLeftHighlight", CK_Word_Left_Highlight
},
146 {"EditWordRightHighlight", CK_Word_Right_Highlight
},
147 {"EditUpHighlight", CK_Up_Highlight
},
148 {"EditDownHighlight", CK_Down_Highlight
},
149 {"EditHomeHighlight", CK_Home_Highlight
},
150 {"EditEndHighlight", CK_End_Highlight
},
151 {"EditBeginningOfTextHighlight", CK_Beginning_Of_Text_Highlight
},
152 {"EditEndOfTextHighlight", CK_End_Of_Text_Highlight
},
153 {"EditBeginPageHighlight", CK_Begin_Page_Highlight
},
154 {"EditEndPageHighlight", CK_End_Page_Highlight
},
155 {"EditScrollUpHighlight", CK_Scroll_Up_Highlight
},
156 {"EditScrollDownHighlight", CK_Scroll_Down_Highlight
},
157 {"EditParagraphUpHighlight", CK_Paragraph_Up_Highlight
},
158 {"EditParagraphDownHighlight", CK_Paragraph_Down_Highlight
},
160 {"EditPageUpAltHighlight", CK_Page_Up_Alt_Highlight
},
161 {"EditPageDownAltHighlight", CK_Page_Down_Alt_Highlight
},
162 {"EditLeftAltHighlight", CK_Left_Alt_Highlight
},
163 {"EditRightAltHighlight", CK_Right_Alt_Highlight
},
164 {"EditWordLeftAltHighlight", CK_Word_Left_Alt_Highlight
},
165 {"EditWordRightAltHighlight", CK_Word_Right_Alt_Highlight
},
166 {"EditUpAltHighlight", CK_Up_Alt_Highlight
},
167 {"EditDownAltHighlight", CK_Down_Alt_Highlight
},
168 {"EditHomeAltHighlight", CK_Home_Alt_Highlight
},
169 {"EditEndAltHighlight", CK_End_Alt_Highlight
},
170 {"EditBeginningOfTextAltHighlight", CK_Beginning_Of_Text_Alt_Highlight
},
171 {"EditEndOfTextAltHighlight", CK_End_Of_Text_Alt_Highlight
},
172 {"EditBeginPageAltHighlight", CK_Begin_Page_Alt_Highlight
},
173 {"EditEndPageAltHighlight", CK_End_Page_Alt_Highlight
},
174 {"EditScrollUpAltHighlight", CK_Scroll_Up_Alt_Highlight
},
175 {"EditScrollDownAltHighlight", CK_Scroll_Down_Alt_Highlight
},
176 {"EditParagraphUpAltHighlight", CK_Paragraph_Up_Alt_Highlight
},
177 {"EditParagraphDownAltHighlight", CK_Paragraph_Down_Alt_Highlight
},
179 {"EditShiftBlockLeft", CK_Shift_Block_Left
},
180 {"EditShiftBlockRight", CK_Shift_Block_Right
},
182 {"EditXStore", CK_XStore
},
183 {"EditXCut", CK_XCut
},
184 {"EditXPaste", CK_XPaste
},
185 {"EditSelectionHistory", CK_Selection_History
},
186 {"EditShell", CK_Shell
},
187 {"EditInsertLiteral", CK_Insert_Literal
},
188 {"EditExecuteMacro", CK_Execute_Macro
},
189 {"EditBeginOrEndMacro", CK_Begin_End_Macro
},
190 {"EditExtMode", CK_Ext_Mode
},
191 {"EditToggleLineState", CK_Toggle_Line_State
},
192 {"EditToggleTabTWS", CK_Toggle_Tab_TWS
},
193 {"EditToggleSyntax", CK_Toggle_Syntax
},
194 {"EditToggleShowMargin", CK_Toggle_Show_Margin
},
195 {"EditFindDefinition", CK_Find_Definition
},
196 {"EditLoadPrevFile", CK_Load_Prev_File
},
197 {"EditLoadNextFile", CK_Load_Next_File
},
198 {"EditOptions", CK_Edit_Options
},
199 {"EditSaveMode", CK_Edit_Save_Mode
},
200 {"EditChooseSyntax", CK_Choose_Syntax
},
201 {"EditAbout", CK_About
},
204 {"EditFocusNext", CK_Focus_Next
},
205 {"EditFocusPrev", CK_Focus_Prev
},
206 {"EditHeightInc", CK_Height_Inc
},
207 {"EditHeightDec", CK_Height_Dec
},
208 {"EditMake", CK_Make
},
209 {"EditErrorNext", CK_Error_Next
},
210 {"EditErrorPrev", CK_Error_Prev
},
214 {"EditSaveDesktop", CK_Save_Desktop
},
215 {"EditNewWindow", CK_New_Window
},
216 {"EditCycle", CK_Cycle
},
217 {"EditSaveAndQuit", CK_Save_And_Quit
},
218 {"EditRunAnother", CK_Run_Another
},
219 {"EditCheckSaveAndQuit", CK_Check_Save_And_Quit
},
220 {"EditMaximize", CK_Maximize
},
223 #endif /* USE_INTERNAL_EDIT */
226 {"ViewHelp", CK_ViewHelp
},
227 {"ViewToggleWrapMode", CK_ViewToggleWrapMode
},
228 {"ViewToggleHexEditMode", CK_ViewToggleHexEditMode
},
229 {"ViewQuit", CK_ViewQuit
},
230 {"ViewToggleHexMode", CK_ViewToggleHexMode
},
231 {"ViewGoto", CK_ViewGoto
},
232 {"ViewHexEditSave", CK_ViewHexEditSave
},
233 {"ViewSearch", CK_ViewSearch
},
234 {"ViewToggleMagicMode", CK_ViewToggleMagicMode
},
235 {"ViewToggleNroffMode", CK_ViewToggleNroffMode
},
236 {"ViewContinueSearch", CK_ViewContinueSearch
},
237 {"ViewGotoBookmark", CK_ViewGotoBookmark
},
238 {"ViewNewBookmark", CK_ViewNewBookmark
},
239 {"ViewMoveUp", CK_ViewMoveUp
},
240 {"ViewMoveDown", CK_ViewMoveDown
},
241 {"ViewMoveLeft", CK_ViewMoveLeft
},
242 {"ViewMoveRight", CK_ViewMoveRight
},
243 {"ViewMoveLeft10", CK_ViewMoveLeft10
},
244 {"ViewMoveRight10", CK_ViewMoveRight10
},
245 {"ViewMovePgDn", CK_ViewMovePgDn
},
246 {"ViewMovePgUp", CK_ViewMovePgUp
},
247 {"ViewMoveHalfPgDn", CK_ViewMoveHalfPgDn
},
248 {"ViewMoveHalfPgUp", CK_ViewMoveHalfPgUp
},
249 {"ViewMoveToBol", CK_ViewMoveToBol
},
250 {"ViewMoveToEol", CK_ViewMoveToEol
},
251 {"ViewMoveTop", CK_ViewMoveTop
},
252 {"ViewMoveBottom", CK_ViewMoveBottom
},
253 {"ViewNextFile", CK_ViewNextFile
},
254 {"ViewPrevFile", CK_ViewPrevFile
},
255 {"ViewToggleRuler", CK_ViewToggleRuler
},
256 {"ViewToggleHexNavMode", CK_ViewToggleHexNavMode
},
259 {"HelpHelp", CK_HelpHelp
},
260 {"HelpIndex", CK_HelpIndex
},
261 {"HelpBack", CK_HelpBack
},
262 {"HelpQuit", CK_HelpQuit
},
263 {"HelpMoveUp", CK_HelpMoveUp
},
264 {"HelpMoveDown", CK_HelpMoveDown
},
265 {"HelpMovePgDn", CK_HelpMovePgDn
},
266 {"HelpMovePgUp", CK_HelpMovePgUp
},
267 {"HelpMoveHalfPgDn", CK_HelpMoveHalfPgDn
},
268 {"HelpMoveHalfPgUp", CK_HelpMoveHalfPgUp
},
269 {"HelpMoveTop", CK_HelpMoveTop
},
270 {"HelpMoveBottom", CK_HelpMoveBottom
},
271 {"HelpSelectLink", CK_HelpSelectLink
},
272 {"HelpNextLink", CK_HelpNextLink
},
273 {"HelpPrevLink", CK_HelpPrevLink
},
274 {"HelpNextNode", CK_HelpNextNode
},
275 {"HelpPrevNode", CK_HelpPrevNode
},
278 {"TreeHelp", CK_TreeHelp
},
279 {"TreeForget", CK_TreeForget
},
280 {"TreeToggleNav", CK_TreeToggleNav
},
281 {"TreeCopy", CK_TreeCopy
},
282 {"TreeMove", CK_TreeMove
},
283 {"TreeMake", CK_TreeMake
},
284 {"TreeMoveUp", CK_TreeMoveUp
},
285 {"TreeMoveDown", CK_TreeMoveDown
},
286 {"TreeMoveLeft", CK_TreeMoveLeft
},
287 {"TreeMoveRight", CK_TreeMoveRight
},
288 {"TreeMoveHome", CK_TreeMoveHome
},
289 {"TreeMoveEnd", CK_TreeMoveEnd
},
290 {"TreeMovePgUp", CK_TreeMovePgUp
},
291 {"TreeMovePgDn", CK_TreeMovePgDn
},
292 {"TreeOpen", CK_TreeOpen
},
293 {"TreeRescan", CK_TreeRescan
},
294 {"TreeStartSearch", CK_TreeStartSearch
},
295 {"TreeRemove", CK_TreeRemove
},
298 {"CmdHelp", CK_HelpCmd
},
299 {"CmdMenu", CK_MenuCmd
},
300 {"CmdChmod", CK_ChmodCmd
},
301 {"CmdMenuLastSelected", CK_MenuLastSelectedCmd
},
302 {"CmdSingleDirsize", CK_SingleDirsizeCmd
},
303 {"CmdCopyCurrentPathname", CK_CopyCurrentPathname
},
304 {"CmdCopyOtherPathname", CK_CopyOtherPathname
},
305 {"CmdSuspend", CK_SuspendCmd
},
306 {"CmdToggleListing", CK_ToggleListingCmd
},
307 {"CmdChownAdvanced", CK_ChownAdvancedCmd
},
308 {"CmdChown", CK_ChownCmd
},
309 {"CmdCompareDirs", CK_CompareDirsCmd
},
310 {"CmdConfigureBox", CK_ConfigureBox
},
311 {"CmdConfigureVfs", CK_ConfigureVfs
},
312 {"CmdConfirmBox", CK_ConfirmBox
},
313 {"CmdCopy", CK_CopyCmd
},
314 {"CmdDelete", CK_DeleteCmd
},
315 {"CmdDirsizes", CK_DirsizesCmd
},
316 {"CmdDisplayBitsBox", CK_DisplayBitsBox
},
317 {"CmdEdit", CK_EditCmd
},
318 #ifdef USE_INTERNAL_EDIT
319 {"CmdEditForceInternal", CK_EditForceInternalCmd
},
321 {"CmdEditExtFile", CK_EditExtFileCmd
},
322 {"CmdEditFhlFile", CK_EditFhlFileCmd
},
323 {"CmdEditMcMenu", CK_EditMcMenuCmd
},
324 {"CmdEditSymlink", CK_EditSymlinkCmd
},
325 {"CmdEditSyntax", CK_EditSyntaxCmd
},
326 {"CmdEditUserMenu", CK_EditUserMenuCmd
},
327 {"CmdExternalPanelize", CK_ExternalPanelize
},
328 {"CmdFilter", CK_FilterCmd
},
329 {"CmdFilteredView", CK_FilteredViewCmd
},
330 {"CmdFind", CK_FindCmd
},
331 #ifdef ENABLE_VFS_FISH
332 {"CmdFishlink", CK_FishlinkCmd
},
334 #ifdef ENABLE_VFS_FTP
335 {"CmdFtplink", CK_FtplinkCmd
},
337 {"CmdHistory", CK_HistoryCmd
},
338 {"CmdInfo", CK_InfoCmd
},
339 #ifdef WITH_BACKGROUND
340 {"CmdJobs", CK_JobsCmd
},
342 {"CmdLayout", CK_LayoutBox
},
343 {"CmdLearnKeys", CK_LearnKeys
},
344 {"CmdLink", CK_LinkCmd
},
345 {"CmdChangeListing", CK_ChangeListingCmd
},
346 {"CmdListing", CK_ListingCmd
},
347 #ifdef LISTMODE_EDITOR
348 {"CmdListmodeCmd", CK_ListmodeCmd
}.
350 {"CmdMkdir", CK_MkdirCmd
},
351 {"CmdPanelOptions", CK_PanelOptionsBox
},
352 {"CmdQuickCd", CK_QuickCdCmd
},
353 {"CmdQuickChdir", CK_QuickChdirCmd
},
354 {"CmdQuickView", CK_QuickViewCmd
},
355 {"CmdQuietQuit", CK_QuietQuitCmd
},
356 {"CmdRelativeSymlink", CK_RelativeSymlinkCmd
},
357 {"CmdRename", CK_RenameCmd
},
358 {"CmdReread", CK_RereadCmd
},
359 {"CmdReselectVfs", CK_ReselectVfs
},
360 {"CmdReverseSelection", CK_ReverseSelectionCmd
},
361 {"CmdSaveSetup", CK_SaveSetupCmd
},
362 {"CmdSelect", CK_SelectCmd
},
363 #ifdef ENABLE_VFS_SMB
364 {"CmdSmblinkCmd", CK_SmblinkCmd
},
366 {"CmdSwapPanel", CK_SwapCmd
},
367 {"CmdSymlink", CK_SymlinkCmd
},
368 {"CmdTree", CK_TreeCmd
},
369 {"CmdTreeBox", CK_TreeBoxCmd
},
370 #ifdef ENABLE_VFS_UNDELFS
371 {"CmdUndelete", CK_UndeleteCmd
},
373 {"CmdUnselect", CK_UnselectCmd
},
374 {"CmdUserMenu", CK_UserMenuCmd
},
375 {"CmdUserFileMenu", CK_UserFileMenuCmd
},
376 {"CmdView", CK_ViewCmd
},
377 {"CmdViewFile", CK_ViewFileCmd
},
378 {"CmdCopyCurrentReadlink", CK_CopyCurrentReadlink
},
379 {"CmdCopyOtherReadlink", CK_CopyOtherReadlink
},
380 {"CmdAddHotlist", CK_AddHotlist
},
381 {"CmdQuit", CK_QuitCmd
},
382 {"CmdCopyCurrentTagged", CK_CopyCurrentTagged
},
383 {"CmdCopyOtherTagged", CK_CopyOtherTagged
},
384 {"CmdToggleShowHidden", CK_ToggleShowHidden
},
385 {"CmdTogglePanelsSplit", CK_TogglePanelsSplit
},
387 {"CmdDiffView", CK_DiffViewCmd
},
389 {"CmdDialogList", CK_DialogListCmd
},
390 {"CmdDialogNext", CK_DialogNextCmd
},
391 {"CmdDialogPrev", CK_DialogPrevCmd
},
394 {"PanelChdirOtherPanel", CK_PanelChdirOtherPanel
},
395 {"PanelChdirToReadlink", CK_PanelChdirToReadlink
},
396 {"PanelCopyLocal", CK_PanelCmdCopyLocal
},
397 {"PanelDeleteLocal", CK_PanelCmdDeleteLocal
},
398 {"PanelDoEnter", CK_PanelCmdDoEnter
},
399 {"PanelEditNew", CK_PanelCmdEditNew
},
400 {"PanelRenameLocal", CK_PanelCmdRenameLocal
},
401 {"PanelReverseSelection", CK_PanelCmdReverseSelection
},
402 {"PanelSelect", CK_PanelCmdSelect
},
403 {"PanelUnselect", CK_PanelCmdUnselect
},
404 {"PanelViewSimple", CK_PanelCmdViewSimple
},
405 {"PanelGotoParentDir", CK_PanelGotoParentDir
},
406 {"PanelGotoChildDir", CK_PanelGotoChildDir
},
407 {"PanelDirectoryHistoryList", CK_PanelDirectoryHistoryList
},
408 {"PanelDirectoryHistoryNext", CK_PanelDirectoryHistoryNext
},
409 {"PanelDirectoryHistoryPrev", CK_PanelDirectoryHistoryPrev
},
410 {"PanelGotoBottomFile", CK_PanelGotoBottomFile
},
411 {"PanelGotoMiddleFile", CK_PanelGotoMiddleFile
},
412 {"PanelGotoTopFile", CK_PanelGotoTopFile
},
413 {"PanelMarkFile", CK_PanelMarkFile
},
414 {"PanelMarkFileDown", CK_PanelMarkFileDown
},
415 {"PanelMarkFileUp", CK_PanelMarkFileUp
},
416 {"PanelMoveUp", CK_PanelMoveUp
},
417 {"PanelMoveDown", CK_PanelMoveDown
},
418 {"PanelMoveLeft", CK_PanelMoveLeft
},
419 {"PanelMoveRight", CK_PanelMoveRight
},
420 {"PanelMoveEnd", CK_PanelMoveEnd
},
421 {"PanelMoveHome", CK_PanelMoveHome
},
422 {"PanelNextPage", CK_PanelNextPage
},
423 {"PanelPrevPage", CK_PanelPrevPage
},
425 {"PanelSetPanelEncoding", CK_PanelSetPanelEncoding
},
427 {"PanelStartSearch", CK_PanelStartSearch
},
428 {"PanelSyncOtherPanel", CK_PanelSyncOtherPanel
},
429 {"PanelToggleSortOrderNext", CK_PanelToggleSortOrderNext
},
430 {"PanelToggleSortOrderPrev", CK_PanelToggleSortOrderPrev
},
431 {"PanelSelectSortOrder", CK_PanelSelectSortOrder
},
432 {"PanelReverseSort", CK_PanelReverseSort
},
433 {"PanelSortOrderByName", CK_PanelSortOrderByName
},
434 {"PanelSortOrderByExt", CK_PanelSortOrderByExt
},
435 {"PanelSortOrderBySize", CK_PanelSortOrderBySize
},
436 {"PanelSortOrderByMTime", CK_PanelSortOrderByMTime
},
437 {"PanelSmartGotoParentDir", CK_PanelSmartGotoParentDir
},
440 {"InputBol", CK_InputBol
},
441 {"InputEol", CK_InputEol
},
442 {"InputMoveLeft", CK_InputMoveLeft
},
443 {"InputWordLeft", CK_InputWordLeft
},
444 {"InputBackwardChar", CK_InputBackwardChar
},
445 {"InputBackwardWord", CK_InputBackwardWord
},
446 {"InputMoveRight", CK_InputMoveRight
},
447 {"InputWordRight", CK_InputWordRight
},
448 {"InputForwardChar", CK_InputForwardChar
},
449 {"InputForwardWord", CK_InputForwardWord
},
450 {"InputBackwardDelete", CK_InputBackwardDelete
},
451 {"InputDeleteChar", CK_InputDeleteChar
},
452 {"InputKillWord", CK_InputKillWord
},
453 {"InputBackwardKillWord", CK_InputBackwardKillWord
},
454 {"InputSetMark", CK_InputSetMark
},
455 {"InputKillRegion", CK_InputKillRegion
},
456 {"InputYank", CK_InputYank
},
457 {"InputKillLine", CK_InputKillLine
},
458 {"InputHistoryPrev", CK_InputHistoryPrev
},
459 {"InputHistoryNext", CK_InputHistoryNext
},
460 {"InputHistoryShow", CK_InputHistoryShow
},
461 {"InputComplete", CK_InputComplete
},
462 {"InputXStore", CK_InputKillSave
},
463 {"InputXPaste", CK_InputPaste
},
464 {"InputClearLine", CK_InputClearLine
},
465 {"InputLeftHighlight", CK_InputLeftHighlight
},
466 {"InputRightHighlight", CK_InputRightHighlight
},
467 {"InputWordLeftHighlight", CK_InputWordLeftHighlight
},
468 {"InputWordRightHighlight", CK_InputWordRightHighlight
},
469 {"InputBolHighlight", CK_InputBolHighlight
},
470 {"InputEolHighlight", CK_InputEolHighlight
},
473 {"ListboxMoveUp", CK_ListboxMoveUp
},
474 {"ListboxMoveDown", CK_ListboxMoveDown
},
475 {"ListboxMoveHome", CK_ListboxMoveHome
},
476 {"ListboxMoveEnd", CK_ListboxMoveEnd
},
477 {"ListboxMovePgUp", CK_ListboxMovePgUp
},
478 {"ListboxMovePgDn", CK_ListboxMovePgDn
},
479 {"ListboxDeleteItem", CK_ListboxDeleteItem
},
480 {"ListboxDeleteAll", CK_ListboxDeleteAll
},
483 {"ExtMap1", CK_StartExtMap1
},
484 {"ExtMap2", CK_StartExtMap2
},
485 {"ShowCommandLine", CK_ShowCommandLine
},
486 {"SelectCodepage", CK_SelectCodepage
},
489 {"DialogOK", CK_DialogOK
},
490 {"DialogCancel", CK_DialogCancel
},
491 {"DialogPrevItem", CK_DialogPrevItem
},
492 {"DialogNextItem", CK_DialogNextItem
},
493 {"DialogHelp", CK_DialogHelp
},
494 {"DialogSuspend", CK_DialogSuspend
},
495 {"DialogRefresh", CK_DialogRefresh
},
499 {"DiffDisplaySymbols", CK_DiffDisplaySymbols
},
500 {"DiffDisplayNumbers", CK_DiffDisplayNumbers
},
501 {"DiffFull", CK_DiffFull
},
502 {"DiffEqual", CK_DiffEqual
},
503 {"DiffSplitMore", CK_DiffSplitMore
},
504 {"DiffSplitLess", CK_DiffSplitLess
},
505 {"DiffShowDiff", CK_DiffShowDiff
},
506 {"DiffSetTab2", CK_DiffSetTab2
},
507 {"DiffSetTab3", CK_DiffSetTab3
},
508 {"DiffSetTab4", CK_DiffSetTab4
},
509 {"DiffSetTab8", CK_DiffSetTab8
},
510 {"DiffSwapPanel", CK_DiffSwapPanel
},
511 {"DiffRedo", CK_DiffRedo
},
512 {"DiffNextHunk", CK_DiffNextHunk
},
513 {"DiffPrevHunk", CK_DiffPrevHunk
},
514 {"DiffGoto", CK_DiffGoto
},
515 {"DiffEditCurrent", CK_DiffEditCurrent
},
516 {"DiffEditOther", CK_DiffEditOther
},
517 {"DiffSearch", CK_DiffSearch
},
518 {"DiffContinueSearch", CK_DiffContinueSearch
},
519 {"DiffEOF", CK_DiffEOF
},
520 {"DiffBOF", CK_DiffBOF
},
521 {"DiffDown", CK_DiffDown
},
522 {"DiffUp", CK_DiffUp
},
523 {"DiffLeft", CK_DiffLeft
},
524 {"DiffRight", CK_DiffRight
},
525 {"DiffPageDown", CK_DiffPageDown
},
526 {"DiffPageUp", CK_DiffPageUp
},
527 {"DiffHome", CK_DiffHome
},
528 {"DiffEnd", CK_DiffEnd
},
529 {"DiffQuit", CK_DiffQuit
},
530 {"DiffHelp", CK_DiffHelp
},
531 {"SelectCodepage", CK_SelectCodepage
},
532 {"DiffMergeCurrentHunk", CK_DiffMergeCurrentHunk
},
533 {"DiffSave", CK_DiffSave
},
534 {"DiffOptions", CK_DiffOptions
},
537 {NULL
, CK_Ignore_Key
}
540 static const size_t num_command_names
= sizeof (command_names
) / sizeof (command_names
[0]) - 1;
542 /*** file scope functions ************************************************************************/
543 /* --------------------------------------------------------------------------------------------- */
546 name_keymap_comparator (const void *p1
, const void *p2
)
548 const name_keymap_t
*m1
= (const name_keymap_t
*) p1
;
549 const name_keymap_t
*m2
= (const name_keymap_t
*) p2
;
551 return str_casecmp (m1
->name
, m2
->name
);
554 /* --------------------------------------------------------------------------------------------- */
557 sort_command_names (void)
559 static gboolean has_been_sorted
= FALSE
;
561 if (!has_been_sorted
)
563 qsort (command_names
, num_command_names
,
564 sizeof (command_names
[0]), &name_keymap_comparator
);
565 has_been_sorted
= TRUE
;
569 /* --------------------------------------------------------------------------------------------- */
572 keymap_add (GArray
* keymap
, long key
, unsigned long cmd
, const char *caption
)
574 if (key
!= 0 && cmd
!= CK_Ignore_Key
)
576 global_keymap_t new_bind
;
579 new_bind
.command
= cmd
;
580 g_snprintf (new_bind
.caption
, sizeof (new_bind
.caption
), "%s", caption
);
581 g_array_append_val (keymap
, new_bind
);
585 /* --------------------------------------------------------------------------------------------- */
586 /*** public functions ****************************************************************************/
587 /* --------------------------------------------------------------------------------------------- */
590 keybind_cmd_bind (GArray
* keymap
, const char *keybind
, unsigned long action
)
592 char *caption
= NULL
;
595 key
= lookup_key (keybind
, &caption
);
596 keymap_add (keymap
, key
, action
, caption
);
600 /* --------------------------------------------------------------------------------------------- */
603 keybind_lookup_action (const char *name
)
605 const name_keymap_t key
= { name
, 0 };
608 sort_command_names ();
610 res
= bsearch (&key
, command_names
, num_command_names
,
611 sizeof (command_names
[0]), name_keymap_comparator
);
613 return (res
!= NULL
) ? res
->val
: CK_Ignore_Key
;
616 /* --------------------------------------------------------------------------------------------- */
619 keybind_lookup_keymap_shortcut (const global_keymap_t
* keymap
, unsigned long action
)
623 for (i
= 0; keymap
[i
].key
!= 0; i
++)
624 if (keymap
[i
].command
== action
)
625 return (keymap
[i
].caption
[0] != '\0') ? keymap
[i
].caption
: NULL
;
630 /* --------------------------------------------------------------------------------------------- */
633 keybind_lookup_keymap_command (const global_keymap_t
* keymap
, long key
)
637 for (i
= 0; keymap
[i
].key
!= 0; i
++)
638 if (keymap
[i
].key
== key
)
639 return keymap
[i
].command
;
641 return CK_Ignore_Key
;
644 /* --------------------------------------------------------------------------------------------- */