Split theme preferences page to allow more easy different theme types.
[tagua/yd.git] / src / highlighter.h
blob867e0f9f06192fe58009e0a932a01c24fbb8d4fc
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef HIGHLIGHTER_H
12 #define HIGHLIGHTER_H
14 #include <QSyntaxHighlighter>
15 #include <QTextCharFormat>
16 #include <boost/shared_ptr.hpp>
18 class PatternListAdaptorOutputIterator;
19 class PatternListAdaptorInputIterator;
21 class Highlighter : public QSyntaxHighlighter {
22 Q_OBJECT
23 public:
24 struct Pattern {
25 QString name;
26 QRegExp pattern;
27 QTextCharFormat format;
29 private:
30 std::vector<Pattern> m_patterns;
31 public:
32 Highlighter(QTextDocument* parent);
33 Highlighter(QTextDocument* parent, const Pattern& pattern);
34 void reload();
36 static void load(PatternListAdaptorOutputIterator& out);
37 static void save(const PatternListAdaptorInputIterator& in);
39 virtual void highlightBlock(const QString& text);
40 std::vector<Pattern>& patterns();
44 class PatternListAdaptorOutputIterator {
45 public:
46 virtual ~PatternListAdaptorOutputIterator() { }
47 virtual void add(const Highlighter::Pattern&) = 0;
50 class PatternListAdaptorInputIterator {
51 public:
52 virtual ~PatternListAdaptorInputIterator() { }
53 virtual boost::shared_ptr<PatternListAdaptorInputIterator> clone() const = 0;
54 virtual bool valid() const = 0;
55 virtual PatternListAdaptorInputIterator& inc() = 0;
56 virtual const Highlighter::Pattern& value() const = 0;
59 #endif // HIGHLIGHTER_H