#include "TGTextViewStream.h"
#include "TSystem.h"
ClassImp(TGTextViewStreamBuf)
#ifdef R__WIN32
#pragma warning( push )
#pragma warning( disable : 4355 )
#endif
TGTextViewStreamBuf::TGTextViewStreamBuf(TGTextView *textview) :
fTextView(textview)
{
fInputbuffer.reserve(32);
setg(&fInputbuffer[0], &fInputbuffer[0], &fInputbuffer[0]);
setp(&fInputbuffer[0], &fInputbuffer[0]);
}
Int_t TGTextViewStreamBuf::overflow(Int_t c)
{
typedef std::char_traits<char> Tr;
if (c == Tr::eof())
return Tr::not_eof(c);
if (c=='\n') {
fLinebuffer.push_back('\0');
fTextView->AddLineFast(&fLinebuffer[0]);
fLinebuffer.clear();
fTextView->ShowBottom();
fTextView->Update();
gSystem->ProcessEvents();
} else {
fLinebuffer.push_back(c);
}
return c;
}
TGTextViewostream::TGTextViewostream(const TGWindow* parent, UInt_t w,
UInt_t h,Int_t id, UInt_t sboptions,
Pixel_t back) :
TGTextView(parent, w, h, id, sboptions, back), std::ostream(&fStreambuffer),
fStreambuffer(this)
{
}
TGTextViewostream::TGTextViewostream(const TGWindow *parent, UInt_t w,
UInt_t h, TGText *text, Int_t id,
UInt_t sboptions, ULong_t back):
TGTextView(parent, w, h, text, id, sboptions, back),
std::ostream(&fStreambuffer), fStreambuffer(this)
{
}
TGTextViewostream::TGTextViewostream(const TGWindow *parent, UInt_t w,
UInt_t h,const char *string, Int_t id,
UInt_t sboptions, ULong_t back):
TGTextView(parent, w, h, string, id, sboptions, back),
std::ostream(&fStreambuffer), fStreambuffer(this)
{
}
#ifdef R__WIN32
#pragma warning( pop )
#endif