Skip to content

Commit

Permalink
Fix syntax highlighting after exception
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and nyalldawson committed Sep 30, 2024
1 parent a05e55b commit 8981b49
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python/console/console_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

class writeOut(QObject):
ERROR_COLOR = "#e31a1c"
ERROR_STYLE_INDEX = 16

def __init__(self, shellOut, out=None, style=None):
"""
Expand All @@ -61,13 +62,14 @@ def write(self, m):
if self.style == "_traceback":
# Show errors in red
stderrColor = QColor(QgsSettings().value("pythonConsole/stderrFontColor", QColor(self.ERROR_COLOR)))
self.sO.SendScintilla(QsciScintilla.SCI_STYLESETFORE, 0o01, stderrColor)
self.sO.SendScintilla(QsciScintilla.SCI_STYLESETITALIC, 0o01, True)
self.sO.SendScintilla(QsciScintilla.SCI_STYLESETBOLD, 0o01, True)
pos = self.sO.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
self.sO.SendScintilla(QsciScintilla.SCI_STARTSTYLING, pos, 31)
self.sO.SendScintilla(QsciScintilla.SCI_STYLESETFORE, self.ERROR_STYLE_INDEX, stderrColor)
self.sO.SendScintilla(QsciScintilla.SCI_STYLESETITALIC, self.ERROR_STYLE_INDEX, True)
self.sO.SendScintilla(QsciScintilla.SCI_STYLESETBOLD, self.ERROR_STYLE_INDEX, True)
pos = self.sO.linearPosition()
self.sO.SendScintilla(QsciScintilla.SCI_STARTSTYLING, pos, 0)
self.sO.append(m)
self.sO.SendScintilla(QsciScintilla.SCI_SETSTYLING, len(m), 0o01)
self.sO.SendScintilla(QsciScintilla.SCI_SETSTYLING, len(m), self.ERROR_STYLE_INDEX)

else:
self.sO.append(m)

Expand Down

0 comments on commit 8981b49

Please sign in to comment.