#ifndef HIGLIGHTER_H
#define HIGLIGHTER_H

#include <QXmlDefaultHandler>
#include <QSyntaxHighlighter>
#include <QRegularExpressionMatchIterator>

class Lighter_class : public QSyntaxHighlighter, public QXmlDefaultHandler
{
    Q_OBJECT

    public:
        Lighter_class(QTextDocument *parent = 0);
        Lighter_class(QTextDocument *parent = 0, const QString& = "");
        bool startElement(const QString&, const QString&, const QString& tagName, const QXmlAttributes& attrs) override;
        bool characters(const QString& strText) override;
        bool endElement(const QString&, const QString&, const QString& str) override;
        bool fatalError(const QXmlParseException& exception) override;
    protected:
        void highlightBlock(const QString &text) override;

    private:
        struct HighlightingRule
        {
            QRegularExpression f_pattern;
            QTextCharFormat f_format;
        };

        QVector<HighlightingRule> f_highlightingRules;

        QRegularExpression f_commentStartExpression;
        QRegularExpression f_commentEndExpression;

        QTextCharFormat f_keywordFormat;
        QTextCharFormat f_classFormat;
        QTextCharFormat f_singleLineCommentFormat;
        QTextCharFormat f_multiLineCommentFormat;
        QTextCharFormat f_quotationFormat;
        QTextCharFormat f_functionFormat;

        bool f_isRightExt;
        QRegularExpression f_pattern;
        QString f_color;
        int f_fontWeight;

        QString f_currentText;
        QString f_currentExt;

};



#endif // HIGLIGHTER_H
