Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGText.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 26/04/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TGText
13#define ROOT_TGText
14
15
16#include "TString.h"
17
18#include "TGDimension.h"
19
20
22
23friend class TGText;
24
25protected:
26 char *fString; ///< line of text
27 ULong_t fLength; ///< length of line
28 TGTextLine *fPrev; ///< previous line
29 TGTextLine *fNext; ///< next line
30
31 TGTextLine(const TGTextLine&);
33
34public:
35 TGTextLine();
37 TGTextLine(const char *string);
38 virtual ~TGTextLine();
39
40 void Clear();
42
43 void DelText(ULong_t pos, ULong_t length);
44 void InsText(ULong_t pos, const char *text);
45 char *GetText(ULong_t pos, ULong_t length);
46 char *GetText() const { return fString; }
47 char *GetWord(ULong_t pos);
48
49 void DelChar(ULong_t pos);
50 void InsChar(ULong_t pos, char character);
51 char GetChar(ULong_t pos);
52
53 ClassDef(TGTextLine,0) // Line in TGText
54};
55
56
57class TGText {
58
59protected:
60 TString fFilename; ///< name of opened file ("" if open buffer)
61 Bool_t fIsSaved; ///< false if text needs to be saved
62 TGTextLine *fFirst; ///< first line of text
63 TGTextLine *fCurrent; ///< current line
64 Long_t fCurrentRow; ///< current row number
65 Long_t fRowCount; ///< number of rows
66 Long_t fColCount; ///< number of columns in current line
67 Long_t fLongestLine; ///< length of longest line
68
69 TGText(const TGText&);
70 TGText& operator=(const TGText&);
71
72 void Init();
74 void LongestLine();
75
76public:
77 TGText();
79 TGText(const char *string);
80 virtual ~TGText();
81
82 void Clear();
83 Bool_t Load(const char *fn, Long_t startpos = 0, Long_t length = -1);
84 Bool_t LoadBuffer(const char *txtbuf);
85 Bool_t Save(const char *fn);
86 Bool_t Append(const char *fn);
87 Bool_t IsSaved() const { return fIsSaved; }
88 const char *GetFileName() const { return fFilename.Data(); }
89
91 Bool_t InsChar(TGLongPosition pos, char c);
92 char GetChar(TGLongPosition pos);
93
95 Bool_t InsText(TGLongPosition pos, const char *buf);
98
102 TGTextLine *GetCurrentLine() const { return fCurrent; }
104 Bool_t InsLine(ULong_t row, const char *string);
105
106 Long_t RowCount() const { return fRowCount; }
107 Long_t ColCount() const { return fColCount; }
108
111
112 void ReTab(Long_t row);
113
114 Bool_t Search(TGLongPosition *foundPos, TGLongPosition start, const char *searchString,
115 Bool_t direction, Bool_t caseSensitive);
116 Bool_t Replace(TGLongPosition start, const char *oldText, const char *newText,
117 Bool_t direction, Bool_t caseSensitive);
118
119 ClassDef(TGText,0) // Text used by TGTextEdit
120};
121
122#endif
#define c(i)
Definition RSha256.hxx:101
bool Bool_t
Definition RtypesCore.h:63
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
#define ClassDef(name, id)
Definition Rtypes.h:337
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char text
virtual ~TGTextLine()
Delete a line of text.
Definition TGText.cxx:116
TGTextLine * fPrev
previous line
Definition TGText.h:28
char * fString
line of text
Definition TGText.h:26
void DelChar(ULong_t pos)
Delete a character from the line.
Definition TGText.cxx:263
void InsChar(ULong_t pos, char character)
Insert a character at the specified position.
Definition TGText.cxx:282
char GetChar(ULong_t pos)
Get a character at the specified position from the line.
Definition TGText.cxx:303
ULong_t GetLineLength()
Definition TGText.h:41
char * GetText() const
Definition TGText.h:46
char * GetWord(ULong_t pos)
Get word at position. Returned string must be deleted.
Definition TGText.cxx:204
void InsText(ULong_t pos, const char *text)
Insert text in line starting at position pos.
Definition TGText.cxx:161
TGTextLine * fNext
next line
Definition TGText.h:29
void Clear()
Clear a line of text.
Definition TGText.cxx:125
TGTextLine()
Create empty line of text (default ctor).
Definition TGText.cxx:47
void DelText(ULong_t pos, ULong_t length)
Delete length chars from line starting at position pos.
Definition TGText.cxx:136
ULong_t fLength
length of line
Definition TGText.h:27
TGTextLine & operator=(const TGTextLine &)
assignment operator
Definition TGText.cxx:99
A TGText is a multi line text buffer.
Definition TGText.h:57
Bool_t InsChar(TGLongPosition pos, char c)
Insert character c at the specified position pos.
Definition TGText.cxx:707
Long_t ColCount() const
Definition TGText.h:107
void ReTab(Long_t row)
Redo all tabs in a line. Needed after a new tab is inserted.
Definition TGText.cxx:1087
virtual ~TGText()
Destroy text buffer.
Definition TGText.cxx:397
Long_t fColCount
number of columns in current line
Definition TGText.h:66
Bool_t AddText(TGText *text)
Add another text buffer to this buffer.
Definition TGText.cxx:911
Long_t RowCount() const
Definition TGText.h:106
Long_t GetLongestLine() const
Definition TGText.h:110
TGTextLine * fFirst
first line of text
Definition TGText.h:62
Bool_t DelText(TGLongPosition start, TGLongPosition end)
Delete text between start and end positions.
Definition TGText.cxx:736
TString fFilename
name of opened file ("" if open buffer)
Definition TGText.h:60
TGText()
Create default (empty) text buffer.
Definition TGText.cxx:363
Long_t fLongestLine
length of longest line
Definition TGText.h:67
Long_t fRowCount
number of rows
Definition TGText.h:65
Bool_t fIsSaved
false if text needs to be saved
Definition TGText.h:61
void LongestLine()
Set fLongestLine.
Definition TGText.cxx:1220
Bool_t Search(TGLongPosition *foundPos, TGLongPosition start, const char *searchString, Bool_t direction, Bool_t caseSensitive)
Search for string searchString starting at the specified position going in forward (direction = true)...
Definition TGText.cxx:1143
Bool_t DelLine(ULong_t pos)
Delete specified row. Returns false if row does not exist.
Definition TGText.cxx:964
Bool_t Save(const char *fn)
Save text buffer to file fn.
Definition TGText.cxx:610
Bool_t Replace(TGLongPosition start, const char *oldText, const char *newText, Bool_t direction, Bool_t caseSensitive)
Replace oldText by newText. Returns false if nothing replaced.
Definition TGText.cxx:1197
Bool_t InsLine(ULong_t row, const char *string)
Insert string before specified position.
Definition TGText.cxx:928
Bool_t SetCurrentRow(Long_t row)
Make specified row the current row.
Definition TGText.cxx:1055
Long_t fCurrentRow
current row number
Definition TGText.h:64
Bool_t DelChar(TGLongPosition pos)
Delete character at specified position pos.
Definition TGText.cxx:691
Bool_t BreakLine(TGLongPosition pos)
Break line at position pos. Returns false if pos is not valid.
Definition TGText.cxx:1008
Bool_t InsText(TGLongPosition pos, const char *buf)
Insert single line at specified position.
Definition TGText.cxx:888
char * GetLine(TGLongPosition pos, ULong_t length)
Return string at position pos.
Definition TGText.cxx:997
TGTextLine * fCurrent
current line
Definition TGText.h:63
char GetChar(TGLongPosition pos)
Get character a position pos. If character not valid return -1.
Definition TGText.cxx:723
Bool_t IsSaved() const
Definition TGText.h:87
Bool_t Load(const char *fn, Long_t startpos=0, Long_t length=-1)
Load text from file fn.
Definition TGText.cxx:431
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
Definition TGText.cxx:513
void Clear()
Clear text buffer.
Definition TGText.cxx:406
Bool_t Append(const char *fn)
Append buffer to file fn.
Definition TGText.cxx:651
TGTextLine * GetCurrentLine() const
Definition TGText.h:102
const char * GetFileName() const
Definition TGText.h:88
Long_t GetLineLength(Long_t row)
Get length of specified line. Returns -1 if row does not exist.
Definition TGText.cxx:1043
void Init()
Common initialization method.
Definition TGText.cxx:349
TString AsString()
Returns content as ROOT string.
Definition TGText.cxx:1238
TGText & operator=(const TGText &)
assignment operator
Definition TGText.cxx:331
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
TLine * line