Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTextViewStream.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2
3/*************************************************************************
4 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11//////////////////////////////////////////////////////////////////////////
12// //
13// TGTextViewStream //
14// //
15// A TGTextViewStream is a text viewer widget. It is a specialization //
16// of TGTextView and std::ostream, and it uses a TGTextViewStreamBuf, //
17// who inherits from std::streambuf, allowing to stream text directly //
18// to the text view in a cout-like fashion //
19// //
20//////////////////////////////////////////////////////////////////////////
21
22#include "TGTextViewStream.h"
23#include "TSystem.h"
24
26
27////////////////////////////////////////////////////////////////////////////////
28/// TGTextViewStreamBuf constructor.
29
31 fTextView(textview)
32{
33 fInputbuffer.reserve(32);
34 setg(&fInputbuffer[0], &fInputbuffer[0], &fInputbuffer[0]);
35 setp(&fInputbuffer[0], &fInputbuffer[0]);
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Method called to put a character into the controlled output sequence
40/// without changing the current position.
41
43{
44 typedef std::char_traits<char> Tr;
45 if (c == Tr::eof())
46 return Tr::not_eof(c);
47 if (c=='\n') {
48 fLinebuffer.push_back('\0');
50 fLinebuffer.clear();
54 } else {
55 fLinebuffer.push_back(c);
56 }
57 return c;
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// TGTextViewostream constructor.
62
64 UInt_t h,Int_t id, UInt_t sboptions,
65 Pixel_t back) :
66 TGTextView(parent, w, h, id, sboptions, back), std::ostream(&fStreambuffer),
67 fStreambuffer(this)
68{
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// TGTextViewostream constructor.
73
75 UInt_t h, TGText *text, Int_t id,
76 UInt_t sboptions, ULong_t back):
77 TGTextView(parent, w, h, text, id, sboptions, back),
78 std::ostream(&fStreambuffer), fStreambuffer(this)
79{
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// TGTextViewostream constructor.
84
86 UInt_t h,const char *string, Int_t id,
87 UInt_t sboptions, ULong_t back):
88 TGTextView(parent, w, h, string, id, sboptions, back),
89 std::ostream(&fStreambuffer), fStreambuffer(this)
90{
91}
92
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
unsigned long ULong_t
Definition RtypesCore.h:55
#define ClassImp(name)
Definition Rtypes.h:364
XFontStruct * id
Definition TGX11.cxx:109
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
virtual int overflow(int=traits::eof())
Method called to put a character into the controlled output sequence without changing the current pos...
std::vector< char > fLinebuffer
TGTextViewStreamBuf(TGTextView *textview)
TGTextViewStreamBuf constructor.
std::vector< char > fInputbuffer
virtual void Update()
update the whole window of text view
virtual void AddLineFast(const char *string)
Add a line of text to the view widget.
virtual void ShowBottom()
Show bottom of the page.
TGTextViewostream(const TGWindow *parent=nullptr, UInt_t w=1, UInt_t h=1, Int_t id=-1, UInt_t sboptions=0, Pixel_t back=TGTextView::GetWhitePixel())
TGTextViewostream constructor.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:417
TText * text