]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/KeyWords.cxx
8a03aa8ac4fbb42e7eb46b1793bfabccb2912682
1 // Scintilla source code edit control
3 ** Colourise for particular languages.
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
19 #include "Scintilla.h"
22 const LexerModule
*LexerModule::base
= 0;
23 int LexerModule::nextLanguage
= SCLEX_AUTOMATIC
+1;
25 LexerModule::LexerModule(int language_
, LexerFunction fnLexer_
,
26 const char *languageName_
, LexerFunction fnFolder_
,
27 const char * const wordListDescriptions_
[]) :
31 wordListDescriptions(wordListDescriptions_
),
32 languageName(languageName_
) {
35 if (language
== SCLEX_AUTOMATIC
) {
36 language
= nextLanguage
;
41 int LexerModule::GetNumWordLists() const {
42 if (wordListDescriptions
== NULL
) {
47 while (wordListDescriptions
[numWordLists
]) {
55 const char * LexerModule::GetWordListDescription(int index
) const {
56 static const char *emptyStr
= "";
58 PLATFORM_ASSERT(index
< GetNumWordLists());
59 if (index
>= GetNumWordLists()) {
62 return wordListDescriptions
[index
];
66 const LexerModule
*LexerModule::Find(int language
) {
67 const LexerModule
*lm
= base
;
69 if (lm
->language
== language
) {
77 const LexerModule
*LexerModule::Find(const char *languageName
) {
79 const LexerModule
*lm
= base
;
81 if (lm
->languageName
&& 0 == strcmp(lm
->languageName
, languageName
)) {
90 void LexerModule::Lex(unsigned int startPos
, int lengthDoc
, int initStyle
,
91 WordList
*keywordlists
[], Accessor
&styler
) const {
93 fnLexer(startPos
, lengthDoc
, initStyle
, keywordlists
, styler
);
96 void LexerModule::Fold(unsigned int startPos
, int lengthDoc
, int initStyle
,
97 WordList
*keywordlists
[], Accessor
&styler
) const {
99 int lineCurrent
= styler
.GetLine(startPos
);
100 // Move back one line in case deletion wrecked current line fold state
101 if (lineCurrent
> 0) {
103 int newStartPos
= styler
.LineStart(lineCurrent
);
104 lengthDoc
+= startPos
- newStartPos
;
105 startPos
= newStartPos
;
108 initStyle
= styler
.StyleAt(startPos
- 1);
111 fnFolder(startPos
, lengthDoc
, initStyle
, keywordlists
, styler
);
115 static void ColouriseNullDoc(unsigned int startPos
, int length
, int, WordList
*[],
117 // Null language means all style bytes are 0 so just mark the end - no need to fill in.
119 styler
.StartAt(startPos
+ length
- 1);
120 styler
.StartSegment(startPos
+ length
- 1);
121 styler
.ColourTo(startPos
+ length
- 1, 0);
125 LexerModule
lmNull(SCLEX_NULL
, ColouriseNullDoc
, "null");
127 // Alternative historical name for Scintilla_LinkLexers
128 int wxForceScintillaLexers(void) {
129 return Scintilla_LinkLexers();
132 // To add or remove a lexer, add or remove its file and run LexGen.py.
134 // Force a reference to all of the Scintilla lexers so that the linker will
135 // not remove the code of the lexers.
136 int Scintilla_LinkLexers() {
137 static int forcer
= 0;
139 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
140 #define LINK_LEXER(lexer) extern LexerModule lexer; forcer += lexer.GetLanguage();
142 //++Autogenerated -- run src/LexGen.py to regenerate
143 //**\(\tLINK_LEXER(\*);\n\)
147 LINK_LEXER(lmBullant
);
151 LINK_LEXER(lmNncrontab
);
152 LINK_LEXER(lmEiffel
);
153 LINK_LEXER(lmEiffelkw
);
160 LINK_LEXER(lmMatlab
);
165 LINK_LEXER(lmErrorList
);
167 LINK_LEXER(lmPascal
);
169 LINK_LEXER(lmPython
);
173 LINK_LEXER(lmVBScript
);
175 //--Autogenerated -- end of automatically generated section