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