mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make colors used by python highlighter work with dark theme as well
This commit is contained in:
parent
307680a019
commit
e9780b2a35
@ -856,16 +856,14 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initializeFormats(cls):
|
def initializeFormats(cls):
|
||||||
if cls.Formats:
|
|
||||||
return
|
|
||||||
baseFormat = QTextCharFormat()
|
baseFormat = QTextCharFormat()
|
||||||
baseFormat.setFontFamily('monospace')
|
baseFormat.setFontFamily('monospace')
|
||||||
baseFormat.setFontPointSize(11)
|
p = QApplication.instance().palette()
|
||||||
for name, color, bold, italic in (
|
for name, color, bold, italic in (
|
||||||
("normal", "#000000", False, False),
|
("normal", None, False, False),
|
||||||
("keyword", "#000080", True, False),
|
("keyword", p.color(p.Link).name(), True, False),
|
||||||
("builtin", "#0000A0", False, False),
|
("builtin", p.color(p.Link).name(), False, False),
|
||||||
("constant", "#0000C0", False, False),
|
("constant", p.color(p.Link).name(), False, False),
|
||||||
("decorator", "#0000E0", False, False),
|
("decorator", "#0000E0", False, False),
|
||||||
("comment", "#007F00", False, True),
|
("comment", "#007F00", False, True),
|
||||||
("string", "#808000", False, False),
|
("string", "#808000", False, False),
|
||||||
@ -874,7 +872,8 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
("pyqt", "#50621A", False, False)):
|
("pyqt", "#50621A", False, False)):
|
||||||
|
|
||||||
format = QTextCharFormat(baseFormat)
|
format = QTextCharFormat(baseFormat)
|
||||||
format.setForeground(QColor(color))
|
if color is not None:
|
||||||
|
format.setForeground(QColor(color))
|
||||||
if bold:
|
if bold:
|
||||||
format.setFontWeight(QFont.Bold)
|
format.setFontWeight(QFont.Bold)
|
||||||
format.setFontItalic(italic)
|
format.setFontItalic(italic)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user