Skip to content

[209_17] Added separate light and dark mode color schemes for Python#2979

Open
1sh-repalto wants to merge 3 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/209_17/add-seperate-dark-colour-schemes-for-python
Open

[209_17] Added separate light and dark mode color schemes for Python#2979
1sh-repalto wants to merge 3 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/209_17/add-seperate-dark-colour-schemes-for-python

Conversation

@1sh-repalto
Copy link
Contributor

@1sh-repalto 1sh-repalto commented Mar 13, 2026

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

Summary

This new approach creates seperate colour schemes for light and dark mode. It also aligns with Mogan's native styling system, allowing for instant theme updates, side-by-side theme support, and better performance.

Developer Document: devel/209_17.md

Issues Found

The previous implementation used a single set of colors for both light and dark modes.

Changes

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

  • Replaced hardcoded color values in define-preferences with symbolic variable names (e.g., syntax-python-keyword).
  • Added a notify-python-pref callback to handle real-time preference updates.
  • Simplified the module by removing imperative theme-switching Scheme logic.

In TeXmacs/plugins/python/packages/code/python.ts:

  • Defined the default (light) values for all syntax-python-* variables.

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

  • Defined the dark-mode overrides for the same syntax-python-* variables.

How to Test

  1. Open Mogan and write some Python code in a code block or session.
  2. Toggle between Document -> Theme -> Dark and Document -> Theme -> Plain.
  3. Verify that the syntax highlighting colors update instantly and remain legible in both themes.
seperate_dark_color_scheme.mp4

Light Mode

image

Dark Mode

Screenshot 2026-03-13 175104

@Yuki-Nagori
Copy link
Contributor

@1sh-repalto Thank you for your code, I reviewed it and it is correct, but you need to add a test document in tests/tmu/, after that we can merge it!

@1sh-repalto
Copy link
Contributor Author

Hello @Yuki-Nagori , I have added the test file TeXmacs/tests/tmu/209_17.tmu. Please let me know if further changes are needed. Thanks!

I verified the document loads and renders perfectly by running:
TEXMACS_PATH=$PWD/TeXmacs ./build/linux/x86_64/release/moganstem TeXmacs/tests/tmu/209_17.tmu

image

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.

2 participants