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