From 14f9f60dcc0cebaaeb15a7e25db222be63e9f7e0 Mon Sep 17 00:00:00 2001 From: silvialpz <74107990+silvialpz@users.noreply.github.com> Date: Tue, 20 Jan 2026 11:37:15 -0600 Subject: [PATCH 1/5] osltoy code editor: make cursor highlighted line text always black for readability in dark mode Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com> --- src/osltoy/codeeditor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osltoy/codeeditor.cpp b/src/osltoy/codeeditor.cpp index d70ccc810b..c831258b50 100644 --- a/src/osltoy/codeeditor.cpp +++ b/src/osltoy/codeeditor.cpp @@ -177,8 +177,10 @@ CodeEditor::highlightCurrentLine() QTextEdit::ExtraSelection selection; QColor lineColor = QColor(Qt::yellow).lighter(160); + QColor textColor = QColor(Qt::black); selection.format.setBackground(lineColor); + selection.format.setForeground(textColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.cursor = textCursor(); selection.cursor.clearSelection(); From 80f3b2f3573a0bad673f10db0c487bbcc80945ec Mon Sep 17 00:00:00 2001 From: silvialpz <74107990+silvialpz@users.noreply.github.com> Date: Tue, 20 Jan 2026 12:00:25 -0600 Subject: [PATCH 2/5] setting tab stops to be 4 chars wide Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com> --- src/osltoy/codeeditor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osltoy/codeeditor.cpp b/src/osltoy/codeeditor.cpp index c831258b50..80f8e23114 100644 --- a/src/osltoy/codeeditor.cpp +++ b/src/osltoy/codeeditor.cpp @@ -53,6 +53,8 @@ CodeEditor::CodeEditor(QWidget* parent, const std::string& filename) setLineWrapMode(QPlainTextEdit::NoWrap); document()->setDefaultFont(fixedFont()); + setTabStopDistance(4 * char_width_pixels()); + lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, From a37a22b8bc886e4e7c3aef53e4bb31a861c85d16 Mon Sep 17 00:00:00 2001 From: silvialpz <74107990+silvialpz@users.noreply.github.com> Date: Tue, 20 Jan 2026 16:32:26 -0600 Subject: [PATCH 3/5] changing char_width_pixels to be using fixedFont() Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com> --- src/osltoy/codeeditor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/osltoy/codeeditor.cpp b/src/osltoy/codeeditor.cpp index 80f8e23114..7387278083 100644 --- a/src/osltoy/codeeditor.cpp +++ b/src/osltoy/codeeditor.cpp @@ -53,8 +53,6 @@ CodeEditor::CodeEditor(QWidget* parent, const std::string& filename) setLineWrapMode(QPlainTextEdit::NoWrap); document()->setDefaultFont(fixedFont()); - setTabStopDistance(4 * char_width_pixels()); - lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, @@ -66,6 +64,7 @@ CodeEditor::CodeEditor(QWidget* parent, const std::string& filename) updateLineNumberAreaWidth(0); highlightCurrentLine(); + setTabStopDistance(4 * char_width_pixels()); } @@ -100,11 +99,12 @@ CodeEditor::text_string() const int CodeEditor::char_width_pixels() const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - return fontMetrics().horizontalAdvance(QLatin1Char('M')); + QFontMetrics metrics(fixedFont()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + return metrics.horizontalAdvance(QLatin1Char('M')); #else // QFontMetric.width() deprecated from 5.11, marked as such in 5.13 - return fontMetrics().width(QLatin1Char('M')); + return metrics.width(QLatin1Char('M')); #endif } From f120a4e9dd989b0839d6f9b2deab4d9961edfc7a Mon Sep 17 00:00:00 2001 From: silvialpz <74107990+silvialpz@users.noreply.github.com> Date: Tue, 20 Jan 2026 17:04:52 -0600 Subject: [PATCH 4/5] clang-format Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com> --- src/osltoy/codeeditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osltoy/codeeditor.cpp b/src/osltoy/codeeditor.cpp index 7387278083..896407331f 100644 --- a/src/osltoy/codeeditor.cpp +++ b/src/osltoy/codeeditor.cpp @@ -100,7 +100,7 @@ int CodeEditor::char_width_pixels() const { QFontMetrics metrics(fixedFont()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) return metrics.horizontalAdvance(QLatin1Char('M')); #else // QFontMetric.width() deprecated from 5.11, marked as such in 5.13 From 70d4c16370a7c34dd82ff2b36adb5378d3c119d1 Mon Sep 17 00:00:00 2001 From: silvialpz <74107990+silvialpz@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:40:05 -0600 Subject: [PATCH 5/5] isolating the highlighted text change Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com> --- src/osltoy/codeeditor.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/osltoy/codeeditor.cpp b/src/osltoy/codeeditor.cpp index 896407331f..c831258b50 100644 --- a/src/osltoy/codeeditor.cpp +++ b/src/osltoy/codeeditor.cpp @@ -64,7 +64,6 @@ CodeEditor::CodeEditor(QWidget* parent, const std::string& filename) updateLineNumberAreaWidth(0); highlightCurrentLine(); - setTabStopDistance(4 * char_width_pixels()); } @@ -99,12 +98,11 @@ CodeEditor::text_string() const int CodeEditor::char_width_pixels() const { - QFontMetrics metrics(fixedFont()); #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - return metrics.horizontalAdvance(QLatin1Char('M')); + return fontMetrics().horizontalAdvance(QLatin1Char('M')); #else // QFontMetric.width() deprecated from 5.11, marked as such in 5.13 - return metrics.width(QLatin1Char('M')); + return fontMetrics().width(QLatin1Char('M')); #endif }