00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGText
00013 #define ROOT_TGText
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ROOT_TString
00027 #include "TString.h"
00028 #endif
00029
00030 #ifndef ROOT_TGDimension
00031 #include "TGDimension.h"
00032 #endif
00033
00034
00035 class TGTextLine {
00036
00037 friend class TGText;
00038
00039 protected:
00040 char *fString;
00041 ULong_t fLength;
00042 TGTextLine *fPrev;
00043 TGTextLine *fNext;
00044
00045 TGTextLine(const TGTextLine&);
00046 TGTextLine& operator=(const TGTextLine&);
00047
00048 public:
00049 TGTextLine();
00050 TGTextLine(TGTextLine *line);
00051 TGTextLine(const char *string);
00052 virtual ~TGTextLine();
00053
00054 void Clear();
00055 ULong_t GetLineLength() { return fLength; }
00056
00057 void DelText(ULong_t pos, ULong_t length);
00058 void InsText(ULong_t pos, const char *text);
00059 char *GetText(ULong_t pos, ULong_t length);
00060 char *GetText() const { return fString; }
00061 char *GetWord(ULong_t pos);
00062
00063 void DelChar(ULong_t pos);
00064 void InsChar(ULong_t pos, char character);
00065 char GetChar(ULong_t pos);
00066
00067 ClassDef(TGTextLine,0)
00068 };
00069
00070
00071 class TGText {
00072
00073 protected:
00074 TString fFilename;
00075 Bool_t fIsSaved;
00076 TGTextLine *fFirst;
00077 TGTextLine *fCurrent;
00078 Long_t fCurrentRow;
00079 Long_t fRowCount;
00080 Long_t fColCount;
00081 Long_t fLongestLine;
00082
00083 TGText(const TGText&);
00084 TGText& operator=(const TGText&);
00085
00086 void Init();
00087 Bool_t SetCurrentRow(Long_t row);
00088 void LongestLine();
00089
00090 public:
00091 TGText();
00092 TGText(TGText *text);
00093 TGText(const char *string);
00094 virtual ~TGText();
00095
00096 void Clear();
00097 Bool_t Load(const char *fn, Long_t startpos = 0, Long_t length = -1);
00098 Bool_t LoadBuffer(const char *txtbuf);
00099 Bool_t Save(const char *fn);
00100 Bool_t Append(const char *fn);
00101 Bool_t IsSaved() const { return fIsSaved; }
00102 const char *GetFileName() const { return fFilename.Data(); }
00103
00104 Bool_t DelChar(TGLongPosition pos);
00105 Bool_t InsChar(TGLongPosition pos, char c);
00106 char GetChar(TGLongPosition pos);
00107
00108 Bool_t DelText(TGLongPosition start, TGLongPosition end);
00109 Bool_t InsText(TGLongPosition pos, const char *buf);
00110 Bool_t InsText(TGLongPosition ins_pos, TGText *src, TGLongPosition start_src, TGLongPosition end_src);
00111 Bool_t AddText(TGText *text);
00112
00113 Bool_t DelLine(ULong_t pos);
00114 char *GetLine(TGLongPosition pos, ULong_t length);
00115 TString AsString();
00116 TGTextLine *GetCurrentLine() const { return fCurrent; }
00117 Bool_t BreakLine(TGLongPosition pos);
00118 Bool_t InsLine(ULong_t row, const char *string);
00119
00120 Long_t RowCount() const { return fRowCount; }
00121 Long_t ColCount() const { return fColCount; }
00122
00123 Long_t GetLineLength(Long_t row);
00124 Long_t GetLongestLine() const { return fLongestLine; }
00125
00126 void ReTab(Long_t row);
00127
00128 Bool_t Search(TGLongPosition *foundPos, TGLongPosition start, const char *searchString,
00129 Bool_t direction, Bool_t caseSensitive);
00130 Bool_t Replace(TGLongPosition start, const char *oldText, const char *newText,
00131 Bool_t direction, Bool_t caseSensitive);
00132
00133 ClassDef(TGText,0)
00134 };
00135
00136 #endif