~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to src/qscintilla2/src/ExternalLexer.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-11-19 15:18:19 UTC
  • mfrom: (1.2.9 upstream) (3.3.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091119151819-me89ezmxzkvl0lws
Tags: 2.1.1-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Scintilla source code edit control
 
2
/** @file ExternalLexer.h
 
3
 ** Support external lexers in DLLs.
 
4
 **/
 
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.
 
7
 
 
8
#ifndef EXTERNALLEXER_H
 
9
#define EXTERNALLEXER_H
 
10
 
 
11
#if PLAT_WIN
 
12
#define EXT_LEXER_DECL __stdcall
 
13
#elif PLAT_QT
 
14
#include <qglobal.h>
 
15
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
 
16
#define EXT_LEXER_DECL __stdcall
 
17
#else
 
18
#define EXT_LEXER_DECL
 
19
#endif
 
20
#else
 
21
#define EXT_LEXER_DECL
 
22
#endif
 
23
 
 
24
#ifdef SCI_NAMESPACE
 
25
namespace Scintilla {
 
26
#endif
 
27
 
 
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);
 
36
 
 
37
//class DynamicLibrary;
 
38
 
 
39
/// Sub-class of LexerModule to use an external lexer.
 
40
class ExternalLexerModule : protected LexerModule {
 
41
protected:
 
42
        ExtLexerFunction fneLexer;
 
43
        ExtFoldFunction fneFolder;
 
44
        int externalLanguage;
 
45
        char name[100];
 
46
public:
 
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));
 
50
                languageName = name;
 
51
        };
 
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);
 
57
};
 
58
 
 
59
/// LexerMinder points to an ExternalLexerModule - so we don't leak them.
 
60
class LexerMinder {
 
61
public:
 
62
        ExternalLexerModule *self;
 
63
        LexerMinder *next;
 
64
};
 
65
 
 
66
/// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.
 
67
class LexerLibrary {
 
68
        DynamicLibrary  *lib;
 
69
        LexerMinder             *first;
 
70
        LexerMinder             *last;
 
71
 
 
72
public:
 
73
        LexerLibrary(const char* ModuleName);
 
74
        ~LexerLibrary();
 
75
        void Release();
 
76
        
 
77
        LexerLibrary    *next;
 
78
        SString                 m_sModuleName;
 
79
};
 
80
 
 
81
/// LexerManager manages external lexers, contains LexerLibrarys.
 
82
class LexerManager {
 
83
public:
 
84
        ~LexerManager();
 
85
        
 
86
        static LexerManager *GetInstance();
 
87
        static void DeleteInstance();
 
88
        
 
89
        void Load(const char* path);
 
90
        void Clear();
 
91
 
 
92
private:
 
93
        LexerManager();
 
94
        static LexerManager *theInstance;
 
95
 
 
96
        void LoadLexerLibrary(const char* module);
 
97
        LexerLibrary *first;
 
98
        LexerLibrary *last;
 
99
};
 
100
 
 
101
class LMMinder {
 
102
public:
 
103
        ~LMMinder();
 
104
};
 
105
 
 
106
#ifdef SCI_NAMESPACE
 
107
}
 
108
#endif
 
109
 
 
110
#endif