blob: b6d88688439f2912681e365ea5a42b1c3b21aa9f (
plain)
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
|
/***************************************************************************
kxesyntaxhighlighter.h - XML Syntax highlighter
-------------------
begin : Ne pro 14 2003
copyright : (C) 2003 by The KXMLEditor Team
email : lvanek.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KXESYNTAXHIGHLIGHTER_H
#define KXESYNTAXHIGHLIGHTER_H
#include <qsyntaxhighlighter.h>
class QTextEdit;
/**XML Syntax highlighter
*@author Lumir Vanek
*/
class KXESyntaxHighlighter : public QSyntaxHighlighter
{
public:
KXESyntaxHighlighter(QTextEdit *);
~KXESyntaxHighlighter();
int highlightParagraph(const QString &text, int endStateOfLastPara);
void setColorDefaultText(const QColor color) { m_clrDefaultText = color; }
void setColorElementNames(const QColor color) { m_clrElementName = color; }
void setColorAttributeNames(const QColor color) { m_clrAttributeName = color; }
void setColorAttributeValues(const QColor color) { m_clrAttributeValue = color; }
void setColorXmlSyntaxChars(const QColor color) { m_clrXmlSyntaxChar = color; }
void setColorComments(const QColor color) { m_clrComment = color; }
void setColorSyntaxError(const QColor color) { m_clrSyntaxError = color; }
const QColor colorDefaultText() const { return m_clrDefaultText; }
const QColor colorElementNames() const { return m_clrElementName; }
const QColor colorAttributeNames() const { return m_clrAttributeName; }
const QColor colorAttributeValues() const { return m_clrAttributeValue; }
const QColor colorXmlSyntaxChars() const { return m_clrXmlSyntaxChar; }
const QColor colorComments() const { return m_clrComment; }
const QColor colorSyntaxError() const { return m_clrSyntaxError; }
protected:
int processDefaultText(int, const QString&);
protected:
QColor m_clrDefaultText;
QColor m_clrElementName;
QColor m_clrAttributeName;
QColor m_clrAttributeValue;
QColor m_clrXmlSyntaxChar; // < > = "
QColor m_clrComment;
QColor m_clrSyntaxError;
// states for parsing XML
enum ParserState
{
parsingNone = 0,
expectElementNameOrSlash,
expectElementName,
expectAtttributeOrEndOfElement,
expectEqual,
expectAttributeValue
};
ParserState m_eParserState;
};
#endif
|