1
// Scintilla source code edit control
2
/** @file LexerModule.cxx
3
** Colourise for particular languages.
5
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
6
// The License.txt file describes the conditions under which this software may be distributed.
18
#include "Scintilla.h"
21
#include "PropSetSimple.h"
23
#include "LexAccessor.h"
25
#include "LexerModule.h"
26
#include "LexerBase.h"
27
#include "LexerSimple.h"
30
using namespace Scintilla;
33
LexerModule::LexerModule(int language_,
34
LexerFunction fnLexer_,
35
const char *languageName_,
36
LexerFunction fnFolder_,
37
const char *const wordListDescriptions_[]) :
42
wordListDescriptions(wordListDescriptions_),
43
languageName(languageName_) {
46
LexerModule::LexerModule(int language_,
47
LexerFactoryFunction fnFactory_,
48
const char *languageName_,
49
const char * const wordListDescriptions_[]) :
53
fnFactory(fnFactory_),
54
wordListDescriptions(wordListDescriptions_),
55
languageName(languageName_) {
58
int LexerModule::GetNumWordLists() const {
59
if (wordListDescriptions == NULL) {
64
while (wordListDescriptions[numWordLists]) {
72
const char *LexerModule::GetWordListDescription(int index) const {
73
assert(index < GetNumWordLists());
74
if (!wordListDescriptions || (index >= GetNumWordLists())) {
77
return wordListDescriptions[index];
81
ILexer *LexerModule::Create() const {
85
return new LexerSimple(this);
88
void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
89
WordList *keywordlists[], Accessor &styler) const {
91
fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
94
void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
95
WordList *keywordlists[], Accessor &styler) const {
97
int lineCurrent = styler.GetLine(startPos);
98
// Move back one line in case deletion wrecked current line fold state
99
if (lineCurrent > 0) {
101
int newStartPos = styler.LineStart(lineCurrent);
102
lengthDoc += startPos - newStartPos;
103
startPos = newStartPos;
106
initStyle = styler.StyleAt(startPos - 1);
109
fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);