diff --git a/private_dot_config/kitty/private_tests/private_test_tab_bar_colors.py b/private_dot_config/kitty/private_tests/private_test_tab_bar_colors.py index 1468b8a..8ecddac 100644 --- a/private_dot_config/kitty/private_tests/private_test_tab_bar_colors.py +++ b/private_dot_config/kitty/private_tests/private_test_tab_bar_colors.py @@ -87,7 +87,37 @@ for theme_bg in (0xF8F8F8, 0x1C2836): f"got {(actual_fg, actual_bg)!r}" ) +# Per-tab colors set by `kitten @ set-tab-color` (see fish __kitty_tab_set) +# must win over the accent, or ssh tabs all render in the same blue. +HOST_BG = 0x689D6A +HOST_FG = 0x000000 + +for theme_bg in (0xF8F8F8, 0x1C2836): + for tab, expected, label in ( + ( + TabBarData("tab", is_active=True, active_bg=HOST_BG, active_fg=HOST_FG), + (as_rgb(HOST_FG), as_rgb(HOST_BG)), + "active tab takes the host color", + ), + ( + TabBarData("tab", is_active=False, inactive_fg=HOST_BG), + (as_rgb(HOST_BG), as_rgb(theme_bg)), + "inactive tab keeps the theme background, host color as text", + ), + ): + screen = RecordingScreen() + renderer.draw_tab( + draw_data(theme_bg), screen, tab, 0, 1, 1, True, ExtraData() + ) + _, actual_fg, actual_bg = screen.draws[0] + if (actual_fg, actual_bg) != expected: + raise RuntimeError( + f"theme #{theme_bg:06x}, {label}: " + f"expected cursor colors {expected!r}, " + f"got {(actual_fg, actual_bg)!r}" + ) + print( "PASS: tab colors ignore theme-provided tab roles " - "for light and dark backgrounds" + "for light and dark backgrounds, and honor per-tab set-tab-color overrides" ) diff --git a/private_dot_config/kitty/tab_bar.py b/private_dot_config/kitty/tab_bar.py index 0e61082..11896ce 100644 --- a/private_dot_config/kitty/tab_bar.py +++ b/private_dot_config/kitty/tab_bar.py @@ -24,12 +24,12 @@ def draw_tab( extra_data: ExtraData ) -> int: colors = tab_colors(draw_data.default_bg) - fg = colors.active_fg if tab.is_active else colors.inactive_fg - bg = colors.active_bg if tab.is_active else colors.inactive_bg - default_bg = as_rgb(int(draw_data.default_bg)) - orig_fg = as_rgb(int(fg)) - orig_bg = as_rgb(int(bg)) title_draw_data = draw_data._replace(**colors._asdict()) + default_bg = as_rgb(int(draw_data.default_bg)) + # tab_fg/tab_bg return a per-tab color when `kitten @ set-tab-color` has set + # one (the ssh wrapper tints tabs per host), else the roles above. + orig_fg = as_rgb(title_draw_data.tab_fg(tab)) + orig_bg = as_rgb(title_draw_data.tab_bg(tab)) screen.cursor.fg = orig_fg screen.cursor.bg = orig_bg left_sep, right_sep = ('', '')