OSDN Git Service

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