]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/include/Accessor.h
minor cleanup
[wxWidgets.git] / src / stc / scintilla / include / Accessor.h
1 // Scintilla source code edit control
2 /** @file Accessor.h
3 ** Rapid easy access to contents of a Scintilla.
4 **/
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
7
8 enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
9
10 class Accessor;
11
12 typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
13
14 /**
15 * Interface to data in a Scintilla.
16 */
17 class Accessor {
18 protected:
19 enum {extremePosition=0x7FFFFFFF};
20 /** @a bufferSize is a trade off between time taken to copy the characters
21 * and retrieval overhead.
22 * @a slopSize positions the buffer before the desired position
23 * in case there is some backtracking. */
24 enum {bufferSize=4000, slopSize=bufferSize/8};
25 char buf[bufferSize+1];
26 int startPos;
27 int endPos;
28 int codePage;
29
30 virtual bool InternalIsLeadByte(char ch)=0;
31 virtual void Fill(int position)=0;
32
33 public:
34 Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
35 virtual ~Accessor() {}
36 char operator[](int position) {
37 if (position < startPos || position >= endPos) {
38 Fill(position);
39 }
40 return buf[position - startPos];
41 }
42 /** Safe version of operator[], returning a defined value for invalid position. */
43 char SafeGetCharAt(int position, char chDefault=' ') {
44 if (position < startPos || position >= endPos) {
45 Fill(position);
46 if (position < startPos || position >= endPos) {
47 // Position is outside range of document
48 return chDefault;
49 }
50 }
51 return buf[position - startPos];
52 }
53 bool IsLeadByte(char ch) {
54 return codePage && InternalIsLeadByte(ch);
55 }
56 void SetCodePage(int codePage_) { codePage = codePage_; }
57
58 virtual bool Match(int pos, const char *s)=0;
59 virtual char StyleAt(int position)=0;
60 virtual int GetLine(int position)=0;
61 virtual int LineStart(int line)=0;
62 virtual int LevelAt(int line)=0;
63 virtual int Length()=0;
64 virtual void Flush()=0;
65 virtual int GetLineState(int line)=0;
66 virtual int SetLineState(int line, int state)=0;
67 virtual int GetPropertyInt(const char *key, int defaultValue=0)=0;
68 virtual char *GetProperties()=0;
69
70 // Style setting
71 virtual void StartAt(unsigned int start, char chMask=31)=0;
72 virtual void SetFlags(char chFlags_, char chWhile_)=0;
73 virtual unsigned int GetStartSegment()=0;
74 virtual void StartSegment(unsigned int pos)=0;
75 virtual void ColourTo(unsigned int pos, int chAttr)=0;
76 virtual void SetLevel(int line, int level)=0;
77 virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
78 };