Don't escape spaces in bus groups and transfer hyperlinks.
Fixes https://gitlab.com/kicad/code/kicad/issues/12451 Fixes https://gitlab.com/kicad/code/kicad/issues/12452
This commit is contained in:
parent
1be8adebf5
commit
e6c8cf0f03
|
@ -69,6 +69,7 @@
|
||||||
#include <symbol_editor_settings.h>
|
#include <symbol_editor_settings.h>
|
||||||
#include <core/kicad_algo.h>
|
#include <core/kicad_algo.h>
|
||||||
#include <wx/textdlg.h>
|
#include <wx/textdlg.h>
|
||||||
|
#include "project/net_settings.h"
|
||||||
|
|
||||||
class SYMBOL_UNIT_MENU : public ACTION_MENU
|
class SYMBOL_UNIT_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
|
@ -1885,6 +1886,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
SCH_ITEM* newtext = nullptr;
|
SCH_ITEM* newtext = nullptr;
|
||||||
VECTOR2I position = item->GetPosition();
|
VECTOR2I position = item->GetPosition();
|
||||||
wxString txt;
|
wxString txt;
|
||||||
|
wxString href;
|
||||||
TEXT_SPIN_STYLE orientation = TEXT_SPIN_STYLE::SPIN::RIGHT;
|
TEXT_SPIN_STYLE orientation = TEXT_SPIN_STYLE::SPIN::RIGHT;
|
||||||
LABEL_FLAG_SHAPE shape = LABEL_FLAG_SHAPE::L_UNSPECIFIED;
|
LABEL_FLAG_SHAPE shape = LABEL_FLAG_SHAPE::L_UNSPECIFIED;
|
||||||
|
|
||||||
|
@ -1899,6 +1901,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
txt = UnescapeString( label->GetText() );
|
txt = UnescapeString( label->GetText() );
|
||||||
orientation = label->GetTextSpinStyle();
|
orientation = label->GetTextSpinStyle();
|
||||||
shape = label->GetShape();
|
shape = label->GetShape();
|
||||||
|
href = label->GetHyperlink();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1914,6 +1917,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
txt = dirlabel->GetFields()[0].GetText();
|
txt = dirlabel->GetFields()[0].GetText();
|
||||||
|
|
||||||
orientation = dirlabel->GetTextSpinStyle();
|
orientation = dirlabel->GetTextSpinStyle();
|
||||||
|
href = dirlabel->GetHyperlink();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1923,6 +1927,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
txt = text->GetText();
|
txt = text->GetText();
|
||||||
orientation = text->GetTextSpinStyle();
|
orientation = text->GetTextSpinStyle();
|
||||||
|
href = text->GetHyperlink();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1971,6 +1976,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
position = m_frame->GetNearestGridPosition( position );
|
position = m_frame->GetNearestGridPosition( position );
|
||||||
|
href = textbox->GetHyperlink();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1979,13 +1985,16 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto prepareForNetName =
|
auto getValidNetname =
|
||||||
[]( wxString& aText )
|
[]( const wxString& aText )
|
||||||
{
|
{
|
||||||
wxString local_txt = aText;
|
wxString local_txt = aText;
|
||||||
local_txt.Replace( "\n", "_" );
|
local_txt.Replace( "\n", "_" );
|
||||||
local_txt.Replace( "\r", "_" );
|
local_txt.Replace( "\r", "_" );
|
||||||
local_txt.Replace( "\t", "_" );
|
local_txt.Replace( "\t", "_" );
|
||||||
|
|
||||||
|
// Bus groups can have spaces; bus vectors and signal names cannot
|
||||||
|
if( !NET_SETTINGS::ParseBusGroup( aText, nullptr, nullptr ) )
|
||||||
local_txt.Replace( " ", "_" );
|
local_txt.Replace( " ", "_" );
|
||||||
|
|
||||||
// label strings are "escaped" i.e. a '/' is replaced by "{slash}"
|
// label strings are "escaped" i.e. a '/' is replaced by "{slash}"
|
||||||
|
@ -1996,30 +2005,33 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
case SCH_LABEL_T:
|
case SCH_LABEL_T:
|
||||||
{
|
{
|
||||||
SCH_LABEL_BASE* new_label = new SCH_LABEL( position, prepareForNetName( txt ) );
|
SCH_LABEL_BASE* new_label = new SCH_LABEL( position, getValidNetname( txt ) );
|
||||||
|
|
||||||
new_label->SetShape( shape );
|
new_label->SetShape( shape );
|
||||||
new_label->SetTextSpinStyle( orientation );
|
new_label->SetTextSpinStyle( orientation );
|
||||||
|
new_label->SetHyperlink( href );
|
||||||
newtext = new_label;
|
newtext = new_label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCH_GLOBAL_LABEL_T:
|
case SCH_GLOBAL_LABEL_T:
|
||||||
{
|
{
|
||||||
SCH_LABEL_BASE* new_label = new SCH_GLOBALLABEL( position, prepareForNetName( txt ) );
|
SCH_LABEL_BASE* new_label = new SCH_GLOBALLABEL( position, getValidNetname( txt ) );
|
||||||
|
|
||||||
new_label->SetShape( shape );
|
new_label->SetShape( shape );
|
||||||
new_label->SetTextSpinStyle( orientation );
|
new_label->SetTextSpinStyle( orientation );
|
||||||
|
new_label->SetHyperlink( href );
|
||||||
newtext = new_label;
|
newtext = new_label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCH_HIER_LABEL_T:
|
case SCH_HIER_LABEL_T:
|
||||||
{
|
{
|
||||||
SCH_LABEL_BASE* new_label = new SCH_HIERLABEL( position, prepareForNetName( txt ) );
|
SCH_LABEL_BASE* new_label = new SCH_HIERLABEL( position, getValidNetname( txt ) );
|
||||||
|
|
||||||
new_label->SetShape( shape );
|
new_label->SetShape( shape );
|
||||||
new_label->SetTextSpinStyle( orientation );
|
new_label->SetTextSpinStyle( orientation );
|
||||||
|
new_label->SetHyperlink( href );
|
||||||
newtext = new_label;
|
newtext = new_label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2037,6 +2049,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
new_label->SetShape( LABEL_FLAG_SHAPE::F_ROUND );
|
new_label->SetShape( LABEL_FLAG_SHAPE::F_ROUND );
|
||||||
new_label->SetTextSpinStyle( orientation );
|
new_label->SetTextSpinStyle( orientation );
|
||||||
|
new_label->SetHyperlink( href );
|
||||||
newtext = new_label;
|
newtext = new_label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2046,6 +2059,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
SCH_TEXT* new_text = new SCH_TEXT( position, txt );
|
SCH_TEXT* new_text = new SCH_TEXT( position, txt );
|
||||||
|
|
||||||
new_text->SetTextSpinStyle( orientation );
|
new_text->SetTextSpinStyle( orientation );
|
||||||
|
new_text->SetHyperlink( href );
|
||||||
newtext = new_text;
|
newtext = new_text;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2094,6 +2108,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_textbox->SetHyperlink( href );
|
||||||
newtext = new_textbox;
|
newtext = new_textbox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue