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