mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Autocomplete for OUTPUT_TMP_PATH_VAR_NAME.
(Along with a list of other env vars in use.)
This commit is contained in:
parent
af1a246e12
commit
dd39a50a14
@ -23,6 +23,8 @@
|
||||
#include <kicommon.h>
|
||||
#include <jobs/job.h>
|
||||
|
||||
#define OUTPUT_TMP_PATH_VAR_NAME wxT( "JOBSET_OUTPUT_TMP_PATH" )
|
||||
|
||||
class KICOMMON_API JOB_SPECIAL_EXECUTE : public JOB
|
||||
{
|
||||
public:
|
||||
|
@ -18,10 +18,14 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "widgets/grid_readonly_text_helpers.h"
|
||||
#include <dialogs/dialog_executecommand_job_settings.h>
|
||||
#include <jobs/job_special_execute.h>
|
||||
#include <scintilla_tricks.h>
|
||||
#include <grid_tricks.h>
|
||||
#include <project.h>
|
||||
#include <env_vars.h>
|
||||
#include <wx/regex.h>
|
||||
|
||||
|
||||
DIALOG_EXECUTECOMMAND_JOB_SETTINGS::DIALOG_EXECUTECOMMAND_JOB_SETTINGS( wxWindow* aParent,
|
||||
@ -45,9 +49,18 @@ DIALOG_EXECUTECOMMAND_JOB_SETTINGS::DIALOG_EXECUTECOMMAND_JOB_SETTINGS( wxWindow
|
||||
[]( const wxString& xRef, wxArrayString* tokens )
|
||||
{
|
||||
ENV_VAR::GetEnvVarAutocompleteTokens( tokens );
|
||||
tokens->Add( OUTPUT_TMP_PATH_VAR_NAME );
|
||||
} );
|
||||
} );
|
||||
|
||||
// add Cut, Copy, and Paste to wxGrids
|
||||
m_path_subs_grid->PushEventHandler( new GRID_TRICKS( m_path_subs_grid ) );
|
||||
|
||||
populateEnvironReadOnlyTable();
|
||||
|
||||
m_path_subs_grid->SetColLabelValue( 0, _( "Name" ) );
|
||||
m_path_subs_grid->SetColLabelValue( 1, _( "Value" ) );
|
||||
|
||||
SetupStandardButtons();
|
||||
|
||||
finishDialogSettings();
|
||||
@ -57,6 +70,9 @@ DIALOG_EXECUTECOMMAND_JOB_SETTINGS::DIALOG_EXECUTECOMMAND_JOB_SETTINGS( wxWindow
|
||||
DIALOG_EXECUTECOMMAND_JOB_SETTINGS::~DIALOG_EXECUTECOMMAND_JOB_SETTINGS()
|
||||
{
|
||||
delete m_scintillaTricks;
|
||||
|
||||
// Delete the GRID_TRICKS.
|
||||
m_path_subs_grid->PopEventHandler( true );
|
||||
}
|
||||
|
||||
|
||||
@ -87,4 +103,87 @@ bool DIALOG_EXECUTECOMMAND_JOB_SETTINGS::TransferDataToWindow()
|
||||
void DIALOG_EXECUTECOMMAND_JOB_SETTINGS::OnRecordOutputClicked( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_textCtrlOutputPath->Enable( m_cbRecordOutput->GetValue() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EXECUTECOMMAND_JOB_SETTINGS::populateEnvironReadOnlyTable()
|
||||
{
|
||||
wxRegEx re( ".*?(\\$\\{(.+?)\\})|(\\$\\((.+?)\\)).*?", wxRE_ADVANCED );
|
||||
wxASSERT( re.IsValid() ); // wxRE_ADVANCED is required.
|
||||
|
||||
std::set<wxString> unique;
|
||||
wxString src = m_textCtrlCommand->GetValue();
|
||||
|
||||
// clear the table
|
||||
m_path_subs_grid->ClearRows();
|
||||
|
||||
while( re.Matches( src ) )
|
||||
{
|
||||
wxString envvar = re.GetMatch( src, 2 );
|
||||
|
||||
// if not ${...} form then must be $(...)
|
||||
if( envvar.IsEmpty() )
|
||||
envvar = re.GetMatch( src, 4 );
|
||||
|
||||
// ignore duplicates
|
||||
unique.insert( envvar );
|
||||
|
||||
// delete the last match and search again
|
||||
src.Replace( re.GetMatch( src, 0 ), wxEmptyString );
|
||||
}
|
||||
|
||||
// Make sure these variables shows up even if not used yet.
|
||||
unique.insert( OUTPUT_TMP_PATH_VAR_NAME );
|
||||
unique.insert( PROJECT_VAR_NAME );
|
||||
|
||||
for( const wxString& evName : unique )
|
||||
{
|
||||
int row = m_path_subs_grid->GetNumberRows();
|
||||
m_path_subs_grid->AppendRows( 1 );
|
||||
|
||||
m_path_subs_grid->SetCellValue( row, 0, wxT( "${" ) + evName + wxT( "}" ) );
|
||||
m_path_subs_grid->SetCellEditor( row, 0, new GRID_CELL_READONLY_TEXT_EDITOR() );
|
||||
|
||||
wxString evValue;
|
||||
|
||||
if( evName.IsSameAs( OUTPUT_TMP_PATH_VAR_NAME ) )
|
||||
{
|
||||
evValue = _( "<value set at runtime>" );
|
||||
m_path_subs_grid->SetCellFont( row, 1, m_path_subs_grid->GetCellFont( row, 1 ).Italic() );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxGetEnv( evName, &evValue );
|
||||
}
|
||||
|
||||
m_path_subs_grid->SetCellValue( row, 1, evValue );
|
||||
m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() );
|
||||
}
|
||||
|
||||
// No combobox editors here, but it looks better if its consistent with the other
|
||||
// grids in the dialog.
|
||||
m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 );
|
||||
|
||||
adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EXECUTECOMMAND_JOB_SETTINGS::adjustPathSubsGridColumns( int aWidth )
|
||||
{
|
||||
// Account for scroll bars
|
||||
aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x );
|
||||
|
||||
m_path_subs_grid->AutoSizeColumn( 0 );
|
||||
m_path_subs_grid->SetColSize( 0, std::max( 200, m_path_subs_grid->GetColSize( 0 ) ) );
|
||||
m_path_subs_grid->SetColSize( 1, std::max( 300, aWidth - m_path_subs_grid->GetColSize( 0 ) ) );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EXECUTECOMMAND_JOB_SETTINGS::onSizeGrid( wxSizeEvent& event )
|
||||
{
|
||||
adjustPathSubsGridColumns( event.GetSize().GetX() );
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,8 +34,14 @@ public:
|
||||
bool TransferDataToWindow() override;
|
||||
|
||||
private:
|
||||
void onSizeGrid( wxSizeEvent& event ) override;
|
||||
void adjustPathSubsGridColumns( int aWidth );
|
||||
void OnRecordOutputClicked( wxCommandEvent& event ) override;
|
||||
|
||||
/// Populate the readonly environment variable table with names and values
|
||||
/// by examining the script and path.
|
||||
void populateEnvironReadOnlyTable();
|
||||
|
||||
private:
|
||||
JOB_SPECIAL_EXECUTE* m_job;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "widgets/wx_grid.h"
|
||||
|
||||
#include "dialog_executecommand_job_settings_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -83,6 +85,48 @@ DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE
|
||||
|
||||
bSizerMain->Add( bSizerBottom, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( 0, 10, 0, wxEXPAND, 5 );
|
||||
|
||||
wxStaticText* stPathsLabel;
|
||||
stPathsLabel = new wxStaticText( this, wxID_ANY, _("Available text variables:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
stPathsLabel->Wrap( -1 );
|
||||
bSizerMain->Add( stPathsLabel, 0, wxTOP|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
|
||||
bSizerMain->Add( 0, 2, 0, wxEXPAND, 5 );
|
||||
|
||||
m_path_subs_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
// Grid
|
||||
m_path_subs_grid->CreateGrid( 1, 2 );
|
||||
m_path_subs_grid->EnableEditing( false );
|
||||
m_path_subs_grid->EnableGridLines( true );
|
||||
m_path_subs_grid->EnableDragGridSize( false );
|
||||
m_path_subs_grid->SetMargins( 0, 0 );
|
||||
|
||||
// Columns
|
||||
m_path_subs_grid->SetColSize( 0, 200 );
|
||||
m_path_subs_grid->SetColSize( 1, 300 );
|
||||
m_path_subs_grid->AutoSizeColumns();
|
||||
m_path_subs_grid->EnableDragColMove( false );
|
||||
m_path_subs_grid->EnableDragColSize( true );
|
||||
m_path_subs_grid->SetColLabelSize( 0 );
|
||||
m_path_subs_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
|
||||
|
||||
// Rows
|
||||
m_path_subs_grid->EnableDragRowSize( true );
|
||||
m_path_subs_grid->SetRowLabelSize( 0 );
|
||||
m_path_subs_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
|
||||
|
||||
// Label Appearance
|
||||
|
||||
// Cell Defaults
|
||||
m_path_subs_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
|
||||
m_path_subs_grid->SetToolTip( _("This is a read-only table which shows pertinent environment variables.") );
|
||||
|
||||
bSizerMain->Add( m_path_subs_grid, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
m_sdbSizer1 = new wxStdDialogButtonSizer();
|
||||
m_sdbSizer1OK = new wxButton( this, wxID_OK );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1OK );
|
||||
@ -90,7 +134,7 @@ DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
|
||||
m_sdbSizer1->Realize();
|
||||
|
||||
bSizerMain->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 );
|
||||
bSizerMain->Add( m_sdbSizer1, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
this->SetSizer( bSizerMain );
|
||||
@ -101,11 +145,13 @@ DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE
|
||||
|
||||
// Connect Events
|
||||
m_cbRecordOutput->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::OnRecordOutputClicked ), NULL, this );
|
||||
m_path_subs_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::onSizeGrid ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::~DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_cbRecordOutput->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::OnRecordOutputClicked ), NULL, this );
|
||||
m_path_subs_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE::onSizeGrid ), NULL, this );
|
||||
|
||||
}
|
||||
|
@ -481,9 +481,181 @@
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="spacer" expanded="true">
|
||||
<property name="height">10</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">10</property>
|
||||
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="true">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="drag_accept_files">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Available text variables:</property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">stPathsLabel</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">none</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="spacer" expanded="true">
|
||||
<property name="height">2</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">10</property>
|
||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxGrid" expanded="true">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="autosize_cols">1</property>
|
||||
<property name="autosize_rows">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="cell_bg"></property>
|
||||
<property name="cell_font"></property>
|
||||
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
|
||||
<property name="cell_text"></property>
|
||||
<property name="cell_vert_alignment">wxALIGN_CENTER</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
|
||||
<property name="col_label_size">0</property>
|
||||
<property name="col_label_values"></property>
|
||||
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
|
||||
<property name="cols">2</property>
|
||||
<property name="column_sizes">200,300</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="drag_accept_files">0</property>
|
||||
<property name="drag_col_move">0</property>
|
||||
<property name="drag_col_size">1</property>
|
||||
<property name="drag_grid_size">0</property>
|
||||
<property name="drag_row_size">1</property>
|
||||
<property name="editing">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="grid_line_color"></property>
|
||||
<property name="grid_lines">1</property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label_bg"></property>
|
||||
<property name="label_font"></property>
|
||||
<property name="label_text"></property>
|
||||
<property name="margin_height">0</property>
|
||||
<property name="margin_width">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_path_subs_grid</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="row_label_horiz_alignment">wxALIGN_CENTER</property>
|
||||
<property name="row_label_size">0</property>
|
||||
<property name="row_label_values"></property>
|
||||
<property name="row_label_vert_alignment">wxALIGN_CENTER</property>
|
||||
<property name="row_sizes"></property>
|
||||
<property name="rows">1</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">This is a read-only table which shows pertinent environment variables.</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnSize">onSizeGrid</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="false">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStdDialogButtonSizer" expanded="false">
|
||||
<property name="Apply">0</property>
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class WX_GRID;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
@ -21,6 +23,7 @@
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
@ -40,12 +43,14 @@ class DIALOG_EXECUTECOMMAND_JOB_SETTINGS_BASE : public DIALOG_SHIM
|
||||
wxTextCtrl* m_textCtrlOutputPath;
|
||||
wxCheckBox* m_cbRecordOutput;
|
||||
wxCheckBox* m_cbIgnoreExitCode;
|
||||
WX_GRID* m_path_subs_grid;
|
||||
wxStdDialogButtonSizer* m_sdbSizer1;
|
||||
wxButton* m_sdbSizer1OK;
|
||||
wxButton* m_sdbSizer1Cancel;
|
||||
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void OnRecordOutputClicked( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onSizeGrid( wxSizeEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
@ -242,7 +242,7 @@ bool JOBS_RUNNER::RunJobsForDestination( JOBSET_DESTINATION* aDestination, bool
|
||||
int failCount = 0;
|
||||
int successCount = 0;
|
||||
|
||||
wxSetEnv( "JOBSET_OUTPUT_TMP_PATH", tempDirPath );
|
||||
wxSetEnv( OUTPUT_TMP_PATH_VAR_NAME, tempDirPath );
|
||||
|
||||
for( const JOBSET_JOB& job : jobsForDestination )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user