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