summaryrefslogtreecommitdiffstats
path: root/part/kxesyntaxhighlighter.h
blob: 6952201f89fab2d18ec793fa3bb1def4b4a68446 (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 <tqsyntaxhighlighter.h>

class TQTextEdit;

/**XML Syntax highlighter
  *@author Lumir Vanek
  */

class KXESyntaxHighlighter : public TQSyntaxHighlighter
{
public: 
	KXESyntaxHighlighter(TQTextEdit *);
	~KXESyntaxHighlighter();

  int highlightParagraph(const TQString &text, int endStateOfLastPara);

  void setColorDefaultText(const TQColor color) { m_clrDefaultText = color; }
  void setColorElementNames(const TQColor color) { m_clrElementName = color; }
  void setColorAttributeNames(const TQColor color) { m_clrAttributeName = color; }
  void setColorAttributeValues(const TQColor color) { m_clrAttributeValue = color; }
  void setColorXmlSyntaxChars(const TQColor color) { m_clrXmlSyntaxChar = color; }
  void setColorComments(const TQColor color) { m_clrComment = color; }
  void setColorSyntaxError(const TQColor color) { m_clrSyntaxError = color; }

  const TQColor colorDefaultText() const { return m_clrDefaultText; }
  const TQColor colorElementNames() const { return m_clrElementName; }
  const TQColor colorAttributeNames() const { return m_clrAttributeName; }
  const TQColor colorAttributeValues() const { return m_clrAttributeValue; }
  const TQColor colorXmlSyntaxChars() const { return m_clrXmlSyntaxChar; }
  const TQColor colorComments() const { return m_clrComment; }
  const TQColor colorSyntaxError() const { return m_clrSyntaxError; }
  
protected:
  int processDefaultText(int, const TQString&);
  
protected:

  TQColor m_clrDefaultText;
  TQColor m_clrElementName;
  TQColor m_clrAttributeName;
  TQColor m_clrAttributeValue;
  TQColor m_clrXmlSyntaxChar; // < > = "
  TQColor m_clrComment;
  TQColor m_clrSyntaxError;

  // states for parsing XML
  enum ParserState
	{
    parsingNone = 0,
    expectElementNameOrSlash,
    expectElementName,
    expectAtttributeOrEndOfElement,
		expectEqual,
    expectAttributeValue
	};

  ParserState m_eParserState;
};

#endif