Skip to content

[209_16] Fixes dark mode syntax highlighting for python#2961

Merged
wumoin merged 3 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/209_16/fix-dark-mode-visibility-python
Mar 10, 2026
Merged

[209_16] Fixes dark mode syntax highlighting for python#2961
wumoin merged 3 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/209_16/fix-dark-mode-visibility-python

Conversation

@1sh-repalto
Copy link
Copy Markdown
Contributor

Fixes #2553
In the dark theme, the syntax highlighting for languages such as Python is also difficult to see.

Summary

  1. Adjusted the syntax highlighting colors for the Python plugin (python-lang.scm) to use lighter color variants that are clearly legible on both light and dark backgrounds.
  2. Modified opacity of focus-color in (dark.ts) from (#3A86FF) to (#3A86FF33) so that the active line marker no longer completely blocks text when a dark theme is active.

Developer Document: devel/209_16.md

Issues Found

  1. With the dark theme enabled, several syntax colors mapped in the Python language definition were illegible or had contrast issues against the dark gray background.
  2. The active line of code feature generated an opaque background because its hexadecimal color was missing transparency, rendering the text on the active line invisible.

Changes

In TeXmacs/plugins/python/progs/code/python-lang.scm:

  • Updated define-preferences hex values and named color mappings to use bright, pastel versions of the original colors.

In TeXmacs/packages/themes/dark/dark.ts:

  • Replaced the opaque focus-color assignment with an 8-character hex code specifying ~20% opacity.
-  <assign|focus-color|##3A86FF>
+  <assign|focus-color|##3A86FF33>

How to Test

  1. Open Mogan and enable the dark GUI theme(Document -> Theme -> Dark).
  2. Start a Python session (Insert -> Session -> Python) or write Python code block.
  3. Verify that the new syntax highlighting is easily readable.
  4. Move the cursor across different lines to see that the active line highlight (focus-color) acts as a translucent overlay rather than an opaque block.
  5. Disable the dark theme and verify that the syntax highlighting colors still provide sufficient contrast on the default light background.

Before (Dark Theme)

Screenshot 2026-03-08 223947

After (Dark Theme)

Screenshot 2026-03-08 223221

Before (Light Theme)

Screenshot 2026-03-08 224032

After (Light Theme)

Screenshot 2026-03-08 224318

Before (Active Code Line)

Screenshot 2026-03-08 224944

After (Active Code Line)

Screenshot 2026-03-08 225325

@git-lakshy
Copy link
Copy Markdown
Contributor

@1sh-repalto , hello I was already working on this issue …

@1sh-repalto
Copy link
Copy Markdown
Contributor Author

Hi @git-lakshy , I asked in the comment section of the issue if you're still working on it. Since I got no reply for a day, I took this issue. You can still open a PR and we'll let the rest for maintainers to decide.

@git-lakshy
Copy link
Copy Markdown
Contributor

That would be inefficient, your fix seems to be working just fine.
But I have been actively contributing too just like you so you could’ve discussed this, and 1 day is not a long time in Open Source.. but yeah no issues I will take some other issue now 👍

@1sh-repalto
Copy link
Copy Markdown
Contributor Author

My apologies, I didn't intend to overlap with your work. I appreciate your contributions and wish you the best with other issues.

@wumoin wumoin merged commit e564d4d into MoganLab:main Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

在dark theme 下 Python 等语言的高亮也会看不清楚

3 participants