0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 00:18:06 +03:00

Script highlighter has been finished

This commit is contained in:
Arin Alexander
2017-09-19 19:05:38 +03:00
parent aa66b6a057
commit f4dbddafad
6 changed files with 295 additions and 22 deletions

View File

@@ -5,13 +5,46 @@
namespace LimeReport{
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;
};
class ScriptHighlighter : QSyntaxHighlighter{
public:
ScriptHighlighter(QTextDocument* parent): QSyntaxHighlighter(parent){}
// QSyntaxHighlighter interface
ScriptHighlighter(QTextDocument* parent);
protected:
void highlightBlock(const QString& text);
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);
};
}
#endif // LRSCRIPTHIGHLIGHTER_H