highlighter.h
changeset 655 d4b49c6c6069
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/highlighter.h	Wed Jan 16 15:45:19 2008 +0000
     1.3 @@ -0,0 +1,63 @@
     1.4 +/****************************************************************************
     1.5 +**
     1.6 +** Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
     1.7 +**
     1.8 +** This file is part of the example classes of the Qt Toolkit.
     1.9 +**
    1.10 +** This file may be used under the terms of the GNU General Public
    1.11 +** License version 2.0 as published by the Free Software Foundation
    1.12 +** and appearing in the file LICENSE.GPL included in the packaging of
    1.13 +** this file.  Please review the following information to ensure GNU
    1.14 +** General Public Licensing requirements will be met:
    1.15 +** http://www.trolltech.com/products/qt/opensource.html
    1.16 +**
    1.17 +** If you are unsure which license is appropriate for your use, please
    1.18 +** review the following information:
    1.19 +** http://www.trolltech.com/products/qt/licensing.html or contact the
    1.20 +** sales department at sales@trolltech.com.
    1.21 +**
    1.22 +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    1.23 +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    1.24 +**
    1.25 +****************************************************************************/
    1.26 +
    1.27 +#ifndef HIGHLIGHTER_H
    1.28 +#define HIGHLIGHTER_H
    1.29 +
    1.30 +#include <QSyntaxHighlighter>
    1.31 +
    1.32 +#include <QHash>
    1.33 +#include <QTextCharFormat>
    1.34 +
    1.35 +class QTextDocument;
    1.36 +
    1.37 +class Highlighter : public QSyntaxHighlighter
    1.38 +{
    1.39 +    Q_OBJECT
    1.40 +
    1.41 +public:
    1.42 +    Highlighter(QTextDocument *parent = 0);
    1.43 +
    1.44 +protected:
    1.45 +    void highlightBlock(const QString &text);
    1.46 +
    1.47 +private:
    1.48 +    struct HighlightingRule
    1.49 +    {
    1.50 +        QRegExp pattern;
    1.51 +        QTextCharFormat format;
    1.52 +    };
    1.53 +    QVector<HighlightingRule> highlightingRules;
    1.54 +
    1.55 +    QRegExp commentStartExpression;
    1.56 +    QRegExp commentEndExpression;
    1.57 +
    1.58 +    QTextCharFormat keywordFormat;
    1.59 +    QTextCharFormat classFormat;
    1.60 +    QTextCharFormat singleLineCommentFormat;
    1.61 +    QTextCharFormat multiLineCommentFormat;
    1.62 +    QTextCharFormat quotationFormat;
    1.63 +    QTextCharFormat functionFormat;
    1.64 +};
    1.65 +
    1.66 +#endif