Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGText.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   26/04/98
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGText
0013 #define ROOT_TGText
0014 
0015 
0016 #include "TString.h"
0017 
0018 #include "TGDimension.h"
0019 
0020 
0021 class TGTextLine {
0022 
0023 friend class TGText;
0024 
0025 protected:
0026    char         *fString;   ///< line of text
0027    ULong_t       fLength;   ///< length of line
0028    TGTextLine   *fPrev;     ///< previous line
0029    TGTextLine   *fNext;     ///< next line
0030 
0031    TGTextLine(const TGTextLine&);
0032    TGTextLine& operator=(const TGTextLine&);
0033 
0034 public:
0035    TGTextLine();
0036    TGTextLine(TGTextLine *line);
0037    TGTextLine(const char *string);
0038    virtual ~TGTextLine();
0039 
0040    void Clear();
0041    ULong_t GetLineLength() { return fLength; }
0042 
0043    void DelText(ULong_t pos, ULong_t length);
0044    void InsText(ULong_t pos, const char *text);
0045    char *GetText(ULong_t pos, ULong_t length);
0046    char *GetText() const { return fString; }
0047    char *GetWord(ULong_t pos);
0048 
0049    void DelChar(ULong_t pos);
0050    void InsChar(ULong_t pos, char character);
0051    char GetChar(ULong_t pos);
0052 
0053    ClassDef(TGTextLine,0)  // Line in TGText
0054 };
0055 
0056 
0057 class TGText {
0058 
0059 protected:
0060    TString      fFilename;       ///< name of opened file ("" if open buffer)
0061    Bool_t       fIsSaved;        ///< false if text needs to be saved
0062    TGTextLine  *fFirst;          ///< first line of text
0063    TGTextLine  *fCurrent;        ///< current line
0064    Long_t       fCurrentRow;     ///< current row number
0065    Long_t       fRowCount;       ///< number of rows
0066    Long_t       fColCount;       ///< number of columns in current line
0067    Long_t       fLongestLine;    ///< length of longest line
0068 
0069    TGText(const TGText&);
0070    TGText& operator=(const TGText&);
0071 
0072    void     Init();
0073    Bool_t   SetCurrentRow(Long_t row);
0074    void     LongestLine();
0075 
0076 public:
0077    TGText();
0078    TGText(TGText *text);
0079    TGText(const char *string);
0080    virtual ~TGText();
0081 
0082    void    Clear();
0083    Bool_t  Load(const char *fn, Long_t startpos = 0, Long_t length = -1);
0084    Bool_t  LoadBuffer(const char *txtbuf);
0085    Bool_t  Save(const char *fn);
0086    Bool_t  Append(const char *fn);
0087    Bool_t  IsSaved() const { return fIsSaved; }
0088    const char *GetFileName() const { return fFilename.Data(); }
0089 
0090    Bool_t  DelChar(TGLongPosition pos);
0091    Bool_t  InsChar(TGLongPosition pos, char c);
0092    char    GetChar(TGLongPosition pos);
0093 
0094    Bool_t  DelText(TGLongPosition start, TGLongPosition end);
0095    Bool_t  InsText(TGLongPosition pos, const char *buf);
0096    Bool_t  InsText(TGLongPosition ins_pos, TGText *src, TGLongPosition start_src, TGLongPosition end_src);
0097    Bool_t  AddText(TGText *text);
0098 
0099    Bool_t  DelLine(ULong_t pos);
0100    char   *GetLine(TGLongPosition pos, ULong_t length);
0101    TString AsString();
0102    TGTextLine *GetCurrentLine() const { return fCurrent; }
0103    Bool_t  BreakLine(TGLongPosition pos);
0104    Bool_t  InsLine(ULong_t row, const char *string);
0105 
0106    Long_t  RowCount() const { return fRowCount; }
0107    Long_t  ColCount() const { return fColCount; }
0108 
0109    Long_t  GetLineLength(Long_t row);
0110    Long_t  GetLongestLine() const { return fLongestLine; }
0111 
0112    void    ReTab(Long_t row);
0113 
0114    Bool_t  Search(TGLongPosition *foundPos, TGLongPosition start, const char *searchString,
0115                   Bool_t direction, Bool_t caseSensitive);
0116    Bool_t  Replace(TGLongPosition start, const char *oldText, const char *newText,
0117                    Bool_t direction, Bool_t caseSensitive);
0118 
0119    ClassDef(TGText,0)  // Text used by TGTextEdit
0120 };
0121 
0122 #endif