2011-10-18 19:59:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-08-16 11:49:13 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2011-10-18 19:59:19 +00:00
|
|
|
* Copyright (C) 2010-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2019-06-10 22:17:45 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-18 19:59:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <hotkeys_basic.h>
|
|
|
|
#include <id.h>
|
|
|
|
#include <kicad_string.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <eda_base_frame.h>
|
2019-06-08 22:14:57 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2018-10-02 21:37:15 +00:00
|
|
|
|
2015-05-05 18:39:42 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2018-10-02 21:37:15 +00:00
|
|
|
#include "dialogs/dialog_hotkey_list.h"
|
2009-04-06 18:54:57 +00:00
|
|
|
#include <wx/apptrait.h>
|
|
|
|
#include <wx/stdpaths.h>
|
2010-08-28 18:02:24 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/tool_action.h>
|
2009-04-06 18:54:57 +00:00
|
|
|
|
2007-08-20 11:33:45 +00:00
|
|
|
|
2019-06-12 14:39:47 +00:00
|
|
|
/*
|
2019-06-10 22:17:45 +00:00
|
|
|
* class to handle the printable name and the keycode
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
|
|
|
struct hotkey_name_descr
|
|
|
|
{
|
2007-10-31 08:34:05 +00:00
|
|
|
const wxChar* m_Name;
|
2010-01-20 18:59:46 +00:00
|
|
|
int m_KeyCode;
|
2007-08-21 19:37:31 +00:00
|
|
|
};
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
/* table giving the hotkey name from the hotkey code, for special keys
|
|
|
|
* Note : when modifiers (ATL, SHIFT, CTRL) do not modify
|
|
|
|
* the code of the key, do need to enter the modified key code
|
|
|
|
* For instance wxT( "F1" ), WXK_F1 handle F1, AltF1, CtrlF1 ...
|
2010-08-29 16:36:52 +00:00
|
|
|
* Key names are:
|
|
|
|
* "Space","Ctrl+Space","Alt+Space" or
|
2019-06-10 15:58:32 +00:00
|
|
|
* "Alt+A","Ctrl+F1", ...
|
2010-08-28 18:02:24 +00:00
|
|
|
*/
|
2018-08-16 11:49:13 +00:00
|
|
|
#define KEY_NON_FOUND -1
|
2015-07-02 07:28:54 +00:00
|
|
|
static struct hotkey_name_descr hotkeyNameList[] =
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
{ wxT( "F1" ), WXK_F1 },
|
|
|
|
{ wxT( "F2" ), WXK_F2 },
|
|
|
|
{ wxT( "F3" ), WXK_F3 },
|
|
|
|
{ wxT( "F4" ), WXK_F4 },
|
|
|
|
{ wxT( "F5" ), WXK_F5 },
|
|
|
|
{ wxT( "F6" ), WXK_F6 },
|
|
|
|
{ wxT( "F7" ), WXK_F7 },
|
|
|
|
{ wxT( "F8" ), WXK_F8 },
|
|
|
|
{ wxT( "F9" ), WXK_F9 },
|
|
|
|
{ wxT( "F10" ), WXK_F10 },
|
|
|
|
{ wxT( "F11" ), WXK_F11 },
|
|
|
|
{ wxT( "F12" ), WXK_F12 },
|
|
|
|
|
|
|
|
{ wxT( "Esc" ), WXK_ESCAPE },
|
|
|
|
{ wxT( "Del" ), WXK_DELETE },
|
2010-08-29 16:36:52 +00:00
|
|
|
{ wxT( "Tab" ), WXK_TAB },
|
2018-08-16 11:49:13 +00:00
|
|
|
{ wxT( "Back" ), WXK_BACK },
|
2010-08-28 18:02:24 +00:00
|
|
|
{ wxT( "Ins" ), WXK_INSERT },
|
|
|
|
|
|
|
|
{ wxT( "Home" ), WXK_HOME },
|
|
|
|
{ wxT( "End" ), WXK_END },
|
|
|
|
{ wxT( "PgUp" ), WXK_PAGEUP },
|
|
|
|
{ wxT( "PgDn" ), WXK_PAGEDOWN },
|
|
|
|
|
|
|
|
{ wxT( "Up" ), WXK_UP },
|
|
|
|
{ wxT( "Down" ), WXK_DOWN },
|
|
|
|
{ wxT( "Left" ), WXK_LEFT },
|
|
|
|
{ wxT( "Right" ), WXK_RIGHT },
|
2010-01-20 18:59:46 +00:00
|
|
|
|
2015-07-02 07:28:54 +00:00
|
|
|
{ wxT( "Return" ), WXK_RETURN },
|
2014-04-03 07:40:55 +00:00
|
|
|
|
2010-08-29 16:36:52 +00:00
|
|
|
{ wxT( "Space" ), WXK_SPACE },
|
|
|
|
|
2020-10-17 04:17:05 +00:00
|
|
|
{ wxT( "Num Pad 0" ), WXK_NUMPAD0 },
|
|
|
|
{ wxT( "Num Pad 1" ), WXK_NUMPAD1 },
|
|
|
|
{ wxT( "Num Pad 2" ), WXK_NUMPAD2 },
|
|
|
|
{ wxT( "Num Pad 3" ), WXK_NUMPAD3 },
|
|
|
|
{ wxT( "Num Pad 4" ), WXK_NUMPAD4 },
|
|
|
|
{ wxT( "Num Pad 5" ), WXK_NUMPAD5 },
|
|
|
|
{ wxT( "Num Pad 6" ), WXK_NUMPAD6 },
|
|
|
|
{ wxT( "Num Pad 7" ), WXK_NUMPAD7 },
|
|
|
|
{ wxT( "Num Pad 8" ), WXK_NUMPAD8 },
|
|
|
|
{ wxT( "Num Pad 9" ), WXK_NUMPAD9 },
|
|
|
|
{ wxT( "Num Pad +" ), WXK_NUMPAD_ADD },
|
|
|
|
{ wxT( "Num Pad -" ), WXK_NUMPAD_SUBTRACT },
|
|
|
|
{ wxT( "Num Pad *" ), WXK_NUMPAD_MULTIPLY },
|
|
|
|
{ wxT( "Num Pad /" ), WXK_NUMPAD_DIVIDE },
|
|
|
|
{ wxT( "Num Pad ." ), WXK_NUMPAD_SEPARATOR },
|
|
|
|
|
2019-06-13 19:38:14 +00:00
|
|
|
{ wxT( "" ), 0 },
|
2018-08-16 11:49:13 +00:00
|
|
|
|
2019-06-14 15:53:53 +00:00
|
|
|
{ wxT( "Click" ), PSEUDO_WXK_CLICK },
|
|
|
|
{ wxT( "DblClick" ), PSEUDO_WXK_DBLCLICK },
|
|
|
|
{ wxT( "Wheel" ), PSEUDO_WXK_WHEEL },
|
2019-06-12 14:39:47 +00:00
|
|
|
|
2010-01-20 18:59:46 +00:00
|
|
|
// Do not change this line: end of list
|
2018-08-16 11:49:13 +00:00
|
|
|
{ wxT( "" ), KEY_NON_FOUND }
|
2007-08-21 19:37:31 +00:00
|
|
|
};
|
|
|
|
|
2015-07-02 07:28:54 +00:00
|
|
|
// name of modifier keys.
|
|
|
|
// Note: the Ctrl key is Cmd key on Mac OS X.
|
|
|
|
// However, in wxWidgets defs, the key WXK_CONTROL is the Cmd key,
|
|
|
|
// so the code using WXK_CONTROL should be ok on any system.
|
|
|
|
// (on Mac OS X the actual Ctrl key code is WXK_RAW_CONTROL)
|
|
|
|
#ifdef __WXMAC__
|
2015-07-04 08:36:58 +00:00
|
|
|
#define USING_MAC_CMD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USING_MAC_CMD
|
2015-07-02 07:28:54 +00:00
|
|
|
#define MODIFIER_CTRL wxT( "Cmd+" )
|
|
|
|
#else
|
|
|
|
#define MODIFIER_CTRL wxT( "Ctrl+" )
|
|
|
|
#endif
|
|
|
|
#define MODIFIER_CMD_MAC wxT( "Cmd+" )
|
|
|
|
#define MODIFIER_CTRL_BASE wxT( "Ctrl+" )
|
|
|
|
#define MODIFIER_ALT wxT( "Alt+" )
|
|
|
|
#define MODIFIER_SHIFT wxT( "Shift+" )
|
2010-08-28 19:08:58 +00:00
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
* Function KeyNameFromKeyCode
|
2007-08-30 08:15:05 +00:00
|
|
|
* return the key name from the key code
|
2009-11-23 15:16:50 +00:00
|
|
|
* Only some wxWidgets key values are handled for function key ( see
|
2015-07-02 07:28:54 +00:00
|
|
|
* hotkeyNameList[] )
|
2010-02-16 10:42:57 +00:00
|
|
|
* @param aKeycode = key code (ascii value, or wxWidgets value for function keys)
|
2018-01-06 04:22:00 +00:00
|
|
|
* @param aIsFound = a pointer to a bool to return true if found, or false. an be nullptr default)
|
2007-08-30 08:15:05 +00:00
|
|
|
* @return the key name in a wxString
|
|
|
|
*/
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
wxString keyname, modifier, fullkeyname;
|
|
|
|
int ii;
|
2010-08-28 18:02:24 +00:00
|
|
|
bool found = false;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2014-10-16 01:17:51 +00:00
|
|
|
// Assume keycode of 0 is "unassigned"
|
2019-06-09 21:57:23 +00:00
|
|
|
if( (aKeycode & MD_CTRL) != 0 )
|
2010-08-28 19:08:58 +00:00
|
|
|
modifier << MODIFIER_CTRL;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( (aKeycode & MD_ALT) != 0 )
|
2010-08-28 19:08:58 +00:00
|
|
|
modifier << MODIFIER_ALT;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( (aKeycode & MD_SHIFT) != 0 )
|
2010-08-28 19:08:58 +00:00
|
|
|
modifier << MODIFIER_SHIFT;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
aKeycode &= ~( MD_CTRL | MD_ALT | MD_SHIFT );
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2010-08-29 16:36:52 +00:00
|
|
|
if( (aKeycode > ' ') && (aKeycode < 0x7F ) )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
found = true;
|
2011-09-01 12:54:34 +00:00
|
|
|
keyname.Append( (wxChar)aKeycode );
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( ii = 0; ; ii++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2018-08-16 11:49:13 +00:00
|
|
|
if( hotkeyNameList[ii].m_KeyCode == KEY_NON_FOUND ) // End of list
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
keyname = wxT( "<unknown>" );
|
|
|
|
break;
|
|
|
|
}
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2015-07-02 07:28:54 +00:00
|
|
|
if( hotkeyNameList[ii].m_KeyCode == aKeycode )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
2015-07-02 07:28:54 +00:00
|
|
|
keyname = hotkeyNameList[ii].m_Name;
|
2010-08-28 18:02:24 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( aIsFound )
|
|
|
|
*aIsFound = found;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
fullkeyname = modifier + keyname;
|
|
|
|
return fullkeyname;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
2007-08-20 11:33:45 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
/**
|
|
|
|
* AddHotkeyName
|
|
|
|
* @param aText - the base text on which to append the hotkey
|
|
|
|
* @param aHotKey - the hotkey keycode
|
|
|
|
* @param aStyle - IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys)
|
|
|
|
* IS_COMMENT to add <spaces><(keyname)> mainly in tool tips
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
wxString AddHotkeyName( const wxString& aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString msg = aText;
|
2019-06-09 21:57:23 +00:00
|
|
|
wxString keyname = KeyNameFromKeyCode( aHotKey );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
if( !keyname.IsEmpty() )
|
2011-04-05 14:46:51 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
switch( aStyle )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2014-10-17 14:36:47 +00:00
|
|
|
case IS_HOTKEY:
|
2019-06-11 13:40:54 +00:00
|
|
|
{
|
|
|
|
// Don't add a suffix for unassigned hotkeys:
|
|
|
|
// WX spews debug from wxAcceleratorEntry::ParseAccel if it doesn't
|
|
|
|
// recognise the keyname, which is the case for <unassigned>.
|
|
|
|
if( aHotKey != 0 )
|
|
|
|
{
|
|
|
|
msg << wxT( "\t" ) << keyname;
|
|
|
|
}
|
2014-10-17 14:36:47 +00:00
|
|
|
break;
|
2019-06-11 13:40:54 +00:00
|
|
|
}
|
2014-10-17 14:36:47 +00:00
|
|
|
case IS_COMMENT:
|
2019-06-11 13:40:54 +00:00
|
|
|
{
|
2014-10-17 14:36:47 +00:00
|
|
|
msg << wxT( " (" ) << keyname << wxT( ")" );
|
|
|
|
break;
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
2019-06-11 13:40:54 +00:00
|
|
|
}
|
2011-04-05 14:46:51 +00:00
|
|
|
}
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2015-07-04 08:36:58 +00:00
|
|
|
#ifdef USING_MAC_CMD
|
2015-08-01 21:46:27 +00:00
|
|
|
// On OSX, the modifier equivalent to the Ctrl key of PCs
|
2015-07-04 08:36:58 +00:00
|
|
|
// is the Cmd key, but in code we should use Ctrl as prefix in menus
|
|
|
|
msg.Replace( MODIFIER_CMD_MAC, MODIFIER_CTRL_BASE );
|
|
|
|
#endif
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
* Function KeyCodeFromKeyName
|
2019-06-10 15:58:32 +00:00
|
|
|
* return the key code from its user-friendly key name (ie: "Ctrl+M")
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
int KeyCodeFromKeyName( const wxString& keyname )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2018-08-16 11:49:13 +00:00
|
|
|
int ii, keycode = KEY_NON_FOUND;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
// Search for modifiers: Ctrl+ Alt+ and Shift+
|
2015-07-02 07:28:54 +00:00
|
|
|
// Note: on Mac OSX, the Cmd key is equiv here to Ctrl
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString key = keyname;
|
2015-07-02 07:28:54 +00:00
|
|
|
wxString prefix;
|
2010-08-28 18:02:24 +00:00
|
|
|
int modifier = 0;
|
2015-07-02 07:28:54 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
while( true )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
2015-07-02 07:28:54 +00:00
|
|
|
prefix.Empty();
|
|
|
|
|
|
|
|
if( key.StartsWith( MODIFIER_CTRL_BASE ) )
|
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
modifier |= MD_CTRL;
|
2015-07-02 07:28:54 +00:00
|
|
|
prefix = MODIFIER_CTRL_BASE;
|
|
|
|
}
|
|
|
|
else if( key.StartsWith( MODIFIER_CMD_MAC ) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
modifier |= MD_CTRL;
|
2015-07-02 07:28:54 +00:00
|
|
|
prefix = MODIFIER_CMD_MAC;
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
2010-08-28 19:08:58 +00:00
|
|
|
else if( key.StartsWith( MODIFIER_ALT ) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
modifier |= MD_ALT;
|
2015-07-02 07:28:54 +00:00
|
|
|
prefix = MODIFIER_ALT;
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
2010-08-28 19:08:58 +00:00
|
|
|
else if( key.StartsWith( MODIFIER_SHIFT ) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
modifier |= MD_SHIFT;
|
2015-07-02 07:28:54 +00:00
|
|
|
prefix = MODIFIER_SHIFT;
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-01 12:54:34 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
break;
|
2011-09-01 12:54:34 +00:00
|
|
|
}
|
2015-07-02 07:28:54 +00:00
|
|
|
|
|
|
|
if( !prefix.IsEmpty() )
|
|
|
|
key.Remove( 0, prefix.Len() );
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
|
2010-08-29 16:36:52 +00:00
|
|
|
if( (key.length() == 1) && (key[0] > ' ') && (key[0] < 0x7F) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
keycode = key[0];
|
|
|
|
keycode += modifier;
|
2010-08-29 16:36:52 +00:00
|
|
|
return keycode;
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
|
2018-08-16 11:49:13 +00:00
|
|
|
for( ii = 0; hotkeyNameList[ii].m_KeyCode != KEY_NON_FOUND; ii++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2015-07-02 07:28:54 +00:00
|
|
|
if( key.CmpNoCase( hotkeyNameList[ii].m_Name ) == 0 )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2015-07-02 07:28:54 +00:00
|
|
|
keycode = hotkeyNameList[ii].m_KeyCode + modifier;
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return keycode;
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2020-10-02 16:31:19 +00:00
|
|
|
/*
|
2019-06-09 21:57:23 +00:00
|
|
|
* DisplayHotkeyList
|
|
|
|
* Displays the hotkeys registered with the given tool manager.
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
void DisplayHotkeyList( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolManager )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
DIALOG_LIST_HOTKEYS dlg( aParent, aToolManager );
|
2018-10-02 21:37:15 +00:00
|
|
|
dlg.ShowModal();
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2019-06-10 15:58:32 +00:00
|
|
|
void ReadHotKeyConfig( wxString fileName, std::map<std::string, int>& aHotKeys )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2019-06-10 15:58:32 +00:00
|
|
|
if( fileName.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxFileName fn( "user" );
|
|
|
|
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
|
2020-01-13 01:44:19 +00:00
|
|
|
fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
|
2019-06-10 15:58:32 +00:00
|
|
|
fileName = fn.GetFullPath();
|
|
|
|
}
|
2020-10-02 16:31:19 +00:00
|
|
|
|
2019-06-10 15:58:32 +00:00
|
|
|
if( !wxFile::Exists( fileName ) )
|
|
|
|
return;
|
2015-05-05 18:39:42 +00:00
|
|
|
|
2019-06-10 15:58:32 +00:00
|
|
|
wxFile file( fileName, wxFile::OpenMode::read );
|
2015-05-05 18:39:42 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( !file.IsOpened() ) // There is a problem to open file
|
2019-06-10 15:58:32 +00:00
|
|
|
return;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2019-06-10 15:58:32 +00:00
|
|
|
wxString input;
|
2019-06-09 21:57:23 +00:00
|
|
|
file.ReadAll( &input );
|
|
|
|
input.Replace( "\r\n", "\n" ); // Convert Windows files to Unix line-ends
|
|
|
|
wxStringTokenizer fileTokenizer( input, "\n", wxTOKEN_STRTOK );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
while( fileTokenizer.HasMoreTokens() )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
wxStringTokenizer lineTokenizer( fileTokenizer.GetNextToken(), "\t" );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
wxString cmdName = lineTokenizer.GetNextToken();
|
|
|
|
wxString keyName = lineTokenizer.GetNextToken();
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( !cmdName.IsEmpty() )
|
2019-06-10 15:58:32 +00:00
|
|
|
aHotKeys[ cmdName.ToStdString() ] = KeyCodeFromKeyName( keyName );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
2019-06-10 15:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
int WriteHotKeyConfig( const std::map<std::string, TOOL_ACTION*>& aActionMap )
|
2019-06-10 15:58:32 +00:00
|
|
|
{
|
|
|
|
std::map<std::string, int> hotkeys;
|
|
|
|
wxFileName fn( "user" );
|
|
|
|
|
|
|
|
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
|
2020-01-13 01:44:19 +00:00
|
|
|
fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2019-06-10 15:58:32 +00:00
|
|
|
// Read the existing config (all hotkeys)
|
|
|
|
//
|
|
|
|
ReadHotKeyConfig( fn.GetFullPath(), hotkeys );
|
2020-10-02 16:31:19 +00:00
|
|
|
|
2019-06-10 15:58:32 +00:00
|
|
|
// Overlay the current app's hotkey definitions onto the map
|
2019-06-09 21:57:23 +00:00
|
|
|
//
|
|
|
|
for( const auto& ii : aActionMap )
|
2019-06-14 10:55:54 +00:00
|
|
|
hotkeys[ ii.first ] = ii.second->GetHotKey();
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
// Write entire hotkey set
|
|
|
|
//
|
2019-06-10 15:58:32 +00:00
|
|
|
wxFile file( fn.GetFullPath(), wxFile::OpenMode::write );
|
2020-10-02 16:31:19 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
for( const auto& ii : hotkeys )
|
|
|
|
file.Write( wxString::Format( "%s\t%s\n", ii.first, KeyNameFromKeyCode( ii.second ) ) );
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
int ReadLegacyHotkeyConfig( const wxString& aAppname, std::map<std::string, int>& aMap )
|
|
|
|
{
|
|
|
|
// For Eeschema and Pcbnew frames, we read the new combined file.
|
|
|
|
// For other kifaces, we read the frame-based file
|
|
|
|
if( aAppname == LIB_EDIT_FRAME_NAME || aAppname == SCH_EDIT_FRAME_NAME )
|
2018-02-23 16:44:29 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
return ReadLegacyHotkeyConfigFile( EESCHEMA_HOTKEY_NAME, aMap );
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
2019-06-09 21:57:23 +00:00
|
|
|
else if( aAppname == PCB_EDIT_FRAME_NAME || aAppname == FOOTPRINT_EDIT_FRAME_NAME )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
return ReadLegacyHotkeyConfigFile( PCBNEW_HOTKEY_NAME, aMap );
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
return ReadLegacyHotkeyConfigFile( aAppname, aMap );
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string, int>& aMap )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2015-03-02 17:29:18 +00:00
|
|
|
wxFileName fn( aFilename );
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
|
2020-01-13 01:44:19 +00:00
|
|
|
fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
|
2018-02-23 16:44:29 +00:00
|
|
|
|
|
|
|
if( !wxFile::Exists( fn.GetFullPath() ) )
|
|
|
|
return 0;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2018-02-23 16:44:29 +00:00
|
|
|
wxFile cfgfile( fn.GetFullPath() );
|
2020-10-02 16:31:19 +00:00
|
|
|
|
2014-11-23 11:41:57 +00:00
|
|
|
if( !cfgfile.IsOpened() ) // There is a problem to open file
|
|
|
|
return 0;
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// get length
|
2010-08-28 18:02:24 +00:00
|
|
|
cfgfile.SeekEnd();
|
|
|
|
wxFileOffset size = cfgfile.Tell();
|
|
|
|
cfgfile.Seek( 0 );
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// read data
|
2018-01-08 11:52:17 +00:00
|
|
|
std::vector<char> buffer( size );
|
2018-01-06 04:22:00 +00:00
|
|
|
cfgfile.Read( buffer.data(), size );
|
2018-09-14 07:59:57 +00:00
|
|
|
wxString data( buffer.data(), wxConvUTF8, size );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2018-02-23 16:44:29 +00:00
|
|
|
// Is this the wxConfig format? If so, remove "Keys=" and parse the newlines.
|
|
|
|
if( data.StartsWith( wxT("Keys="), &data ) )
|
|
|
|
data.Replace( "\\n", "\n", true );
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// parse
|
2010-08-28 18:02:24 +00:00
|
|
|
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
|
|
|
|
|
|
|
|
while( tokenizer.HasMoreTokens() )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString line = tokenizer.GetNextToken();
|
|
|
|
wxStringTokenizer lineTokenizer( line );
|
|
|
|
|
|
|
|
wxString line_type = lineTokenizer.GetNextToken();
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( line_type[0] == '#' ) // comment
|
2010-08-28 18:02:24 +00:00
|
|
|
continue;
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( line_type[0] == '[' ) // tags ignored reading legacy hotkeys
|
2007-09-06 11:52:26 +00:00
|
|
|
continue;
|
2018-02-23 17:22:56 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( line_type == wxT( "$Endlist" ) )
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( line_type != wxT( "shortcut" ) )
|
|
|
|
continue;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// Get the key name
|
2010-08-28 18:02:24 +00:00
|
|
|
lineTokenizer.SetString( lineTokenizer.GetString(), L"\"\r\n\t ", wxTOKEN_STRTOK );
|
|
|
|
wxString keyname = lineTokenizer.GetNextToken();
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString remainder = lineTokenizer.GetString();
|
2008-09-03 16:19:06 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// Get the command name
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' );
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
// Add the pair to the map
|
|
|
|
aMap[ fctname.ToStdString() ] = KeyCodeFromKeyName( keyname );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
2019-06-09 21:57:23 +00:00
|
|
|
|
|
|
|
// cleanup
|
|
|
|
cfgfile.Close();
|
|
|
|
return 1;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
|