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.
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <ctype.h>
11 #include <stdio.h>
12
13 #include "Platform.h"
14
15 #include "PropSet.h"
16 #include "Accessor.h"
17 #include "StyleContext.h"
18
getRange(unsigned int start,unsigned int end,Accessor & styler,char * s,unsigned int len)19 static void getRange(unsigned int start,
20 unsigned int end,
21 Accessor &styler,
22 char *s,
23 unsigned int len) {
24 unsigned int i = 0;
25 while ((i < end - start + 1) && (i < len-1)) {
26 s[i] = styler[start + i];
27 i++;
28 }
29 s[i] = '\0';
30 }
31
GetCurrent(char * s,unsigned int len)32 void StyleContext::GetCurrent(char *s, unsigned int len) {
33 getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
34 }
35
getRangeLowered(unsigned int start,unsigned int end,Accessor & styler,char * s,unsigned int len)36 static void getRangeLowered(unsigned int start,
37 unsigned int end,
38 Accessor &styler,
39 char *s,
40 unsigned int len) {
41 unsigned int i = 0;
42 while ((i < end - start + 1) && (i < len-1)) {
43 s[i] = static_cast<char>(tolower(styler[start + i]));
44 i++;
45 }
46 s[i] = '\0';
47 }
48
GetCurrentLowered(char * s,unsigned int len)49 void StyleContext::GetCurrentLowered(char *s, unsigned int len) {
50 getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
51 }
52