]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/stc/scintilla/include/Accessor.h
Updated to version 1.40 of Scintilla
[wxWidgets.git] / contrib / src / stc / scintilla / include / Accessor.h
CommitLineData
65ec6247
RD
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>
9ce192d4
RD
6// The License.txt file describes the conditions under which this software may be distributed.
7
f6bcfd97
BP
8enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
9
10class Accessor;
11
12typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
13
65ec6247
RD
14/**
15 * Interface to data in a Scintilla.
16 */
9ce192d4
RD
17class Accessor {
18protected:
f6bcfd97 19 enum {extremePosition=0x7FFFFFFF};
65ec6247
RD
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. */
9ce192d4
RD
24 enum {bufferSize=4000, slopSize=bufferSize/8};
25 char buf[bufferSize+1];
9ce192d4
RD
26 int startPos;
27 int endPos;
f6bcfd97
BP
28 int codePage;
29
30 virtual bool InternalIsLeadByte(char ch)=0;
31 virtual void Fill(int position)=0;
65ec6247 32
9ce192d4 33public:
f6bcfd97
BP
34 Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
35 virtual ~Accessor() {}
9ce192d4 36 char operator[](int position) {
9ce192d4
RD
37 if (position < startPos || position >= endPos) {
38 Fill(position);
39 }
40 return buf[position - startPos];
41 }
65ec6247 42 /** Safe version of operator[], returning a defined value for invalid position. */
9ce192d4 43 char SafeGetCharAt(int position, char chDefault=' ') {
9ce192d4
RD
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 }
f6bcfd97
BP
53 bool IsLeadByte(char ch) {
54 return codePage && InternalIsLeadByte(ch);
9ce192d4 55 }
f6bcfd97 56 void SetCodePage(int codePage_) { codePage = codePage_; }
9ce192d4 57
f6bcfd97
BP
58 virtual char StyleAt(int position)=0;
59 virtual int GetLine(int position)=0;
60 virtual int LineStart(int line)=0;
61 virtual int LevelAt(int line)=0;
62 virtual int Length()=0;
63 virtual void Flush()=0;
64 virtual int GetLineState(int line)=0;
65 virtual int SetLineState(int line, int state)=0;
66 virtual int GetPropertyInt(const char *key, int defaultValue=0)=0;
65ec6247 67 virtual char *GetProperties()=0;
f6bcfd97
BP
68
69 // Style setting
70 virtual void StartAt(unsigned int start, char chMask=31)=0;
71 virtual void SetFlags(char chFlags_, char chWhile_)=0;
72 virtual unsigned int GetStartSegment()=0;
73 virtual void StartSegment(unsigned int pos)=0;
74 virtual void ColourTo(unsigned int pos, int chAttr)=0;
75 virtual void SetLevel(int line, int level)=0;
76 virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
9ce192d4 77};