]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/include/Accessor.h
no changes
[wxWidgets.git] / src / stc / scintilla / include / Accessor.h
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.
5
6 enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
7
8 class Accessor;
9
10 typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
11
12 // Interface to data in a Scintilla
13 class Accessor {
14 protected:
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];
20 int startPos;
21 int endPos;
22 int codePage;
23
24 virtual bool InternalIsLeadByte(char ch)=0;
25 virtual void Fill(int position)=0;
26 public:
27 Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
28 virtual ~Accessor() {}
29 char operator[](int position) {
30 if (position < startPos || position >= endPos) {
31 Fill(position);
32 }
33 return buf[position - startPos];
34 }
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) {
38 Fill(position);
39 if (position < startPos || position >= endPos) {
40 // Position is outside range of document
41 return chDefault;
42 }
43 }
44 return buf[position - startPos];
45 }
46 bool IsLeadByte(char ch) {
47 return codePage && InternalIsLeadByte(ch);
48 }
49 void SetCodePage(int codePage_) { codePage = codePage_; }
50
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;
60
61 // Style setting
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;
69 };
70