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
12
#define EXT_LEXER_DECL __stdcall
15
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
16
#define EXT_LEXER_DECL __stdcall
18
#define EXT_LEXER_DECL
21
#define EXT_LEXER_DECL
28
// External Lexer function definitions...
29
typedef void (EXT_LEXER_DECL *ExtLexerFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
30
char *words[], WindowID window, char *props);
31
typedef void (EXT_LEXER_DECL *ExtFoldFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
32
char *words[], WindowID window, char *props);
33
typedef void* (EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index);
34
typedef int (EXT_LEXER_DECL *GetLexerCountFn)();
35
typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength);
37
//class DynamicLibrary;
39
/// Sub-class of LexerModule to use an external lexer.
40
class ExternalLexerModule : protected LexerModule {
42
ExtLexerFunction fneLexer;
43
ExtFoldFunction fneFolder;
47
ExternalLexerModule(int language_, LexerFunction fnLexer_,
48
const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){
49
strncpy(name, languageName_, sizeof(name));
52
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
53
WordList *keywordlists[], Accessor &styler) const;
54
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
55
WordList *keywordlists[], Accessor &styler) const;
56
virtual void SetExternal(ExtLexerFunction fLexer, ExtFoldFunction fFolder, int index);
59
/// LexerMinder points to an ExternalLexerModule - so we don't leak them.
62
ExternalLexerModule *self;
66
/// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.
73
LexerLibrary(const char* ModuleName);
78
SString m_sModuleName;
81
/// LexerManager manages external lexers, contains LexerLibrarys.
86
static LexerManager *GetInstance();
87
static void DeleteInstance();
89
void Load(const char* path);
94
static LexerManager *theInstance;
96
void LoadLexerLibrary(const char* module);