]>
Commit | Line | Data |
---|---|---|
65ec6247 RD |
1 | // Scintilla source code edit control |
2 | /** @file DocumentAccessor.h | |
3 | ** Implementation of BufferAccess and StylingAccess on a Scintilla | |
4 | ** rapid easy access to contents of a Scintilla. | |
5 | **/ | |
6 | // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> | |
f6bcfd97 BP |
7 | // The License.txt file describes the conditions under which this software may be distributed. |
8 | ||
9 | class Document; | |
10 | ||
65ec6247 RD |
11 | /** |
12 | */ | |
f6bcfd97 BP |
13 | class DocumentAccessor : public Accessor { |
14 | // Private so DocumentAccessor objects can not be copied | |
15 | DocumentAccessor(const DocumentAccessor &source) : Accessor(), props(source.props) {} | |
16 | DocumentAccessor &operator=(const DocumentAccessor &) { return *this; } | |
65ec6247 | 17 | |
f6bcfd97 BP |
18 | protected: |
19 | Document *pdoc; | |
20 | PropSet &props; | |
65ec6247 | 21 | WindowID id; |
f6bcfd97 BP |
22 | int lenDoc; |
23 | ||
24 | char styleBuf[bufferSize]; | |
25 | int validLen; | |
26 | char chFlags; | |
27 | char chWhile; | |
28 | unsigned int startSeg; | |
1a2fb4cd | 29 | int startPosStyling; |
1e9bafca | 30 | int mask; |
f6bcfd97 BP |
31 | |
32 | bool InternalIsLeadByte(char ch); | |
33 | void Fill(int position); | |
65ec6247 | 34 | |
f6bcfd97 | 35 | public: |
88a8b04e | 36 | DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) : |
65ec6247 | 37 | Accessor(), pdoc(pdoc_), props(props_), id(id_), |
88a8b04e | 38 | lenDoc(-1), validLen(0), chFlags(0), chWhile(0), |
1e9bafca RD |
39 | startSeg(0), startPosStyling(0), |
40 | mask(127) { // Initialize the mask to be big enough for any lexer. | |
f6bcfd97 BP |
41 | } |
42 | ~DocumentAccessor(); | |
a834585d | 43 | bool Match(int pos, const char *s); |
f6bcfd97 BP |
44 | char StyleAt(int position); |
45 | int GetLine(int position); | |
46 | int LineStart(int line); | |
47 | int LevelAt(int line); | |
48 | int Length(); | |
49 | void Flush(); | |
50 | int GetLineState(int line); | |
51 | int SetLineState(int line, int state); | |
88a8b04e RD |
52 | int GetPropertyInt(const char *key, int defaultValue=0) { |
53 | return props.GetInt(key, defaultValue); | |
f6bcfd97 | 54 | } |
65ec6247 RD |
55 | char *GetProperties() { |
56 | return props.ToString(); | |
57 | } | |
58 | WindowID GetWindow() { return id; } | |
f6bcfd97 BP |
59 | |
60 | void StartAt(unsigned int start, char chMask=31); | |
61 | void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; | |
62 | unsigned int GetStartSegment() { return startSeg; } | |
63 | void StartSegment(unsigned int pos); | |
64 | void ColourTo(unsigned int pos, int chAttr); | |
65 | void SetLevel(int line, int level); | |
66 | int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); | |
67 | }; |