105 braces = QStringList() <<
"{"
131 for (QString currKeyword :
keywords) {
139 for (QString currBrace :
braces) {
171 "\\b[+-]?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b", 0,
178 int idx = currRule.pattern.indexIn(text, 0);
181 idx = currRule.pattern.pos(currRule.nth);
182 int length = currRule.pattern.cap(currRule.nth).length();
183 setFormat(idx, length, currRule.format);
184 idx = currRule.pattern.indexIn(text, idx + length);
187 setCurrentBlockState(0);
195 const int inState,
const QTextCharFormat& style)
203 if (previousBlockState() == inState) {
209 start = delimiter.indexIn(text);
211 add = delimiter.matchedLength();
216 end = delimiter.indexIn(text, start + add);
219 length = end - start + add + delimiter.matchedLength();
220 setCurrentBlockState(0);
224 setCurrentBlockState(inState);
225 length = text.length() - start + add;
228 setFormat(start, length, style);
229 start = delimiter.indexIn(text, start + length);
232 if (currentBlockState() == inState)
239 const QString& style)
241 QTextCharFormat charFormat;
242 QColor color(colorName);
243 charFormat.setForeground(color);
244 if (style.contains(
"bold", Qt::CaseInsensitive))
245 charFormat.setFontWeight(QFont::Bold);
246 if (style.contains(
"italic", Qt::CaseInsensitive))
247 charFormat.setFontItalic(
true);
Defines class PythonSyntaxHighlighter.
Container to describe a highlighting rule.
void highlightBlock(const QString &text)
const QTextCharFormat getTextCharFormat(const QString &colorName, const QString &style="")
QHash< QString, QTextCharFormat > basicStyles
bool matchMultiline(const QString &text, const QRegExp &delimiter, const int inState, const QTextCharFormat &style)
Highlighst multi-line strings, returns true if after processing we are still within the.
PythonSyntaxHighlighter(QTextDocument *parent=0)
QList< HighlightingRule > rules