~ubuntu-branches/ubuntu/wily/geany/wily

« back to all changes in this revision

Viewing changes to scintilla/src/Catalogue.cxx

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Scintilla source code edit control
 
2
/** @file KeyWords.cxx
 
3
 ** Colourise for particular languages.
 
4
 **/
 
5
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
 
6
// The License.txt file describes the conditions under which this software may be distributed.
 
7
 
 
8
#include <stdlib.h>
 
9
#include <string.h>
 
10
#include <ctype.h>
 
11
#include <stdio.h>
 
12
#include <stdarg.h>
 
13
#include <assert.h>
 
14
 
 
15
#include <vector>
 
16
 
 
17
#include "ILexer.h"
 
18
#include "Scintilla.h"
 
19
#include "SciLexer.h"
 
20
 
 
21
#include "LexerModule.h"
 
22
#include "Catalogue.h"
 
23
 
 
24
#ifdef SCI_NAMESPACE
 
25
using namespace Scintilla;
 
26
#endif
 
27
 
 
28
static std::vector<LexerModule *> lexerCatalogue;
 
29
static int nextLanguage = SCLEX_AUTOMATIC+1;
 
30
 
 
31
const LexerModule *Catalogue::Find(int language) {
 
32
        Scintilla_LinkLexers();
 
33
        for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
 
34
                it != lexerCatalogue.end(); ++it) {
 
35
                if ((*it)->GetLanguage() == language) {
 
36
                        return *it;
 
37
                }
 
38
        }
 
39
        return 0;
 
40
}
 
41
 
 
42
const LexerModule *Catalogue::Find(const char *languageName) {
 
43
        Scintilla_LinkLexers();
 
44
        if (languageName) {
 
45
                for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
 
46
                        it != lexerCatalogue.end(); ++it) {
 
47
                        if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) {
 
48
                                return *it;
 
49
                        }
 
50
                }
 
51
        }
 
52
        return 0;
 
53
}
 
54
 
 
55
void Catalogue::AddLexerModule(LexerModule *plm) {
 
56
        if (plm->GetLanguage() == SCLEX_AUTOMATIC) {
 
57
                plm->language = nextLanguage;
 
58
                nextLanguage++;
 
59
        }
 
60
        lexerCatalogue.push_back(plm);
 
61
}
 
62
 
 
63
// Alternative historical name for Scintilla_LinkLexers
 
64
int wxForceScintillaLexers(void) {
 
65
        return Scintilla_LinkLexers();
 
66
}
 
67
 
 
68
// To add or remove a lexer, add or remove its file and run LexGen.py.
 
69
 
 
70
// Force a reference to all of the Scintilla lexers so that the linker will
 
71
// not remove the code of the lexers.
 
72
int Scintilla_LinkLexers() {
 
73
 
 
74
        static int initialised = 0;
 
75
        if (initialised)
 
76
                return 0;
 
77
        initialised = 1;
 
78
 
 
79
// Shorten the code that declares a lexer and ensures it is linked in by calling a method.
 
80
#define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
 
81
 
 
82
//++Autogenerated -- run src/LexGen.py to regenerate
 
83
//**\(\tLINK_LEXER(\*);\n\)
 
84
        LINK_LEXER(lmAda);
 
85
        LINK_LEXER(lmAsm);
 
86
        LINK_LEXER(lmBash);
 
87
        LINK_LEXER(lmCaml);
 
88
        LINK_LEXER(lmCmake);
 
89
        LINK_LEXER(lmCOBOL);
 
90
        LINK_LEXER(lmCPP);
 
91
        LINK_LEXER(lmCss);
 
92
        LINK_LEXER(lmD);
 
93
        LINK_LEXER(lmDiff);
 
94
        LINK_LEXER(lmErlang);
 
95
        LINK_LEXER(lmF77);
 
96
        LINK_LEXER(lmForth);
 
97
        LINK_LEXER(lmFortran);
 
98
        LINK_LEXER(lmFreeBasic);
 
99
        LINK_LEXER(lmHaskell);
 
100
        LINK_LEXER(lmHTML);
 
101
        LINK_LEXER(lmLatex);
 
102
        LINK_LEXER(lmLISP);
 
103
        LINK_LEXER(lmLua);
 
104
        LINK_LEXER(lmMake);
 
105
        LINK_LEXER(lmMarkdown);
 
106
        // We use Octave instead of Matlab
 
107
        LINK_LEXER(lmNsis);
 
108
        LINK_LEXER(lmNull);
 
109
        LINK_LEXER(lmOctave);
 
110
        LINK_LEXER(lmPascal);
 
111
        LINK_LEXER(lmPerl);
 
112
        LINK_LEXER(lmPo);
 
113
        LINK_LEXER(lmProps);
 
114
        LINK_LEXER(lmPython);
 
115
        LINK_LEXER(lmR);
 
116
        LINK_LEXER(lmRuby);
 
117
        LINK_LEXER(lmSQL);
 
118
        LINK_LEXER(lmTCL);
 
119
        LINK_LEXER(lmTxt2tags);
 
120
        LINK_LEXER(lmVerilog);
 
121
        LINK_LEXER(lmVHDL);
 
122
        LINK_LEXER(lmXML);
 
123
        LINK_LEXER(lmYAML);
 
124
 
 
125
//--Autogenerated -- end of automatically generated section
 
126
 
 
127
        return 1;
 
128
}