/
SourceView.h
172 lines (154 loc) · 3.11 KB
/
SourceView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#pragma once
#include <map>
#include <wx/stc/stc.h>
namespace wxutil
{
/**
* greebo: This is a custom extension of the wxWidgets styles text control,
* providing a few methods to make the actual code style mapping easier.
* It's advisable to subclass this control and map the various lexer-recognised
* elements to a specific appearance.
*/
class SourceViewCtrl :
public wxStyledTextCtrl
{
public:
enum FontStyle
{
Normal = 1,
Italic = 2,
Bold = 4,
Underline = 8,
Hidden = 16,
};
// Describes a specific style (e.g. a code comment)
struct Style
{
wxString foreground;
wxString fontname;
int fontsize;
FontStyle fontstyle;
Style() :
foreground("BLACK"),
fontname(""),
fontsize(10),
fontstyle(Normal)
{};
Style(const char* foreground_,
FontStyle fontStyle_ = Normal,
int fontSize_ = 10,
const char* fontname_ = "") :
foreground(foreground_),
fontname(fontname_),
fontsize(fontSize_),
fontstyle(fontStyle_)
{}
};
// Elements as recognised by the STC lexer
enum Element
{
Default = 0,
Keyword1,
Keyword2,
Keyword3,
Keyword4,
Keyword5,
Keyword6,
Comment,
CommentDoc,
CommentLine,
SpecialComment,
Character,
CharacterEOL,
String,
StringEOL,
Delimiter,
Punctuation,
Operator,
Brace,
Command,
Identifier,
Label,
Number,
Parameter,
RegEx,
UUID,
Value,
Preprocessor,
Script,
Error,
Undefined,
NumElements,
};
protected:
typedef std::map<Element, Style> StyleMap;
StyleMap _predefinedStyles;
public:
SourceViewCtrl(wxWindow* parent);
virtual ~SourceViewCtrl() {}
// Use this method to set a lexer-recognised element to a certain style
// e.g. SetStyleMapping(0, Number), provided that the lexer is using
// the index 0 to represent numbers in the source.
virtual void SetStyleMapping(int elementIndex, Element elementType);
};
/**
* A special class providing syntax highlighting for the Python
* scripting language.
*/
class PythonSourceViewCtrl :
public SourceViewCtrl
{
public:
PythonSourceViewCtrl(wxWindow* parent);
};
/**
* A base class providing highlighting for the Doom 3
* declaration syntax, loosely based on C++ highlighting.
*/
class D3DeclarationViewCtrl :
public SourceViewCtrl
{
public:
D3DeclarationViewCtrl(wxWindow* parent);
};
/**
* A special class providing highlighting for the Doom 3
* material syntax.
*/
class D3MaterialSourceViewCtrl :
public D3DeclarationViewCtrl
{
public:
D3MaterialSourceViewCtrl(wxWindow* parent);
};
/**
* A special class providing highlighting for the Doom 3
* sound shader syntax.
*/
class D3SoundShaderSourceViewCtrl :
public D3DeclarationViewCtrl
{
public:
D3SoundShaderSourceViewCtrl(wxWindow* parent);
};
/**
* A special class providing highlighting for the Doom 3
* particle syntax.
*/
class D3ParticleSourceViewCtrl :
public D3DeclarationViewCtrl
{
public:
D3ParticleSourceViewCtrl(wxWindow* parent);
};
/**
* A special class providing highlighting for the Doom 3
* modelDef syntax.
*/
class D3ModelDefSourceViewCtrl :
public D3DeclarationViewCtrl
{
public:
D3ModelDefSourceViewCtrl(wxWindow* parent);
};
} // namespace