OSDN Git Service

Commit DialogBox compile Okay
[tortoisegit/TortoiseGitJp.git] / ext / scintilla / src / ExternalLexer.h
1 // Scintilla source code edit control\r
2 /** @file ExternalLexer.h\r
3  ** Support external lexers in DLLs.\r
4  **/\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
7 \r
8 #ifndef EXTERNALLEXER_H\r
9 #define EXTERNALLEXER_H\r
10 \r
11 #if PLAT_WIN\r
12 #define EXT_LEXER_DECL __stdcall\r
13 #else\r
14 #define EXT_LEXER_DECL\r
15 #endif\r
16 \r
17 #ifdef SCI_NAMESPACE\r
18 namespace Scintilla {\r
19 #endif\r
20 \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
29 \r
30 //class DynamicLibrary;\r
31 \r
32 /// Sub-class of LexerModule to use an external lexer.\r
33 class ExternalLexerModule : protected LexerModule {\r
34 protected:\r
35         ExtLexerFunction fneLexer;\r
36         ExtFoldFunction fneFolder;\r
37         int externalLanguage;\r
38         char name[100];\r
39 public:\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
44         };\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
50 };\r
51 \r
52 /// LexerMinder points to an ExternalLexerModule - so we don't leak them.\r
53 class LexerMinder {\r
54 public:\r
55         ExternalLexerModule *self;\r
56         LexerMinder *next;\r
57 };\r
58 \r
59 /// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.\r
60 class LexerLibrary {\r
61         DynamicLibrary  *lib;\r
62         LexerMinder             *first;\r
63         LexerMinder             *last;\r
64 \r
65 public:\r
66         LexerLibrary(const char* ModuleName);\r
67         ~LexerLibrary();\r
68         void Release();\r
69         \r
70         LexerLibrary    *next;\r
71         SString                 m_sModuleName;\r
72 };\r
73 \r
74 /// LexerManager manages external lexers, contains LexerLibrarys.\r
75 class LexerManager {\r
76 public:\r
77         ~LexerManager();\r
78         \r
79         static LexerManager *GetInstance();\r
80         static void DeleteInstance();\r
81         \r
82         void Load(const char* path);\r
83         void Clear();\r
84 \r
85 private:\r
86         LexerManager();\r
87         static LexerManager *theInstance;\r
88 \r
89         void LoadLexerLibrary(const char* module);\r
90         LexerLibrary *first;\r
91         LexerLibrary *last;\r
92 };\r
93 \r
94 class LMMinder {\r
95 public:\r
96         ~LMMinder();\r
97 };\r
98 \r
99 #ifdef SCI_NAMESPACE\r
100 }\r
101 #endif\r
102 \r
103 #endif\r