1 // Scintilla source code edit control
\r
2 /** @file ExternalLexer.h
\r
3 ** Support external lexers in DLLs.
\r
5 // Copyright 2001 Simon Steele <ss@pnotepad.org>, portions copyright Neil Hodgson.
\r
6 // The License.txt file describes the conditions under which this software may be distributed.
\r
8 #ifndef EXTERNALLEXER_H
\r
9 #define EXTERNALLEXER_H
\r
12 #define EXT_LEXER_DECL __stdcall
\r
14 #define EXT_LEXER_DECL
\r
17 #ifdef SCI_NAMESPACE
\r
18 namespace Scintilla {
\r
21 // External Lexer function definitions...
\r
22 typedef void (EXT_LEXER_DECL *ExtLexerFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
\r
23 char *words[], WindowID window, char *props);
\r
24 typedef void (EXT_LEXER_DECL *ExtFoldFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
\r
25 char *words[], WindowID window, char *props);
\r
26 typedef void* (EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index);
\r
27 typedef int (EXT_LEXER_DECL *GetLexerCountFn)();
\r
28 typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength);
\r
30 //class DynamicLibrary;
\r
32 /// Sub-class of LexerModule to use an external lexer.
\r
33 class ExternalLexerModule : protected LexerModule {
\r
35 ExtLexerFunction fneLexer;
\r
36 ExtFoldFunction fneFolder;
\r
37 int externalLanguage;
\r
40 ExternalLexerModule(int language_, LexerFunction fnLexer_,
\r
41 const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){
\r
42 strncpy(name, languageName_, sizeof(name));
\r
43 languageName = name;
\r
45 virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
\r
46 WordList *keywordlists[], Accessor &styler) const;
\r
47 virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
\r
48 WordList *keywordlists[], Accessor &styler) const;
\r
49 virtual void SetExternal(ExtLexerFunction fLexer, ExtFoldFunction fFolder, int index);
\r
52 /// LexerMinder points to an ExternalLexerModule - so we don't leak them.
\r
55 ExternalLexerModule *self;
\r
59 /// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.
\r
60 class LexerLibrary {
\r
61 DynamicLibrary *lib;
\r
66 LexerLibrary(const char* ModuleName);
\r
71 SString m_sModuleName;
\r
74 /// LexerManager manages external lexers, contains LexerLibrarys.
\r
75 class LexerManager {
\r
79 static LexerManager *GetInstance();
\r
80 static void DeleteInstance();
\r
82 void Load(const char* path);
\r
87 static LexerManager *theInstance;
\r
89 void LoadLexerLibrary(const char* module);
\r
90 LexerLibrary *first;
\r
99 #ifdef SCI_NAMESPACE
\r