]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/StyleContext.h
4c9352916da7925aa4f3c7f4c968576cbeefdd4c
   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                 if (currentPos 
< endPos
) { 
  62                         atLineStart 
= atLineEnd
; 
  63                         // A lot of this is repeated from the constructor - TODO: merge code 
  69                         chNext 
= static_cast<unsigned char>(styler
.SafeGetCharAt(currentPos
+1)); 
  70                         if (styler
.IsLeadByte(static_cast<char>(chNext
))) { 
  72                                 chNext 
|= static_cast<unsigned char>(styler
.SafeGetCharAt(currentPos 
+ 2)); 
  74                         // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) 
  75                         // Avoid triggering two times on Dos/Win 
  77                         atLineEnd 
= (ch 
== '\r' && chNext 
!= '\n') || (ch 
== '\n') || (currentPos 
>= endPos
); 
  86         void ChangeState(int state_
) { 
  89         void SetState(int state_
) { 
  90                 styler
.ColourTo(currentPos 
- 1, state
); 
  93         void ForwardSetState(int state_
) { 
  95                 styler
.ColourTo(currentPos 
- 1, state
); 
  99                 return currentPos 
- styler
.GetStartSegment(); 
 101         int GetRelative(int n
) { 
 102                 return styler
.SafeGetCharAt(currentPos
+n
); 
 104         bool Match(char ch0
) { 
 107         bool Match(char ch0
, char ch1
) { 
 108                 return (ch 
== ch0
) && (chNext 
== ch1
); 
 110         bool Match(const char *s
) { 
 117                 for (int n
=2; *s
; n
++) { 
 118                         if (*s 
!= styler
.SafeGetCharAt(currentPos
+n
)) 
 124         bool MatchIgnoreCase(const char *s
) { 
 125                 if (tolower(ch
) != *s
) 
 128                 if (tolower(chNext
) != *s
) 
 131                 for (int n
=2; *s
; n
++) { 
 132                         if (*s 
!= tolower((styler
.SafeGetCharAt(currentPos
+n
)))) 
 139         void GetCurrent(char *s
, int len
); 
 140         void GetCurrentLowered(char *s
, int len
); 
 143 inline bool IsASpace(unsigned int ch
) { 
 144     return (ch 
== ' ') || ((ch 
>= 0x09) && (ch 
<= 0x0d)); 
 147 inline bool IsASpaceOrTab(unsigned int ch
) { 
 148         return (ch 
== ' ') || (ch 
== '\t'); 
 151 inline bool IsADigit(unsigned int ch
) { 
 152         return (ch 
>= '0') && (ch 
<= '9');