43 self.setCurrentBlockState(0)
45 if text.trimmed().isEmpty():
52 if self.previousBlockState() != 1:
60 while startIndex >= 0:
65 self.setCurrentBlockState(1)
66 commentLength = text.length() - startIndex
68 commentLength = endIndex - startIndex + \
74 startIndex + commentLength)
78 for expression, format
in self.
rules:
80 index = expression.indexIn(text, start)
81 while index >= start
and index < finish:
82 length = expression.matchedLength()
83 self.setFormat(index, min(length, finish - index), format)
84 index = expression.indexIn(text, index + length)
93 self.
keywordFormat.setForeground(QtCore.Qt.GlobalColor.darkBlue)
98 self.
magicFormat.setForeground(QtGui.QColor(224, 128, 0))
100 self.
qtFormat.setForeground(QtCore.Qt.GlobalColor.blue)
101 self.
qtFormat.setFontWeight(QtGui.QFont.Weight.Bold)
103 self.
selfFormat.setForeground(QtCore.Qt.GlobalColor.red)
109 QtGui.QBrush(QtGui.QColor(127, 127, 255)))
118 self.
rules += map(
lambda s: (QtCore.QRegularExpression(
r"\b" + s +
r"\b"),
121 self.
rules.append((QtCore.QRegularExpression(
r"\b[A-Za-z_]+\(.*\)"), self.
callableFormat))
122 self.
rules.append((QtCore.QRegularExpression(
r"\b__[a-z]+__\b"), self.
magicFormat))
123 self.
rules.append((QtCore.QRegularExpression(
r"\bself\b"), self.
selfFormat))
124 self.
rules.append((QtCore.QRegularExpression(
r"\bQ([A-Z][a-z]*)+\b"), self.
qtFormat))