]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/Accessor.cxx
57b7e4dc4e3eecd35b8d3e45d0dfb022c12a6800
1 // SciTE - Scintilla based Text Editor
2 // Accessor.cxx - 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.
13 #include "Scintilla.h"
15 void Accessor::Fill(int position
) {
17 lenDoc
= Platform::SendScintilla(id
, WM_GETTEXTLENGTH
, 0, 0);
18 startPos
= position
- slopSize
;
19 if (startPos
+ bufferSize
> lenDoc
)
20 startPos
= lenDoc
- bufferSize
;
23 endPos
= startPos
+ bufferSize
;
27 TEXTRANGE tr
= {{startPos
, endPos
}, buf
};
28 Platform::SendScintilla(id
, EM_GETTEXTRANGE
, 0, reinterpret_cast<LPARAM
>(&tr
));
31 char Accessor::StyleAt(int position
) {
32 return static_cast<char>(Platform::SendScintilla(
33 id
, SCI_GETSTYLEAT
, position
, 0));
36 int Accessor::GetLine(int position
) {
37 return Platform::SendScintilla(id
, EM_LINEFROMCHAR
, position
, 0);
40 int Accessor::LineStart(int line
) {
41 return Platform::SendScintilla(id
, EM_LINEINDEX
, line
, 0);
44 int Accessor::LevelAt(int line
) {
45 return Platform::SendScintilla(id
, SCI_GETFOLDLEVEL
, line
, 0);
48 int Accessor::Length() {
50 lenDoc
= Platform::SendScintilla(id
, WM_GETTEXTLENGTH
, 0, 0);
54 int Accessor::GetLineState(int line
) {
55 return Platform::SendScintilla(id
, SCI_GETLINESTATE
, line
);
58 int Accessor::SetLineState(int line
, int state
) {
59 return Platform::SendScintilla(id
, SCI_SETLINESTATE
, line
, state
);
62 void StylingContext::StartAt(unsigned int start
, char chMask
) {
63 Platform::SendScintilla(id
, SCI_STARTSTYLING
, start
, chMask
);
66 void StylingContext::ColourSegment(unsigned int start
, unsigned int end
, int chAttr
) {
67 // Only perform styling if non empty range
68 if (end
!= start
- 1) {
70 Platform::DebugPrintf("Bad colour positions %d - %d\n", start
, end
);
73 if (validLen
+ (end
- start
+ 1) >= bufferSize
)
75 if (validLen
+ (end
- start
+ 1) >= bufferSize
) {
76 // Too big for buffer so send directly
77 Platform::SendScintilla(id
, SCI_SETSTYLING
, end
- start
+ 1, chAttr
);
79 if (chAttr
!= chWhile
)
82 for (unsigned int i
= start
; i
<= end
; i
++) {
83 styleBuf
[validLen
++] = chAttr
;
89 void StylingContext::StartSegment(unsigned int pos
) {
93 void StylingContext::ColourTo(unsigned int pos
, int chAttr
) {
94 ColourSegment(startSeg
, pos
, chAttr
);
98 int StylingContext::GetLine(int position
) {
99 return Platform::SendScintilla(id
, EM_LINEFROMCHAR
, position
, 0);
102 void StylingContext::SetLevel(int line
, int level
) {
103 Platform::SendScintilla(id
, SCI_SETFOLDLEVEL
, line
, level
);
106 void StylingContext::Flush() {
108 Platform::SendScintilla(id
, SCI_SETSTYLINGEX
, validLen
,
109 reinterpret_cast<LPARAM
>(styleBuf
));