1
// Scintilla source code edit control
2
/** @file ExternalLexer.h
3
** Support external lexers in DLLs.
5
// Copyright 2001 Simon Steele <ss@pnotepad.org>, portions copyright Neil Hodgson.
6
// The License.txt file describes the conditions under which this software may be distributed.
8
#ifndef EXTERNALLEXER_H
9
#define EXTERNALLEXER_H
11
#define EXT_LEXER_DECL
13
// External Lexer function definitions...
14
typedef void (EXT_LEXER_DECL *ExtLexerFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
15
char *words[], WindowID window, char *props);
16
typedef void (EXT_LEXER_DECL *ExtFoldFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
17
char *words[], WindowID window, char *props);
18
typedef void* (EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index);
19
typedef int (EXT_LEXER_DECL *GetLexerCountFn)();
20
typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength);
22
//class DynamicLibrary;
24
/// Sub-class of LexerModule to use an external lexer.
25
class ExternalLexerModule : protected LexerModule {
27
ExtLexerFunction fneLexer;
28
ExtFoldFunction fneFolder;
32
ExternalLexerModule(int language_, LexerFunction fnLexer_,
33
const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){
34
strncpy(name, languageName_, sizeof(name));
37
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
38
WordList *keywordlists[], Accessor &styler) const;
39
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
40
WordList *keywordlists[], Accessor &styler) const;
41
virtual void SetExternal(ExtLexerFunction fLexer, ExtFoldFunction fFolder, int index);
44
/// LexerMinder points to an ExternalLexerModule - so we don't leak them.
47
ExternalLexerModule *self;
51
/// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.
58
LexerLibrary(const char* ModuleName);
63
SString m_sModuleName;
66
/// LexerManager manages external lexers, contains LexerLibrarys.
71
static LexerManager *GetInstance();
72
static void DeleteInstance();
74
void Load(const char* path);
79
static LexerManager *theInstance;
81
void LoadLexerLibrary(const char* module);