Collect comment lines into following spice unit.

This can't distinguish a header block comment in front of a file
with multiple spice units, and so will include that into the first
unit only.

Also fixes the pin assignments reference textbox to use a
fixed-width font as many .subckt's contain ASCII graphics for
pin definitions (not that it helps any with the test case from
the given bug).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15660

(cherry picked from commit ede542f911)
This commit is contained in:
Jeff Young 2023-09-15 19:55:36 +01:00
parent 17b0bdc9fe
commit c858643100
3 changed files with 25 additions and 19 deletions

View File

@ -49,19 +49,20 @@ using CATEGORY = SIM_MODEL::PARAM::CATEGORY;
template <typename T_symbol, typename T_field> template <typename T_symbol, typename T_field>
DIALOG_SIM_MODEL<T_symbol, T_field>::DIALOG_SIM_MODEL( wxWindow* aParent, T_symbol& aSymbol, DIALOG_SIM_MODEL<T_symbol, T_field>::DIALOG_SIM_MODEL( wxWindow* aParent, T_symbol& aSymbol,
std::vector<T_field>& aFields ) std::vector<T_field>& aFields ) :\
: DIALOG_SIM_MODEL_BASE( aParent ), DIALOG_SIM_MODEL_BASE( aParent ),
m_symbol( aSymbol ), m_symbol( aSymbol ),
m_fields( aFields ), m_fields( aFields ),
m_libraryModelsMgr( &Prj() ), m_libraryModelsMgr( &Prj() ),
m_builtinModelsMgr( &Prj() ), m_builtinModelsMgr( &Prj() ),
m_prevModel( nullptr ), m_prevModel( nullptr ),
m_curModelType( SIM_MODEL::TYPE::NONE ), m_curModelType( SIM_MODEL::TYPE::NONE ),
m_scintillaTricks( nullptr ), m_scintillaTricksCode( nullptr ),
m_firstCategory( nullptr ), m_scintillaTricksSubckt( nullptr ),
m_prevParamGridSelection( nullptr ), m_firstCategory( nullptr ),
m_lastParamGridWidth( 0 ), m_prevParamGridSelection( nullptr ),
m_inKillFocus( false ) m_lastParamGridWidth( 0 ),
m_inKillFocus( false )
{ {
m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) ); m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) );
@ -81,7 +82,8 @@ DIALOG_SIM_MODEL<T_symbol, T_field>::DIALOG_SIM_MODEL( wxWindow* aParent, T_symb
m_typeChoice->Clear(); m_typeChoice->Clear();
m_scintillaTricks = new SCINTILLA_TRICKS( m_codePreview, wxT( "{}" ), false ); m_scintillaTricksCode = new SCINTILLA_TRICKS( m_codePreview, wxT( "{}" ), false );
m_scintillaTricksSubckt = new SCINTILLA_TRICKS( m_subckt, wxT( "()" ), false );
m_paramGridMgr->Bind( wxEVT_PG_SELECTED, &DIALOG_SIM_MODEL::onParamGridSelectionChange, this ); m_paramGridMgr->Bind( wxEVT_PG_SELECTED, &DIALOG_SIM_MODEL::onParamGridSelectionChange, this );
@ -131,7 +133,8 @@ DIALOG_SIM_MODEL<T_symbol, T_field>::~DIALOG_SIM_MODEL()
// Delete the GRID_TRICKS. // Delete the GRID_TRICKS.
m_pinAssignmentsGrid->PopEventHandler( true ); m_pinAssignmentsGrid->PopEventHandler( true );
delete m_scintillaTricks; delete m_scintillaTricksCode;
delete m_scintillaTricksSubckt;
} }
@ -663,6 +666,7 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::updatePinAssignments( SIM_MODEL* aMode
{ {
SIM_MODEL_SUBCKT* subckt = static_cast<SIM_MODEL_SUBCKT*>( aModel ); SIM_MODEL_SUBCKT* subckt = static_cast<SIM_MODEL_SUBCKT*>( aModel );
m_subckt->SetText( subckt->GetSpiceCode() ); m_subckt->SetText( subckt->GetSpiceCode() );
m_subckt->SetEditable( false );
} }
else else
{ {

View File

@ -130,7 +130,8 @@ private:
std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType; std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
SIM_MODEL::TYPE m_curModelType; SIM_MODEL::TYPE m_curModelType;
SCINTILLA_TRICKS* m_scintillaTricks; SCINTILLA_TRICKS* m_scintillaTricksCode;
SCINTILLA_TRICKS* m_scintillaTricksSubckt;
wxPGProperty* m_firstCategory; // Used to add principal parameters to root. wxPGProperty* m_firstCategory; // Used to add principal parameters to root.
wxPGProperty* m_prevParamGridSelection; wxPGProperty* m_prevParamGridSelection;

View File

@ -193,9 +193,10 @@ namespace SPICE_GRAMMAR
spiceUnit>>> {}; spiceUnit>>> {};
struct modelUnit : sor<dotModelAko, struct modelUnit : seq<star<commentLine>,
dotModel, sor<dotModelAko,
dotSubckt> {}; dotModel,
dotSubckt>> {};
// Intentionally no if_must<>. // Intentionally no if_must<>.