Ansi themes#6513
Merged
willmcgugan merged 19 commits intomainfrom Apr 30, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6490
Added two ANSI themes; ansi-dark and ansi-light.
A theme can now explicitly declare itself as an ANSI theme, which will prevent ANSI colors from being promoted to true-color. This means that here is probably no reason to set
ansi_coloron the app constructor any more. ANSI and truecolor themes can co-exist in the same app.Fixed an issue related to the ordering of text spans that impacted selection.
ANSI themes
Previously the App constructor accept an
ansi_colorboolean.ansi_colorFalseTrueansi_colormay now also beNonewhich will cause the app to use the value ofansiset on the Theme. Most apps should leaveansi_coloras the default (None).This allows for explicit ANSI themes. ANSI tends to be an all or nothing thing. If you mix RGB colors with ANSI colors you have no way of knowing if your colors + user colors will be legible.
There are two new themes: ansi-light and ansi-dark. Users with a dark terminal theme should pick
ansi-dark, users with a light terminal theme should pickansi-light.Customizing ANSI themes
Default widgets should work with ANSI themes (open an issue if something breaks), but if you may still want customizations for ANSI only. To do this, you can use the
:ansipseudo class.The most straightforward way of doing this is to add a single
App:ansirule to your stylesheet with ANSI specific rules. Something like the following:This should ensure that the rules have greater specificity.