45 m_scintillaTricks( nullptr ),
46 m_helpWindow( nullptr )
49 [
this]( wxKeyEvent& aEvent )
52 wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
59 m_typeRegex.Compile(
"^Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
60 m_viaTypeRegex.Compile(
"^Via_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
61 m_padTypeRegex.Compile(
"^Pad_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
62 m_pinTypeRegex.Compile(
"^Pin_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
63 m_fabPropRegex.Compile(
"^Fabrication_Property\\s*[!=]=\\s*$", wxRE_ADVANCED );
64 m_shapeRegex.Compile(
"^Shape\\s*[!=]=\\s*$", wxRE_ADVANCED );
69 m_textEditor->SetZoom(
Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom );
80 Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom =
m_textEditor->GetZoom();
91 if( aEvent.GetKeyCode() == WXK_ESCAPE && !
m_textEditor->AutoCompActive() )
95 if( !
IsOK(
this,
_(
"Cancel Changes?" ) ) )
108 menu.Append( wxID_UNDO,
_(
"Undo" ) );
109 menu.Append( wxID_REDO,
_(
"Redo" ) );
111 menu.AppendSeparator();
113 menu.Append( 1,
_(
"Cut" ) );
114 menu.Append( 2,
_(
"Copy" ) );
115 menu.Append( 3,
_(
"Paste" ) );
116 menu.Append( 4,
_(
"Delete" ) );
118 menu.AppendSeparator();
120 menu.Append( 5,
_(
"Select All" ) );
122 menu.AppendSeparator();
124 menu.Append( wxID_ZOOM_IN,
_(
"Zoom In" ) );
125 menu.Append( wxID_ZOOM_OUT,
_(
"Zoom Out" ) );
128 switch( GetPopupMenuSelectionFromUser( menu ) )
180 for(
int line =
m_textEditor->LineFromPosition( currentPos ); line > 0; line-- )
183 wxString beginning =
m_textEditor->GetTextRange( lineStart, lineStart + 10 );
185 if( beginning.StartsWith( wxT(
"(rule " ) ) )
187 startPos = lineStart;
202 auto isDisallowToken =
203 [](
const wxString& token ) ->
bool
205 return token == wxT(
"buried_via" )
206 || token == wxT(
"graphic" )
207 || token == wxT(
"hole" )
208 || token == wxT(
"micro_via" )
209 || token == wxT(
"pad" )
210 || token == wxT(
"text" )
211 || token == wxT(
"track" )
212 || token == wxT(
"via" )
213 || token == wxT(
"zone" );
216 std::stack<wxString> sexprs;
220 int expr_context =
NONE;
222 for(
int i = startPos; i < currentPos; ++i )
230 else if( context ==
STRING )
238 if( expr_context ==
STRING )
248 partial = wxEmptyString;
253 partial = wxEmptyString;
254 expr_context = STRUCT_REF;
265 partial = wxEmptyString;
270 if( context == SEXPR_OPEN && !partial.IsEmpty() )
273 sexprs.push( partial );
276 partial = wxEmptyString;
277 context = SEXPR_OPEN;
281 while( !sexprs.empty() && ( sexprs.top() == wxT(
"assertion" )
282 || sexprs.top() == wxT(
"disallow" )
283 || isDisallowToken( sexprs.top() )
284 || sexprs.top() == wxT(
"min_resolved_spokes" )
285 || sexprs.top() == wxT(
"zone_connection" ) ) )
290 if( !sexprs.empty() )
297 if( context == SEXPR_OPEN && ( partial == wxT(
"constraint" )
298 || partial == wxT(
"disallow" )
299 || partial == wxT(
"layer" )
300 || partial == wxT(
"severity" ) ) )
303 sexprs.push( partial );
305 partial = wxEmptyString;
306 context = SEXPR_TOKEN;
309 else if( partial == wxT(
"disallow" )
310 || isDisallowToken( partial )
311 || partial == wxT(
"min_resolved_spokes" )
312 || partial == wxT(
"zone_connection" ) )
315 sexprs.push( partial );
317 partial = wxEmptyString;
318 context = SEXPR_TOKEN;
321 else if( partial == wxT(
"rule" )
322 || partial == wxT(
"assertion" )
323 || partial == wxT(
"condition" ) )
326 sexprs.push( partial );
328 partial = wxEmptyString;
329 context = SEXPR_STRING;
343 if( context == SEXPR_OPEN )
347 tokens = wxT(
"rule|"
350 else if( sexprs.top() == wxT(
"rule" ) )
352 tokens = wxT(
"condition|"
357 else if( sexprs.top() == wxT(
"constraint" ) )
359 tokens = wxT(
"max|min|opt" );
362 else if( context == SEXPR_TOKEN )
368 else if( sexprs.top() == wxT(
"constraint" ) )
370 tokens = wxT(
"annular_width|"
374 "courtyard_clearance|"
376 "diff_pair_uncoupled|"
383 "min_resolved_spokes|"
384 "physical_clearance|"
385 "physical_hole_clearance|"
390 "thermal_relief_gap|"
391 "thermal_spoke_width|"
397 else if( sexprs.top() == wxT(
"disallow" ) || isDisallowToken( sexprs.top() ) )
399 tokens = wxT(
"buried_via|"
409 else if( sexprs.top() == wxT(
"zone_connection" ) )
411 tokens = wxT(
"none|solid|thermal_reliefs" );
413 else if( sexprs.top() == wxT(
"min_resolved_spokes" ) )
415 tokens = wxT(
"0|1|2|3|4" );
417 else if( sexprs.top() == wxT(
"layer" ) )
419 tokens = wxT(
"inner|outer|\"x\"" );
421 else if( sexprs.top() == wxT(
"severity" ) )
423 tokens = wxT(
"warning|error|ignore|exclusion" );
426 else if( context == SEXPR_STRING && !sexprs.empty()
427 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
431 else if( context ==
STRING && !sexprs.empty()
432 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
434 if( expr_context == STRUCT_REF )
437 std::set<wxString> propNames;
448 if( prop->IsHiddenFromRulesEditor() )
451 wxString ref( prop->Name() );
452 ref.Replace( wxT(
" " ), wxT(
"_" ) );
453 propNames.insert( ref );
457 for(
const wxString& propName : propNames )
458 tokens += wxT(
"|" ) + propName;
464 if( !funcSig.Contains(
"DEPRECATED" ) )
465 tokens += wxT(
"|" ) + funcSig;
468 else if( expr_context ==
STRING )
473 std::shared_ptr<NET_SETTINGS>& netSettings = bds.
m_NetSettings;
475 for(
const auto& [
name, netclass ] : netSettings->m_NetClasses )
476 tokens += wxT(
"|" ) +
name;
483 tokens += wxT(
"|" ) + netnameCandidate;
487 tokens = wxT(
"Bitmap|"
503 tokens = wxT(
"Through|"
509 tokens = wxT(
"Through-hole|"
512 "NPTH, mechanical" );
516 tokens = wxT(
"Input|"
531 tokens = wxT(
"None|"
533 "Fiducial, global to board|"
534 "Fiducial, local to footprint|"
541 tokens = wxT(
"Segment|"
550 tokens = wxT(
"Inherited|"
558 if( !tokens.IsEmpty() )
569 std::vector<std::shared_ptr<DRC_RULE>> dummyRules;
577 wxString msg = wxString::Format( wxT(
"%s <a href='%d:%d'>%s</a>%s" ),
593 wxString link =
event.GetLinkInfo().GetHref();
595 long line = 0, offset = 0;
599 if( parts.size() > 1 )
601 parts[0].ToLong( &line );
602 parts[1].ToLong( &offset );
605 int pos =
m_textEditor->PositionFromLine( line - 1 ) + ( offset - 1 );
617 if( rulesFile.FileExists() )
619 wxTextFile file( rulesFile.GetFullPath() );
623 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
631 wxCommandEvent
dummy;
641 m_textEditor->AddText(
_(
"Design rules cannot be added without a project" ) );
691 msg.Replace( wxT(
"Ctrl+" ), wxT(
"Cmd+" ) );
700 html_txt.Replace( wxS(
"<td" ), wxS(
"<td valign=top" ) );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
std::shared_ptr< DRC_ENGINE > m_DRCEngine
Information pertinent to a Pcbnew printed circuit board.
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Parse(std::vector< std::shared_ptr< DRC_RULE > > &aRules, REPORTER *aReporter)
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
Class PANEL_SETUP_RULES_BASE.
wxStyledTextCtrl * m_textEditor
WX_HTML_REPORT_BOX * m_errorsReport
wxBitmapButton * m_compileButton
bool TransferDataToWindow() override
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
void OnContextMenu(wxMouseEvent &event) override
~PANEL_SETUP_RULES() override
HTML_MESSAGE_BOX * m_helpWindow
void OnCompile(wxCommandEvent &event) override
wxRegEx m_zoneConnStyleRegex
bool TransferDataFromWindow() override
void OnSyntaxHelp(wxHyperlinkEvent &aEvent) override
PANEL_SETUP_RULES(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
void onCharHook(wxKeyEvent &aEvent)
SCINTILLA_TRICKS * m_scintillaTricks
const wxArrayString GetSignatures() const
static PCBEXPR_BUILTIN_FUNCTIONS & Instance()
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
The main frame for Pcbnew.
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Provide class metadata.Helper macro to map type hashes to names.
CLASSES_INFO GetAllClasses()
const PROPERTY_LIST & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
static PROPERTY_MANAGER & Instance()
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
void Clear()
Delete the stored messages.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void Flush()
Build the HTML messages page.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
This file is part of the common library.
std::vector< PROPERTY_BASE * > PROPERTY_LIST
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
bool ConvertSmartQuotesAndDashes(wxString *aString)
Convert curly quotes and em/en dashes to straight quotes and dashes.
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
A filename or source description, a problem input line, a line number, a byte offset,...
int lineNumber
at which line number, 1 based index.
const wxString ParseProblem()
int byteIndex
at which byte offset within the line, 1 based index