@@ -2,6 +2,7 @@ package tui
22
33import "github.com/charmbracelet/lipgloss"
44
5+ // Palette defines a set of colors for a theme.
56type Palette struct {
67 Black , Red , Green , Yellow , Blue , Magenta , Cyan , White ,
78 BrightBlack , BrightRed , BrightGreen , BrightYellow , BrightBlue , BrightMagenta , BrightCyan , BrightWhite ,
@@ -85,8 +86,6 @@ var Palettes = map[string]Palette{
8586
8687// Theme represents the styles for different components of the UI.
8788type Theme struct {
88- ActivePanel lipgloss.Style
89- InactivePanel lipgloss.Style
9089 ActiveTitle lipgloss.Style
9190 InactiveTitle lipgloss.Style
9291 NormalText lipgloss.Style
@@ -95,34 +94,24 @@ type Theme struct {
9594 HelpButton lipgloss.Style
9695 ScrollbarThumb lipgloss.Style
9796 SelectedLine lipgloss.Style
98-
99- // Git status styles
100- GitStaged lipgloss.Style
101- GitUnstaged lipgloss.Style
102- GitUntracked lipgloss.Style
103- GitConflicted lipgloss.Style
104-
105- // Branch styles
106- BranchCurrent lipgloss.Style
107- BranchDate lipgloss.Style
108-
109- // Commit log styles
110- CommitSHA lipgloss.Style
111- CommitAuthor lipgloss.Style
112- CommitMerge lipgloss.Style
113-
114- // Stash styles
115- StashName lipgloss.Style
116- StashMessage lipgloss.Style
117-
118- Tree TreeStyle
119-
97+ GitStaged lipgloss.Style
98+ GitUnstaged lipgloss.Style
99+ GitUntracked lipgloss.Style
100+ GitConflicted lipgloss.Style
101+ BranchCurrent lipgloss.Style
102+ BranchDate lipgloss.Style
103+ CommitSHA lipgloss.Style
104+ CommitAuthor lipgloss.Style
105+ CommitMerge lipgloss.Style
106+ GraphEdge lipgloss.Style
107+ GraphNode lipgloss.Style
108+ StashName lipgloss.Style
109+ StashMessage lipgloss.Style
120110 ActiveBorder BorderStyle
121111 InactiveBorder BorderStyle
112+ Tree TreeStyle
122113}
123114
124- const scrollThumb string = "▐"
125-
126115// BorderStyle defines the characters and styles for a panel's border.
127116type BorderStyle struct {
128117 Top string
@@ -136,63 +125,49 @@ type BorderStyle struct {
136125 Style lipgloss.Style
137126}
138127
128+ // TreeStyle defines the characters used to render the file tree.
139129type TreeStyle struct {
140- Connector string
141- ConnectorLast string
142- Prefix string
143- PrefixLast string
130+ Connector , ConnectorLast , Prefix , PrefixLast string
144131}
145132
146- // NewThemeFromPalette creates a Theme from a Palette.
147- func NewThemeFromPalette (p Palette ) Theme {
148- return Theme {
149- ActiveTitle : lipgloss .NewStyle ().
150- Foreground (lipgloss .Color (p .Bg )).
151- Background (lipgloss .Color (p .BrightCyan )),
152- InactiveTitle : lipgloss .NewStyle ().
153- Foreground (lipgloss .Color (p .Fg )).
154- Background (lipgloss .Color (p .Black )),
155- NormalText : lipgloss .NewStyle ().
156- Foreground (lipgloss .Color (p .Fg )),
157- HelpTitle : lipgloss .NewStyle ().
158- Foreground (lipgloss .Color (p .Green )).
159- Bold (true ),
160- HelpKey : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
161- HelpButton : lipgloss .NewStyle ().
162- Foreground (lipgloss .Color (p .Bg )).
163- Background (lipgloss .Color (p .Green )).
164- Margin (0 , 1 ),
165- ScrollbarThumb : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightGreen )),
166- SelectedLine : lipgloss .NewStyle ().
167- Background (lipgloss .Color (p .DarkBlue )).
168- Foreground (lipgloss .Color (p .BrightWhite )),
133+ const (
134+ scrollThumb = "▐"
135+ graphNode = "○"
136+ )
169137
170- GitStaged : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )),
171- GitUnstaged : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Red )),
172- GitUntracked : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightBlack )),
173- GitConflicted : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightRed )).Bold (true ),
174-
175- // Tree style
176- Tree : TreeStyle {
177- Connector : "├─" ,
178- ConnectorLast : "└─" ,
179- Prefix : "│ " ,
180- PrefixLast : " " ,
181- },
182-
183- // Branch styles
184- BranchCurrent : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )).Bold (true ),
185- BranchDate : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
186-
187- // Commit log styles
188- CommitSHA : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
189- CommitAuthor : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )),
190- CommitMerge : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Magenta )),
138+ // Themes holds all the available themes, generated from palettes.
139+ var Themes = map [string ]Theme {}
191140
192- // Stash styles
193- StashName : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
194- StashMessage : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Fg )),
141+ func init () {
142+ for name , p := range Palettes {
143+ Themes [name ] = NewThemeFromPalette (p )
144+ }
145+ }
195146
147+ // NewThemeFromPalette creates a Theme from a given color Palette.
148+ func NewThemeFromPalette (p Palette ) Theme {
149+ return Theme {
150+ ActiveTitle : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Bg )).Background (lipgloss .Color (p .BrightCyan )),
151+ InactiveTitle : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Fg )).Background (lipgloss .Color (p .Black )),
152+ NormalText : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Fg )),
153+ HelpTitle : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )).Bold (true ),
154+ HelpKey : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
155+ HelpButton : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Bg )).Background (lipgloss .Color (p .Green )).Margin (0 , 1 ),
156+ ScrollbarThumb : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightGreen )),
157+ SelectedLine : lipgloss .NewStyle ().Background (lipgloss .Color (p .DarkBlue )).Foreground (lipgloss .Color (p .BrightWhite )),
158+ GitStaged : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )),
159+ GitUnstaged : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Red )),
160+ GitUntracked : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightBlack )),
161+ GitConflicted : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightRed )).Bold (true ),
162+ BranchCurrent : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )).Bold (true ),
163+ BranchDate : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
164+ CommitSHA : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
165+ CommitAuthor : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )),
166+ CommitMerge : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Magenta )),
167+ GraphEdge : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightBlack )),
168+ GraphNode : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Green )),
169+ StashName : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Yellow )),
170+ StashMessage : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .Fg )),
196171 ActiveBorder : BorderStyle {
197172 Top : "─" , Bottom : "─" , Left : "│" , Right : "│" ,
198173 TopLeft : "╭" , TopRight : "╮" , BottomLeft : "╰" , BottomRight : "╯" ,
@@ -203,15 +178,12 @@ func NewThemeFromPalette(p Palette) Theme {
203178 TopLeft : "╭" , TopRight : "╮" , BottomLeft : "╰" , BottomRight : "╯" ,
204179 Style : lipgloss .NewStyle ().Foreground (lipgloss .Color (p .BrightBlack )),
205180 },
206- }
207- }
208-
209- // Themes holds all the available themes, generated from palettes.
210- var Themes = map [string ]Theme {}
211-
212- func init () {
213- for name , p := range Palettes {
214- Themes [name ] = NewThemeFromPalette (p )
181+ Tree : TreeStyle {
182+ Connector : "" ,
183+ ConnectorLast : "" ,
184+ Prefix : " " ,
185+ PrefixLast : " " ,
186+ },
215187 }
216188}
217189
0 commit comments