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
|
|
|
|
2024-01-01 09:46:17 +03:00
|
|
|
Copyright (C) 2005-2024
|
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
|
2020-07-26 14:18:00 +03:00
|
|
|
Andrew Borodin <aborodin@vmail.ru>, 2009-2020
|
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 ****************************************************************/
|
|
|
|
|
2020-07-26 14:18:00 +03:00
|
|
|
#define ADD_KEYMAP_NAME(name) \
|
|
|
|
{ #name, CK_##name }
|
|
|
|
|
2010-11-18 12:39:09 +03:00
|
|
|
/*** file scope type declarations ****************************************************************/
|
|
|
|
|
2021-02-14 20:23:04 +03:00
|
|
|
typedef struct name_keymap_t
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
long val;
|
|
|
|
} name_keymap_t;
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/*** forward declarations (file scope functions) *************************************************/
|
|
|
|
|
2010-11-18 12:39:09 +03:00
|
|
|
/*** file scope variables ************************************************************************/
|
|
|
|
|
|
|
|
static name_keymap_t command_names[] = {
|
2011-01-21 10:02:12 +03:00
|
|
|
/* common */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (InsertChar),
|
|
|
|
ADD_KEYMAP_NAME (Enter),
|
|
|
|
ADD_KEYMAP_NAME (ChangePanel),
|
|
|
|
ADD_KEYMAP_NAME (Up),
|
|
|
|
ADD_KEYMAP_NAME (Down),
|
|
|
|
ADD_KEYMAP_NAME (Left),
|
|
|
|
ADD_KEYMAP_NAME (Right),
|
|
|
|
ADD_KEYMAP_NAME (LeftQuick),
|
|
|
|
ADD_KEYMAP_NAME (RightQuick),
|
|
|
|
ADD_KEYMAP_NAME (Home),
|
|
|
|
ADD_KEYMAP_NAME (End),
|
|
|
|
ADD_KEYMAP_NAME (PageUp),
|
|
|
|
ADD_KEYMAP_NAME (PageDown),
|
|
|
|
ADD_KEYMAP_NAME (HalfPageUp),
|
|
|
|
ADD_KEYMAP_NAME (HalfPageDown),
|
|
|
|
ADD_KEYMAP_NAME (Top),
|
|
|
|
ADD_KEYMAP_NAME (Bottom),
|
|
|
|
ADD_KEYMAP_NAME (TopOnScreen),
|
|
|
|
ADD_KEYMAP_NAME (MiddleOnScreen),
|
|
|
|
ADD_KEYMAP_NAME (BottomOnScreen),
|
|
|
|
ADD_KEYMAP_NAME (WordLeft),
|
|
|
|
ADD_KEYMAP_NAME (WordRight),
|
|
|
|
ADD_KEYMAP_NAME (Copy),
|
|
|
|
ADD_KEYMAP_NAME (Move),
|
|
|
|
ADD_KEYMAP_NAME (Delete),
|
|
|
|
ADD_KEYMAP_NAME (MakeDir),
|
|
|
|
ADD_KEYMAP_NAME (ChangeMode),
|
|
|
|
ADD_KEYMAP_NAME (ChangeOwn),
|
|
|
|
ADD_KEYMAP_NAME (ChangeOwnAdvanced),
|
2020-04-12 10:46:29 +03:00
|
|
|
#ifdef ENABLE_EXT2FS_ATTR
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (ChangeAttributes),
|
2020-04-12 10:46:29 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (Remove),
|
|
|
|
ADD_KEYMAP_NAME (BackSpace),
|
|
|
|
ADD_KEYMAP_NAME (Redo),
|
|
|
|
ADD_KEYMAP_NAME (Clear),
|
|
|
|
ADD_KEYMAP_NAME (Menu),
|
|
|
|
ADD_KEYMAP_NAME (MenuLastSelected),
|
|
|
|
ADD_KEYMAP_NAME (UserMenu),
|
|
|
|
ADD_KEYMAP_NAME (EditUserMenu),
|
|
|
|
ADD_KEYMAP_NAME (Search),
|
|
|
|
ADD_KEYMAP_NAME (SearchContinue),
|
|
|
|
ADD_KEYMAP_NAME (Replace),
|
|
|
|
ADD_KEYMAP_NAME (ReplaceContinue),
|
|
|
|
ADD_KEYMAP_NAME (Help),
|
|
|
|
ADD_KEYMAP_NAME (Shell),
|
|
|
|
ADD_KEYMAP_NAME (Edit),
|
|
|
|
ADD_KEYMAP_NAME (EditNew),
|
2011-01-21 11:47:27 +03:00
|
|
|
#ifdef HAVE_CHARSET
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (SelectCodepage),
|
2011-01-21 11:47:27 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (EditorViewerHistory),
|
|
|
|
ADD_KEYMAP_NAME (History),
|
|
|
|
ADD_KEYMAP_NAME (HistoryNext),
|
|
|
|
ADD_KEYMAP_NAME (HistoryPrev),
|
|
|
|
ADD_KEYMAP_NAME (Complete),
|
|
|
|
ADD_KEYMAP_NAME (Save),
|
|
|
|
ADD_KEYMAP_NAME (SaveAs),
|
|
|
|
ADD_KEYMAP_NAME (Goto),
|
|
|
|
ADD_KEYMAP_NAME (Reread),
|
|
|
|
ADD_KEYMAP_NAME (Refresh),
|
|
|
|
ADD_KEYMAP_NAME (Suspend),
|
|
|
|
ADD_KEYMAP_NAME (Swap),
|
|
|
|
ADD_KEYMAP_NAME (HotList),
|
|
|
|
ADD_KEYMAP_NAME (SelectInvert),
|
|
|
|
ADD_KEYMAP_NAME (ScreenList),
|
|
|
|
ADD_KEYMAP_NAME (ScreenNext),
|
|
|
|
ADD_KEYMAP_NAME (ScreenPrev),
|
|
|
|
ADD_KEYMAP_NAME (FileNext),
|
|
|
|
ADD_KEYMAP_NAME (FilePrev),
|
|
|
|
ADD_KEYMAP_NAME (DeleteToHome),
|
|
|
|
ADD_KEYMAP_NAME (DeleteToEnd),
|
|
|
|
ADD_KEYMAP_NAME (DeleteToWordBegin),
|
|
|
|
ADD_KEYMAP_NAME (DeleteToWordEnd),
|
|
|
|
ADD_KEYMAP_NAME (Cut),
|
|
|
|
ADD_KEYMAP_NAME (Store),
|
|
|
|
ADD_KEYMAP_NAME (Paste),
|
|
|
|
ADD_KEYMAP_NAME (Mark),
|
|
|
|
ADD_KEYMAP_NAME (MarkLeft),
|
|
|
|
ADD_KEYMAP_NAME (MarkRight),
|
|
|
|
ADD_KEYMAP_NAME (MarkUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkDown),
|
|
|
|
ADD_KEYMAP_NAME (MarkToWordBegin),
|
|
|
|
ADD_KEYMAP_NAME (MarkToWordEnd),
|
|
|
|
ADD_KEYMAP_NAME (MarkToHome),
|
|
|
|
ADD_KEYMAP_NAME (MarkToEnd),
|
|
|
|
ADD_KEYMAP_NAME (ToggleNavigation),
|
|
|
|
ADD_KEYMAP_NAME (Sort),
|
|
|
|
ADD_KEYMAP_NAME (Options),
|
|
|
|
ADD_KEYMAP_NAME (LearnKeys),
|
|
|
|
ADD_KEYMAP_NAME (Bookmark),
|
|
|
|
ADD_KEYMAP_NAME (Quit),
|
|
|
|
ADD_KEYMAP_NAME (QuitQuiet),
|
|
|
|
ADD_KEYMAP_NAME (ExtendedKeyMap),
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* main commands */
|
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (EditForceInternal),
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (View),
|
|
|
|
ADD_KEYMAP_NAME (ViewRaw),
|
|
|
|
ADD_KEYMAP_NAME (ViewFile),
|
|
|
|
ADD_KEYMAP_NAME (ViewFiltered),
|
|
|
|
ADD_KEYMAP_NAME (Find),
|
|
|
|
ADD_KEYMAP_NAME (DirSize),
|
|
|
|
ADD_KEYMAP_NAME (CompareDirs),
|
2011-01-21 11:47:27 +03:00
|
|
|
#ifdef USE_DIFF_VIEW
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (CompareFiles),
|
2011-01-21 11:47:27 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (OptionsVfs),
|
|
|
|
ADD_KEYMAP_NAME (OptionsConfirm),
|
|
|
|
ADD_KEYMAP_NAME (OptionsDisplayBits),
|
|
|
|
ADD_KEYMAP_NAME (EditExtensionsFile),
|
|
|
|
ADD_KEYMAP_NAME (EditFileHighlightFile),
|
|
|
|
ADD_KEYMAP_NAME (LinkSymbolicEdit),
|
|
|
|
ADD_KEYMAP_NAME (ExternalPanelize),
|
|
|
|
ADD_KEYMAP_NAME (Filter),
|
2023-09-24 17:32:22 +03:00
|
|
|
#ifdef ENABLE_VFS_SHELL
|
|
|
|
ADD_KEYMAP_NAME (ConnectShell),
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_VFS_FTP
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (ConnectFtp),
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2012-04-13 14:40:53 +04:00
|
|
|
#ifdef ENABLE_VFS_SFTP
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (ConnectSftp),
|
2011-01-21 11:47:27 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (PanelInfo),
|
2012-01-09 15:48:39 +04:00
|
|
|
#ifdef ENABLE_BACKGROUND
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (Jobs),
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (OptionsLayout),
|
|
|
|
ADD_KEYMAP_NAME (OptionsAppearance),
|
|
|
|
ADD_KEYMAP_NAME (Link),
|
|
|
|
ADD_KEYMAP_NAME (SetupListingFormat),
|
|
|
|
ADD_KEYMAP_NAME (PanelListing),
|
2011-01-21 10:02:12 +03:00
|
|
|
#ifdef LISTMODE_EDITOR
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (ListMode),
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (OptionsPanel),
|
|
|
|
ADD_KEYMAP_NAME (CdQuick),
|
|
|
|
ADD_KEYMAP_NAME (PanelQuickView),
|
|
|
|
ADD_KEYMAP_NAME (LinkSymbolicRelative),
|
|
|
|
ADD_KEYMAP_NAME (VfsList),
|
|
|
|
ADD_KEYMAP_NAME (SaveSetup),
|
|
|
|
ADD_KEYMAP_NAME (LinkSymbolic),
|
|
|
|
ADD_KEYMAP_NAME (PanelTree),
|
|
|
|
ADD_KEYMAP_NAME (Tree),
|
2011-01-21 10:02:12 +03:00
|
|
|
#ifdef ENABLE_VFS_UNDELFS
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (Undelete),
|
2011-01-21 10:02:12 +03:00
|
|
|
#endif
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (PutCurrentLink),
|
|
|
|
ADD_KEYMAP_NAME (PutOtherLink),
|
|
|
|
ADD_KEYMAP_NAME (HotListAdd),
|
|
|
|
ADD_KEYMAP_NAME (ShowHidden),
|
|
|
|
ADD_KEYMAP_NAME (SplitVertHoriz),
|
|
|
|
ADD_KEYMAP_NAME (SplitEqual),
|
|
|
|
ADD_KEYMAP_NAME (SplitMore),
|
|
|
|
ADD_KEYMAP_NAME (SplitLess),
|
|
|
|
ADD_KEYMAP_NAME (PutCurrentPath),
|
|
|
|
ADD_KEYMAP_NAME (PutOtherPath),
|
|
|
|
ADD_KEYMAP_NAME (PutCurrentSelected),
|
|
|
|
ADD_KEYMAP_NAME (PutCurrentFullSelected),
|
|
|
|
ADD_KEYMAP_NAME (PutCurrentTagged),
|
|
|
|
ADD_KEYMAP_NAME (PutOtherTagged),
|
|
|
|
ADD_KEYMAP_NAME (Select),
|
|
|
|
ADD_KEYMAP_NAME (Unselect),
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* panel */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (SelectExt),
|
|
|
|
ADD_KEYMAP_NAME (ScrollLeft),
|
|
|
|
ADD_KEYMAP_NAME (ScrollRight),
|
|
|
|
ADD_KEYMAP_NAME (PanelOtherCd),
|
|
|
|
ADD_KEYMAP_NAME (PanelOtherCdLink),
|
|
|
|
ADD_KEYMAP_NAME (CopySingle),
|
|
|
|
ADD_KEYMAP_NAME (MoveSingle),
|
|
|
|
ADD_KEYMAP_NAME (DeleteSingle),
|
|
|
|
ADD_KEYMAP_NAME (CdParent),
|
|
|
|
ADD_KEYMAP_NAME (CdChild),
|
|
|
|
ADD_KEYMAP_NAME (Panelize),
|
|
|
|
ADD_KEYMAP_NAME (PanelOtherSync),
|
|
|
|
ADD_KEYMAP_NAME (SortNext),
|
|
|
|
ADD_KEYMAP_NAME (SortPrev),
|
|
|
|
ADD_KEYMAP_NAME (SortReverse),
|
|
|
|
ADD_KEYMAP_NAME (SortByName),
|
|
|
|
ADD_KEYMAP_NAME (SortByExt),
|
|
|
|
ADD_KEYMAP_NAME (SortBySize),
|
|
|
|
ADD_KEYMAP_NAME (SortByMTime),
|
|
|
|
ADD_KEYMAP_NAME (CdParentSmart),
|
|
|
|
ADD_KEYMAP_NAME (CycleListingFormat),
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* dialog */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (Ok),
|
|
|
|
ADD_KEYMAP_NAME (Cancel),
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* input line */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (Yank),
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* help */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (Index),
|
|
|
|
ADD_KEYMAP_NAME (Back),
|
|
|
|
ADD_KEYMAP_NAME (LinkNext),
|
|
|
|
ADD_KEYMAP_NAME (LinkPrev),
|
|
|
|
ADD_KEYMAP_NAME (NodeNext),
|
|
|
|
ADD_KEYMAP_NAME (NodePrev),
|
2011-01-21 10:02:12 +03:00
|
|
|
|
|
|
|
/* tree */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (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)
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (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 */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (MarkAndDown),
|
2020-04-12 10:46:29 +03:00
|
|
|
|
2011-01-21 11:47:27 +03:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (Close),
|
|
|
|
ADD_KEYMAP_NAME (Tab),
|
|
|
|
ADD_KEYMAP_NAME (Undo),
|
|
|
|
ADD_KEYMAP_NAME (ScrollUp),
|
|
|
|
ADD_KEYMAP_NAME (ScrollDown),
|
|
|
|
ADD_KEYMAP_NAME (Return),
|
|
|
|
ADD_KEYMAP_NAME (ParagraphUp),
|
|
|
|
ADD_KEYMAP_NAME (ParagraphDown),
|
|
|
|
ADD_KEYMAP_NAME (EditFile),
|
|
|
|
ADD_KEYMAP_NAME (MarkWord),
|
|
|
|
ADD_KEYMAP_NAME (MarkLine),
|
|
|
|
ADD_KEYMAP_NAME (MarkAll),
|
|
|
|
ADD_KEYMAP_NAME (Unmark),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumn),
|
|
|
|
ADD_KEYMAP_NAME (BlockSave),
|
|
|
|
ADD_KEYMAP_NAME (InsertFile),
|
|
|
|
ADD_KEYMAP_NAME (InsertOverwrite),
|
|
|
|
ADD_KEYMAP_NAME (Date),
|
|
|
|
ADD_KEYMAP_NAME (DeleteLine),
|
|
|
|
ADD_KEYMAP_NAME (EditMail),
|
|
|
|
ADD_KEYMAP_NAME (ParagraphFormat),
|
|
|
|
ADD_KEYMAP_NAME (MatchBracket),
|
|
|
|
ADD_KEYMAP_NAME (ExternalCommand),
|
|
|
|
ADD_KEYMAP_NAME (MacroStartRecord),
|
|
|
|
ADD_KEYMAP_NAME (MacroStopRecord),
|
|
|
|
ADD_KEYMAP_NAME (MacroStartStopRecord),
|
|
|
|
ADD_KEYMAP_NAME (MacroDelete),
|
|
|
|
ADD_KEYMAP_NAME (RepeatStartStopRecord),
|
2012-04-26 14:05:48 +04:00
|
|
|
#ifdef HAVE_ASPELL
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (SpellCheck),
|
|
|
|
ADD_KEYMAP_NAME (SpellCheckCurrentWord),
|
|
|
|
ADD_KEYMAP_NAME (SpellCheckSelectLang),
|
2012-04-26 14:05:48 +04:00
|
|
|
#endif /* HAVE_ASPELL */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (BookmarkFlush),
|
|
|
|
ADD_KEYMAP_NAME (BookmarkNext),
|
|
|
|
ADD_KEYMAP_NAME (BookmarkPrev),
|
|
|
|
ADD_KEYMAP_NAME (MarkPageUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkPageDown),
|
|
|
|
ADD_KEYMAP_NAME (MarkToFileBegin),
|
|
|
|
ADD_KEYMAP_NAME (MarkToFileEnd),
|
|
|
|
ADD_KEYMAP_NAME (MarkToPageBegin),
|
|
|
|
ADD_KEYMAP_NAME (MarkToPageEnd),
|
|
|
|
ADD_KEYMAP_NAME (MarkScrollUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkScrollDown),
|
|
|
|
ADD_KEYMAP_NAME (MarkParagraphUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkParagraphDown),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnPageUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnPageDown),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnLeft),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnRight),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnDown),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnScrollUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnScrollDown),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnParagraphUp),
|
|
|
|
ADD_KEYMAP_NAME (MarkColumnParagraphDown),
|
|
|
|
ADD_KEYMAP_NAME (BlockShiftLeft),
|
|
|
|
ADD_KEYMAP_NAME (BlockShiftRight),
|
|
|
|
ADD_KEYMAP_NAME (InsertLiteral),
|
|
|
|
ADD_KEYMAP_NAME (ShowTabTws),
|
|
|
|
ADD_KEYMAP_NAME (SyntaxOnOff),
|
|
|
|
ADD_KEYMAP_NAME (SyntaxChoose),
|
|
|
|
ADD_KEYMAP_NAME (ShowMargin),
|
|
|
|
ADD_KEYMAP_NAME (OptionsSaveMode),
|
|
|
|
ADD_KEYMAP_NAME (About),
|
2011-02-20 18:23:32 +03:00
|
|
|
/* An action to run external script from macro */
|
|
|
|
{"ExecuteScript", CK_PipeBlock (0)},
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (WindowMove),
|
|
|
|
ADD_KEYMAP_NAME (WindowResize),
|
|
|
|
ADD_KEYMAP_NAME (WindowFullscreen),
|
|
|
|
ADD_KEYMAP_NAME (WindowList),
|
|
|
|
ADD_KEYMAP_NAME (WindowNext),
|
|
|
|
ADD_KEYMAP_NAME (WindowPrev),
|
2010-11-18 12:39:09 +03:00
|
|
|
#endif /* USE_INTERNAL_EDIT */
|
|
|
|
|
|
|
|
/* viewer */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (WrapMode),
|
|
|
|
ADD_KEYMAP_NAME (HexEditMode),
|
|
|
|
ADD_KEYMAP_NAME (HexMode),
|
|
|
|
ADD_KEYMAP_NAME (MagicMode),
|
|
|
|
ADD_KEYMAP_NAME (NroffMode),
|
|
|
|
ADD_KEYMAP_NAME (BookmarkGoto),
|
|
|
|
ADD_KEYMAP_NAME (Ruler),
|
|
|
|
ADD_KEYMAP_NAME (SearchForward),
|
|
|
|
ADD_KEYMAP_NAME (SearchBackward),
|
|
|
|
ADD_KEYMAP_NAME (SearchForwardContinue),
|
|
|
|
ADD_KEYMAP_NAME (SearchBackwardContinue),
|
|
|
|
ADD_KEYMAP_NAME (SearchOppositeContinue),
|
2010-11-18 12:39:09 +03:00
|
|
|
|
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
/* diff viewer */
|
2020-07-26 14:18:00 +03:00
|
|
|
ADD_KEYMAP_NAME (ShowSymbols),
|
|
|
|
ADD_KEYMAP_NAME (SplitFull),
|
|
|
|
ADD_KEYMAP_NAME (Tab2),
|
|
|
|
ADD_KEYMAP_NAME (Tab3),
|
|
|
|
ADD_KEYMAP_NAME (Tab4),
|
|
|
|
ADD_KEYMAP_NAME (Tab8),
|
|
|
|
ADD_KEYMAP_NAME (HunkNext),
|
|
|
|
ADD_KEYMAP_NAME (HunkPrev),
|
|
|
|
ADD_KEYMAP_NAME (EditOther),
|
|
|
|
ADD_KEYMAP_NAME (Merge),
|
|
|
|
ADD_KEYMAP_NAME (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
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
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
|
2024-06-01 21:12:14 +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
|
2024-06-01 21:12:14 +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;
|
|
|
|
|
2023-04-15 15:19:05 +03:00
|
|
|
key = tty_keyname_to_keycode (keybind, &caption);
|
2010-11-18 12:39:09 +03:00
|
|
|
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 *
|
2024-06-01 21:12:14 +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
|
2024-06-01 21:12:14 +03:00
|
|
|
keybind_lookup_keymap_command (const global_keymap_t *keymap, long key)
|
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].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
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|