fix(config): map bonsai colors in eight-color fallback

When a config predates true-color mode (no RGB values present), the
migrator switches `full_color` off and remaps the legacy animations'
colors to 8-color palette indices. The new `bonsai_*` color fields were
absent from that remap, so their 24-bit RGB defaults were sent to a
terminal in 8-color output mode and rendered as the default foreground.

Extend `color_properties` and `lateConfigFieldHandler` so that, in
8-color fallback, leaf colors map to ECOL_GREEN (bright = bold) and wood
colors map to ECOL_YELLOW (bright = bold). User-provided RGB values for
any of these fields disable the 8-color heuristic, matching how the
existing animations behave.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
CM Geldenhuys 2026-05-04 20:02:15 +02:00
commit 81b068a4d1

View file

@ -28,10 +28,15 @@ const color_properties = [_][]const u8{
"error_bg",
"error_fg",
"fg",
"bonsai_leaf_dark",
"bonsai_leaf_bright",
"bonsai_wood_dark",
"bonsai_wood_bright",
"bonsai_text_color",
};
var set_color_properties =
[_]bool{ false, false, false, false, false, false, false, false, false };
[_]bool{false} ** color_properties.len;
const removed_properties = [_][]const u8{
"wayland_specifier",
@ -251,6 +256,11 @@ pub fn lateConfigFieldHandler(config: *Config) void {
if (!set_color_properties[6]) config.error_bg = Color.DEFAULT;
if (!set_color_properties[7]) config.error_fg = Styling.BOLD | Color.ECOL_RED;
if (!set_color_properties[8]) config.fg = Color.ECOL_WHITE;
if (!set_color_properties[9]) config.bonsai_leaf_dark = Color.ECOL_GREEN;
if (!set_color_properties[10]) config.bonsai_leaf_bright = Styling.BOLD | Color.ECOL_GREEN;
if (!set_color_properties[11]) config.bonsai_wood_dark = Color.ECOL_YELLOW;
if (!set_color_properties[12]) config.bonsai_wood_bright = Styling.BOLD | Color.ECOL_YELLOW;
if (!set_color_properties[13]) config.bonsai_text_color = Color.ECOL_WHITE;
}
}