From 1b948b339d70e916dc8d12314430fa5f5dc7c3a0 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 1c3aafba395a77bda97f8c52019178a3775e4edc 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 7b80b05001ceee7803c608ca7482f929644de5eb 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 9ef817035116b7a9ff1e2644a6f5ba3025b7415a 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 df3c9e7dba3c626c355cb15101439725af175315 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 }