File indexing completed on 2024-04-28 11:20:40

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2010 Oleksiy Protas <elfy.ua@gmail.com>
0004 */
0005 
0006 #ifndef _RHIGHLIGHTER_H
0007 #define _RHIGHLIGHTER_H
0008 
0009 #include "defaulthighlighter.h"
0010 
0011 #include <QRegExp>
0012 
0013 class RSession;
0014 
0015 class RHighlighter : public Cantor::DefaultHighlighter
0016 {
0017   Q_OBJECT
0018 
0019   public:
0020     explicit RHighlighter( QObject* parent, RSession* session);
0021     ~RHighlighter() override = default;
0022 
0023   protected:
0024     QStringList parseBlockTextToWords(const QString& text) override;
0025 
0026   private:
0027     inline void formatRule(const QRegExp &p, const QTextCharFormat &fmt, const QString& text,bool shift=false);
0028     inline void massFormat(const QVector<QRegExp>& rules, const QTextCharFormat &fmt, const QString& text,bool shift=false);
0029 
0030     static const QStringList operators_list;
0031     static const QStringList specials_list;
0032     QVector<QRegExp> operators;
0033     QVector<QRegExp> specials;
0034     QVector<QRegExp> functions;
0035     QVector<QRegExp> variables;
0036 };
0037 
0038 #endif /* _RHIGHLIGHTER_H */