LimeReport/limereport/scripteditor/lrscripthighlighter.h

51 lines
1.1 KiB
C
Raw Normal View History

2017-09-16 16:04:29 +03:00
#ifndef LRSCRIPTHIGHLIGHTER_H
#define LRSCRIPTHIGHLIGHTER_H
#include <QSyntaxHighlighter>
namespace LimeReport{
2017-09-19 19:05:38 +03:00
enum ParenthesisType {LeftParenthesis, RightParenthesis, ParenthesisTypeCount};
#define PARENHEIS_COUNT 3
const QChar parenthesisCharacters[ParenthesisTypeCount][PARENHEIS_COUNT] = {
{'(', '{', '['},
{')', '}', ']'}
};
struct ParenthesisInfo
{
char character;
int position;
};
class TextBlockData : public QTextBlockUserData
{
public:
TextBlockData(){}
QVector<ParenthesisInfo *> parentheses();
void insert(ParenthesisInfo *info);
private:
QVector<ParenthesisInfo *> m_parentheses;
};
2017-09-16 16:04:29 +03:00
class ScriptHighlighter : QSyntaxHighlighter{
public:
2017-09-19 19:05:38 +03:00
ScriptHighlighter(QTextDocument* parent);
2017-09-16 16:04:29 +03:00
protected:
void highlightBlock(const QString& text);
2017-09-19 19:05:38 +03:00
enum ScriptFormats {
NumberFormat, StringFormat, KeywordFormat,
CommentFormat, FormatsCount
};
QTextCharFormat m_formats[FormatsCount];
bool isKeyWord(const QString& word);
bool isDark(QColor color);
void createParentheisisInfo(const char& literal, TextBlockData *data, const QString& text);
2017-09-16 16:04:29 +03:00
};
2017-09-19 19:05:38 +03:00
2017-09-16 16:04:29 +03:00
}
#endif // LRSCRIPTHIGHLIGHTER_H