Allow translating keys to current keyboard layout.
UI is not refreshed at layout change yet.
This commit is contained in:
parent
002503d9bd
commit
a679901803
|
@ -143,15 +143,15 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
|
||||||
"Use %s+Tab to activate selector.\n"
|
"Use %s+Tab to activate selector.\n"
|
||||||
"Successive Tabs while holding %s down will "
|
"Successive Tabs while holding %s down will "
|
||||||
"cycle through presets in the popup." ),
|
"cycle through presets in the popup." ),
|
||||||
KeyNameFromKeyCode( PRESET_SWITCH_KEY ),
|
KeyNameFromKeyCode( PRESET_SWITCH_KEY, true ),
|
||||||
KeyNameFromKeyCode( PRESET_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( PRESET_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
m_cbViewports->SetToolTip( wxString::Format( _( "Save and restore camera position and zoom.\n"
|
m_cbViewports->SetToolTip( wxString::Format( _( "Save and restore camera position and zoom.\n"
|
||||||
"Use %s+Tab to activate selector.\n"
|
"Use %s+Tab to activate selector.\n"
|
||||||
"Successive Tabs while holding %s down will "
|
"Successive Tabs while holding %s down will "
|
||||||
"cycle through viewports in the popup." ),
|
"cycle through viewports in the popup." ),
|
||||||
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ),
|
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY, true ),
|
||||||
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
if( screenHeight <= 900 && m_pointSize >= indicatorSize )
|
if( screenHeight <= 900 && m_pointSize >= indicatorSize )
|
||||||
m_pointSize = m_pointSize * 8 / 10;
|
m_pointSize = m_pointSize * 8 / 10;
|
||||||
|
@ -605,7 +605,7 @@ void APPEARANCE_CONTROLS_3D::UpdateLayerCtls()
|
||||||
void APPEARANCE_CONTROLS_3D::rebuildLayerPresetsWidget()
|
void APPEARANCE_CONTROLS_3D::rebuildLayerPresetsWidget()
|
||||||
{
|
{
|
||||||
m_presetsLabel->SetLabel( wxString::Format( _( "Presets (%s+Tab):" ),
|
m_presetsLabel->SetLabel( wxString::Format( _( "Presets (%s+Tab):" ),
|
||||||
KeyNameFromKeyCode( PRESET_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( PRESET_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
m_cbLayerPresets->Clear();
|
m_cbLayerPresets->Clear();
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ void APPEARANCE_CONTROLS_3D::doApplyLayerPreset( const LAYER_PRESET_3D& aPreset
|
||||||
void APPEARANCE_CONTROLS_3D::rebuildViewportsWidget()
|
void APPEARANCE_CONTROLS_3D::rebuildViewportsWidget()
|
||||||
{
|
{
|
||||||
m_viewportsLabel->SetLabel( wxString::Format( _( "Viewports (%s+Tab):" ),
|
m_viewportsLabel->SetLabel( wxString::Format( _( "Viewports (%s+Tab):" ),
|
||||||
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
m_cbViewports->Clear();
|
m_cbViewports->Clear();
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,8 @@ PANEL_GRID_SETTINGS::PANEL_GRID_SETTINGS( wxWindow* aParent, UNITS_PROVIDER* aUn
|
||||||
|
|
||||||
int hk1 = ACTIONS::gridFast1.GetHotKey();
|
int hk1 = ACTIONS::gridFast1.GetHotKey();
|
||||||
int hk2 = ACTIONS::gridFast2.GetHotKey();
|
int hk2 = ACTIONS::gridFast2.GetHotKey();
|
||||||
m_grid1HotKey->SetLabel( wxString::Format( wxT( "(%s)" ), KeyNameFromKeyCode( hk1 ) ) );
|
m_grid1HotKey->SetLabel( wxString::Format( wxT( "(%s)" ), KeyNameFromKeyCode( hk1, true ) ) );
|
||||||
m_grid2HotKey->SetLabel( wxString::Format( wxT( "(%s)" ), KeyNameFromKeyCode( hk2 ) ) );
|
m_grid2HotKey->SetLabel( wxString::Format( wxT( "(%s)" ), KeyNameFromKeyCode( hk2, true ) ) );
|
||||||
|
|
||||||
m_addGridButton->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
m_addGridButton->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
||||||
m_removeGridButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
m_removeGridButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
||||||
|
|
|
@ -259,8 +259,8 @@ void PANEL_HOTKEYS_EDITOR::dumpHotkeys()
|
||||||
|
|
||||||
if( hk.m_EditKeycode > 0 )
|
if( hk.m_EditKeycode > 0 )
|
||||||
{
|
{
|
||||||
stream << wxT( " | kbd:[" ) << KeyNameFromKeyCode( hk.m_EditKeycode ) << ']'
|
stream << wxT( " | kbd:[" ) << KeyNameFromKeyCode( hk.m_EditKeycode, false ) << ']'
|
||||||
<< endl;
|
<< endl; // TODO: localized or not?
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -169,10 +169,11 @@ static struct hotkey_name_descr hotkeyNameList[] =
|
||||||
* Only some wxWidgets key values are handled for function key ( see hotkeyNameList[] )
|
* Only some wxWidgets key values are handled for function key ( see hotkeyNameList[] )
|
||||||
*
|
*
|
||||||
* @param aKeycode key code (ASCII value, or wxWidgets value for function keys).
|
* @param aKeycode key code (ASCII value, or wxWidgets value for function keys).
|
||||||
|
* @param aLocalized set to true to translate the key using current keyboard layout instead of US layout.
|
||||||
* @param aIsFound a pointer to a bool to return true if found, or false. an be nullptr default).
|
* @param aIsFound a pointer to a bool to return true if found, or false. an be nullptr default).
|
||||||
* @return the key name in a wxString.
|
* @return the key name in a wxString.
|
||||||
*/
|
*/
|
||||||
wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
|
wxString KeyNameFromKeyCode( int aKeycode, bool aLocalized, bool* aIsFound )
|
||||||
{
|
{
|
||||||
wxString keyname, modifier, fullkeyname;
|
wxString keyname, modifier, fullkeyname;
|
||||||
int ii;
|
int ii;
|
||||||
|
@ -199,10 +200,26 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
|
||||||
|
|
||||||
aKeycode &= ~( MD_CTRL | MD_ALT | MD_SHIFT );
|
aKeycode &= ~( MD_CTRL | MD_ALT | MD_SHIFT );
|
||||||
|
|
||||||
if( (aKeycode > ' ') && (aKeycode < 0x7F ) )
|
if( ( aKeycode > ' ' ) && ( aKeycode < 0x7F ) )
|
||||||
{
|
{
|
||||||
found = true;
|
if( aLocalized )
|
||||||
keyname.Append( (wxChar)aKeycode );
|
{
|
||||||
|
GeckoKeys::CodeNameIndex idx = GeckoKeys::CodeNameIndexFromWXK( aKeycode );
|
||||||
|
uint32_t scancode = GeckoKeys::ScancodeFromCodeNameIndex( idx );
|
||||||
|
wchar_t ch = GeckoKeys::CharFromScancode( scancode );
|
||||||
|
|
||||||
|
if( ch )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
keyname.Append( ch );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !found )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
keyname.Append( (wxChar) aKeycode );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -240,7 +257,7 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
|
||||||
wxString AddHotkeyName( const wxString& aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle )
|
wxString AddHotkeyName( const wxString& aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle )
|
||||||
{
|
{
|
||||||
wxString msg = aText;
|
wxString msg = aText;
|
||||||
wxString keyname = KeyNameFromKeyCode( aHotKey );
|
wxString keyname = KeyNameFromKeyCode( aHotKey, true );
|
||||||
|
|
||||||
if( !keyname.IsEmpty() )
|
if( !keyname.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -429,9 +446,10 @@ int WriteHotKeyConfig( const std::vector<TOOL_ACTION*>& aActions )
|
||||||
wxTextOutputStream txtStream( outStream, wxEOL_UNIX );
|
wxTextOutputStream txtStream( outStream, wxEOL_UNIX );
|
||||||
|
|
||||||
for( const std::pair<const std::string, std::pair<int, int>>& entry : hotkeys )
|
for( const std::pair<const std::string, std::pair<int, int>>& entry : hotkeys )
|
||||||
txtStream << entry.first
|
{
|
||||||
<< "\t" << KeyNameFromKeyCode( entry.second.first )
|
txtStream << entry.first << "\t" << KeyNameFromKeyCode( entry.second.first, false ) << "\t"
|
||||||
<< "\t" << KeyNameFromKeyCode( entry.second.second ) << endl;
|
<< KeyNameFromKeyCode( entry.second.second, false ) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
txtStream.Flush();
|
txtStream.Flush();
|
||||||
outStream.Close();
|
outStream.Close();
|
||||||
|
|
|
@ -48,7 +48,7 @@ ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
|
||||||
std::string groupName = "none";
|
std::string groupName = "none";
|
||||||
|
|
||||||
std::optional<TOOL_ACTION_GROUP> group = action->GetActionGroup();
|
std::optional<TOOL_ACTION_GROUP> group = action->GetActionGroup();
|
||||||
|
|
||||||
if( group.has_value() )
|
if( group.has_value() )
|
||||||
{
|
{
|
||||||
groupID = group.value().GetGroupID();
|
groupID = group.value().GetGroupID();
|
||||||
|
@ -144,8 +144,8 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||||
if( key >= 'a' && key <= 'z' )
|
if( key >= 'a' && key <= 'z' )
|
||||||
key = std::toupper( key );
|
key = std::toupper( key );
|
||||||
|
|
||||||
wxLogTrace( kicadTraceToolStack, wxS( "ACTION_MANAGER::RunHotKey Key: %s" ),
|
wxLogTrace( kicadTraceToolStack, wxS( "ACTION_MANAGER::RunHotKey Key: %s, Translated: %s" ),
|
||||||
KeyNameFromKeyCode( aHotKey ) );
|
KeyNameFromKeyCode( aHotKey, false ), KeyNameFromKeyCode( aHotKey, true ) );
|
||||||
|
|
||||||
HOTKEY_LIST::const_iterator it = m_actionHotKeys.find( key | mod );
|
HOTKEY_LIST::const_iterator it = m_actionHotKeys.find( key | mod );
|
||||||
|
|
||||||
|
@ -156,8 +156,9 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||||
if( it == m_actionHotKeys.end() )
|
if( it == m_actionHotKeys.end() )
|
||||||
{
|
{
|
||||||
wxLogTrace( kicadTraceToolStack,
|
wxLogTrace( kicadTraceToolStack,
|
||||||
wxS( "ACTION_MANAGER::RunHotKey No actions found, searching with key: %s" ),
|
wxS( "ACTION_MANAGER::RunHotKey No actions found, searching with key: %s, translated: %s" ),
|
||||||
KeyNameFromKeyCode( key | ( mod & ~MD_SHIFT ) ) );
|
KeyNameFromKeyCode( key | ( mod & ~MD_SHIFT ), false ),
|
||||||
|
KeyNameFromKeyCode( key | ( mod & ~MD_SHIFT ), true ) );
|
||||||
|
|
||||||
it = m_actionHotKeys.find( key | ( mod & ~MD_SHIFT ) );
|
it = m_actionHotKeys.find( key | ( mod & ~MD_SHIFT ) );
|
||||||
|
|
||||||
|
@ -210,10 +211,11 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||||
runAction = aCond->enableCondition( sel );
|
runAction = aCond->enableCondition( sel );
|
||||||
|
|
||||||
wxLogTrace( kicadTraceToolStack,
|
wxLogTrace( kicadTraceToolStack,
|
||||||
wxS( "ACTION_MANAGER::RunHotKey %s context action: %s for hotkey %s" ),
|
wxS( "ACTION_MANAGER::RunHotKey %s context action: %s for hotkey %s, translated %s" ),
|
||||||
runAction ? wxS( "Running" ) : wxS( "Not running" ),
|
runAction ? wxS( "Running" ) : wxS( "Not running" ),
|
||||||
context->GetName(),
|
context->GetName(),
|
||||||
KeyNameFromKeyCode( aHotKey ) );
|
KeyNameFromKeyCode( aHotKey, false ),
|
||||||
|
KeyNameFromKeyCode( aHotKey, true ) );
|
||||||
|
|
||||||
if( runAction )
|
if( runAction )
|
||||||
return m_toolMgr->RunAction( *context );
|
return m_toolMgr->RunAction( *context );
|
||||||
|
@ -228,10 +230,11 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||||
runAction = aCond->enableCondition( sel );
|
runAction = aCond->enableCondition( sel );
|
||||||
|
|
||||||
wxLogTrace( kicadTraceToolStack,
|
wxLogTrace( kicadTraceToolStack,
|
||||||
wxS( "ACTION_MANAGER::RunHotKey %s global action: %s for hotkey %s" ),
|
wxS( "ACTION_MANAGER::RunHotKey %s global action: %s for hotkey %s, translated %s" ),
|
||||||
runAction ? wxS( "Running" ) : wxS( "Not running" ),
|
runAction ? wxS( "Running" ) : wxS( "Not running" ),
|
||||||
act->GetName(),
|
act->GetName(),
|
||||||
KeyNameFromKeyCode( aHotKey ) );
|
KeyNameFromKeyCode( aHotKey, false ),
|
||||||
|
KeyNameFromKeyCode( aHotKey, true ) );
|
||||||
|
|
||||||
if( runAction && m_toolMgr->RunAction( *act ) )
|
if( runAction && m_toolMgr->RunAction( *act ) )
|
||||||
return true;
|
return true;
|
||||||
|
@ -239,8 +242,9 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogTrace( kicadTraceToolStack,
|
wxLogTrace( kicadTraceToolStack,
|
||||||
wxS( "ACTION_MANAGER::RunHotKey No action found for key %s" ),
|
wxS( "ACTION_MANAGER::RunHotKey No action found for key %s, translated %s" ),
|
||||||
KeyNameFromKeyCode( aHotKey ) );
|
KeyNameFromKeyCode( aHotKey, false ),
|
||||||
|
KeyNameFromKeyCode( aHotKey, true ) );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ wxString TOOL_ACTION::GetTooltip( bool aIncludeHotkey ) const
|
||||||
wxString tooltip = wxGetTranslation( m_tooltip );
|
wxString tooltip = wxGetTranslation( m_tooltip );
|
||||||
|
|
||||||
if( aIncludeHotkey && GetHotKey() )
|
if( aIncludeHotkey && GetHotKey() )
|
||||||
tooltip += wxString::Format( wxT( " (%s)" ), KeyNameFromKeyCode( GetHotKey() ) );
|
tooltip += wxString::Format( wxT( " (%s)" ), KeyNameFromKeyCode( GetHotKey(), true ) );
|
||||||
|
|
||||||
return tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ wxString TOOL_ACTION::GetButtonTooltip() const
|
||||||
wxString tooltip = GetFriendlyName();
|
wxString tooltip = GetFriendlyName();
|
||||||
|
|
||||||
if( GetHotKey() )
|
if( GetHotKey() )
|
||||||
tooltip += wxString::Format( wxT( " (%s)" ), KeyNameFromKeyCode( GetHotKey() ) );
|
tooltip += wxString::Format( wxT( " (%s)" ), KeyNameFromKeyCode( GetHotKey(), true ) );
|
||||||
|
|
||||||
if( !GetTooltip( false ).IsEmpty() )
|
if( !GetTooltip( false ).IsEmpty() )
|
||||||
tooltip += '\n' + GetTooltip( false );
|
tooltip += '\n' + GetTooltip( false );
|
||||||
|
|
|
@ -202,7 +202,7 @@ protected:
|
||||||
if( keycode == WXK_NONE )
|
if( keycode == WXK_NONE )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_key_label_1->SetLabel( KeyNameFromKeyCode( keycode ) );
|
m_key_label_1->SetLabel( KeyNameFromKeyCode( keycode, true ) );
|
||||||
m_event = aEvent;
|
m_event = aEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ public:
|
||||||
if( normedInfo.Contains( m_normalised_filter_str ) )
|
if( normedInfo.Contains( m_normalised_filter_str ) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode );
|
const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode, true );
|
||||||
|
|
||||||
if( keyName.Upper().Contains( m_normalised_filter_str ) )
|
if( keyName.Upper().Contains( m_normalised_filter_str ) )
|
||||||
return true;
|
return true;
|
||||||
|
@ -307,8 +307,8 @@ void WIDGET_HOTKEY_LIST::updateFromClientData()
|
||||||
{
|
{
|
||||||
const HOTKEY& changed_hk = hkdata->GetChangedHotkey();
|
const HOTKEY& changed_hk = hkdata->GetChangedHotkey();
|
||||||
wxString label = changed_hk.m_Actions[ 0 ]->GetFriendlyName();
|
wxString label = changed_hk.m_Actions[ 0 ]->GetFriendlyName();
|
||||||
wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode );
|
wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode, true );
|
||||||
wxString alt_text = KeyNameFromKeyCode( changed_hk.m_EditKeycodeAlt );
|
wxString alt_text = KeyNameFromKeyCode( changed_hk.m_EditKeycodeAlt, true );
|
||||||
wxString description = changed_hk.m_Actions[ 0 ]->GetDescription();
|
wxString description = changed_hk.m_Actions[ 0 ]->GetDescription();
|
||||||
|
|
||||||
if( label.IsEmpty() )
|
if( label.IsEmpty() )
|
||||||
|
@ -479,7 +479,7 @@ bool WIDGET_HOTKEY_LIST::resolveKeyConflicts( TOOL_ACTION* aAction, long aKey )
|
||||||
TOOL_ACTION* conflictingAction = conflictingHotKey->m_Actions[ 0 ];
|
TOOL_ACTION* conflictingAction = conflictingHotKey->m_Actions[ 0 ];
|
||||||
wxString msg = wxString::Format( _( "'%s' is already assigned to '%s' in section '%s'. "
|
wxString msg = wxString::Format( _( "'%s' is already assigned to '%s' in section '%s'. "
|
||||||
"Are you sure you want to change its assignment?" ),
|
"Are you sure you want to change its assignment?" ),
|
||||||
KeyNameFromKeyCode( aKey ),
|
KeyNameFromKeyCode( aKey, true ),
|
||||||
conflictingAction->GetFriendlyName(),
|
conflictingAction->GetFriendlyName(),
|
||||||
HOTKEY_STORE::GetSectionName( conflictingAction ) );
|
HOTKEY_STORE::GetSectionName( conflictingAction ) );
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,10 @@ int KeyCodeFromKeyName( const wxString& keyname );
|
||||||
* Return the user friendly key name (ie: "Ctrl+M") from the key code.
|
* Return the user friendly key name (ie: "Ctrl+M") from the key code.
|
||||||
*
|
*
|
||||||
* @param aKeycode key code (ASCII value, or wxWidgets value for function keys).
|
* @param aKeycode key code (ASCII value, or wxWidgets value for function keys).
|
||||||
|
* @param aLocalized set to true to translate the key using current keyboard layout instead of US layout.
|
||||||
* @param aIsFound a pointer to a bool to return true if found, or false.
|
* @param aIsFound a pointer to a bool to return true if found, or false.
|
||||||
*/
|
*/
|
||||||
wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound = nullptr );
|
wxString KeyNameFromKeyCode( int aKeycode, bool aLocalized, bool* aIsFound = nullptr );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In menus we can add a hot key, or an accelerator, or sometimes just a comment. Hot keys
|
* In menus we can add a hot key, or an accelerator, or sometimes just a comment. Hot keys
|
||||||
|
|
|
@ -1934,7 +1934,7 @@ void ROUTER_TOOL::performDragging( int aMode )
|
||||||
{
|
{
|
||||||
wxString hint;
|
wxString hint;
|
||||||
hint.Printf( _( "(%s to commit anyway.)" ),
|
hint.Printf( _( "(%s to commit anyway.)" ),
|
||||||
KeyNameFromKeyCode( MD_CTRL + PSEUDO_WXK_CLICK ) );
|
KeyNameFromKeyCode( MD_CTRL + PSEUDO_WXK_CLICK, true ) );
|
||||||
|
|
||||||
ROUTER_STATUS_VIEW_ITEM* statusItem = new ROUTER_STATUS_VIEW_ITEM();
|
ROUTER_STATUS_VIEW_ITEM* statusItem = new ROUTER_STATUS_VIEW_ITEM();
|
||||||
statusItem->SetMessage( _( "Track violates DRC." ) );
|
statusItem->SetMessage( _( "Track violates DRC." ) );
|
||||||
|
@ -2417,7 +2417,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxString hint;
|
wxString hint;
|
||||||
hint.Printf( _( "(%s to commit anyway.)" ),
|
hint.Printf( _( "(%s to commit anyway.)" ),
|
||||||
KeyNameFromKeyCode( MD_CTRL + PSEUDO_WXK_CLICK ) );
|
KeyNameFromKeyCode( MD_CTRL + PSEUDO_WXK_CLICK, true ) );
|
||||||
|
|
||||||
ROUTER_STATUS_VIEW_ITEM* statusItem = new ROUTER_STATUS_VIEW_ITEM();
|
ROUTER_STATUS_VIEW_ITEM* statusItem = new ROUTER_STATUS_VIEW_ITEM();
|
||||||
statusItem->SetMessage( _( "Track violates DRC." ) );
|
statusItem->SetMessage( _( "Track violates DRC." ) );
|
||||||
|
|
|
@ -760,12 +760,12 @@ void PAD_TOOL::enterPadEditMode()
|
||||||
if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
|
if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ),
|
msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ),
|
||||||
KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey() ) );
|
KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey(), true ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Pad Edit Mode. Press %s to exit." ),
|
msg.Printf( _( "Pad Edit Mode. Press %s to exit." ),
|
||||||
KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey() ) );
|
KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey(), true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
infoBar->RemoveAllButtons();
|
infoBar->RemoveAllButtons();
|
||||||
|
|
|
@ -247,7 +247,7 @@ void PCB_CONTROL::unfilledZoneCheck()
|
||||||
wxString msg;
|
wxString msg;
|
||||||
msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
|
msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
|
||||||
"if you wish to see all fills." ),
|
"if you wish to see all fills." ),
|
||||||
KeyNameFromKeyCode( PCB_ACTIONS::zoneFillAll.GetHotKey() ) );
|
KeyNameFromKeyCode( PCB_ACTIONS::zoneFillAll.GetHotKey(), true ) );
|
||||||
|
|
||||||
infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
|
infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,15 +445,15 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
|
||||||
"Use %s+Tab to activate selector.\n"
|
"Use %s+Tab to activate selector.\n"
|
||||||
"Successive Tabs while holding %s down will "
|
"Successive Tabs while holding %s down will "
|
||||||
"cycle through presets in the popup." ),
|
"cycle through presets in the popup." ),
|
||||||
KeyNameFromKeyCode( PRESET_SWITCH_KEY ),
|
KeyNameFromKeyCode( PRESET_SWITCH_KEY, true ),
|
||||||
KeyNameFromKeyCode( PRESET_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( PRESET_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
m_cbViewports->SetToolTip( wxString::Format( _( "Save and restore view location and zoom.\n"
|
m_cbViewports->SetToolTip( wxString::Format( _( "Save and restore view location and zoom.\n"
|
||||||
"Use %s+Tab to activate selector.\n"
|
"Use %s+Tab to activate selector.\n"
|
||||||
"Successive Tabs while holding %s down will "
|
"Successive Tabs while holding %s down will "
|
||||||
"cycle through viewports in the popup." ),
|
"cycle through viewports in the popup." ),
|
||||||
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ),
|
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY, true ),
|
||||||
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
createControls();
|
createControls();
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ void APPEARANCE_CONTROLS::createControls()
|
||||||
hotkey = PCB_ACTIONS::highContrastModeCycle.GetHotKey();
|
hotkey = PCB_ACTIONS::highContrastModeCycle.GetHotKey();
|
||||||
|
|
||||||
if( hotkey )
|
if( hotkey )
|
||||||
msg = wxString::Format( _( "Inactive layers (%s):" ), KeyNameFromKeyCode( hotkey ) );
|
msg = wxString::Format( _( "Inactive layers (%s):" ), KeyNameFromKeyCode( hotkey, true ) );
|
||||||
else
|
else
|
||||||
msg = _( "Inactive layers:" );
|
msg = _( "Inactive layers:" );
|
||||||
|
|
||||||
|
@ -700,7 +700,7 @@ void APPEARANCE_CONTROLS::createControls()
|
||||||
hotkey = PCB_ACTIONS::netColorModeCycle.GetHotKey();
|
hotkey = PCB_ACTIONS::netColorModeCycle.GetHotKey();
|
||||||
|
|
||||||
if( hotkey )
|
if( hotkey )
|
||||||
msg = wxString::Format( _( "Net colors (%s):" ), KeyNameFromKeyCode( hotkey ) );
|
msg = wxString::Format( _( "Net colors (%s):" ), KeyNameFromKeyCode( hotkey, true ) );
|
||||||
else
|
else
|
||||||
msg = _( "Net colors:" );
|
msg = _( "Net colors:" );
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ void APPEARANCE_CONTROLS::createControls()
|
||||||
hotkey = PCB_ACTIONS::ratsnestModeCycle.GetHotKey();
|
hotkey = PCB_ACTIONS::ratsnestModeCycle.GetHotKey();
|
||||||
|
|
||||||
if( hotkey )
|
if( hotkey )
|
||||||
msg = wxString::Format( _( "Ratsnest display (%s):" ), KeyNameFromKeyCode( hotkey ) );
|
msg = wxString::Format( _( "Ratsnest display (%s):" ), KeyNameFromKeyCode( hotkey, true ) );
|
||||||
else
|
else
|
||||||
msg = _( "Ratsnest display:" );
|
msg = _( "Ratsnest display:" );
|
||||||
|
|
||||||
|
@ -1798,7 +1798,7 @@ void APPEARANCE_CONTROLS::rebuildLayers()
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
if( hotkey )
|
if( hotkey )
|
||||||
msg = wxString::Format( _( "Inactive layers (%s):" ), KeyNameFromKeyCode( hotkey ) );
|
msg = wxString::Format( _( "Inactive layers (%s):" ), KeyNameFromKeyCode( hotkey, true ) );
|
||||||
else
|
else
|
||||||
msg = _( "Inactive layers:" );
|
msg = _( "Inactive layers:" );
|
||||||
|
|
||||||
|
@ -2507,7 +2507,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
hotkey = PCB_ACTIONS::netColorModeCycle.GetHotKey();
|
hotkey = PCB_ACTIONS::netColorModeCycle.GetHotKey();
|
||||||
|
|
||||||
if( hotkey )
|
if( hotkey )
|
||||||
msg = wxString::Format( _( "Net colors (%s):" ), KeyNameFromKeyCode( hotkey ) );
|
msg = wxString::Format( _( "Net colors (%s):" ), KeyNameFromKeyCode( hotkey, true ) );
|
||||||
else
|
else
|
||||||
msg = _( "Net colors:" );
|
msg = _( "Net colors:" );
|
||||||
|
|
||||||
|
@ -2526,7 +2526,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
hotkey = PCB_ACTIONS::ratsnestModeCycle.GetHotKey();
|
hotkey = PCB_ACTIONS::ratsnestModeCycle.GetHotKey();
|
||||||
|
|
||||||
if( hotkey )
|
if( hotkey )
|
||||||
msg = wxString::Format( _( "Ratsnest display (%s):" ), KeyNameFromKeyCode( hotkey ) );
|
msg = wxString::Format( _( "Ratsnest display (%s):" ), KeyNameFromKeyCode( hotkey, true ) );
|
||||||
else
|
else
|
||||||
msg = _( "Ratsnest display:" );
|
msg = _( "Ratsnest display:" );
|
||||||
|
|
||||||
|
@ -2552,7 +2552,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
void APPEARANCE_CONTROLS::rebuildLayerPresetsWidget()
|
void APPEARANCE_CONTROLS::rebuildLayerPresetsWidget()
|
||||||
{
|
{
|
||||||
m_viewportsLabel->SetLabel( wxString::Format( _( "Presets (%s+Tab):" ),
|
m_viewportsLabel->SetLabel( wxString::Format( _( "Presets (%s+Tab):" ),
|
||||||
KeyNameFromKeyCode( PRESET_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( PRESET_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
m_cbLayerPresets->Clear();
|
m_cbLayerPresets->Clear();
|
||||||
|
|
||||||
|
@ -2851,7 +2851,7 @@ void APPEARANCE_CONTROLS::doApplyLayerPreset( const LAYER_PRESET& aPreset )
|
||||||
void APPEARANCE_CONTROLS::rebuildViewportsWidget()
|
void APPEARANCE_CONTROLS::rebuildViewportsWidget()
|
||||||
{
|
{
|
||||||
m_viewportsLabel->SetLabel( wxString::Format( _( "Viewports (%s+Tab):" ),
|
m_viewportsLabel->SetLabel( wxString::Format( _( "Viewports (%s+Tab):" ),
|
||||||
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ) ) );
|
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY, true ) ) );
|
||||||
|
|
||||||
m_cbViewports->Clear();
|
m_cbViewports->Clear();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
#include <gecko_keys.h>
|
#include <gecko_keys.h>
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
|
|
||||||
|
#if defined( _WIN32 )
|
||||||
|
#include <Windows.h>
|
||||||
|
#elif defined(__WXGTK__)
|
||||||
|
#include "x11/keysym2ucs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace GeckoKeys
|
namespace GeckoKeys
|
||||||
{
|
{
|
||||||
|
@ -93,6 +99,21 @@ CodeNameIndex CodeNameIndexFromWXK( int aWXKey )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t ScancodeFromCodeNameIndex( CodeNameIndex aCodeNameIndex )
|
||||||
|
{
|
||||||
|
// clang-format off
|
||||||
|
#define NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, aCodeNameIndexIt) \
|
||||||
|
if( aCodeNameIndex == aCodeNameIndexIt) return aNativeKey;
|
||||||
|
|
||||||
|
#include "NativeKeyToDOMCodeName.h"
|
||||||
|
|
||||||
|
#undef NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
return WXK_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int WXKFromKeyEvent( uint32_t aRawKeyCode, uint32_t aRawKeyFlags )
|
int WXKFromKeyEvent( uint32_t aRawKeyCode, uint32_t aRawKeyFlags )
|
||||||
{
|
{
|
||||||
return WXKFromCodeNameIndex(
|
return WXKFromCodeNameIndex(
|
||||||
|
@ -100,4 +121,78 @@ int WXKFromKeyEvent( uint32_t aRawKeyCode, uint32_t aRawKeyFlags )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WXKFromScancode( int aScancode )
|
||||||
|
{
|
||||||
|
return WXKFromCodeNameIndex( CodeNameIndexFromScanCode( aScancode ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wchar_t CharFromScancode( uint32_t aScancode )
|
||||||
|
{
|
||||||
|
#if defined( _WIN32 )
|
||||||
|
HKL layout = ::GetKeyboardLayout( 0 );
|
||||||
|
uint32_t vk = ::MapVirtualKeyExW( aScancode, MAPVK_VSC_TO_VK, layout );
|
||||||
|
wchar_t ch = ::MapVirtualKeyExW( vk, MAPVK_VK_TO_CHAR, layout );
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
#elif defined( __APPLE__ )
|
||||||
|
const UCKeyboardLayout* UCKey = GetUCKeyboardLayout();
|
||||||
|
UInt32 kbType = ::LMGetKbdType();
|
||||||
|
|
||||||
|
UInt32 modifiers = 0;
|
||||||
|
UInt32 deadKeyState = 0;
|
||||||
|
UniCharCount len = 0;
|
||||||
|
UniChar chars[5] = { 0 };
|
||||||
|
OSStatus err = ::UCKeyTranslate( UCKey, aScancode, kUCKeyActionDown, modifiers >> 8, kbType,
|
||||||
|
kUCKeyTranslateNoDeadKeysMask, &deadKeyState, 5, &len, chars );
|
||||||
|
|
||||||
|
return chars[0];
|
||||||
|
#else
|
||||||
|
GdkDisplay* disp = gdk_display_get_default();
|
||||||
|
keymap = gdk_keymap_get_for_display( disp );
|
||||||
|
|
||||||
|
GdkKeymapKey* keys = nullptr;
|
||||||
|
gint count = 0;
|
||||||
|
gint minGroup = -1;
|
||||||
|
if( gdk_keymap_get_entries_for_keyval( mGdkKeymap, GDK_a, &keys, &count ) )
|
||||||
|
{
|
||||||
|
// find the minimum number group for latin inputtable layout
|
||||||
|
for( gint i = 0; i < count && minGroup != 0; ++i )
|
||||||
|
{
|
||||||
|
if( keys[i].level != 0 && keys[i].level != 1 )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if( minGroup >= 0 && keys[i].group > minGroup )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
minGroup = keys[i].group;
|
||||||
|
}
|
||||||
|
g_free( keys );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( minGroup == -1 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
guint state = 0;
|
||||||
|
guint keyval = 0;
|
||||||
|
|
||||||
|
gdk_keymap_translate_keyboard_state( keymap, aScancode, GdkModifierType( state ), minGroup,
|
||||||
|
&keyval, nullptr, nullptr, nullptr );
|
||||||
|
|
||||||
|
static const long MAX_UNICODE = 0x10FFFF;
|
||||||
|
|
||||||
|
// we're supposedly printable, let's try to convert
|
||||||
|
long ucs = keysym2ucs( aGdkKeyEvent->keyval );
|
||||||
|
if( ( ucs != -1 ) && ( ucs < MAX_UNICODE ) )
|
||||||
|
{
|
||||||
|
return ucs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// I guess we couldn't convert
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,9 @@ unsigned int ScanCodeFromKeyEvent( uint32_t aRawKeyCode, uint32_t aRawKeyFlags
|
||||||
CodeNameIndex CodeNameIndexFromScanCode( unsigned int aScanCode );
|
CodeNameIndex CodeNameIndexFromScanCode( unsigned int aScanCode );
|
||||||
int WXKFromCodeNameIndex( CodeNameIndex aCodeNameIndex );
|
int WXKFromCodeNameIndex( CodeNameIndex aCodeNameIndex );
|
||||||
CodeNameIndex CodeNameIndexFromWXK( int aWXKey );
|
CodeNameIndex CodeNameIndexFromWXK( int aWXKey );
|
||||||
|
uint32_t ScancodeFromCodeNameIndex( CodeNameIndex aCodeNameIndex );
|
||||||
int WXKFromKeyEvent( uint32_t aRawKeyCode, uint32_t aRawKeyFlags );
|
int WXKFromKeyEvent( uint32_t aRawKeyCode, uint32_t aRawKeyFlags );
|
||||||
|
wchar_t CharFromScancode( uint32_t aScancode );
|
||||||
|
|
||||||
} // namespace GeckoKeys
|
} // namespace GeckoKeys
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue