1 // SciTE - Scintilla based Text Editor 
   2 // Accessor.h - rapid easy access to contents of a Scintilla 
   3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> 
   4 // The License.txt file describes the conditions under which this software may be distributed. 
   6 enum { wsSpace 
= 1, wsTab 
= 2, wsSpaceTab 
= 4, wsInconsistent
=8}; 
  10 typedef bool (*PFNIsCommentLeader
)(Accessor 
&styler
, int pos
, int len
); 
  12 // Interface to data in a Scintilla 
  15         enum {extremePosition
=0x7FFFFFFF}; 
  16         // bufferSize is a trade off between time taken to copy the characters and retrieval overhead 
  17         // slopSize positions the buffer before the desired position in case there is some backtracking 
  18         enum {bufferSize
=4000, slopSize
=bufferSize
/8}; 
  19         char buf
[bufferSize
+1]; 
  24         virtual bool InternalIsLeadByte(char ch
)=0; 
  25         virtual void Fill(int position
)=0; 
  27         Accessor() : startPos(extremePosition
), endPos(0), codePage(0) {} 
  28         virtual ~Accessor() {} 
  29         char operator[](int position
) { 
  30                 if (position 
< startPos 
|| position 
>= endPos
) { 
  33                 return buf
[position 
- startPos
]; 
  35         char SafeGetCharAt(int position
, char chDefault
=' ') { 
  36                 // Safe version of operator[], returning a defined value for invalid position  
  37                 if (position 
< startPos 
|| position 
>= endPos
) { 
  39                         if (position 
< startPos 
|| position 
>= endPos
) { 
  40                                 // Position is outside range of document  
  44                 return buf
[position 
- startPos
]; 
  46         bool IsLeadByte(char ch
) { 
  47                 return codePage 
&& InternalIsLeadByte(ch
); 
  49         void SetCodePage(int codePage_
) { codePage 
= codePage_
; } 
  51         virtual char StyleAt(int position
)=0; 
  52         virtual int GetLine(int position
)=0; 
  53         virtual int LineStart(int line
)=0; 
  54         virtual int LevelAt(int line
)=0; 
  55         virtual int Length()=0; 
  56         virtual void Flush()=0; 
  57         virtual int GetLineState(int line
)=0; 
  58         virtual int SetLineState(int line
, int state
)=0; 
  59         virtual int GetPropertyInt(const char *key
, int defaultValue
=0)=0; 
  62         virtual void StartAt(unsigned int start
, char chMask
=31)=0; 
  63         virtual void SetFlags(char chFlags_
, char chWhile_
)=0; 
  64         virtual unsigned int GetStartSegment()=0; 
  65         virtual void StartSegment(unsigned int pos
)=0; 
  66         virtual void ColourTo(unsigned int pos
, int chAttr
)=0; 
  67         virtual void SetLevel(int line
, int level
)=0; 
  68         virtual int IndentAmount(int line
, int *flags
, PFNIsCommentLeader pfnIsCommentLeader 
= 0)=0;