Skip to content

Allow disabling the command bar background - #3020

Open
ChrisJr404 wants to merge 1 commit into
gitui-org:masterfrom
ChrisJr404:cmdbar-bg-optional
Open

Allow disabling the command bar background#3020
ChrisJr404 wants to merge 1 commit into
gitui-org:masterfrom
ChrisJr404:cmdbar-bg-optional

Conversation

@ChrisJr404

Copy link
Copy Markdown

Fixes #3011. Makes cmdbar_bg an Option<Color> so a theme can turn the command bar background fill off and let the terminal show through, which is what you want with an opacity/blur setup.

Themes get applied as a patch through struct_patch, which wraps the field again, so on disk the type is effectively Option<Option<Color>>. To actually clear the fill you set cmdbar_bg: Some(None). A bare cmdbar_bg: None reads as "leave the default alone" (same as omitting any field), so Some(None) is the value that disables it. When the field ends up None the command bar style just doesn't set a bg. The default stays Some(Blue), so any theme that doesn't touch it renders exactly like before.

The one thing that needed care was backward compat. Themes written before this, or hand-written following THEMES.md, have cmdbar_bg: Some("SomeColor"), and that wouldn't parse against the new nested option. So there's a small deserialize_with on the patch field that accepts the legacy Some("Color") form as well as the new Some(Some("Color")) / Some(None).

Tests in src/ui/style.rs cover: the default still filling blue, Some(None) clearing the bg, the legacy Some("Color") form still parsing, the nested form, and a round-trip back through into_patch_by_diff (which serializes unchanged fields as None, so I wanted to be sure an untouched cmdbar_bg survives a save/reload without turning transparent). make check (fmt + clippy + test, 85 tests) passes. Docs and changelog updated.

I wasn't sure whether you'd prefer this or the disable_cmdbar_bg: bool alternative from the issue, happy to switch if that reads cleaner to you.

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.

Feature: Theme option to make cmdbar_bg transparent

1 participant