1 // Scintilla source code edit control 2 /** @file StyleContext.cxx 3 ** Lexer infrastructure. 4 **/ 5 // Copyright 1998-2004 by Neil Hodgson <[email protected]> 6 // This file is in the public domain. 7 8 #include <cstdlib> 9 #include <cassert> 10 11 #include "ILexer.h" 12 13 #include "LexAccessor.h" 14 #include "Accessor.h" 15 #include "StyleContext.h" 16 #include "CharacterSet.h" 17 18 using namespace Scintilla; 19 20 bool StyleContext::MatchIgnoreCase(const char *s) { 21 if (MakeLowerCase(ch) != static_cast<unsigned char>(*s)) 22 return false; 23 s++; 24 if (MakeLowerCase(chNext) != static_cast<unsigned char>(*s)) 25 return false; 26 s++; 27 for (int n = 2; *s; n++) { 28 if (*s != 29 MakeLowerCase(styler.SafeGetCharAt(currentPos + n, 0))) 30 return false; 31 s++; 32 } 33 return true; 34 } 35 36 static void getRange(Sci_PositionU start, 37 Sci_PositionU end, 38 LexAccessor &styler, 39 char *s, 40 Sci_PositionU len) { 41 Sci_PositionU i = 0; 42 while ((i < end - start + 1) && (i < len-1)) { 43 s[i] = styler[start + i]; 44 i++; 45 } 46 s[i] = '\0'; 47 } 48 49 void StyleContext::GetCurrent(char *s, Sci_PositionU len) { 50 getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len); 51 } 52 53 static void getRangeLowered(Sci_PositionU start, 54 Sci_PositionU end, 55 LexAccessor &styler, 56 char *s, 57 Sci_PositionU len) { 58 Sci_PositionU i = 0; 59 while ((i < end - start + 1) && (i < len-1)) { 60 s[i] = MakeLowerCase(styler[start + i]); 61 i++; 62 } 63 s[i] = '\0'; 64 } 65 66 void StyleContext::GetCurrentLowered(char *s, Sci_PositionU len) { 67 getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len); 68 } 69