#include "TGText.h"
#include <ctype.h>
const Int_t kMaxLen = 8000;
ClassImp(TGTextLine)
TGTextLine::TGTextLine()
{
fLength = 0;
fString = 0;
fPrev = fNext = 0;
}
TGTextLine::TGTextLine(TGTextLine *line)
{
fLength = line->GetLineLength();
fString = 0;
if (fLength > 0)
fString = line->GetText(0, line->GetLineLength());
fPrev = fNext = 0;
}
TGTextLine::TGTextLine(const char *string)
{
if (string) {
fLength = strlen(string);
fString = new char[fLength+1];
strcpy(fString, string);
} else {
fLength = 0;
fString = 0;
}
fPrev = fNext = 0;
}
TGTextLine::TGTextLine(const TGTextLine& tl) :
fString(tl.fString),
fLength(tl.fLength),
fPrev(tl.fPrev),
fNext(tl.fNext)
{
}
TGTextLine& TGTextLine::operator=(const TGTextLine& tl)
{
if(this!=&tl) {
fString=tl.fString;
fLength=tl.fLength;
fPrev=tl.fPrev;
fNext=tl.fNext;
}
return *this;
}
TGTextLine::~TGTextLine()
{
if (fString)
delete [] fString;
}
void TGTextLine::Clear()
{
if (fString)
delete [] fString;
fString = 0;
fLength = 0;
}
void TGTextLine::DelText(ULong_t pos, ULong_t length)
{
if (fLength == 0 || pos >= fLength)
return;
if (pos+length > fLength)
length = fLength - pos;
if (fLength - length <= 0) {
delete [] fString;
fLength = 0;
fString = 0;
return;
}
char *newstring = new char[fLength - length+1];
strncpy(newstring, fString, (UInt_t)pos);
strncpy(newstring+pos, fString+pos+length, UInt_t(fLength-pos-length));
delete [] fString;
fString = newstring;
fLength = fLength - length;
fString[fLength] = '\0';
}
void TGTextLine::InsText(ULong_t pos, const char *text)
{
if (pos > fLength || !text)
return;
char *newstring = new char[strlen(text)+fLength+1];
if (fString != 0)
strncpy(newstring, fString, (UInt_t)pos);
strcpy(newstring+pos, text);
if (fLength - pos > 0)
strncpy(newstring+pos+strlen(text), fString+pos, UInt_t(fLength-pos));
fLength = fLength + strlen(text);
delete [] fString;
fString = newstring;
fString[fLength] ='\0';
}
char *TGTextLine::GetText(ULong_t pos, ULong_t length)
{
if (pos >= fLength) {
return 0;
}
if (pos + length > (ULong_t)fString) {
length = fLength - pos;
}
char *retstring = new char[length+1];
retstring[length] = '\0';
strncpy(retstring, fString+pos, (UInt_t)length);
return retstring;
}
char *TGTextLine::GetWord(ULong_t pos)
{
if (pos >= fLength) {
return 0;
}
Int_t start = (Int_t)pos;
UInt_t end = (UInt_t)pos;
UInt_t i = (UInt_t)pos;
if (fString[i] == ' ' || fString[i] == '\t') {
while (start >= 0) {
if (fString[start] == ' ' || fString[start] == '\t') --start;
else break;
}
++start;
while (end < fLength) {
if (fString[end] == ' ' || fString[end] == '\t') ++end;
else break;
}
} else if (isalnum(fString[i])) {
while (start >= 0) {
if (isalnum(fString[start])) --start;
else break;
}
++start;
while (end < fLength) {
if (isalnum(fString[end])) ++end;
else break;
}
} else {
while (start >= 0) {
if (isalnum(fString[start]) || fString[start] == ' ' || fString[start] == '\t') {
break;
} else {
--start;
}
}
++start;
while (end < fLength) {
if (isalnum(fString[end]) || fString[end] == ' ' || fString[end] == '\t') {
break;
} else {
++end;
}
}
}
UInt_t length = UInt_t(end - start);
char *retstring = new char[length+1];
retstring[length] = '\0';
strncpy(retstring, fString+start, length);
return retstring;
}
void TGTextLine::DelChar(ULong_t pos)
{
char *newstring;
if ((fLength <= 0) || (pos > fLength))
return;
newstring = new char[fLength];
strncpy(newstring, fString, (UInt_t)pos-1);
if (pos < fLength)
strncpy(newstring+pos-1, fString+pos, UInt_t(fLength-pos+1));
else
newstring[pos-1] = 0;
delete [] fString;
fString = newstring;
fLength--;
}
void TGTextLine::InsChar(ULong_t pos, char character)
{
char *newstring;
if (pos > fLength)
return;
newstring = new char[fLength+2];
newstring[fLength+1] = '\0';
if (fLength > 0)
strncpy (newstring, fString, (UInt_t)pos);
newstring[pos] = character;
if (fLength - pos > 0)
strncpy(newstring+pos+1, fString+pos, UInt_t(fLength-pos));
delete [] fString;
fString = newstring;
fLength++;
}
char TGTextLine::GetChar(ULong_t pos)
{
if ((fLength <= 0) || (pos >= fLength))
return -1;
return fString[pos];
}
ClassImp(TGText)
TGText::TGText(const TGText& gt) :
fFilename(gt.fFilename),
fIsSaved(gt.fIsSaved),
fFirst(gt.fFirst),
fCurrent(gt.fCurrent),
fCurrentRow(gt.fCurrentRow),
fRowCount(gt.fRowCount),
fColCount(gt.fColCount),
fLongestLine(gt.fLongestLine)
{
}
TGText& TGText::operator=(const TGText& gt)
{
if(this!=>) {
fFilename=gt.fFilename;
fIsSaved=gt.fIsSaved;
fFirst=gt.fFirst;
fCurrent=gt.fCurrent;
fCurrentRow=gt.fCurrentRow;
fRowCount=gt.fRowCount;
fColCount=gt.fColCount;
fLongestLine=gt.fLongestLine;
}
return *this;
}
void TGText::Init()
{
fFirst = new TGTextLine;
fCurrent = fFirst;
fCurrentRow = 0;
fColCount = 0;
fRowCount = 1;
fLongestLine = 0;
fIsSaved = kTRUE;
}
TGText::TGText()
{
Init();
}
TGText::TGText(TGText *text)
{
TGLongPosition pos, end;
pos.fX = pos.fY = 0;
end.fY = text->RowCount() - 1;
end.fX = text->GetLineLength(end.fY) - 1;
Init();
InsText(pos, text, pos, end);
}
TGText::TGText(const char *string)
{
TGLongPosition pos;
pos.fX = pos.fY = 0;
Init();
InsText(pos, string);
}
TGText::~TGText()
{
Clear();
delete fFirst;
}
void TGText::Clear()
{
TGTextLine *travel = fFirst->fNext;
TGTextLine *toDelete;
while (travel != 0) {
toDelete = travel;
travel = travel->fNext;
delete toDelete;
}
fFirst->Clear();
fFirst->fNext = 0;
fCurrent = fFirst;
fCurrentRow = 0;
fColCount = 0;
fRowCount = 1;
fLongestLine = 0;
fIsSaved = kTRUE;
fFilename = "";
}
Bool_t TGText::Load(const char *fn, Long_t startpos, Long_t length)
{
Bool_t isFirst = kTRUE;
Bool_t finished = kFALSE;
Long_t count, charcount, i, cnt;
FILE *fp;
char buf[kMaxLen], c, *src, *dst, *buffer, *buf2;
TGTextLine *travel, *temp;
travel = fFirst;
if (!(fp = fopen(fn, "r"))) return kFALSE;
i = 0;
fseek(fp, startpos, SEEK_SET);
charcount = 0;
while (fgets(buf, kMaxLen, fp)) {
if ((length != -1) && (charcount+(Int_t)strlen(buf) > length)) {
count = length - charcount;
finished = kTRUE;
} else
count = kMaxLen;
charcount += strlen(buf);
buf2 = new char[count+1];
buf2[count] = '\0';
src = buf;
dst = buf2;
cnt = 0;
while ((c = *src++)) {
if (c == 0x0D || c == 0x0A)
break;
else if (c == 0x09) {
*dst++ = '\t';
while (((dst-buf2) & 0x7) && (cnt++ < count-1))
*dst++ = 16;
} else
*dst++ = c;
if (cnt++ >= count-1) break;
}
*dst = '\0';
temp = new TGTextLine;
buffer = new char[strlen(buf2)+1];
strcpy(buffer, buf2);
temp->fLength = strlen(buf2);
temp->fString = buffer;
temp->fNext = temp->fPrev = 0;
if (isFirst) {
delete fFirst;
fFirst = temp;
fCurrent = temp;
travel = fFirst;
isFirst = kFALSE;
} else {
travel->fNext = temp;
temp->fPrev = travel;
travel = travel->fNext;
}
++i;
delete [] buf2;
if (finished)
break;
}
fclose(fp);
fRowCount = i;
if (fRowCount == 0)
fRowCount++;
fIsSaved = kTRUE;
fFilename = fn;
LongestLine();
return kTRUE;
}
Bool_t TGText::LoadBuffer(const char *txtbuf)
{
Bool_t isFirst = kTRUE;
Bool_t finished = kFALSE, lastnl = kFALSE;
Long_t i, cnt;
TGTextLine *travel, *temp;
char buf[kMaxLen], c, *src, *dst, *buffer, *buf2, *s;
const char *tbuf = txtbuf;
travel = fFirst;
if (!tbuf || !strlen(tbuf))
return kFALSE;
i = 0;
next:
if ((s = (char*)strchr(tbuf, '\n'))) {
if (s-tbuf+1 >= kMaxLen-1) {
strncpy(buf, tbuf, kMaxLen-2);
buf[kMaxLen-2] = '\n';
buf[kMaxLen-1] = 0;
} else {
strncpy(buf, tbuf, s-tbuf+1);
buf[s-tbuf+1] = 0;
}
tbuf = s+1;
} else {
if ((Int_t)strlen(tbuf) >= kMaxLen) {
strncpy(buf, tbuf, kMaxLen-1);
buf[kMaxLen-1] = 0;
} else
strcpy(buf, tbuf);
finished = kTRUE;
}
buf2 = new char[kMaxLen+1];
buf2[kMaxLen] = '\0';
src = buf;
dst = buf2;
cnt = 0;
while ((c = *src++)) {
if (c == 0x0D || c == 0x0A)
break;
else if (c == 0x09) {
*dst++ = '\t';
while (((dst-buf2) & 0x7) && (cnt++ < kMaxLen-1))
*dst++ = 16;
} else
*dst++ = c;
if (cnt++ >= kMaxLen-1) break;
}
*dst = '\0';
temp = new TGTextLine;
buffer = new char[strlen(buf2)+1];
strcpy(buffer, buf2);
temp->fLength = strlen(buf2);
temp->fString = buffer;
temp->fNext = temp->fPrev = 0;
if (isFirst) {
delete fFirst;
fFirst = temp;
fCurrent = temp;
travel = fFirst;
isFirst = kFALSE;
} else {
travel->fNext = temp;
temp->fPrev = travel;
travel = travel->fNext;
}
++i;
delete [] buf2;
if (!lastnl && !*tbuf && *(tbuf-1) == '\n') {
tbuf--;
lastnl = kTRUE;
}
if (!finished && tbuf && strlen(tbuf))
goto next;
fRowCount = i;
if (fRowCount == 0)
fRowCount++;
fIsSaved = kTRUE;
fFilename = "";
LongestLine();
return kTRUE;
}
Bool_t TGText::Save(const char *fn)
{
char *buffer;
TGTextLine *travel = fFirst;
FILE *fp;
if (!(fp = fopen(fn, "w"))) return kFALSE;
while (travel) {
ULong_t i = 0;
buffer = new char[travel->fLength+2];
strncpy(buffer, travel->fString, (UInt_t)travel->fLength);
buffer[travel->fLength] = '\n';
buffer[travel->fLength+1] = '\0';
while (buffer[i] != '\0') {
if (buffer[i] == '\t') {
ULong_t j = i+1;
while (buffer[j] == 16 && buffer[j] != '\0')
j++;
strcpy(buffer+i+1, buffer+j);
}
i++;
}
if (fputs(buffer, fp) == EOF) {
delete [] buffer;
fclose(fp);
return kFALSE;
}
delete [] buffer;
travel = travel->fNext;
}
fIsSaved = kTRUE;
fFilename = fn;
fclose(fp);
return kTRUE;
}
Bool_t TGText::Append(const char *fn)
{
char *buffer;
TGTextLine *travel = fFirst;
FILE *fp;
if (!(fp = fopen(fn, "a"))) return kFALSE;
while (travel) {
ULong_t i = 0;
buffer = new char[travel->fLength+2];
strncpy(buffer, travel->fString, (UInt_t)travel->fLength);
buffer[travel->fLength] = '\n';
buffer[travel->fLength+1] = '\0';
while (buffer[i] != '\0') {
if (buffer[i] == '\t') {
ULong_t j = i+1;
while (buffer[j] == 16 && buffer[j] != '\0')
j++;
strcpy(buffer+i+1, buffer+j);
}
i++;
}
if (fputs(buffer, fp) == EOF) {
delete [] buffer;
fclose(fp);
return kFALSE;
}
delete [] buffer;
travel = travel->fNext;
}
fIsSaved = kTRUE;
fclose(fp);
return kTRUE;
}
Bool_t TGText::DelChar(TGLongPosition pos)
{
if ((pos.fY >= fRowCount) || (pos.fY < 0))
return kFALSE;
if (!SetCurrentRow(pos.fY)) return kFALSE;
fCurrent->DelChar(pos.fX);
fIsSaved = kFALSE;
LongestLine();
return kTRUE;
}
Bool_t TGText::InsChar(TGLongPosition pos, char c)
{
if ((pos.fY >= fRowCount) || (pos.fY < 0) || (pos.fX < 0))
return kFALSE;
if (!SetCurrentRow(pos.fY)) return kFALSE;
fCurrent->InsChar(pos.fX, c);
fIsSaved = kFALSE;
LongestLine();
return kTRUE;
}
char TGText::GetChar(TGLongPosition pos)
{
if (pos.fY >= fRowCount)
return -1;
if (!SetCurrentRow(pos.fY)) return -1;
return fCurrent->GetChar(pos.fX);
}
Bool_t TGText::DelText(TGLongPosition start, TGLongPosition end)
{
if ((start.fY < 0) || (start.fY >= fRowCount) ||
(end.fY < 0) || (end.fY >= fRowCount)) {
return kFALSE;
}
if ((end.fX < 0) || (end.fX > GetLineLength(end.fY))) {
return kFALSE;
}
char *tempbuffer;
if (!SetCurrentRow(start.fY)) return kFALSE;
if (start.fY == end.fY) {
fCurrent->DelText(start.fX, end.fX-start.fX+1);
return kTRUE;
}
fCurrent->DelText(start.fX, fCurrent->fLength-start.fX);
SetCurrentRow(fCurrentRow+1);
for (Long_t i = start.fY+1; i < end.fY; i++) {
DelLine(fCurrentRow);
}
tempbuffer = fCurrent->GetText(end.fX+1, fCurrent->fLength-end.fX-1);
DelLine(fCurrentRow);
SetCurrentRow(start.fY);
if (tempbuffer) {
fCurrent->InsText(fCurrent->GetLineLength(), tempbuffer);
} else {
if (fCurrent->fNext) {
fCurrent->InsText(fCurrent->fLength, fCurrent->fNext->fString);
DelLine(fCurrentRow+1);
SetCurrentRow(start.fY);
}
}
fIsSaved = kFALSE;
LongestLine();
return kTRUE;
}
Bool_t TGText::InsText(TGLongPosition ins_pos, TGText *src,
TGLongPosition start_src, TGLongPosition end_src)
{
if (ins_pos.fY > fRowCount)
return kFALSE;
TGLongPosition pos;
ULong_t len;
char *lineString;
char *restString;
TGTextLine *following;
if (ins_pos.fY == fRowCount) {
pos.fY = fRowCount - 1;
pos.fX = GetLineLength(pos.fY);
BreakLine(pos);
} else {
if (!SetCurrentRow(ins_pos.fY)) return kFALSE;
}
restString = fCurrent->GetText(ins_pos.fX, fCurrent->fLength - ins_pos.fX);
fCurrent->DelText(ins_pos.fX, fCurrent->fLength - ins_pos.fX);
following = fCurrent->fNext;
if (start_src.fY == end_src.fY) {
len = end_src.fX - start_src.fX+1;
} else {
len = src->GetLineLength(start_src.fY) - start_src.fX;
}
if (len > 0) {
lineString = src->GetLine(start_src, len);
fCurrent->InsText(ins_pos.fX, lineString);
delete [] lineString;
}
pos.fY = start_src.fY+1;
pos.fX = 0;
for ( ; pos.fY < end_src.fY; pos.fY++) {
lineString = src->GetLine(pos, src->GetLineLength(pos.fY));
fCurrent->fNext = new TGTextLine(lineString);
fCurrent->fNext->fPrev = fCurrent;
fCurrent = fCurrent->fNext;
fRowCount++;
fCurrentRow++;
delete [] lineString;
}
if (start_src.fY != end_src.fY) {
pos.fY = end_src.fY;
pos.fX = 0;
lineString = src->GetLine(pos, end_src.fX+1);
fCurrent->fNext = new TGTextLine(lineString);
fCurrent->fNext->fPrev = fCurrent;
fCurrent = fCurrent->fNext;
fRowCount++;
fCurrentRow++;
delete [] lineString;
}
if (restString) {
#if 0
if (ins_pos.fX == 0) {
fCurrent->fNext = new TGTextLine(restString);
fCurrent->fNext->fPrev = fCurrent;
fCurrent = fCurrent->fNext;
fRowCount++;
fCurrentRow++;
} else
#endif
fCurrent->InsText(fCurrent->fLength, restString);
delete [] restString;
}
fCurrent->fNext = following;
if (fCurrent->fNext) {
fCurrent->fNext->fPrev = fCurrent;
}
LongestLine();
fIsSaved = kFALSE;
return kTRUE;
}
Bool_t TGText::InsText(TGLongPosition pos, const char *buffer)
{
if (pos.fY < 0 || pos.fY > fRowCount) {
return kFALSE;
}
if (pos.fY == fRowCount) {
SetCurrentRow(fRowCount-1);
fCurrent->fNext = new TGTextLine(buffer);
fCurrent->fNext->fPrev = fCurrent;
fRowCount++;
} else {
SetCurrentRow(pos.fY);
fCurrent->InsText(pos.fX, buffer);
}
LongestLine();
fIsSaved = kFALSE;
return kTRUE;
}
Bool_t TGText::AddText(TGText *text)
{
TGLongPosition end, start_src, end_src;
end.fY = fRowCount;
end.fX = 0;
start_src.fX = start_src.fY = 0;
end_src.fY = text->RowCount()-1;
end_src.fX = text->GetLineLength(end_src.fY)-1;
fIsSaved = kFALSE;
return InsText(end, text, start_src, end_src);
}
Bool_t TGText::InsLine(ULong_t pos, const char *string)
{
TGTextLine *previous, *newline;
if ((Long_t)pos > fRowCount) {
return kFALSE;
}
if ((Long_t)pos < fRowCount) {
SetCurrentRow(pos);
} else {
SetCurrentRow(fRowCount-1);
}
if (!fCurrent) return kFALSE;
previous = fCurrent->fPrev;
newline = new TGTextLine(string);
newline->fPrev = previous;
if (previous) {
previous->fNext = newline;
} else {
fFirst = newline;
}
newline->fNext = fCurrent;
fCurrent->fPrev = newline;
fRowCount++;
fCurrentRow++;
LongestLine();
fIsSaved = kFALSE;
return kTRUE;
}
Bool_t TGText::DelLine(ULong_t pos)
{
if (!SetCurrentRow(pos) || (fRowCount == 1)) {
return kFALSE;
}
TGTextLine *travel = fCurrent;
if (travel == fFirst) {
fFirst = fFirst->fNext;
fFirst->fPrev = 0;
} else {
travel->fPrev->fNext = travel->fNext;
if (travel->fNext) {
travel->fNext->fPrev = travel->fPrev;
fCurrent = fCurrent->fNext;
} else {
fCurrent = fCurrent->fPrev;
fCurrentRow--;
}
}
delete travel;
fRowCount--;
fIsSaved = kFALSE;
LongestLine();
return kTRUE;
}
char *TGText::GetLine(TGLongPosition pos, ULong_t length)
{
if (SetCurrentRow(pos.fY)) {
return fCurrent->GetText(pos.fX, length);
}
return 0;
}
Bool_t TGText::BreakLine(TGLongPosition pos)
{
if (!SetCurrentRow(pos.fY))
return kFALSE;
if ((pos.fX < 0) || (pos.fX > (Long_t)fCurrent->fLength))
return kFALSE;
TGTextLine *temp;
char *tempbuffer;
if (pos.fX < (Long_t)fCurrent->fLength) {
tempbuffer = fCurrent->GetText(pos.fX, fCurrent->fLength-pos.fX);
temp = new TGTextLine(tempbuffer);
fCurrent->DelText(pos.fX, fCurrent->fLength - pos.fX);
delete [] tempbuffer;
} else {
temp = new TGTextLine;
}
temp->fPrev = fCurrent;
temp->fNext = fCurrent->fNext;
fCurrent->fNext = temp;
if (temp->fNext) {
temp->fNext->fPrev = temp;
}
fIsSaved = kFALSE;
fRowCount++;
fCurrentRow++;
fCurrent = fCurrent->fNext;
LongestLine();
return kTRUE;
}
Long_t TGText::GetLineLength(Long_t row)
{
if (!SetCurrentRow(row)) {
return -1;
}
return (Long_t)fCurrent->GetLineLength();
}
Bool_t TGText::SetCurrentRow(Long_t row)
{
Long_t count;
if ((row < 0) || (row >= fRowCount)) {
return kFALSE;
}
if (row > fCurrentRow) {
for (count = fCurrentRow; count < row; count++) {
if (!fCurrent->fNext) {
fCurrentRow = count;
return kFALSE;
}
fCurrent = fCurrent->fNext;
}
} else {
if (fCurrentRow == row)
return kTRUE;
for (count = fCurrentRow; count > row; count--) {
if (!fCurrent->fPrev) {
fCurrentRow = count;
return kFALSE;
}
fCurrent = fCurrent->fPrev;
}
}
fCurrentRow = row;
return kTRUE;
}
void TGText::ReTab(Long_t row)
{
if (!SetCurrentRow(row)) {
return;
}
char *buffer;
ULong_t i = 0;
buffer = fCurrent->fString;
while (buffer[i] != '\0') {
if (buffer[i] == '\t') {
ULong_t j = i+1;
while (buffer[j] == 16 && buffer[j] != '\0') {
j++;
}
strcpy(buffer+i+1, buffer+j);
}
i++;
}
char c, *src, *dst, *buf2;
Long_t cnt;
buf2 = new char[kMaxLen+1];
buf2[kMaxLen] = '\0';
src = buffer;
dst = buf2;
cnt = 0;
while ((c = *src++)) {
if (c == 0x09) {
*dst++ = '\t';
while (((dst-buf2) & 0x7) && (cnt++ < kMaxLen-1)) {
*dst++ = 16;
}
} else {
*dst++ = c;
}
if (cnt++ >= kMaxLen-1) break;
}
*dst = '\0';
fCurrent->fString = buf2;
fCurrent->fLength = strlen(buf2);
delete [] buffer;
}
Bool_t TGText::Search(TGLongPosition *foundPos, TGLongPosition start,
const char *searchString,
Bool_t direction, Bool_t caseSensitive)
{
if (!SetCurrentRow(start.fY))
return kFALSE;
Ssiz_t x = kNPOS;
if (direction) {
while(1) {
TString s = fCurrent->fString;
x = s.Index(searchString, (Ssiz_t)start.fX,
caseSensitive ? TString::kExact : TString::kIgnoreCase);
if (x != kNPOS) {
foundPos->fX = x;
foundPos->fY = fCurrentRow;
return kTRUE;
}
if (!SetCurrentRow(fCurrentRow+1))
break;
start.fX = 0;
}
} else {
while(1) {
TString s = fCurrent->fString;
for (int i = (int)start.fX; i >= 0; i--) {
x = s.Index(searchString, (Ssiz_t)i,
caseSensitive ? TString::kExact : TString::kIgnoreCase);
if (x >= start.fX) {
x = kNPOS;
continue;
}
if (x != kNPOS) {
break;
}
}
if (x != kNPOS) {
foundPos->fX = x;
foundPos->fY = fCurrentRow;
return kTRUE;
}
if (!SetCurrentRow(fCurrentRow-1)) {
break;
}
start.fX = fCurrent->fLength;
}
}
return kFALSE;
}
Bool_t TGText::Replace(TGLongPosition start, const char *oldText, const char *newText,
Bool_t direction, Bool_t caseSensitive)
{
if (!SetCurrentRow(start.fY)) {
return kFALSE;
}
TGLongPosition foundPos;
if (!Search(&foundPos, start, oldText, direction, caseSensitive)) {
return kFALSE;
}
TGLongPosition delEnd;
delEnd.fY = foundPos.fY;
delEnd.fX = foundPos.fX + strlen(oldText) - 1;
DelText(foundPos, delEnd);
InsText(foundPos, newText);
return kTRUE;
}
void TGText::LongestLine()
{
Long_t line_count = 0;
TGTextLine *travel = fFirst;
fColCount = 0;
while (travel) {
if ((Long_t)travel->fLength > fColCount) {
fColCount = travel->fLength;
fLongestLine = line_count;
}
travel = travel->fNext;
line_count++;
}
}
TString TGText::AsString()
{
TString ret;
Long_t line_count = 0;
TGTextLine *travel = fFirst;
fColCount = 0;
while (travel) {
if ((Long_t)travel->fLength > fColCount) {
fColCount = travel->fLength;
fLongestLine = line_count;
}
ret += travel->GetText();
travel = travel->fNext;
if (travel) ret += '\n';
line_count++;
}
return ret;
}
Last change: Wed Jun 25 08:43:16 2008
Last generated: 2008-06-25 08:43
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.