85 fPrev(tl.fPrev), fNext(tl.fNext)
148 char *newstring =
new char[
fLength - length+1];
165 char *newstring =
new char[strlen(
text)+
fLength+1];
169 strcpy(newstring+pos,
text);
193 char *retstring =
new char[length+1];
194 retstring[length] =
'\0';
223 }
else if (isalnum(
fString[i])) {
225 if (isalnum(
fString[start])) --start;
230 if (isalnum(
fString[end])) ++end;
252 char *retstring =
new char[length+1];
253 retstring[length] =
'\0';
254 strncpy(retstring,
fString+start, length);
272 newstring[pos-1] = 0;
286 newstring =
new char[
fLength+2];
290 newstring[pos] = character;
316 fFilename(gt.fFilename),
317 fIsSaved(gt.fIsSaved),
319 fCurrent(gt.fCurrent),
320 fCurrentRow(gt.fCurrentRow),
321 fRowCount(gt.fRowCount),
322 fColCount(gt.fColCount),
323 fLongestLine(gt.fLongestLine)
375 end.
fY =
text->RowCount() - 1;
376 end.
fX =
text->GetLineLength(end.
fY) - 1;
409 while (travel != 0) {
411 travel = travel->
fNext;
436 char *buf,
c, *src, *dst, *buffer, *buf2;
441 if (!(fp = fopen(fn,
"r")))
return kFALSE;
444 fseek(fp, startpos, SEEK_SET);
446 while (fgets(buf,
kMaxLen, fp)) {
447 if ((length != -1) && (charcount+(
Int_t)strlen(buf) > length)) {
448 count = length - charcount;
452 charcount += strlen(buf);
453 buf2 =
new char[count+1];
458 while ((
c = *src++)) {
460 if (
c == 0x0D ||
c == 0x0A)
463 else if (
c == 0x09) {
465 while (((dst-buf2) & 0x7) && (
cnt++ < count-1))
469 if (
cnt++ >= count-1)
break;
473 const size_t bufferSize = strlen(buf2)+1;
474 buffer =
new char[bufferSize];
475 strlcpy(buffer, buf2, bufferSize);
486 travel->
fNext = temp;
487 temp->
fPrev = travel;
488 travel = travel->
fNext;
518 char *buf,
c, *src, *dst, *buffer, *buf2, *
s;
519 const char *tbuf = txtbuf;
523 if (!tbuf || !tbuf[0])
529 if ((
s = (
char*)strchr(tbuf,
'\n'))) {
535 strncpy(buf, tbuf,
s-tbuf+1);
550 while ((
c = *src++)) {
552 if (
c == 0x0D ||
c == 0x0A)
555 else if (
c == 0x09) {
557 while (((dst-buf2) & 0x7) && (
cnt++ <
kMaxLen-1))
565 const size_t bufferSize = strlen(buf2) + 1;
566 buffer =
new char[bufferSize];
567 strlcpy(buffer, buf2, bufferSize);
578 travel->
fNext = temp;
579 temp->
fPrev = travel;
580 travel = travel->
fNext;
586 if (!lastnl && !*tbuf && *(tbuf-1) ==
'\n') {
591 if (!finished && strlen(tbuf))
614 if (!(fp = fopen(fn,
"w")))
return kFALSE;
618 buffer =
new char[travel->
fLength+2];
620 buffer[travel->
fLength] =
'\n';
621 buffer[travel->
fLength+1] =
'\0';
622 while (buffer[i] !=
'\0') {
623 if (buffer[i] ==
'\t') {
625 while (buffer[j] == 16)
628 strcpy(buffer+i+1, buffer+j);
632 if (fputs(buffer, fp) == EOF) {
638 travel = travel->
fNext;
655 if (!(fp = fopen(fn,
"a")))
return kFALSE;
659 buffer =
new char[travel->
fLength+2];
661 buffer[travel->
fLength] =
'\n';
662 buffer[travel->
fLength+1] =
'\0';
663 while (buffer[i] !=
'\0') {
664 if (buffer[i] ==
'\t') {
666 while (buffer[j] == 16 && buffer[j] !=
'\0')
669 strcpy(buffer+i+1, buffer+j);
673 if (fputs(buffer, fp) == EOF) {
679 travel = travel->
fNext;
750 if (start.
fY == end.
fY) {
756 for (
Long_t i = start.
fY+1; i < end.
fY; i++) {
765 delete [] tempbuffer;
822 if (start_src.
fY == end_src.
fY) {
823 len = end_src.
fX - start_src.
fX+1;
829 lineString = src->
GetLine(start_src, len);
831 delete [] lineString;
834 pos.
fY = start_src.
fY+1;
836 for ( ; pos.
fY < end_src.
fY; pos.
fY++) {
838 lineString = src->
GetLine(pos, llen > 0 ? llen : 0);
844 delete [] lineString;
847 if (start_src.
fY != end_src.
fY) {
850 lineString = src->
GetLine(pos, end_src.
fX+1);
856 delete [] lineString;
861 if (ins_pos.
fX == 0) {
870 delete [] restString;
916 start_src.
fX = start_src.
fY = 0;
917 end_src.
fY =
text->RowCount()-1;
918 end_src.
fX =
text->GetLineLength(end_src.
fY)-1;
943 newline->
fPrev = previous;
945 previous->
fNext = newline;
1020 delete [] tempbuffer;
1097 while (buffer[i] !=
'\0') {
1098 if (buffer[i] ==
'\t') {
1100 while (buffer[j] == 16 && buffer[j] !=
'\0') {
1104 strcpy(buffer+i+1, buffer+j);
1109 char c, *src, *dst, *buf2;
1117 while ((
c = *src++)) {
1121 while (((dst-buf2) & 0x7) && (
cnt++ <
kMaxLen-1)) {
1143 const char *searchString,
1168 for (
int i = (
int)start.
fX; i >= 0; i--) {
1169 x =
s.Index(searchString, (
Ssiz_t)i,
1171 if (
x >= start.
fX) {
1204 if (!
Search(&foundPos, start, oldText, direction, caseSensitive)) {
1209 delEnd.
fY = foundPos.
fY;
1210 delEnd.
fX = foundPos.
fX + strlen(oldText) - 1;
1229 travel = travel->
fNext;
1250 char *txt = travel->
GetText();
1253 travel = travel->
fNext;
1254 if (travel) ret +=
'\n';
virtual ~TGTextLine()
Delete a line of text.
void DelChar(ULong_t pos)
Delete a character from the line.
void InsChar(ULong_t pos, char character)
Insert a character at the specified position.
char GetChar(ULong_t pos)
Get a character at the specified position from the line.
char * GetWord(ULong_t pos)
Get word at position. Returned string must be deleted.
void InsText(ULong_t pos, const char *text)
Insert text in line starting at position pos.
void Clear()
Clear a line of text.
TGTextLine()
Create empty line of text (default ctor).
void DelText(ULong_t pos, ULong_t length)
Delete length chars from line starting at position pos.
char * GetText(ULong_t pos, ULong_t length)
Get length characters from line starting at pos.
TGTextLine & operator=(const TGTextLine &)
assignment operator
Bool_t InsChar(TGLongPosition pos, char c)
Insert character c at the specified position pos.
void ReTab(Long_t row)
Redo all tabs in a line. Needed after a new tab is inserted.
virtual ~TGText()
Destroy text buffer.
Bool_t AddText(TGText *text)
Add another text buffer to this buffer.
Bool_t DelText(TGLongPosition start, TGLongPosition end)
Delete text between start and end positions.
TGText()
Create default (empty) text buffer.
void LongestLine()
Set fLongestLine.
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)...
Bool_t DelLine(ULong_t pos)
Delete specified row. Returns false if row does not exist.
Bool_t Save(const char *fn)
Save text buffer to file fn.
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.
Bool_t InsLine(ULong_t row, const char *string)
Insert string before specified position.
Bool_t SetCurrentRow(Long_t row)
Make specified row the current row.
Bool_t DelChar(TGLongPosition pos)
Delete character at specified position pos.
Bool_t BreakLine(TGLongPosition pos)
Break line at position pos. Returns false if pos is not valid.
Bool_t InsText(TGLongPosition pos, const char *buf)
Insert single line at specified position.
char * GetLine(TGLongPosition pos, ULong_t length)
Return string at position pos.
char GetChar(TGLongPosition pos)
Get character a position pos. If charcater not valid return -1.
Bool_t Load(const char *fn, Long_t startpos=0, Long_t length=-1)
Load text from file fn.
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
void Clear()
Clear text buffer.
Bool_t Append(const char *fn)
Append buffer to file fn.
Long_t GetLineLength(Long_t row)
Get length of specified line. Returns -1 if row does not exist.
void Init()
Common initialization method.
TString AsString()
Returns content as ROOT string.
TGText & operator=(const TGText &)
assignment operator
static constexpr double s