11package theme
22
3- import "github.com/gdamore/tcell/v2"
3+ import (
4+ "github.com/gdamore/tcell/v2"
5+ "github.com/rivo/tview"
6+ )
47
58type Theme struct {
9+ // Application-specific colors
610 DefaultTextColor tcell.Color
711 DefaultBgColor tcell.Color
812 WarningColor tcell.Color
@@ -18,24 +22,69 @@ type Theme struct {
1822 LegendColor tcell.Color
1923 TableHeaderColor tcell.Color
2024 SearchLabelColor tcell.Color
25+
26+ // tview global styles (mapped to tview.Styles)
27+ PrimitiveBackgroundColor tcell.Color
28+ ContrastBackgroundColor tcell.Color
29+ MoreContrastBackgroundColor tcell.Color
30+ BorderColor tcell.Color
31+ GraphicsColor tcell.Color
32+ PrimaryTextColor tcell.Color
33+ SecondaryTextColor tcell.Color
34+ TertiaryTextColor tcell.Color
35+ InverseTextColor tcell.Color
36+ ContrastSecondaryTextColor tcell.Color
2137}
2238
2339func NewTheme () * Theme {
24- return & Theme {
25- DefaultTextColor : tcell .ColorWhite ,
26- DefaultBgColor : tcell .ColorBlack ,
27- WarningColor : tcell .ColorYellow ,
28- SuccessColor : tcell .ColorGreen ,
29- ErrorColor : tcell .ColorRed ,
30-
31- TitleColor : tcell .ColorMediumVioletRed ,
40+ theme := & Theme {
41+ // Application-specific colors
42+ DefaultTextColor : tcell .ColorDefault ,
43+ DefaultBgColor : tcell .ColorDefault ,
44+
45+ // Use standard ANSI colors that work well on both light and dark themes
46+ WarningColor : tcell .ColorYellow ,
47+ SuccessColor : tcell .ColorGreen ,
48+ ErrorColor : tcell .ColorRed ,
49+
50+ // Component colors
51+ TitleColor : tcell .ColorPurple ,
3252 LabelColor : tcell .ColorYellow ,
33- ButtonBgColor : tcell .ColorGray ,
34- ButtonTextColor : tcell .ColorWhite ,
53+ ButtonBgColor : tcell .ColorDefault ,
54+ ButtonTextColor : tcell .ColorDefault ,
3555
36- ModalBgColor : tcell .ColorDarkSlateGray ,
37- LegendColor : tcell .ColorWhite ,
56+ ModalBgColor : tcell .ColorDefault ,
57+ LegendColor : tcell .ColorDefault ,
3858 TableHeaderColor : tcell .ColorBlue ,
39- SearchLabelColor : tcell .ColorMediumVioletRed ,
59+ SearchLabelColor : tcell .ColorPurple ,
60+
61+ // tview global styles - use terminal default colors for better compatibility
62+ // By default, tview uses hardcoded colors (like tcell.ColorBlack) which don't
63+ // adapt to the terminal's theme. We set them all to ColorDefault.
64+ PrimitiveBackgroundColor : tcell .ColorDefault ,
65+ ContrastBackgroundColor : tcell .ColorDefault ,
66+ MoreContrastBackgroundColor : tcell .ColorDefault ,
67+ BorderColor : tcell .ColorDefault ,
68+ GraphicsColor : tcell .ColorDefault ,
69+ PrimaryTextColor : tcell .ColorDefault ,
70+ SecondaryTextColor : tcell .ColorDefault ,
71+ TertiaryTextColor : tcell .ColorDefault ,
72+ InverseTextColor : tcell .ColorDefault ,
73+ ContrastSecondaryTextColor : tcell .ColorDefault ,
4074 }
75+
76+ // Apply theme to tview global styles
77+ tview .Styles .PrimitiveBackgroundColor = theme .PrimitiveBackgroundColor
78+ tview .Styles .ContrastBackgroundColor = theme .ContrastBackgroundColor
79+ tview .Styles .MoreContrastBackgroundColor = theme .MoreContrastBackgroundColor
80+ tview .Styles .BorderColor = theme .BorderColor
81+ tview .Styles .TitleColor = theme .TitleColor
82+ tview .Styles .GraphicsColor = theme .GraphicsColor
83+ tview .Styles .PrimaryTextColor = theme .PrimaryTextColor
84+ tview .Styles .SecondaryTextColor = theme .SecondaryTextColor
85+ tview .Styles .TertiaryTextColor = theme .TertiaryTextColor
86+ tview .Styles .InverseTextColor = theme .InverseTextColor
87+ tview .Styles .ContrastSecondaryTextColor = theme .ContrastSecondaryTextColor
88+
89+ return theme
4190}
0 commit comments