]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/include/Accessor.h
1 // SciTE - Scintilla based Text Editor
2 // Accessor.h - rapid easy access to contents of a Scintilla
3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4 // The License.txt file describes the conditions under which this software may be distributed.
8 // bufferSize is a trade off between time taken to copy the characters and SendMessage overhead
9 // slopSize positions the buffer before the desired position in case there is some backtracking
10 enum {bufferSize
=4000, slopSize
=bufferSize
/8};
11 char buf
[bufferSize
+1];
17 int offset
; // Optional but including an offset makes GCC generate better code
18 void Fill(int position
);
20 Accessor(WindowID id_
, PropSet
&props_
, int offset_
=0) :
21 id(id_
), props(props_
), startPos(0x7FFFFFFF), endPos(0),
22 lenDoc(-1), offset(offset_
) {
24 char operator[](int position
) {
26 if (position
< startPos
|| position
>= endPos
) {
29 return buf
[position
- startPos
];
31 char SafeGetCharAt(int position
, char chDefault
=' ') {
32 // Safe version of operator[], returning a defined value for invalid position
34 if (position
< startPos
|| position
>= endPos
) {
36 if (position
< startPos
|| position
>= endPos
) {
37 // Position is outside range of document
41 return buf
[position
- startPos
];
43 char StyleAt(int position
);
44 int GetLine(int position
);
45 int LineStart(int line
);
46 int LevelAt(int line
);
49 startPos
= 0x7FFFFFFF;
52 int GetLineState(int line
);
53 int SetLineState(int line
, int state
);
54 PropSet
&GetPropSet() { return props
; }
57 class StylingContext
: public Accessor
{
58 char styleBuf
[bufferSize
];
62 unsigned int startSeg
;
64 StylingContext(WindowID id_
, PropSet
&props_
, int offset_
=0) :
65 Accessor(id_
,props_
,offset_
), validLen(0), chFlags(0) {}
66 void StartAt(unsigned int start
, char chMask
=31);
67 void SetFlags(char chFlags_
, char chWhile_
) {chFlags
= chFlags_
; chWhile
= chWhile_
; };
68 void ColourSegment(unsigned int start
, unsigned int end
, int chAttr
);
69 unsigned int GetStartSegment() { return startSeg
; }
70 void StartSegment(unsigned int pos
);
71 void ColourTo(unsigned int pos
, int chAttr
);
72 int GetLine(int position
);
73 void SetLevel(int line
, int level
);