12 #include <wx/string.h> 13 #include <wx/textctrl.h> 14 #include <wx/thread.h> 51 wxTextCtrl*
obj,
bool yieldApplication =
false,
int bufferSize = 3000,
52 bool also_cerr =
false,
bool threadSafe =
false,
53 bool also_to_cout_cerr =
false)
62 char* ptr =
new char[bufferSize];
63 setp(ptr, ptr + bufferSize);
66 setp(
nullptr,
nullptr);
69 sbOld = std::cout.rdbuf();
70 std::cout.rdbuf(
this);
75 std::cerr.rdbuf(
this);
83 std::cout.rdbuf(
sbOld);
95 const auto s = wxString(str);
97 #if wxCHECK_VERSION(3, 0, 0) && !defined(__APPLE__) // OSX build error? 98 m_txt->GetEventHandler()->CallAfter(&wxTextCtrl::WriteText,
s);
111 wxTheApp->Yield(
true);
120 wxCriticalSectionLocker lock(
m_cs);
141 wxCriticalSectionLocker lock(
m_cs);
142 if (pbase() == epptr())
157 wxCriticalSectionLocker lock(
m_cs);
159 if (pbase() != pptr())
161 int len = int(pptr() - pbase());
164 setp(pbase(), epptr());
const bool m_also_to_cout_cerr
GLsizei GLsizei GLuint * obj
This auxiliary class redirects the output sent to a streambuf to a wxTextCtrl object.
const bool m_yieldApplication
std::streambuf * sbOldErr
GLsizei const GLchar ** string
int overflow(int c) override
~CMyRedirector() override
virtual void writeString(const std::string &str)
CMyRedirector(wxTextCtrl *obj, bool yieldApplication=false, int bufferSize=3000, bool also_cerr=false, bool threadSafe=false, bool also_to_cout_cerr=false)
void dumpNow()
Writes all the stored strings to the text control (only for threadSafe mode).