highlighter.h
author insilmaril
Tue Mar 30 17:30:39 2010 +0000 (2010-03-30)
changeset 842 bec082472471
permissions -rw-r--r--
Much improved results in FindResultsWidget
insilmaril@436
     1
/****************************************************************************
insilmaril@436
     2
**
insilmaril@436
     3
** Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
insilmaril@436
     4
**
insilmaril@436
     5
** This file is part of the example classes of the Qt Toolkit.
insilmaril@436
     6
**
insilmaril@436
     7
** This file may be used under the terms of the GNU General Public
insilmaril@436
     8
** License version 2.0 as published by the Free Software Foundation
insilmaril@436
     9
** and appearing in the file LICENSE.GPL included in the packaging of
insilmaril@436
    10
** this file.  Please review the following information to ensure GNU
insilmaril@436
    11
** General Public Licensing requirements will be met:
insilmaril@436
    12
** http://www.trolltech.com/products/qt/opensource.html
insilmaril@436
    13
**
insilmaril@436
    14
** If you are unsure which license is appropriate for your use, please
insilmaril@436
    15
** review the following information:
insilmaril@436
    16
** http://www.trolltech.com/products/qt/licensing.html or contact the
insilmaril@436
    17
** sales department at sales@trolltech.com.
insilmaril@436
    18
**
insilmaril@436
    19
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
insilmaril@436
    20
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
insilmaril@436
    21
**
insilmaril@436
    22
****************************************************************************/
insilmaril@436
    23
insilmaril@436
    24
#ifndef HIGHLIGHTER_H
insilmaril@436
    25
#define HIGHLIGHTER_H
insilmaril@436
    26
insilmaril@436
    27
#include <QSyntaxHighlighter>
insilmaril@436
    28
insilmaril@436
    29
#include <QHash>
insilmaril@436
    30
#include <QTextCharFormat>
insilmaril@436
    31
insilmaril@436
    32
class QTextDocument;
insilmaril@436
    33
insilmaril@436
    34
class Highlighter : public QSyntaxHighlighter
insilmaril@436
    35
{
insilmaril@436
    36
    Q_OBJECT
insilmaril@436
    37
insilmaril@436
    38
public:
insilmaril@436
    39
    Highlighter(QTextDocument *parent = 0);
insilmaril@436
    40
insilmaril@436
    41
protected:
insilmaril@436
    42
    void highlightBlock(const QString &text);
insilmaril@436
    43
insilmaril@436
    44
private:
insilmaril@436
    45
    struct HighlightingRule
insilmaril@436
    46
    {
insilmaril@436
    47
        QRegExp pattern;
insilmaril@436
    48
        QTextCharFormat format;
insilmaril@436
    49
    };
insilmaril@436
    50
    QVector<HighlightingRule> highlightingRules;
insilmaril@436
    51
insilmaril@436
    52
    QRegExp commentStartExpression;
insilmaril@436
    53
    QRegExp commentEndExpression;
insilmaril@436
    54
insilmaril@436
    55
    QTextCharFormat keywordFormat;
insilmaril@436
    56
    QTextCharFormat classFormat;
insilmaril@436
    57
    QTextCharFormat singleLineCommentFormat;
insilmaril@436
    58
    QTextCharFormat multiLineCommentFormat;
insilmaril@436
    59
    QTextCharFormat quotationFormat;
insilmaril@436
    60
    QTextCharFormat functionFormat;
insilmaril@436
    61
};
insilmaril@436
    62
insilmaril@436
    63
#endif