]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/include/Accessor.h
Added classinfo macros for wxTreeEvent
[wxWidgets.git] / src / stc / scintilla / include / Accessor.h
CommitLineData
9ce192d4
RD
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
f6bcfd97
BP
6enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
7
8class Accessor;
9
10typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
11
12// Interface to data in a Scintilla
9ce192d4
RD
13class Accessor {
14protected:
f6bcfd97
BP
15 enum {extremePosition=0x7FFFFFFF};
16 // bufferSize is a trade off between time taken to copy the characters and retrieval overhead
9ce192d4
RD
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];
9ce192d4
RD
20 int startPos;
21 int endPos;
f6bcfd97
BP
22 int codePage;
23
24 virtual bool InternalIsLeadByte(char ch)=0;
25 virtual void Fill(int position)=0;
9ce192d4 26public:
f6bcfd97
BP
27 Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
28 virtual ~Accessor() {}
9ce192d4 29 char operator[](int position) {
9ce192d4
RD
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
9ce192d4
RD
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 }
f6bcfd97
BP
46 bool IsLeadByte(char ch) {
47 return codePage && InternalIsLeadByte(ch);
9ce192d4 48 }
f6bcfd97 49 void SetCodePage(int codePage_) { codePage = codePage_; }
9ce192d4 50
f6bcfd97
BP
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;
9ce192d4
RD
69};
70