| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef GAMESSHIGHLIGHTER_H |
| 7 |
#define GAMESSHIGHLIGHTER_H |
| 8 |
|
| 9 |
#include <QSyntaxHighlighter> |
| 10 |
|
| 11 |
#include <QRegularExpression> |
| 12 |
#include <QStringList> |
| 13 |
#include <QTextCharFormat> |
| 14 |
|
| 15 |
class QTextDocument; |
| 16 |
|
| 17 |
namespace Avogadro { |
| 18 |
namespace QtPlugins { |
| 19 |
|
| 20 |
class GamessHighlighter : public QSyntaxHighlighter |
| 21 |
{ |
| 22 |
Q_OBJECT |
| 23 |
|
| 24 |
public: |
| 25 |
GamessHighlighter(QTextDocument* parent_ = nullptr); |
| 26 |
|
| 27 |
protected: |
| 28 |
void highlightBlock(const QString& text) override; |
| 29 |
|
| 30 |
private: |
| 31 |
struct HighlightingRule |
| 32 |
{ |
| 33 |
QRegularExpression pattern; |
| 34 |
QTextCharFormat format; |
| 35 |
}; |
| 36 |
QVector<HighlightingRule> m_highlightingRules; |
| 37 |
|
| 38 |
QStringList m_keywords; |
| 39 |
|
| 40 |
QRegularExpression m_commentStartExpression; |
| 41 |
QRegularExpression m_commentEndExpression; |
| 42 |
|
| 43 |
QTextCharFormat m_keywordFormat; |
| 44 |
QTextCharFormat m_numberFormat; |
| 45 |
QTextCharFormat m_singleLineCommentFormat; |
| 46 |
QTextCharFormat m_inDataBlockFormat; |
| 47 |
QTextCharFormat m_errorFormat; |
| 48 |
}; |
| 49 |
|
| 50 |
} // End namespace QtPlugins |
| 51 |
} // End namespace Avogadro |
| 52 |
|
| 53 |
#endif // GAMESSHIGHLIGHTER_H |