# HG changeset patch
# User Peter Demcak <
majs...@gmail.com>
# Date 1772737138 -3600
# Thu Mar 05 19:58:58 2026 +0100
# Node ID 14c976e0c44030e3eb9c560d0428411a07888a3d
# Parent 4ff067cd6020d6635b8237f57912512d9feb0482
cmdui, docklog: apply dark theme to console and log widgets
Add _apply_dark_console_markers() in cmdui.LogWidget to override
error/warning/control marker colors.
Apply THEME colors to docklog console Scintilla paper, text, selection, caret,
prompt marker.
diff -r 4ff067cd6020 -r 14c976e0c440 tortoisehg/hgqt/cmdui.py
--- a/tortoisehg/hgqt/cmdui.py Thu Mar 05 19:58:41 2026 +0100
+++ b/tortoisehg/hgqt/cmdui.py Thu Mar 05 19:58:58 2026 +0100
@@ -52,6 +52,8 @@
qscilib,
)
+from .theme import THEME
+
def startProgress(topic, status):
topic, item, pos, total, unit = topic, '...', status, None, ''
@@ -229,6 +231,10 @@
self.setWrapMode(QsciScintilla.WrapMode.WrapCharacter)
self._initfont()
self._initmarkers()
+
+ if THEME.enabled:
+ self._apply_dark_console_markers()
+
qscilib.unbindConflictedKeys(self)
def _initfont(self):
@@ -250,6 +256,12 @@
# NOTE: self.setMarkerForegroundColor() doesn't take effect,
# because it's a *Background* marker.
+ def _apply_dark_console_markers(self):
+ self.setMarkerBackgroundColor(THEME.ui_error, self._markers.get('ui.error'))
+ self.setMarkerBackgroundColor(THEME.ui_warning, self._markers.get('ui.warning'))
+ self.setMarkerBackgroundColor(THEME.ui_control, self._markers.get('control'))
+
+
@pyqtSlot(str, str)
def appendLog(self, msg: str, label: str):
"""Append log text to the last line; scrolls down to there"""
diff -r 4ff067cd6020 -r 14c976e0c440 tortoisehg/hgqt/docklog.py
--- a/tortoisehg/hgqt/docklog.py Thu Mar 05 19:58:41 2026 +0100
+++ b/tortoisehg/hgqt/docklog.py Thu Mar 05 19:58:58 2026 +0100
@@ -45,6 +45,8 @@
qtlib,
)
+from .theme import THEME
+
class _LogWidgetForConsole(cmdui.LogWidget):
"""Wrapped LogWidget for ConsoleWidget"""
@@ -57,8 +59,52 @@
def __init__(self, parent=None):
super().__init__(parent)
- self._prompt_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
- self.setMarkerBackgroundColor(QColor('#e8f3fe'), self._prompt_marker)
+
+ if THEME.enabled:
+ # Override light 'control' marker from cmdui.LogWidget
+ if hasattr(self, '_markers') and 'control' in self._markers:
+ self.setMarkerBackgroundColor(THEME.background, self._markers['control'])
+ # Make sure the existing 'control' marker used by _setmarker(..., 'control')
+ # has dark background.
+ m = None
+ for attr in ('_markers', '_markerids', '_markermap'):
+ d = getattr(self, attr, None)
+ if isinstance(d, dict) and 'control' in d:
+ m = d['control']
+ break
+ if m is not None:
+ self.setMarkerBackgroundColor(THEME.background, m)
+
+ control_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
+ self.setMarkerBackgroundColor(THEME.background, control_marker)
+
+ # LogWidget-specific styles (used by appendLog labels)
+ for style in (
+ QsciScintilla.STYLE_LINENUMBER,
+ QsciScintilla.STYLE_BRACELIGHT,
+ QsciScintilla.STYLE_BRACEBAD,
+ QsciScintilla.STYLE_CONTROLCHAR,
+ QsciScintilla.STYLE_INDENTGUIDE,
+ ):
+ self.SendScintilla(QsciScintilla.SCI_STYLESETBACK, style, THEME.background)
+ self.SendScintilla(QsciScintilla.SCI_STYLESETFORE, style, THEME.text)
+
+ # Basic widget colors
+ self.setPaper(THEME.background)
+ self.setColor(THEME.text)
+ self.setSelectionBackgroundColor(THEME.selection_background)
+ self.setSelectionForegroundColor(THEME.selection_text)
+ self.setCaretForegroundColor(THEME.caret_foreground)
+
+ # Prompt line marker background (was light blue)
+ # We'll set it after marker is created (see below)
+ self._prompt_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
+ self.setMarkerBackgroundColor(THEME.backgroundLighter, self._prompt_marker)
+ else:
+ self._prompt_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
+ self.setMarkerBackgroundColor(QColor('#e8f3fe'), self._prompt_marker)
+
+
self.cursorPositionChanged.connect(self._updatePrompt)
# ensure not moving prompt line even if completion list get shorter,
# by allowing to scroll one page below the last line