]>
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 | ||
7e0c58e9 RD |
9 | #ifdef SCI_NAMESPACE |
10 | namespace Scintilla { | |
11 | #endif | |
12 | ||
f6bcfd97 BP |
13 | class Document; |
14 | ||
65ec6247 RD |
15 | /** |
16 | */ | |
f6bcfd97 BP |
17 | class DocumentAccessor : public Accessor { |
18 | // Private so DocumentAccessor objects can not be copied | |
19 | DocumentAccessor(const DocumentAccessor &source) : Accessor(), props(source.props) {} | |
20 | DocumentAccessor &operator=(const DocumentAccessor &) { return *this; } | |
65ec6247 | 21 | |
f6bcfd97 BP |
22 | protected: |
23 | Document *pdoc; | |
24 | PropSet &props; | |
65ec6247 | 25 | WindowID id; |
f6bcfd97 BP |
26 | int lenDoc; |
27 | ||
28 | char styleBuf[bufferSize]; | |
29 | int validLen; | |
30 | char chFlags; | |
31 | char chWhile; | |
32 | unsigned int startSeg; | |
1a2fb4cd | 33 | int startPosStyling; |
1e9bafca | 34 | int mask; |
f6bcfd97 BP |
35 | |
36 | bool InternalIsLeadByte(char ch); | |
37 | void Fill(int position); | |
65ec6247 | 38 | |
f6bcfd97 | 39 | public: |
88a8b04e | 40 | DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) : |
65ec6247 | 41 | Accessor(), pdoc(pdoc_), props(props_), id(id_), |
88a8b04e | 42 | lenDoc(-1), validLen(0), chFlags(0), chWhile(0), |
1e9bafca RD |
43 | startSeg(0), startPosStyling(0), |
44 | mask(127) { // Initialize the mask to be big enough for any lexer. | |
f6bcfd97 BP |
45 | } |
46 | ~DocumentAccessor(); | |
a834585d | 47 | bool Match(int pos, const char *s); |
f6bcfd97 BP |
48 | char StyleAt(int position); |
49 | int GetLine(int position); | |
50 | int LineStart(int line); | |
51 | int LevelAt(int line); | |
52 | int Length(); | |
53 | void Flush(); | |
54 | int GetLineState(int line); | |
55 | int SetLineState(int line, int state); | |
88a8b04e RD |
56 | int GetPropertyInt(const char *key, int defaultValue=0) { |
57 | return props.GetInt(key, defaultValue); | |
f6bcfd97 | 58 | } |
65ec6247 RD |
59 | char *GetProperties() { |
60 | return props.ToString(); | |
61 | } | |
62 | WindowID GetWindow() { return id; } | |
f6bcfd97 BP |
63 | |
64 | void StartAt(unsigned int start, char chMask=31); | |
7e0c58e9 | 65 | void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; |
f6bcfd97 BP |
66 | unsigned int GetStartSegment() { return startSeg; } |
67 | void StartSegment(unsigned int pos); | |
68 | void ColourTo(unsigned int pos, int chAttr); | |
69 | void SetLevel(int line, int level); | |
70 | int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); | |
7e0c58e9 | 71 | void IndicatorFill(int start, int end, int indicator, int value); |
f6bcfd97 | 72 | }; |
7e0c58e9 RD |
73 | |
74 | #ifdef SCI_NAMESPACE | |
75 | } | |
76 | #endif |