Skip to content

feat(themes): support "none" color for the terminal default - #1126

Open
ChrisJr404 wants to merge 1 commit into
alexpasmantier:mainfrom
ChrisJr404:feat/theme-none-color
Open

feat(themes): support "none" color for the terminal default#1126
ChrisJr404 wants to merge 1 commit into
alexpasmantier:mainfrom
ChrisJr404:feat/theme-none-color

Conversation

@ChrisJr404

Copy link
Copy Markdown

📺 PR Description

This adds a "none" pseudo-color that maps to the terminal's default color, so a theme (or a theme_overrides entry) can leave an element uncolored instead of forcing a concrete color. It closes #1103.

The motivation is transparency: when you start from a builtin theme but want the background to fall through to your terminal emulator (which may be transparent), there was previously no way to express that through an override — every value had to be a concrete ANSI or hex color. background = "none" now keeps the terminal's own background. The same works for any foreground field if you'd rather inherit the terminal default there too.

Under the hood this is a new Color::Reset variant that resolves to ratatui's Color::Reset. Parsing goes through the single Color::from_str used by both theme files and overrides, so both paths pick it up. "none" is the primary spelling; "default" and "reset" are accepted as aliases. Existing themes are unaffected — no builtin uses these words.

Docs: added a line to the theme color reference in docs/user-guide/05-themes.md.

Checklist

  • my commits and PR title follow the conventional commits format
  • if this is a new feature, I have added tests to consolidate the feature and prevent regressions
  • if this is a bug fix, I have added a test that reproduces the bug (if applicable)
  • I have added a reasonable amount of documentation to the code where appropriate

Tests

Added four unit tests in config::themes: "none"/"default"/"reset" (case-insensitive) parse to Color::Reset; Color::Reset converts to ratatui::style::Color::Reset; background = "none" deserializes from a theme file; and an override of background = "none" merges correctly. cargo test --lib themes passes (11/11), and cargo fmt --check / cargo clippy --lib are clean.

Add a "none" pseudo-color (also accepted as "default"/"reset") that maps to
ratatui's Color::Reset, so a theme or an override can leave an element uncolored
and fall back to the terminal's default. This makes it possible to keep a
transparent background when overriding a builtin theme, e.g.

    [ui.theme_overrides]
    background = "none"

Closes alexpasmantier#1103
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.

Provide a way to unset color

1 participant