]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/include/KeyWords.h
Fix [ 1574240 ] wx.RadioButton doesn't navigate correctly
[wxWidgets.git] / src / stc / scintilla / include / KeyWords.h
CommitLineData
65ec6247
RD
1// Scintilla source code edit control
2/** @file KeyWords.h
3 ** Colourise for particular languages.
4 **/
5// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
9ce192d4
RD
6// The License.txt file describes the conditions under which this software may be distributed.
7
f6bcfd97
BP
8typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
9 WordList *keywordlists[], Accessor &styler);
88a8b04e 10
65ec6247
RD
11/**
12 * A LexerModule is responsible for lexing and folding a particular language.
13 * The class maintains a list of LexerModules which can be searched to find a
14 * module appropriate to a particular language.
15 */
f6bcfd97 16class LexerModule {
65ec6247 17protected:
1a2fb4cd 18 const LexerModule *next;
f6bcfd97 19 int language;
65ec6247
RD
20 LexerFunction fnLexer;
21 LexerFunction fnFolder;
a834585d 22 const char * const * wordListDescriptions;
1e9bafca 23 int styleBits;
a834585d 24
1a2fb4cd 25 static const LexerModule *base;
65ec6247
RD
26 static int nextLanguage;
27
f6bcfd97 28public:
1a2fb4cd 29 const char *languageName;
1e9bafca
RD
30 LexerModule(int language_,
31 LexerFunction fnLexer_,
32 const char *languageName_=0,
33 LexerFunction fnFolder_=0,
34 const char * const wordListDescriptions_[] = NULL,
35 int styleBits_=5);
36 virtual ~LexerModule() {
37 }
1a2fb4cd 38 int GetLanguage() const { return language; }
a834585d
RD
39
40 // -1 is returned if no WordList information is available
41 int GetNumWordLists() const;
42 const char *GetWordListDescription(int index) const;
43
1e9bafca
RD
44 int GetStyleBitsNeeded() const;
45
65ec6247 46 virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
1a2fb4cd 47 WordList *keywordlists[], Accessor &styler) const;
65ec6247 48 virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
1a2fb4cd
RD
49 WordList *keywordlists[], Accessor &styler) const;
50 static const LexerModule *Find(int language);
51 static const LexerModule *Find(const char *languageName);
f6bcfd97
BP
52};
53
65ec6247
RD
54/**
55 * Check if a character is a space.
56 * This is ASCII specific but is safe with chars >= 0x80.
57 */
58inline bool isspacechar(unsigned char ch) {
59 return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
60}
61
f6bcfd97 62inline bool iswordchar(char ch) {
65ec6247 63 return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_');
f6bcfd97
BP
64}
65
66inline bool iswordstart(char ch) {
65ec6247 67 return isascii(ch) && (isalnum(ch) || ch == '_');
f6bcfd97
BP
68}
69
70inline bool isoperator(char ch) {
65ec6247 71 if (isascii(ch) && isalnum(ch))
f6bcfd97
BP
72 return false;
73 // '.' left out as it is used to make up numbers
74 if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
75 ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
76 ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
77 ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
78 ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
79 ch == '?' || ch == '!' || ch == '.' || ch == '~')
80 return true;
81 return false;
82}