OSDN Git Service

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