41 : QSyntaxHighlighter(parent)
106 braces = QStringList() <<
"{"
132 for (
const QString& currKeyword :
keywords) {
136 for (
const QString& currOperator :
operators) {
140 for (
const QString& currBrace :
braces)
170 R
"(\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b)", 0,
177 int idx = currRule.pattern.indexIn(text, 0);
180 idx = currRule.pattern.pos(currRule.nth);
181 int length = currRule.pattern.cap(currRule.nth).length();
182 setFormat(idx, length, currRule.format);
183 idx = currRule.pattern.indexIn(text, idx + length);
186 setCurrentBlockState(0);
194 const int inState,
const QTextCharFormat& style)
202 if (previousBlockState() == inState) {
208 start = delimiter.indexIn(text);
210 add = delimiter.matchedLength();
215 end = delimiter.indexIn(text, start + add);
218 length = end - start + add + delimiter.matchedLength();
219 setCurrentBlockState(0);
223 setCurrentBlockState(inState);
224 length = text.length() - start + add;
227 setFormat(start, length, style);
228 start = delimiter.indexIn(text, start + length);
231 return currentBlockState() == inState;
235 const QString& style)
237 QTextCharFormat charFormat;
238 QColor color(colorName);
239 charFormat.setForeground(color);
240 if (style.contains(
"bold", Qt::CaseInsensitive))
241 charFormat.setFontWeight(QFont::Bold);
242 if (style.contains(
"italic", Qt::CaseInsensitive))
243 charFormat.setFontItalic(
true);
Defines class PythonSyntaxHighlighter.
Container to describe a highlighting rule. Based on a regular expression, a relevant match # and the ...
PythonSyntaxHighlighter(QTextDocument *parent=nullptr)
void highlightBlock(const QString &text) override
QHash< QString, QTextCharFormat > basicStyles
bool matchMultiline(const QString &text, const QRegExp &delimiter, int inState, const QTextCharFormat &style)
Highlighst multi-line strings, returns true if after processing we are still within the.
QTextCharFormat getTextCharFormat(const QString &colorName, const QString &style="")
QList< HighlightingRule > rules