-
Notifications
You must be signed in to change notification settings - Fork 10
/
SourceLexer.h
63 lines (52 loc) · 1.27 KB
/
SourceLexer.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
#pragma once
#define STYLE_TEXT 0
#define STYLE_QUOTE 1
#define STYLE_QUOTEBRACKET 2
#define STYLE_INFORM6 3
#define STYLE_HEADING 4
#define STYLE_COMMENT 5
#define NEST_COMMENTS 16
class SourceEdit;
class SourceLexer
{
public:
enum LexAction
{
LexApply,
LexHeadings
};
SourceLexer(SourceEdit* edit, LexAction action);
void Process(int startPos, int endPos, bool includeExt);
enum HeadingLevel
{
Root = 0,
Title,
ExtensionPart,
Volume,
Book,
Part,
Chapter,
Section,
Example,
No_Heading = -1
};
struct Heading
{
HeadingLevel level;
CStringW name;
int line;
Heading();
Heading(HeadingLevel lv, LPCSTR n, int ln);
};
static HeadingLevel IsHeading(const char* line, bool includeExt);
const CArray<Heading>& GetHeadings(void) const;
static const int StyleMask;
private:
void ApplyStyle(int& start, int pos, int& style, int newStyle, int mask);
void AddHeading(HeadingLevel level, LPCSTR name, int pos);
bool IsQuote(unsigned char c, int& pos, bool advance);
LONG_PTR CallEdit(UINT msg, DWORD wp = 0, LONG_PTR lp = 0);
SourceEdit* m_edit;
LexAction m_action;
CArray<Heading> m_headings;
};