summaryrefslogtreecommitdiffstats
path: root/part/kxesyntaxhighlighter.h
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2016-03-26 13:50:43 +0100
committerSlávek Banko <slavek.banko@axis.cz>2016-03-26 13:50:43 +0100
commitd62c8c002c51fb7c36487839eeeb4ac89f044dee (patch)
treebb4d1f5c631ab1f22a3018ba39e6a806035f80fd /part/kxesyntaxhighlighter.h
downloadkxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.tar.gz
kxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.zip
Initial import of kxmleditor 1.1.4
Diffstat (limited to 'part/kxesyntaxhighlighter.h')
-rw-r--r--part/kxesyntaxhighlighter.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/part/kxesyntaxhighlighter.h b/part/kxesyntaxhighlighter.h
new file mode 100644
index 0000000..b6d8868
--- /dev/null
+++ b/part/kxesyntaxhighlighter.h
@@ -0,0 +1,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