From b1e5cb5a5632e8b9ac07a78af2d1b4edbe1fd4fd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 2 Sep 2022 22:32:50 +0100 Subject: [PATCH] ADDED ${SYMBOL_DESCRIPTION} and ${SYMBOL_KEYWORDS}. Fixes https://gitlab.com/kicad/code/kicad/issues/9783 --- eeschema/sch_symbol.cpp | 21 +++++++++++++++++++++ eeschema/sch_symbol.h | 7 ++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index b14ef7e3a9..025eca9a25 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -315,6 +315,15 @@ wxString SCH_SYMBOL::GetDescription() const } +wxString SCH_SYMBOL::GetKeyWords() const +{ + if( m_part ) + return m_part->GetKeyWords(); + + return wxEmptyString; +} + + wxString SCH_SYMBOL::GetDatasheet() const { if( m_part ) @@ -1022,6 +1031,8 @@ void SCH_SYMBOL::GetContextualTextVars( wxArrayString* aVars ) const aVars->push_back( wxT( "UNIT" ) ); aVars->push_back( wxT( "SYMBOL_LIBRARY" ) ); aVars->push_back( wxT( "SYMBOL_NAME" ) ); + aVars->push_back( wxT( "SYMBOL_DESCRIPTION" ) ); + aVars->push_back( wxT( "SYMBOL_KEYWORDS" ) ); } @@ -1114,6 +1125,16 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const *token = m_lib_id.GetLibItemName(); return true; } + else if( token->IsSameAs( wxT( "SYMBOL_DESCRIPTION" ) ) ) + { + *token = GetDescription(); + return true; + } + else if( token->IsSameAs( wxT( "SYMBOL_KEYWORDS" ) ) ) + { + *token = GetKeyWords(); + return true; + } return false; } diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index db6ac28218..45bdb1f1b0 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -208,10 +208,15 @@ public: void SetLibSymbol( LIB_SYMBOL* aLibSymbol ); /** - * Return information about the aliased parts + * @return the associated LIB_SYMBOL's description field (or wxEmptyString). */ wxString GetDescription() const; + /** + * @return the associated LIB_SYMBOL's keywords field (or wxEmptyString). + */ + wxString GetKeyWords() const; + /** * Return the documentation text for the given part alias */