]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/KeyWords.cxx
d1eddef5ff814bf16e1fb96cbe9ec8e8ab1f1532
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_
) :
30 languageName(languageName_
) {
33 if (language
== SCLEX_AUTOMATIC
) {
34 language
= nextLanguage
;
39 const LexerModule
*LexerModule::Find(int language
) {
40 const LexerModule
*lm
= base
;
42 if (lm
->language
== language
) {
50 const LexerModule
*LexerModule::Find(const char *languageName
) {
52 const LexerModule
*lm
= base
;
54 if (lm
->languageName
&& 0 == strcmp(lm
->languageName
, languageName
)) {
63 void LexerModule::Lex(unsigned int startPos
, int lengthDoc
, int initStyle
,
64 WordList
*keywordlists
[], Accessor
&styler
) const {
66 fnLexer(startPos
, lengthDoc
, initStyle
, keywordlists
, styler
);
69 void LexerModule::Fold(unsigned int startPos
, int lengthDoc
, int initStyle
,
70 WordList
*keywordlists
[], Accessor
&styler
) const {
72 int lineCurrent
= styler
.GetLine(startPos
);
73 // Move back one line in case deletion wrecked current line fold state
74 if (lineCurrent
> 0) {
76 int newStartPos
= styler
.LineStart(lineCurrent
);
77 lengthDoc
+= startPos
- newStartPos
;
78 startPos
= newStartPos
;
81 initStyle
= styler
.StyleAt(startPos
- 1);
84 fnFolder(startPos
, lengthDoc
, initStyle
, keywordlists
, styler
);
88 static void ColouriseNullDoc(unsigned int startPos
, int length
, int, WordList
*[],
90 // Null language means all style bytes are 0 so just mark the end - no need to fill in.
92 styler
.StartAt(startPos
+ length
- 1);
93 styler
.StartSegment(startPos
+ length
- 1);
94 styler
.ColourTo(startPos
+ length
- 1, 0);
98 LexerModule
lmNull(SCLEX_NULL
, ColouriseNullDoc
, "null");
106 // The following code forces a reference to all of the Scintilla lexers.
107 // If we don't do something like this, then the linker tends to "optimize"
108 // them away. (eric@sourcegear.com)
110 // Taken from wxWindow's stc.cpp. Walter.
112 int wxForceScintillaLexers(void) {
113 return Scintilla_LinkLexers();
116 int Scintilla_LinkLexers() {
117 extern LexerModule lmAda
;
118 extern LexerModule lmAVE
;
119 extern LexerModule lmBaan
;
120 extern LexerModule lmBatch
;
121 extern LexerModule lmConf
;
122 extern LexerModule lmCPP
;
123 extern LexerModule lmDiff
;
124 extern LexerModule lmEiffel
;
125 extern LexerModule lmEiffelkw
;
126 extern LexerModule lmErrorList
;
127 extern LexerModule lmHTML
;
128 extern LexerModule lmLatex
;
129 extern LexerModule lmLISP
;
130 extern LexerModule lmLua
;
131 extern LexerModule lmMake
;
132 extern LexerModule lmMatlab
;
133 extern LexerModule lmPascal
;
134 extern LexerModule lmPerl
;
135 extern LexerModule lmProps
;
136 extern LexerModule lmPython
;
137 extern LexerModule lmRuby
;
138 extern LexerModule lmSQL
;
139 extern LexerModule lmVB
;
140 extern LexerModule lmXML
;
141 extern LexerModule lmBullant
;