]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/lexlib/StyleContext.cxx
simplify code so it always returns the same object
[wxWidgets.git] / src / stc / scintilla / lexlib / StyleContext.cxx
CommitLineData
b8b0e402
RD
1// Scintilla source code edit control
2/** @file StyleContext.cxx
3 ** Lexer infrastructure.
4 **/
591d01be 5// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
b8b0e402
RD
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>
1dcf666d 12#include <assert.h>
b8b0e402 13
1dcf666d 14#include "ILexer.h"
b8b0e402 15
1dcf666d 16#include "LexAccessor.h"
b8b0e402
RD
17#include "Accessor.h"
18#include "StyleContext.h"
19
7e0c58e9
RD
20#ifdef SCI_NAMESPACE
21using namespace Scintilla;
22#endif
23
b8b0e402
RD
24static void getRange(unsigned int start,
25 unsigned int end,
1dcf666d 26 LexAccessor &styler,
b8b0e402
RD
27 char *s,
28 unsigned int len) {
29 unsigned int i = 0;
30 while ((i < end - start + 1) && (i < len-1)) {
31 s[i] = styler[start + i];
32 i++;
33 }
34 s[i] = '\0';
35}
36
9e730a78 37void StyleContext::GetCurrent(char *s, unsigned int len) {
b8b0e402
RD
38 getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
39}
40
41static void getRangeLowered(unsigned int start,
42 unsigned int end,
1dcf666d 43 LexAccessor &styler,
b8b0e402
RD
44 char *s,
45 unsigned int len) {
46 unsigned int i = 0;
47 while ((i < end - start + 1) && (i < len-1)) {
48 s[i] = static_cast<char>(tolower(styler[start + i]));
49 i++;
50 }
51 s[i] = '\0';
52}
53
9e730a78 54void StyleContext::GetCurrentLowered(char *s, unsigned int len) {
b8b0e402
RD
55 getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
56}