]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/StyleContext.h
5bc6371fd32f512d052360593fdfaff4de49f357
1 // Scintilla source code edit control
2 /** @file StyleContext.cxx
3 ** Lexer infrastructure.
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // This file is in the public domain.
8 // All languages handled so far can treat all characters >= 0x80 as one class
9 // which just continues the current token or starts an identifier if in default.
10 // DBCS treated specially as the second character can be < 0x80 and hence
11 // syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
15 StyleContext
& operator=(const StyleContext
&) {
27 StyleContext(unsigned int startPos
, int length
,
28 int initStyle
, Accessor
&styler_
, char chMask
=31) :
30 endPos(startPos
+ length
),
38 styler
.StartAt(startPos
, chMask
);
39 styler
.StartSegment(startPos
);
41 ch
= static_cast<unsigned char>(styler
.SafeGetCharAt(pos
));
42 if (styler
.IsLeadByte(static_cast<char>(ch
))) {
45 ch
|= static_cast<unsigned char>(styler
.SafeGetCharAt(pos
));
47 chNext
= static_cast<unsigned char>(styler
.SafeGetCharAt(pos
+1));
48 if (styler
.IsLeadByte(static_cast<char>(chNext
))) {
50 chNext
|= static_cast<unsigned char>(styler
.SafeGetCharAt(pos
+2));
52 atLineEnd
= (ch
== '\r' && chNext
!= '\n') || (ch
== '\n') || (currentPos
>= endPos
);
55 styler
.ColourTo(currentPos
- 1, state
);
58 return currentPos
<= endPos
;
61 atLineStart
= atLineEnd
;
62 // A lot of this is repeated from the constructor - TODO: merge code
68 chNext
= static_cast<unsigned char>(styler
.SafeGetCharAt(currentPos
+1));
69 if (styler
.IsLeadByte(static_cast<char>(chNext
))) {
71 chNext
|= static_cast<unsigned char>(styler
.SafeGetCharAt(currentPos
+ 2));
73 // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
74 // Avoid triggering two times on Dos/Win
76 atLineEnd
= (ch
== '\r' && chNext
!= '\n') || (ch
== '\n') || (currentPos
>= endPos
);
78 void ChangeState(int state_
) {
81 void SetState(int state_
) {
82 styler
.ColourTo(currentPos
- 1, state
);
85 void ForwardSetState(int state_
) {
87 styler
.ColourTo(currentPos
- 1, state
);
91 return currentPos
- styler
.GetStartSegment();
93 int GetRelative(int n
) {
94 return styler
.SafeGetCharAt(currentPos
+n
);
96 bool Match(char ch0
) {
99 bool Match(char ch0
, char ch1
) {
100 return (ch
== ch0
) && (chNext
== ch1
);
102 bool Match(const char *s
) {
109 for (int n
=2; *s
; n
++) {
110 if (*s
!= styler
.SafeGetCharAt(currentPos
+n
))
117 void GetCurrent(char *s
, int len
);
118 void GetCurrentLowered(char *s
, int len
);
121 inline bool IsASpace(unsigned int ch
) {
122 return (ch
== ' ') || ((ch
>= 0x09) && (ch
<= 0x0d));
125 inline bool IsADigit(unsigned int ch
) {
126 return (ch
>= '0') && (ch
<= '9');