1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
// Scintilla source code edit control
/** @file KeyWords.cxx
** Colourise for particular languages.
**/
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_, LexerFunction fnFolder_) :
language(language_),
languageName(languageName_),
fnLexer(fnLexer_),
fnFolder(fnFolder_) {
next = base;
base = this;
if (language == SCLEX_AUTOMATIC) {
language = nextLanguage;
nextLanguage++;
}
}
LexerModule *LexerModule::Find(int language) {
LexerModule *lm = base;
while (lm) {
if (lm->language == language) {
return lm;
}
lm = lm->next;
}
return 0;
}
LexerModule *LexerModule::Find(const char *languageName) {
if (languageName) {
LexerModule *lm = base;
while (lm) {
if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
return lm;
}
lm = lm->next;
}
}
return 0;
}
void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) {
if (fnLexer)
fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
}
void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) {
if (fnFolder) {
int lineCurrent = styler.GetLine(startPos);
// Move back one line in case deletion wrecked current line fold state
if (lineCurrent > 0) {
lineCurrent--;
int newStartPos = styler.LineStart(lineCurrent);
lengthDoc += startPos - newStartPos;
startPos = newStartPos;
initStyle = 0;
if (startPos > 0) {
initStyle = styler.StyleAt(startPos - 1);
}
}
fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);
}
}
static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[],
Accessor &styler) {
// Null language means all style bytes are 0 so just mark the end - no need to fill in.
if (length > 0) {
styler.StartAt(startPos + length - 1);
styler.StartSegment(startPos + length - 1);
styler.ColourTo(startPos + length - 1, 0);
}
}
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
#ifdef __vms
#define LINK_LEXERS
#endif
#ifdef LINK_LEXERS
// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// them away. (eric@sourcegear.com)
// Taken from wxWindow's stc.cpp. Walter.
int wxForceScintillaLexers(void) {
Scintilla_LinkLexers();
}
int Scintilla_LinkLexers() {
extern LexerModule lmAda;
extern LexerModule lmAVE;
extern LexerModule lmBaan;
extern LexerModule lmBatch;
extern LexerModule lmConf;
extern LexerModule lmCPP;
extern LexerModule lmDiff;
extern LexerModule lmEiffel;
extern LexerModule lmEiffelkw;
extern LexerModule lmErrorList;
extern LexerModule lmHTML;
extern LexerModule lmLatex;
extern LexerModule lmLISP;
extern LexerModule lmLua;
extern LexerModule lmMake;
extern LexerModule lmPascal;
extern LexerModule lmPerl;
extern LexerModule lmProps;
extern LexerModule lmPython;
extern LexerModule lmRuby;
extern LexerModule lmSQL;
extern LexerModule lmVB;
extern LexerModule lmXML;
extern LexerModule lmBullant;
if (
&lmAda
&& &lmAVE
&& &lmBaan
&& &lmConf
&& &lmDiff
&& &lmLatex
&& &lmPascal
&& &lmCPP
&& &lmHTML
&& &lmXML
&& &lmProps
&& &lmErrorList
&& &lmMake
&& &lmBatch
&& &lmPerl
&& &lmPython
&& &lmSQL
&& &lmVB
&& &lmRuby
&& &lmEiffel
&& &lmEiffelkw
&& &lmLISP
&& &lmLua
&& &lmNull
&& &lmBullant
)
{
return 1;
}
else
{
return 0;
}
}
#endif
|