KiCad PCB EDA Suite
Loading...
Searching...
No Matches
hotkeys_basic.cpp File Reference
#include <kiface_base.h>
#include <hotkeys_basic.h>
#include <id.h>
#include <string_utils.h>
#include <eda_base_frame.h>
#include <eda_draw_frame.h>
#include <wildcards_and_files_ext.h>
#include <paths.h>
#include <tool/tool_manager.h>
#include "dialogs/dialog_hotkey_list.h"
#include <wx/apptrait.h>
#include <wx/stdpaths.h>
#include <wx/tokenzr.h>
#include <wx/txtstrm.h>
#include <wx/wfstream.h>
#include <tool/tool_action.h>
#include <tool/tool_event.h>

Go to the source code of this file.

Classes

struct  hotkey_name_descr
 

Macros

#define KEY_NON_FOUND   -1
 
#define MODIFIER_CTRL   wxT( "Ctrl+" )
 
#define MODIFIER_ALT   wxT( "Alt+" )
 
#define MODIFIER_CMD_MAC   wxT( "Cmd+" )
 
#define MODIFIER_CTRL_BASE   wxT( "Ctrl+" )
 
#define MODIFIER_SHIFT   wxT( "Shift+" )
 
#define MODIFIER_META   wxT( "Meta+" )
 
#define MODIFIER_WIN   wxT( "Win+" )
 
#define MODIFIER_SUPER   wxT( "Super+" )
 
#define MODIFIER_ALTGR   wxT( "AltGr+" )
 

Functions

wxString KeyNameFromKeyCode (int aKeycode, bool *aIsFound)
 Return the key name from the key code.
 
wxString AddHotkeyName (const wxString &aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle)
 
int KeyCodeFromKeyName (const wxString &keyname)
 Return the key code from its user-friendly key name (ie: "Ctrl+M").
 
void DisplayHotkeyList (EDA_BASE_FRAME *aParent)
 Display the current hotkey list.
 
void ReadHotKeyConfig (const wxString &aFileName, std::map< std::string, std::pair< int, int > > &aHotKeys)
 Read a hotkey config file into a map.
 
void ReadHotKeyConfigIntoActions (const wxString &aFileName, std::vector< TOOL_ACTION * > &aActions)
 Read a hotkey config file into a list of actions.
 
int WriteHotKeyConfig (const std::vector< TOOL_ACTION * > &aActions)
 Update the hotkeys config file with the hotkeys from the given actions map.
 
int ReadLegacyHotkeyConfig (const wxString &aAppname, std::map< std::string, int > &aMap)
 Read configuration data and fill the current hotkey list with hotkeys.
 
int ReadLegacyHotkeyConfigFile (const wxString &aFilename, std::map< std::string, int > &aMap)
 Read hotkey configuration for a given app.
 

Variables

static struct hotkey_name_descr hotkeyNameList []
 

Macro Definition Documentation

◆ KEY_NON_FOUND

#define KEY_NON_FOUND   -1

Definition at line 64 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().

◆ MODIFIER_ALT

#define MODIFIER_ALT   wxT( "Alt+" )

Definition at line 158 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().

◆ MODIFIER_ALTGR

#define MODIFIER_ALTGR   wxT( "AltGr+" )

Definition at line 166 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().

◆ MODIFIER_CMD_MAC

#define MODIFIER_CMD_MAC   wxT( "Cmd+" )

Definition at line 160 of file hotkeys_basic.cpp.

Referenced by AddHotkeyName(), and KeyCodeFromKeyName().

◆ MODIFIER_CTRL

#define MODIFIER_CTRL   wxT( "Ctrl+" )

Definition at line 157 of file hotkeys_basic.cpp.

Referenced by KeyNameFromKeyCode().

◆ MODIFIER_CTRL_BASE

#define MODIFIER_CTRL_BASE   wxT( "Ctrl+" )

Definition at line 161 of file hotkeys_basic.cpp.

Referenced by AddHotkeyName(), KeyCodeFromKeyName(), and KeyNameFromKeyCode().

◆ MODIFIER_META

#define MODIFIER_META   wxT( "Meta+" )

Definition at line 163 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().

◆ MODIFIER_SHIFT

#define MODIFIER_SHIFT   wxT( "Shift+" )

Definition at line 162 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().

◆ MODIFIER_SUPER

#define MODIFIER_SUPER   wxT( "Super+" )

Definition at line 165 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName().

◆ MODIFIER_WIN

#define MODIFIER_WIN   wxT( "Win+" )

Definition at line 164 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().

Function Documentation

◆ AddHotkeyName()

wxString AddHotkeyName ( const wxString & aText,
int aHotKey,
HOTKEY_ACTION_TYPE aStyle = IS_HOTKEY )
Parameters
aTextthe base text on which to append the hotkey.
aHotKeythe hotkey keycode.
aStyleIS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys). IS_COMMENT to add <spaces><(keyname)> mainly in tool tips.

Definition at line 245 of file hotkeys_basic.cpp.

References IS_COMMENT, IS_HOTKEY, KeyNameFromKeyCode(), MODIFIER_CMD_MAC, and MODIFIER_CTRL_BASE.

Referenced by FOOTPRINT_DIFF_WIDGET::FOOTPRINT_DIFF_WIDGET(), PCB_ONE_LAYER_SELECTOR::getLayerHotKey(), TOOL_ACTION::GetMenuItem(), PCB_LAYER_BOX_SELECTOR::Resync(), and SYMBOL_DIFF_WIDGET::SYMBOL_DIFF_WIDGET().

◆ DisplayHotkeyList()

void DisplayHotkeyList ( EDA_BASE_FRAME * aFrame)

Display the current hotkey list.

Parameters
aFramecurrent active frame.
aToolMgrthe tool manager holding the registered actions from which the hotkeys will be harvested.

Definition at line 366 of file hotkeys_basic.cpp.

References DIALOG_SHIM::ShowModal().

Referenced by COMMON_CONTROL::ListHotKeys().

◆ KeyCodeFromKeyName()

int KeyCodeFromKeyName ( const wxString & keyname)

◆ KeyNameFromKeyCode()

wxString KeyNameFromKeyCode ( int aKeycode,
bool * aIsFound = nullptr )

Return the key name from the key code.

Only some wxWidgets key values are handled for function key ( see hotkeyNameList[] )

Parameters
aKeycodekey code (ASCII value, or wxWidgets value for function keys).
aIsFounda pointer to a bool to return true if found, or false. an be nullptr default).
Returns
the key name in a wxString.

Definition at line 169 of file hotkeys_basic.cpp.

References hotkeyNameList, KEY_NON_FOUND, hotkey_name_descr::m_KeyCode, MD_ALT, MD_ALTGR, MD_CTRL, MD_META, MD_MODIFIER_MASK, MD_SHIFT, MD_SUPER, MODIFIER_ALT, MODIFIER_ALTGR, MODIFIER_CTRL, MODIFIER_CTRL_BASE, MODIFIER_META, MODIFIER_SHIFT, and MODIFIER_WIN.

Referenced by AddHotkeyName(), APPEARANCE_CONTROLS::APPEARANCE_CONTROLS(), APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D(), BOOST_AUTO_TEST_CASE(), WIDGET_HOTKEY_LIST::changeHotkey(), APPEARANCE_CONTROLS::createControls(), DIALOG_FIND::DIALOG_FIND(), DIALOG_SCH_FIND::DIALOG_SCH_FIND(), PANEL_HOTKEYS_EDITOR::dumpHotkeys(), PAD_TOOL::enterPadEditMode(), HOTKEY_FILTER::FilterMatches(), TOOL_ACTION::GetButtonTooltip(), TOOL_ACTION::GetTooltip(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::performDragging(), APPEARANCE_CONTROLS::rebuildLayerPresetsWidget(), APPEARANCE_CONTROLS_3D::rebuildLayerPresetsWidget(), APPEARANCE_CONTROLS::rebuildLayers(), APPEARANCE_CONTROLS::rebuildNets(), APPEARANCE_CONTROLS::rebuildViewportsWidget(), APPEARANCE_CONTROLS_3D::rebuildViewportsWidget(), WIDGET_HOTKEY_LIST::resolveKeyConflicts(), ACTION_MANAGER::RunHotKey(), PCB_CONTROL::unfilledZoneCheck(), WIDGET_HOTKEY_LIST::updateFromClientData(), and WriteHotKeyConfig().

◆ ReadHotKeyConfig()

void ReadHotKeyConfig ( const wxString & aFileName,
std::map< std::string, std::pair< int, int > > & aHotKeys )

Read a hotkey config file into a map.

If aFileName is empty it will read in the default hotkeys file.

Definition at line 373 of file hotkeys_basic.cpp.

References PATHS::GetUserSettingsPath(), FILEEXT::HotkeyFileExtension, and KeyCodeFromKeyName().

Referenced by PANEL_HOTKEYS_EDITOR::ImportHotKeys(), ReadHotKeyConfigIntoActions(), ACTION_MANAGER::UpdateHotKeys(), and WriteHotKeyConfig().

◆ ReadHotKeyConfigIntoActions()

void ReadHotKeyConfigIntoActions ( const wxString & aFileName,
std::vector< TOOL_ACTION * > & aActions )

Read a hotkey config file into a list of actions.

If aFileName is empty it will read in the default hotkeys file.

Definition at line 416 of file hotkeys_basic.cpp.

References hotkeys, and ReadHotKeyConfig().

Referenced by DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS(), and EDA_BASE_FRAME::ShowPreferences().

◆ ReadLegacyHotkeyConfig()

int ReadLegacyHotkeyConfig ( const wxString & aAppname,
std::map< std::string, int > & aMap )

Read configuration data and fill the current hotkey list with hotkeys.

Parameters
aAppnamethe value of the app's m_FrameName.
aMapThe list of keycodes mapped by legacy property names.

Definition at line 467 of file hotkeys_basic.cpp.

References EESCHEMA_HOTKEY_NAME, FOOTPRINT_EDIT_FRAME_NAME, LIB_EDIT_FRAME_NAME, PCB_EDIT_FRAME_NAME, PCBNEW_HOTKEY_NAME, ReadLegacyHotkeyConfigFile(), and SCH_EDIT_FRAME_NAME.

Referenced by ACTION_MANAGER::UpdateHotKeys().

◆ ReadLegacyHotkeyConfigFile()

int ReadLegacyHotkeyConfigFile ( const wxString & aFilename,
std::map< std::string, int > & aMap )

Read hotkey configuration for a given app.

Parameters
aFilenamethe filename to save the hotkeys as.
aMapThe list of keycodes mapped by legacy property names.
Returns
1 on success, 0 on failure.

Definition at line 484 of file hotkeys_basic.cpp.

References PATHS::GetUserSettingsPath(), FILEEXT::HotkeyFileExtension, and KeyCodeFromKeyName().

Referenced by ReadLegacyHotkeyConfig().

◆ WriteHotKeyConfig()

int WriteHotKeyConfig ( const std::vector< TOOL_ACTION * > & aActions)

Update the hotkeys config file with the hotkeys from the given actions map.

Definition at line 435 of file hotkeys_basic.cpp.

References PATHS::GetUserSettingsPath(), FILEEXT::HotkeyFileExtension, hotkeys, KeyNameFromKeyCode(), and ReadHotKeyConfig().

Referenced by PANEL_HOTKEYS_EDITOR::TransferDataFromWindow().

Variable Documentation

◆ hotkeyNameList

struct hotkey_name_descr hotkeyNameList[]
static

Definition at line 65 of file hotkeys_basic.cpp.

Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().