2010-11-18 12:39:09 +03:00
|
|
|
/*
|
2011-10-15 14:56:47 +04:00
|
|
|
Definitions of key bindings.
|
2010-11-18 12:39:09 +03:00
|
|
|
|
2020-01-18 19:54:37 +03:00
|
|
|
Copyright (C) 2005-2020
|
2014-02-12 10:33:10 +04:00
|
|
|
Free Software Foundation, Inc.
|
2011-10-15 14:56:47 +04:00
|
|
|
|
|
|
|
Written by:
|
|
|
|
Vitja Makarov, 2005
|
2012-04-26 14:05:48 +04:00
|
|
|
Ilia Maslakov <il.smind@gmail.com>, 2009, 2012
|
2011-07-23 15:30:31 +04:00
|
|
|
Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2011, 2012
|
2010-11-18 12:39:09 +03:00
|
|
|
|
|
|
|
This file is part of the Midnight Commander.
|
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is free software: you can redistribute it
|
2010-11-18 12:39:09 +03:00
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
2011-10-15 14:56:47 +04:00
|
|
|
published by the Free Software Foundation, either version 3 of the License,
|
|
|
|
or (at your option) any later version.
|
2010-11-18 12:39:09 +03:00
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2010-11-18 12:39:09 +03:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2011-10-15 14:56:47 +04:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-18 12:39:09 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "lib/global.h"
|
|
|
|
#include "lib/tty/key.h" /* KEY_M_ */
|
|
|
|
#include "lib/keybind.h"
|
|
|
|
|
|
|
|
/*** global variables ****************************************************************************/
|
|
|
|
|
|
|
|
/*** file scope macro definitions ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope type declarations ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope variables ************************************************************************/
|
|
|
|
|
|
|
|
static name_keymap_t command_names[] = {
|
2011-01-21 10:02:12 +03:00
|
|
|
/* common */
|
2012-03-21 17:18:20 +04:00
|
|
|
{"InsertChar", CK_InsertChar},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Enter", CK_Enter},
|
2016-09-14 13:56:24 +03:00
|
|
|
{"ChangePanel", CK_ChangePanel},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Up", CK_Up},
|
|
|
|
{"Down", CK_Down},
|
|
|
|
{"Left", CK_Left},
|
|
|
|
{"Right", CK_Right},
|
|
|
|
{"LeftQuick", CK_LeftQuick},
|
|
|
|
{"RightQuick", CK_RightQuick},
|
|
|
|
{"Home", CK_Home},
|
|
|
|
{"End", CK_End},
|
|
|
|
{"PageUp", CK_PageUp},
|
|
|
|
{"PageDown", CK_PageDown},
|
|
|
|
{"HalfPageUp", CK_HalfPageUp},
|
|
|
|
{"HalfPageDown", CK_HalfPageDown},
|
|
|
|
{"Top", CK_Top},
|
|
|
|
{"Bottom", CK_Bottom},
|
|
|
|
{"TopOnScreen", CK_TopOnScreen},
|
|
|
|
{"MiddleOnScreen", CK_MiddleOnScreen},
|
|
|
|
{"BottomOnScreen", CK_BottomOnScreen},
|
|
|
|
{"WordLeft", CK_WordLeft},
|
|
|
|
{"WordRight", CK_WordRight},
|
|
|
|
{"Copy", CK_Copy},
|
|
|
|
{"Move", CK_Move},
|
|
|
|
{"Delete", CK_Delete},
|
|
|
|
{"MakeDir", CK_MakeDir},
|
|
|
|
{"ChangeMode", CK_ChangeMode},
|
|
|
|
{"ChangeOwn", CK_ChangeOwn},
|
|
|
|
{"ChangeOwnAdvanced", CK_ChangeOwnAdvanced},
|
2020-04-12 10:46:29 +03:00
|
|
|
#ifdef ENABLE_EXT2FS_ATTR
|
|
|
|
{"ChangeAttributes", CK_ChangeAttributes},
|
|
|
|
#endif
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Remove", CK_Remove},
|
|
|
|
{"BackSpace", CK_BackSpace},
|
|
|
|
{"Redo", CK_Redo},
|
|
|
|
{"Clear", CK_Clear},
|
|
|
|
{"Menu", CK_Menu},
|
|
|
|
{"MenuLastSelected", CK_MenuLastSelected},
|
|
|
|
{"UserMenu", CK_UserMenu},
|
|
|
|
{"EditUserMenu", CK_EditUserMenu},
|
|
|
|
{"Search", CK_Search},
|
|
|
|
{"SearchContinue", CK_SearchContinue},
|
|
|
|
{"Replace", CK_Replace},
|
|
|
|
{"ReplaceContinue", CK_ReplaceContinue},
|
|
|
|
{"Help", CK_Help},
|
|
|
|
{"Shell", CK_Shell},
|
|
|
|
{"Edit", CK_Edit},
|
|
|
|
{"EditNew", CK_EditNew},
|
|
|
|
#ifdef HAVE_CHARSET
|
2011-01-21 10:02:12 +03:00
|
|
|
{"SelectCodepage", CK_SelectCodepage},
|
2011-01-21 11:47:27 +03:00
|
|
|
#endif
|
2012-02-14 10:49:53 +04:00
|
|
|
{"EditorViewerHistory", CK_EditorViewerHistory},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"History", CK_History},
|
|
|
|
{"HistoryNext", CK_HistoryNext},
|
|
|
|
{"HistoryPrev", CK_HistoryPrev},
|
|
|
|
{"Complete", CK_Complete},
|
|
|
|
{"Save", CK_Save},
|
|
|
|
{"SaveAs", CK_SaveAs},
|
|
|
|
{"Goto", CK_Goto},
|
|
|
|
{"Reread", CK_Reread},
|
|
|
|
{"Refresh", CK_Refresh},
|
|
|
|
{"Suspend", CK_Suspend},
|
|
|
|
{"Swap", CK_Swap},
|
|
|
|
{"HotList", CK_HotList},
|
|
|
|
{"SelectInvert", CK_SelectInvert},
|
|
|
|
{"ScreenList", CK_ScreenList},
|
|
|
|
{"ScreenNext", CK_ScreenNext},
|
|
|
|
{"ScreenPrev", CK_ScreenPrev},
|
|
|
|
{"FileNext", CK_FileNext},
|
|
|
|
{"FilePrev", CK_FilePrev},
|
2012-01-09 21:03:46 +04:00
|
|
|
{"DeleteToHome", CK_DeleteToHome},
|
|
|
|
{"DeleteToEnd", CK_DeleteToEnd},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"DeleteToWordBegin", CK_DeleteToWordBegin},
|
|
|
|
{"DeleteToWordEnd", CK_DeleteToWordEnd},
|
|
|
|
{"Cut", CK_Cut},
|
|
|
|
{"Store", CK_Store},
|
|
|
|
{"Paste", CK_Paste},
|
|
|
|
{"Mark", CK_Mark},
|
|
|
|
{"MarkLeft", CK_MarkLeft},
|
|
|
|
{"MarkRight", CK_MarkRight},
|
|
|
|
{"MarkUp", CK_MarkUp},
|
|
|
|
{"MarkDown", CK_MarkDown},
|
|
|
|
{"MarkToWordBegin", CK_MarkToWordBegin},
|
|
|
|
{"MarkToWordEnd", CK_MarkToWordEnd},
|
|
|
|
{"MarkToHome", CK_MarkToHome},
|
|
|
|
{"MarkToEnd", CK_MarkToEnd},
|
|
|
|
{"ToggleNavigation", CK_ToggleNavigation},
|
|
|
|
{"Sort", CK_Sort},
|
|
|
|
{"Options", CK_Options},
|
|
|
|
{"LearnKeys", CK_LearnKeys},
|
|
|
|
{"Bookmark", CK_Bookmark},
|
|
|
|
{"Quit", CK_Quit},
|
|
|
|
{"QuitQuiet", CK_QuitQuiet},
|
|
|
|
{"ExtendedKeyMap", CK_ExtendedKeyMap},
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* main commands */
|
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2011-01-21 11:47:27 +03:00
|
|
|
{"EditForceInternal", CK_EditForceInternal},
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2011-01-21 11:47:27 +03:00
|
|
|
{"View", CK_View},
|
|
|
|
{"ViewRaw", CK_ViewRaw},
|
|
|
|
{"ViewFile", CK_ViewFile},
|
|
|
|
{"ViewFiltered", CK_ViewFiltered},
|
|
|
|
{"Find", CK_Find},
|
|
|
|
{"DirSize", CK_DirSize},
|
|
|
|
{"CompareDirs", CK_CompareDirs},
|
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
{"CompareFiles", CK_CompareFiles},
|
|
|
|
#endif
|
|
|
|
{"OptionsVfs", CK_OptionsVfs},
|
|
|
|
{"OptionsConfirm", CK_OptionsConfirm},
|
|
|
|
{"OptionsDisplayBits", CK_OptionsDisplayBits},
|
|
|
|
{"EditExtensionsFile", CK_EditExtensionsFile},
|
|
|
|
{"EditFileHighlightFile", CK_EditFileHighlightFile},
|
|
|
|
{"LinkSymbolicEdit", CK_LinkSymbolicEdit},
|
|
|
|
{"ExternalPanelize", CK_ExternalPanelize},
|
|
|
|
{"Filter", CK_Filter},
|
2011-01-21 10:02:12 +03:00
|
|
|
#ifdef ENABLE_VFS_FISH
|
2011-01-21 11:47:27 +03:00
|
|
|
{"ConnectFish", CK_ConnectFish},
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_VFS_FTP
|
2011-01-21 11:47:27 +03:00
|
|
|
{"ConnectFtp", CK_ConnectFtp},
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2012-04-13 14:40:53 +04:00
|
|
|
#ifdef ENABLE_VFS_SFTP
|
|
|
|
{"ConnectSftp", CK_ConnectSftp},
|
|
|
|
#endif
|
2011-01-21 11:47:27 +03:00
|
|
|
#ifdef ENABLE_VFS_SMB
|
|
|
|
{"ConnectSmb", CK_ConnectSmb},
|
|
|
|
#endif
|
|
|
|
{"PanelInfo", CK_PanelInfo},
|
2012-01-09 15:48:39 +04:00
|
|
|
#ifdef ENABLE_BACKGROUND
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Jobs", CK_Jobs},
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2011-01-21 11:47:27 +03:00
|
|
|
{"OptionsLayout", CK_OptionsLayout},
|
2014-02-08 19:37:11 +04:00
|
|
|
{"OptionsAppearance", CK_OptionsAppearance},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Link", CK_Link},
|
2017-04-23 11:11:35 +03:00
|
|
|
{"SetupListingFormat", CK_SetupListingFormat},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"PanelListing", CK_PanelListing},
|
2011-01-21 10:02:12 +03:00
|
|
|
#ifdef LISTMODE_EDITOR
|
2011-01-21 11:47:27 +03:00
|
|
|
{"ListMode", CK_ListMode}.
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2011-01-21 11:47:27 +03:00
|
|
|
{"OptionsPanel", CK_OptionsPanel},
|
|
|
|
{"CdQuick", CK_CdQuick},
|
|
|
|
{"PanelQuickView", CK_PanelQuickView},
|
|
|
|
{"LinkSymbolicRelative", CK_LinkSymbolicRelative},
|
|
|
|
{"VfsList", CK_VfsList},
|
|
|
|
{"SaveSetup", CK_SaveSetup},
|
|
|
|
{"LinkSymbolic", CK_LinkSymbolic},
|
|
|
|
{"PanelTree", CK_PanelTree},
|
|
|
|
{"Tree", CK_Tree},
|
2011-01-21 10:02:12 +03:00
|
|
|
#ifdef ENABLE_VFS_UNDELFS
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Undelete", CK_Undelete},
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2011-01-21 11:47:27 +03:00
|
|
|
{"PutCurrentLink", CK_PutCurrentLink},
|
|
|
|
{"PutOtherLink", CK_PutOtherLink},
|
|
|
|
{"HotListAdd", CK_HotListAdd},
|
|
|
|
{"ShowHidden", CK_ShowHidden},
|
|
|
|
{"SplitVertHoriz", CK_SplitVertHoriz},
|
2012-02-06 19:14:22 +04:00
|
|
|
{"SplitEqual", CK_SplitEqual},
|
|
|
|
{"SplitMore", CK_SplitMore},
|
|
|
|
{"SplitLess", CK_SplitLess},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"PutCurrentPath", CK_PutCurrentPath},
|
|
|
|
{"PutOtherPath", CK_PutOtherPath},
|
2016-07-17 18:23:17 +03:00
|
|
|
{"PutCurrentSelected", CK_PutCurrentSelected},
|
|
|
|
{"PutCurrentFullSelected", CK_PutCurrentFullSelected},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"PutCurrentTagged", CK_PutCurrentTagged},
|
|
|
|
{"PutOtherTagged", CK_PutOtherTagged},
|
|
|
|
{"Select", CK_Select},
|
|
|
|
{"Unselect", CK_Unselect},
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* panel */
|
2014-06-25 18:23:35 +04:00
|
|
|
{"SelectExt", CK_SelectExt},
|
2012-02-10 18:54:14 +04:00
|
|
|
{"ScrollLeft", CK_ScrollLeft},
|
|
|
|
{"ScrollRight", CK_ScrollRight},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"PanelOtherCd", CK_PanelOtherCd},
|
|
|
|
{"PanelOtherCdLink", CK_PanelOtherCdLink},
|
|
|
|
{"CopySingle", CK_CopySingle},
|
|
|
|
{"MoveSingle", CK_MoveSingle},
|
|
|
|
{"DeleteSingle", CK_DeleteSingle},
|
|
|
|
{"CdParent", CK_CdParent},
|
|
|
|
{"CdChild", CK_CdChild},
|
2011-08-08 13:25:55 +04:00
|
|
|
{"Panelize", CK_Panelize},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"PanelOtherSync", CK_PanelOtherSync},
|
|
|
|
{"SortNext", CK_SortNext},
|
|
|
|
{"SortPrev", CK_SortPrev},
|
|
|
|
{"SortReverse", CK_SortReverse},
|
|
|
|
{"SortByName", CK_SortByName},
|
|
|
|
{"SortByExt", CK_SortByExt},
|
|
|
|
{"SortBySize", CK_SortBySize},
|
|
|
|
{"SortByMTime", CK_SortByMTime},
|
|
|
|
{"CdParentSmart", CK_CdParentSmart},
|
2017-04-19 11:45:23 +03:00
|
|
|
{"CycleListingFormat", CK_CycleListingFormat},
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* dialog */
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Ok", CK_Ok},
|
|
|
|
{"Cancel", CK_Cancel},
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* input line */
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Yank", CK_Yank},
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* help */
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Index", CK_Index},
|
|
|
|
{"Back", CK_Back},
|
|
|
|
{"LinkNext", CK_LinkNext},
|
|
|
|
{"LinkPrev", CK_LinkPrev},
|
|
|
|
{"NodeNext", CK_NodeNext},
|
|
|
|
{"NodePrev", CK_NodePrev},
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* tree */
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Forget", CK_Forget},
|
2011-01-21 10:02:12 +03:00
|
|
|
|
2011-01-21 11:47:27 +03:00
|
|
|
#if defined (USE_INTERNAL_EDIT) || defined (USE_DIFF_VIEW)
|
|
|
|
{"ShowNumbers", CK_ShowNumbers},
|
2010-11-18 12:39:09 +03:00
|
|
|
#endif
|
2011-01-21 11:47:27 +03:00
|
|
|
|
2020-04-12 10:46:29 +03:00
|
|
|
/* chattr dialog */
|
|
|
|
{"MarkAndDown", CK_MarkAndDown},
|
|
|
|
|
2011-01-21 11:47:27 +03:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2011-07-28 12:53:34 +04:00
|
|
|
{"Close", CK_Close},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"Tab", CK_Tab},
|
2012-01-09 21:03:46 +04:00
|
|
|
{"Undo", CK_Undo},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"ScrollUp", CK_ScrollUp},
|
|
|
|
{"ScrollDown", CK_ScrollDown},
|
|
|
|
{"Return", CK_Return},
|
|
|
|
{"ParagraphUp", CK_ParagraphUp},
|
|
|
|
{"ParagraphDown", CK_ParagraphDown},
|
|
|
|
{"EditFile", CK_EditFile},
|
|
|
|
{"MarkWord", CK_MarkWord},
|
|
|
|
{"MarkLine", CK_MarkLine},
|
|
|
|
{"MarkAll", CK_MarkAll},
|
|
|
|
{"Unmark", CK_Unmark},
|
|
|
|
{"MarkColumn", CK_MarkColumn},
|
|
|
|
{"BlockSave", CK_BlockSave},
|
|
|
|
{"InsertFile", CK_InsertFile},
|
|
|
|
{"InsertOverwrite", CK_InsertOverwrite},
|
|
|
|
{"Date", CK_Date},
|
|
|
|
{"DeleteLine", CK_DeleteLine},
|
2010-11-18 12:39:09 +03:00
|
|
|
{"EditMail", CK_Mail},
|
2011-01-21 11:47:27 +03:00
|
|
|
{"ParagraphFormat", CK_ParagraphFormat},
|
|
|
|
{"MatchBracket", CK_MatchBracket},
|
|
|
|
{"ExternalCommand", CK_ExternalCommand},
|
|
|
|
{"MacroStartRecord", CK_MacroStartRecord},
|
|
|
|
{"MacroStopRecord", CK_MacroStopRecord},
|
|
|
|
{"MacroStartStopRecord", CK_MacroStartStopRecord},
|
|
|
|
{"MacroDelete", CK_MacroDelete},
|
|
|
|
{"RepeatStartStopRecord", CK_RepeatStartStopRecord},
|
2012-04-26 14:05:48 +04:00
|
|
|
#ifdef HAVE_ASPELL
|
|
|
|
{"SpellCheck", CK_SpellCheck},
|
|
|
|
{"SpellCheckCurrentWord", CK_SpellCheckCurrentWord},
|
|
|
|
{"SpellCheckSelectLang", CK_SpellCheckSelectLang},
|
|
|
|
#endif /* HAVE_ASPELL */
|
2011-01-21 11:47:27 +03:00
|
|
|
{"BookmarkFlush", CK_BookmarkFlush},
|
|
|
|
{"BookmarkNext", CK_BookmarkNext},
|
|
|
|
{"BookmarkPrev", CK_BookmarkPrev},
|
|
|
|
{"MarkPageUp", CK_MarkPageUp},
|
|
|
|
{"MarkPageDown", CK_MarkPageDown},
|
|
|
|
{"MarkToFileBegin", CK_MarkToFileBegin},
|
|
|
|
{"MarkToFileEnd", CK_MarkToFileEnd},
|
|
|
|
{"MarkToPageBegin", CK_MarkToPageBegin},
|
|
|
|
{"MarkToPageEnd", CK_MarkToPageEnd},
|
|
|
|
{"MarkScrollUp", CK_MarkScrollUp},
|
|
|
|
{"MarkScrollDown", CK_MarkScrollDown},
|
|
|
|
{"MarkParagraphUp", CK_MarkParagraphUp},
|
|
|
|
{"MarkParagraphDown", CK_MarkParagraphDown},
|
|
|
|
{"MarkColumnPageUp", CK_MarkColumnPageUp},
|
|
|
|
{"MarkColumnPageDown", CK_MarkColumnPageDown},
|
|
|
|
{"MarkColumnLeft", CK_MarkColumnLeft},
|
|
|
|
{"MarkColumnRight", CK_MarkColumnRight},
|
|
|
|
{"MarkColumnUp", CK_MarkColumnUp},
|
|
|
|
{"MarkColumnDown", CK_MarkColumnDown},
|
|
|
|
{"MarkColumnScrollUp", CK_MarkColumnScrollUp},
|
|
|
|
{"MarkColumnScrollDown", CK_MarkColumnScrollDown},
|
|
|
|
{"MarkColumnParagraphUp", CK_MarkColumnParagraphUp},
|
|
|
|
{"MarkColumnParagraphDown", CK_MarkColumnParagraphDown},
|
|
|
|
{"BlockShiftLeft", CK_BlockShiftLeft},
|
|
|
|
{"BlockShiftRight", CK_BlockShiftRight},
|
|
|
|
{"InsertLiteral", CK_InsertLiteral},
|
|
|
|
{"ShowTabTws", CK_ShowTabTws},
|
|
|
|
{"SyntaxOnOff", CK_SyntaxOnOff},
|
|
|
|
{"SyntaxChoose", CK_SyntaxChoose},
|
|
|
|
{"ShowMargin", CK_ShowMargin},
|
|
|
|
{"OptionsSaveMode", CK_OptionsSaveMode},
|
|
|
|
{"About", CK_About},
|
2011-02-20 18:23:32 +03:00
|
|
|
/* An action to run external script from macro */
|
|
|
|
{"ExecuteScript", CK_PipeBlock (0)},
|
2011-07-23 15:30:31 +04:00
|
|
|
{"WindowMove", CK_WindowMove},
|
|
|
|
{"WindowResize", CK_WindowResize},
|
2011-10-25 14:36:51 +04:00
|
|
|
{"WindowFullscreen", CK_WindowFullscreen},
|
2011-08-01 13:04:28 +04:00
|
|
|
{"WindowList", CK_WindowList},
|
|
|
|
{"WindowNext", CK_WindowNext},
|
|
|
|
{"WindowPrev", CK_WindowPrev},
|
2010-11-18 12:39:09 +03:00
|
|
|
#endif /* USE_INTERNAL_EDIT */
|
|
|
|
|
|
|
|
/* viewer */
|
2011-01-21 11:47:27 +03:00
|
|
|
{"WrapMode", CK_WrapMode},
|
|
|
|
{"HexEditMode", CK_HexEditMode},
|
|
|
|
{"HexMode", CK_HexMode},
|
|
|
|
{"MagicMode", CK_MagicMode},
|
|
|
|
{"NroffMode", CK_NroffMode},
|
|
|
|
{"BookmarkGoto", CK_BookmarkGoto},
|
|
|
|
{"Ruler", CK_Ruler},
|
2011-10-27 18:03:44 +04:00
|
|
|
{"SearchForward", CK_SearchForward},
|
|
|
|
{"SearchBackward", CK_SearchBackward},
|
|
|
|
{"SearchForwardContinue", CK_SearchForwardContinue},
|
|
|
|
{"SearchBackwardContinue", CK_SearchBackwardContinue},
|
2019-04-20 18:46:37 +03:00
|
|
|
{"SearchOppositeContinue", CK_SearchOppositeContinue},
|
2010-11-18 12:39:09 +03:00
|
|
|
|
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
/* diff viewer */
|
2011-01-21 11:47:27 +03:00
|
|
|
{"ShowSymbols", CK_ShowSymbols},
|
|
|
|
{"SplitFull", CK_SplitFull},
|
|
|
|
{"Tab2", CK_Tab2},
|
|
|
|
{"Tab3", CK_Tab3},
|
|
|
|
{"Tab4", CK_Tab4},
|
|
|
|
{"Tab8", CK_Tab8},
|
|
|
|
{"HunkNext", CK_HunkNext},
|
|
|
|
{"HunkPrev", CK_HunkPrev},
|
|
|
|
{"EditOther", CK_EditOther},
|
|
|
|
{"Merge", CK_Merge},
|
2012-08-24 18:30:12 +04:00
|
|
|
{"MergeOther", CK_MergeOther},
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif /* USE_DIFF_VIEW */
|
2010-11-18 12:39:09 +03:00
|
|
|
|
2011-02-20 18:23:32 +03:00
|
|
|
{NULL, CK_IgnoreKey}
|
2010-11-18 12:39:09 +03:00
|
|
|
};
|
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
/* *INDENT-OFF* */
|
2011-01-21 10:02:12 +03:00
|
|
|
static const size_t num_command_names = G_N_ELEMENTS (command_names) - 1;
|
2011-10-15 14:56:47 +04:00
|
|
|
/* *INDENT-ON* */
|
2010-11-18 12:39:09 +03:00
|
|
|
|
|
|
|
/*** file scope functions ************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
|
|
|
name_keymap_comparator (const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const name_keymap_t *m1 = (const name_keymap_t *) p1;
|
|
|
|
const name_keymap_t *m2 = (const name_keymap_t *) p2;
|
|
|
|
|
2011-10-21 20:11:22 +04:00
|
|
|
return g_ascii_strcasecmp (m1->name, m2->name);
|
2010-11-18 12:39:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
sort_command_names (void)
|
|
|
|
{
|
|
|
|
static gboolean has_been_sorted = FALSE;
|
|
|
|
|
|
|
|
if (!has_been_sorted)
|
|
|
|
{
|
|
|
|
qsort (command_names, num_command_names,
|
|
|
|
sizeof (command_names[0]), &name_keymap_comparator);
|
|
|
|
has_been_sorted = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
2015-11-21 18:15:11 +03:00
|
|
|
keymap_add (GArray * keymap, long key, long cmd, const char *caption)
|
2010-11-18 12:39:09 +03:00
|
|
|
{
|
2011-02-20 18:23:32 +03:00
|
|
|
if (key != 0 && cmd != CK_IgnoreKey)
|
2010-11-18 12:39:09 +03:00
|
|
|
{
|
|
|
|
global_keymap_t new_bind;
|
|
|
|
|
|
|
|
new_bind.key = key;
|
|
|
|
new_bind.command = cmd;
|
|
|
|
g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
|
|
|
|
g_array_append_val (keymap, new_bind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** public functions ****************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void
|
2015-11-21 18:15:11 +03:00
|
|
|
keybind_cmd_bind (GArray * keymap, const char *keybind, long action)
|
2010-11-18 12:39:09 +03:00
|
|
|
{
|
|
|
|
char *caption = NULL;
|
|
|
|
long key;
|
|
|
|
|
|
|
|
key = lookup_key (keybind, &caption);
|
|
|
|
keymap_add (keymap, key, action, caption);
|
|
|
|
g_free (caption);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2015-11-21 18:15:11 +03:00
|
|
|
long
|
2010-11-18 12:39:09 +03:00
|
|
|
keybind_lookup_action (const char *name)
|
|
|
|
{
|
|
|
|
const name_keymap_t key = { name, 0 };
|
|
|
|
name_keymap_t *res;
|
|
|
|
|
|
|
|
sort_command_names ();
|
|
|
|
|
|
|
|
res = bsearch (&key, command_names, num_command_names,
|
|
|
|
sizeof (command_names[0]), name_keymap_comparator);
|
|
|
|
|
2011-02-20 18:23:32 +03:00
|
|
|
return (res != NULL) ? res->val : CK_IgnoreKey;
|
2010-11-18 12:39:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2011-01-22 00:10:36 +03:00
|
|
|
const char *
|
2015-11-21 18:15:11 +03:00
|
|
|
keybind_lookup_actionname (long action)
|
2011-01-22 00:10:36 +03:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; command_names[i].name != NULL; i++)
|
|
|
|
if (command_names[i].val == action)
|
|
|
|
return command_names[i].name;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-11-18 12:39:09 +03:00
|
|
|
const char *
|
2015-11-21 18:15:11 +03:00
|
|
|
keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, long action)
|
2010-11-18 12:39:09 +03:00
|
|
|
{
|
2011-02-25 14:31:30 +03:00
|
|
|
if (keymap != NULL)
|
2013-10-15 10:34:04 +04:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2011-02-25 14:31:30 +03:00
|
|
|
for (i = 0; keymap[i].key != 0; i++)
|
|
|
|
if (keymap[i].command == action)
|
|
|
|
return (keymap[i].caption[0] != '\0') ? keymap[i].caption : NULL;
|
2013-10-15 10:34:04 +04:00
|
|
|
}
|
2010-11-18 12:39:09 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2015-11-21 18:15:11 +03:00
|
|
|
long
|
2010-11-18 12:39:09 +03:00
|
|
|
keybind_lookup_keymap_command (const global_keymap_t * keymap, long key)
|
|
|
|
{
|
2011-02-25 14:31:30 +03:00
|
|
|
if (keymap != NULL)
|
2013-10-15 10:34:04 +04:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2011-02-25 14:31:30 +03:00
|
|
|
for (i = 0; keymap[i].key != 0; i++)
|
|
|
|
if (keymap[i].key == key)
|
|
|
|
return keymap[i].command;
|
2013-10-15 10:34:04 +04:00
|
|
|
}
|
2010-11-18 12:39:09 +03:00
|
|
|
|
2011-02-20 18:23:32 +03:00
|
|
|
return CK_IgnoreKey;
|
2010-11-18 12:39:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|