Merge pull request #2212 from TwlyY29/bibtex-parser
[geany-mirror.git] / scintilla / lexlib / StyleContext.cxx
blobfe56e53d7b22aa184eb83164c850bc94764268d7
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>
11 #include "ILexer.h"
13 #include "LexAccessor.h"
14 #include "Accessor.h"
15 #include "StyleContext.h"
16 #include "CharacterSet.h"
18 using namespace Scintilla;
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++;
33 return true;
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++;
46 s[i] = '\0';
49 void StyleContext::GetCurrent(char *s, Sci_PositionU len) {
50 getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
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++;
63 s[i] = '\0';
66 void StyleContext::GetCurrentLowered(char *s, Sci_PositionU len) {
67 getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);