Autocomplete for page layout editor text items.
This commit is contained in:
parent
fbef52ec33
commit
a6eaa3257a
|
@ -85,6 +85,32 @@ const COLOR4D& WS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
|
|||
}
|
||||
|
||||
|
||||
void WS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars )
|
||||
{
|
||||
aVars->push_back( wxT( "KICAD_VERSION" ) );
|
||||
aVars->push_back( wxT( "#" ) );
|
||||
aVars->push_back( wxT( "##" ) );
|
||||
aVars->push_back( wxT( "SHEETNAME" ) );
|
||||
aVars->push_back( wxT( "FILENAME" ) );
|
||||
aVars->push_back( wxT( "PAPER" ) );
|
||||
aVars->push_back( wxT( "LAYER" ) );
|
||||
aVars->push_back( wxT( "ISSUE_DATE" ) );
|
||||
aVars->push_back( wxT( "REVISION" ) );
|
||||
aVars->push_back( wxT( "TITLE" ) );
|
||||
aVars->push_back( wxT( "COMPANY" ) );
|
||||
aVars->push_back( wxT( "COMMENT0" ) );
|
||||
aVars->push_back( wxT( "COMMENT1" ) );
|
||||
aVars->push_back( wxT( "COMMENT2" ) );
|
||||
aVars->push_back( wxT( "COMMENT3" ) );
|
||||
aVars->push_back( wxT( "COMMENT4" ) );
|
||||
aVars->push_back( wxT( "COMMENT5" ) );
|
||||
aVars->push_back( wxT( "COMMENT6" ) );
|
||||
aVars->push_back( wxT( "COMMENT7" ) );
|
||||
aVars->push_back( wxT( "COMMENT8" ) );
|
||||
aVars->push_back( wxT( "COMMENT9" ) );
|
||||
}
|
||||
|
||||
|
||||
// returns the full text corresponding to the aTextbase,
|
||||
// after replacing format symbols by the corresponding value
|
||||
wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
||||
|
|
|
@ -513,6 +513,8 @@ public:
|
|||
*/
|
||||
void BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo, const TITLE_BLOCK& aTitleBlock );
|
||||
|
||||
static void GetTextVars( wxArrayString* aVars );
|
||||
|
||||
/**
|
||||
* Function BuildFullText
|
||||
* returns the full text corresponding to the aTextbase,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Dec 1 2018)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -24,7 +24,7 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
|
|||
|
||||
m_staticTextType = new wxStaticText( m_swItemProperties, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextType->Wrap( -1 );
|
||||
m_staticTextType->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
m_staticTextType->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_SLANT, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizerButt->Add( m_staticTextType, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
|
@ -46,8 +46,36 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
|
|||
m_staticTextText->Wrap( -1 );
|
||||
m_SizerTextOptions->Add( m_staticTextText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_textCtrlText = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
|
||||
m_SizerTextOptions->Add( m_textCtrlText, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
m_stcText = new wxStyledTextCtrl( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
||||
m_stcText->SetUseTabs( true );
|
||||
m_stcText->SetTabWidth( 4 );
|
||||
m_stcText->SetIndent( 4 );
|
||||
m_stcText->SetTabIndents( true );
|
||||
m_stcText->SetBackSpaceUnIndents( true );
|
||||
m_stcText->SetViewEOL( false );
|
||||
m_stcText->SetViewWhiteSpace( false );
|
||||
m_stcText->SetMarginWidth( 2, 0 );
|
||||
m_stcText->SetIndentationGuides( false );
|
||||
m_stcText->SetMarginWidth( 1, 0 );
|
||||
m_stcText->SetMarginWidth( 0, 0 );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS );
|
||||
m_stcText->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) );
|
||||
m_stcText->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS );
|
||||
m_stcText->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) );
|
||||
m_stcText->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS );
|
||||
m_stcText->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) );
|
||||
m_stcText->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS );
|
||||
m_stcText->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) );
|
||||
m_stcText->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY );
|
||||
m_stcText->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
m_stcText->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
|
||||
m_SizerTextOptions->Add( m_stcText, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxBoxSizer* bSizerFontOpt;
|
||||
bSizerFontOpt = new wxBoxSizer( wxVERTICAL );
|
||||
|
|
|
@ -438,11 +438,11 @@
|
|||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxTextCtrl" expanded="0">
|
||||
<object class="wxStyledTextCtrl" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -451,6 +451,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="backspace_unindents">1</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
|
@ -466,19 +467,21 @@
|
|||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="folding">0</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="indentation_guides">0</property>
|
||||
<property name="line_numbers">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength">0</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_textCtrlText</property>
|
||||
<property name="name">m_stcText</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -488,15 +491,14 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxTE_MULTILINE</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="tab_indents">1</property>
|
||||
<property name="tab_width">4</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="value"></property>
|
||||
<property name="use_tabs">1</property>
|
||||
<property name="view_eol">0</property>
|
||||
<property name="view_whitespace">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Dec 1 2018)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -19,8 +19,9 @@
|
|||
#include <wx/choice.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/stc/stc.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
|
@ -48,7 +49,7 @@ class PANEL_PROPERTIES_BASE : public wxPanel
|
|||
wxStaticLine* m_staticline5;
|
||||
wxBoxSizer* m_SizerTextOptions;
|
||||
wxStaticText* m_staticTextText;
|
||||
wxTextCtrl* m_textCtrlText;
|
||||
wxStyledTextCtrl* m_stcText;
|
||||
wxStaticText* m_staticTextHjust;
|
||||
wxChoice* m_choiceHjustify;
|
||||
wxCheckBox* m_checkBoxBold;
|
||||
|
|
|
@ -26,16 +26,23 @@
|
|||
#include <fctsys.h>
|
||||
#include <ws_draw_item.h>
|
||||
#include <ws_data_model.h>
|
||||
#include <project.h>
|
||||
#include <properties_frame.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pl_selection_tool.h>
|
||||
#include <pl_draw_panel_gal.h>
|
||||
#include <scintilla_tricks.h>
|
||||
|
||||
PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) :
|
||||
PANEL_PROPERTIES_BASE( aParent )
|
||||
PANEL_PROPERTIES_BASE( aParent ),
|
||||
m_scintillaTricks( nullptr )
|
||||
{
|
||||
m_parent = aParent;
|
||||
|
||||
m_stcText->SetUseVerticalScrollBar( false );
|
||||
m_stcText->SetUseHorizontalScrollBar( false );
|
||||
m_scintillaTricks = new SCINTILLA_TRICKS( m_stcText, wxT( "{}" ) );
|
||||
|
||||
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
|
||||
m_staticTextSizeInfo->SetFont( infoFont );
|
||||
|
@ -43,11 +50,14 @@ PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ):
|
|||
m_staticTextInfoThickness->SetFont( infoFont );
|
||||
|
||||
m_buttonOK->SetDefault();
|
||||
|
||||
m_stcText->Bind( wxEVT_STC_CHARADDED, &PROPERTIES_FRAME::onScintillaCharAdded, this );
|
||||
}
|
||||
|
||||
|
||||
PROPERTIES_FRAME::~PROPERTIES_FRAME()
|
||||
{
|
||||
delete m_scintillaTricks;
|
||||
}
|
||||
|
||||
|
||||
|
@ -195,7 +205,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WS_DATA_ITEM* aItem )
|
|||
item->m_FullText = item->m_TextBase;
|
||||
// Replace our '\' 'n' sequence by the EOL char
|
||||
item->ReplaceAntiSlashSequence();
|
||||
m_textCtrlText->SetValue( item->m_FullText );
|
||||
m_stcText->SetValue( item->m_FullText );
|
||||
|
||||
msg.Printf( wxT("%d"), item->m_IncrementLabel );
|
||||
m_textCtrlTextIncrement->SetValue( msg );
|
||||
|
@ -402,7 +412,7 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( WS_DATA_ITEM* aItem )
|
|||
{
|
||||
WS_DATA_ITEM_TEXT* item = (WS_DATA_ITEM_TEXT*) aItem;
|
||||
|
||||
item->m_TextBase = m_textCtrlText->GetValue();
|
||||
item->m_TextBase = m_stcText->GetValue();
|
||||
|
||||
msg = m_textCtrlTextIncrement->GetValue();
|
||||
msg.ToLong( &itmp );
|
||||
|
@ -464,3 +474,26 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( WS_DATA_ITEM* aItem )
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void PROPERTIES_FRAME::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
||||
{
|
||||
wxArrayString autocompleteTokens;
|
||||
int pos = m_stcText->GetCurrentPos();
|
||||
int start = m_stcText->WordStartPosition( pos, true );
|
||||
wxString partial;
|
||||
|
||||
if( start >= 2
|
||||
&& m_stcText->GetCharAt( start-2 ) == '$'
|
||||
&& m_stcText->GetCharAt( start-1 ) == '{' )
|
||||
{
|
||||
WS_DRAW_ITEM_LIST::GetTextVars( &autocompleteTokens );
|
||||
|
||||
partial = m_stcText->GetTextRange( start, pos );
|
||||
|
||||
for( std::pair<wxString, wxString> entry : m_parent->Prj().GetTextVars() )
|
||||
autocompleteTokens.push_back( entry.first );
|
||||
}
|
||||
|
||||
m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
|
||||
m_stcText->SetFocus();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <pl_editor_frame.h>
|
||||
#include <dialogs/properties_frame_base.h>
|
||||
#include <scintilla_tricks.h>
|
||||
|
||||
class WS_DATA_ITEM;
|
||||
|
||||
|
@ -41,6 +42,7 @@ class WS_DATA_ITEM;
|
|||
class PROPERTIES_FRAME : public PANEL_PROPERTIES_BASE
|
||||
{
|
||||
PL_EDITOR_FRAME* m_parent;
|
||||
SCINTILLA_TRICKS* m_scintillaTricks;
|
||||
|
||||
public:
|
||||
PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent );
|
||||
|
@ -50,7 +52,7 @@ public:
|
|||
void OnPageChanged( wxNotebookEvent& event ) override;
|
||||
void OnAcceptPrms( wxCommandEvent& event ) override;
|
||||
void OnSetDefaultValues( wxCommandEvent& event ) override;
|
||||
|
||||
void onScintillaCharAdded( wxStyledTextEvent &aEvent );
|
||||
|
||||
// Data transfert from general properties to widgets
|
||||
void CopyPrmsFromGeneralToPanel();
|
||||
|
|
Loading…
Reference in New Issue