Add missing autocomplete for FILENAME, PROJECTNAME

This commit is contained in:
Graham Keeth 2023-02-01 14:14:26 -05:00 committed by Jeff Young
parent 9a34178f66
commit 9b9ebebb2d
3 changed files with 34 additions and 3 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -221,6 +221,10 @@ void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const
sheetPath.pop_back();
sheetPath.Last()->GetContextualTextVars( aVars );
}
else if( Schematic() )
{
Schematic()->GetContextualTextVars( aVars );
}
add( wxT( "#" ) );
add( wxT( "##" ) );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
@ -19,6 +19,7 @@
#include <bus_alias.h>
#include <connection_graph.h>
#include <core/kicad_algo.h>
#include <erc_settings.h>
#include <sch_marker.h>
#include <project.h>
@ -122,6 +123,30 @@ SCH_SCREEN* SCHEMATIC::RootScreen() const
}
void SCHEMATIC::GetContextualTextVars( wxArrayString* aVars ) const
{
auto add =
[&]( const wxString& aVar )
{
if( !alg::contains( *aVars, aVar ) )
aVars->push_back( aVar );
};
add( wxT( "#" ) );
add( wxT( "##" ) );
add( wxT( "SHEETPATH" ) );
add( wxT( "SHEETNAME" ) );
add( wxT( "FILENAME" ) );
add( wxT( "PROJECTNAME" ) );
if( !CurrentSheet().empty() )
CurrentSheet().LastScreen()->GetTitleBlock().GetContextualTextVars( aVars );
for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
add( entry.first );
}
bool SCHEMATIC::ResolveTextVar( wxString* token, int aDepth ) const
{
if( !CurrentSheet().empty() )

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
@ -112,6 +112,8 @@ public:
/// Helper to retrieve the screen of the root sheet
SCH_SCREEN* RootScreen() const;
void GetContextualTextVars( wxArrayString* aVars ) const;
bool ResolveTextVar( wxString* token, int aDepth ) const;
/// Helper to retrieve the filename from the root sheet screen