File indexing completed on 2024-05-12 17:11:42
0001 /*************************************************************************** 0002 * Copyright (C) 2014 by Renaud Guezennec * 0003 * http://www.rolisteam.org/ * 0004 * * 0005 * This file is part of rcse * 0006 * * 0007 * rcse is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 * rcse is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 ***************************************************************************/ 0022 0023 #ifndef QMLJSHIGHLIGHTER_H 0024 #define QMLJSHIGHLIGHTER_H 0025 0026 #include <QSyntaxHighlighter> 0027 #include <QRegularExpression> 0028 0029 class QmlHighlighter : public QSyntaxHighlighter 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 QmlHighlighter(QTextDocument *parent = 0); 0035 0036 protected: 0037 struct HighlightingRule 0038 { 0039 QRegularExpression pattern; 0040 QTextCharFormat format; 0041 }; 0042 void highlightBlock(const QString &text); 0043 0044 void loadDictionary(QString filepath, HighlightingRule& rule); 0045 private: 0046 QVector<HighlightingRule> m_highlightingRules; 0047 0048 QTextCharFormat keywordFormat; 0049 QTextCharFormat propertyFormat; 0050 QTextCharFormat lookupFormat; 0051 QTextCharFormat quotationFormat; 0052 QTextCharFormat itemFormat; 0053 QTextCharFormat cppObjectFormat; 0054 QTextCharFormat commentFormat; 0055 }; 0056 #endif // QMLJSHIGHLIGHTER_H