35#include <wx/textctrl.h>
36#include <wx/statusbr.h>
37#include <wx/tokenzr.h>
38#include <wx/weakref.h>
68 if( statusBar && !statusBar->IsBeingDeleted() )
97 wxT(
"No wxTextCtrl object defined in WX_TEXT_CTRL_REPORTER." ) );
115 std::lock_guard lock(
m_mutex );
124 std::lock_guard lock(
m_mutex );
133 std::lock_guard lock(
m_mutex );
142 std::lock_guard lock(
m_mutex );
150 std::lock_guard lock(
m_mutex );
158 std::lock_guard lock(
m_mutex );
166 std::lock_guard lock(
m_mutex );
174 std::lock_guard lock(
m_mutex );
176 return m_reporter->HasMessageOfSeverity( aSeverityMask );
182 std::lock_guard lock(
m_mutex );
209 static REPORTER* s_nullReporter =
nullptr;
211 if( !s_nullReporter )
214 return *s_nullReporter;
226 FILE* target = stdout;
232 const int fd = _fileno( target );
234 if( fd >= 0 && !_isatty( fd ) )
236 wxMessageOutputStderr( target, wxConvUTF8 ).Output( aMsg );
241 if( std::fwide( target, 0 ) < 0 )
243 wxMessageOutputStderr( target ).Output( aMsg );
248 if( aMsg.EndsWith( wxS(
"\n" ) ) )
249 wxFprintf( target, aMsg );
251 wxFprintf( target, aMsg + wxS(
"\n" ) );
265 return s_cliReporter;
285 std::cout << aMsg << std::endl;
293 static REPORTER* s_stdoutReporter =
nullptr;
295 if( !s_stdoutReporter )
298 return *s_stdoutReporter;
326 static REPORTER* s_wxLogReporter =
nullptr;
329 if( !s_wxLogReporter )
332 return *s_wxLogReporter;
345 target->
Report( aMsg, aSeverity );
356 return s_loadInfoReporter;
421 if( wxIsMainThread() )
424 statusBar->SetStatusText( aText, position );
428 statusBar->CallAfter(
429 [statusBar, position, aText]()
431 statusBar->SetStatusText( aText, position );
441 const wxString& aSource ) :
456 if( !statusBar || aText.IsEmpty() )
459 std::vector<KI_ERROR> messages;
460 wxStringTokenizer tokenizer( aText, wxS(
"\n" ), wxTOKEN_STRTOK );
463 while( tokenizer.HasMoreTokens() )
466 message.
SetTitle( tokenizer.GetNextToken() );
468 messages.emplace_back( std::move( message ) );
471 if( messages.empty() )
476 messages.emplace_back( std::move( message ) );
489 statusBar->AddWarningMessages(
m_impl->m_source, { aError } );
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
static CLI_REPORTER & GetInstance()
~FONTCONFIG_REPORTER_SCOPE()
FONTCONFIG_REPORTER_SCOPE(REPORTER *aReporter)
REPORTER * m_previousReporter
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
void AddWarningMessages(const wxString &aSource, const wxString &aMessages)
Add warning/error messages (not thread-safe, use the std::vector<KI_ERROR> variant from other threads...
Holds a structured error message.
SEVERITY GetSeverity() const
wxString AsString() const
KI_ERROR & SetSeverity(SEVERITY aSeverity)
KI_ERROR & SetTitle(const wxString &aTitle)
LOAD_INFO_REPORTER_SCOPE(REPORTER *aReporter)
~LOAD_INFO_REPORTER_SCOPE()
LOAD_INFO_REPORTER & m_reporter
REPORTER * m_previousReporter
REPORTER * GetRedirectTarget() const
REPORTER * m_redirectTarget
static LOAD_INFO_REPORTER & GetInstance()
void SetRedirectTarget(REPORTER *aReporter)
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
static REPORTER & GetInstance()
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
REPORTER * m_redirectTarget
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
wxStatusBar * m_statusBar
wxWeakRef< KISTATUSBAR > m_statusBar
KISTATUSBAR * GetStatusBar() const
STATUSBAR_WARNING_REPORTER_IMPL(KISTATUSBAR *aStatusBar, const wxString &aSource)
STATUSBAR_WARNING_REPORTER(KISTATUSBAR *aStatusBar, const wxString &aSource)
~STATUSBAR_WARNING_REPORTER() override
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
std::shared_ptr< STATUSBAR_WARNING_REPORTER_IMPL > m_impl
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
static REPORTER & GetInstance()
bool HasMessage() const override
Returns true if any messages were reported.
REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the beginning of the list for objects that support ordering.
EDA_UNITS GetUnits() const override
bool HasMessageOfSeverity(int aSeverityMask) const override
Returns true if the reporter has one or more messages matching the specified severity mask.
REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the end of the list, for objects that support report ordering.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
static REPORTER & GetInstance()
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
const wxString & GetMessages() const
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
static const wxChar traceReporter[]
Flag to enable reporter debugging output.
This file contains miscellaneous commonly used macros and functions.
static std::mutex g_logReporterMutex
wxString From_UTF8(const char *cstring)