1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
package styles
import (
"image/color"
"github.com/charmbracelet/lipgloss/v2"
"github.com/charmbracelet/lipgloss/v2/compat"
)
// IsNoColor checks if a color is the special NoColor type
func IsNoColor(c color.Color) bool {
_, ok := c.(lipgloss.NoColor)
return ok
}
// Style wraps lipgloss.Style to provide a fluent API for handling "none" colors
type Style struct {
lipgloss.Style
}
// NewStyle creates a new Style with proper handling of "none" colors
func NewStyle() Style {
return Style{lipgloss.NewStyle()}
}
func (s Style) Lipgloss() lipgloss.Style {
return s.Style
}
// Foreground sets the foreground color, handling "none" appropriately
func (s Style) Foreground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetForeground()}
}
return Style{s.Style.Foreground(c)}
}
// Background sets the background color, handling "none" appropriately
func (s Style) Background(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBackground()}
}
return Style{s.Style.Background(c)}
}
// BorderForeground sets the border foreground color, handling "none" appropriately
func (s Style) BorderForeground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderForeground()}
}
return Style{s.Style.BorderForeground(c)}
}
// BorderBackground sets the border background color, handling "none" appropriately
func (s Style) BorderBackground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderBackground()}
}
return Style{s.Style.BorderBackground(c)}
}
// BorderTopForeground sets the border top foreground color, handling "none" appropriately
func (s Style) BorderTopForeground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderTopForeground()}
}
return Style{s.Style.BorderTopForeground(c)}
}
// BorderTopBackground sets the border top background color, handling "none" appropriately
func (s Style) BorderTopBackground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderTopBackground()}
}
return Style{s.Style.BorderTopBackground(c)}
}
// BorderBottomForeground sets the border bottom foreground color, handling "none" appropriately
func (s Style) BorderBottomForeground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderBottomForeground()}
}
return Style{s.Style.BorderBottomForeground(c)}
}
// BorderBottomBackground sets the border bottom background color, handling "none" appropriately
func (s Style) BorderBottomBackground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderBottomBackground()}
}
return Style{s.Style.BorderBottomBackground(c)}
}
// BorderLeftForeground sets the border left foreground color, handling "none" appropriately
func (s Style) BorderLeftForeground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderLeftForeground()}
}
return Style{s.Style.BorderLeftForeground(c)}
}
// BorderLeftBackground sets the border left background color, handling "none" appropriately
func (s Style) BorderLeftBackground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderLeftBackground()}
}
return Style{s.Style.BorderLeftBackground(c)}
}
// BorderRightForeground sets the border right foreground color, handling "none" appropriately
func (s Style) BorderRightForeground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderRightForeground()}
}
return Style{s.Style.BorderRightForeground(c)}
}
// BorderRightBackground sets the border right background color, handling "none" appropriately
func (s Style) BorderRightBackground(c compat.AdaptiveColor) Style {
if IsNoColor(c.Dark) && IsNoColor(c.Light) {
return Style{s.Style.UnsetBorderRightBackground()}
}
return Style{s.Style.BorderRightBackground(c)}
}
// Render applies the style to a string
func (s Style) Render(str string) string {
return s.Style.Render(str)
}
// Common lipgloss.Style method delegations for seamless usage
func (s Style) Bold(v bool) Style {
return Style{s.Style.Bold(v)}
}
func (s Style) Italic(v bool) Style {
return Style{s.Style.Italic(v)}
}
func (s Style) Underline(v bool) Style {
return Style{s.Style.Underline(v)}
}
func (s Style) Strikethrough(v bool) Style {
return Style{s.Style.Strikethrough(v)}
}
func (s Style) Blink(v bool) Style {
return Style{s.Style.Blink(v)}
}
func (s Style) Faint(v bool) Style {
return Style{s.Style.Faint(v)}
}
func (s Style) Reverse(v bool) Style {
return Style{s.Style.Reverse(v)}
}
func (s Style) Width(i int) Style {
return Style{s.Style.Width(i)}
}
func (s Style) Height(i int) Style {
return Style{s.Style.Height(i)}
}
func (s Style) Padding(i ...int) Style {
return Style{s.Style.Padding(i...)}
}
func (s Style) PaddingTop(i int) Style {
return Style{s.Style.PaddingTop(i)}
}
func (s Style) PaddingBottom(i int) Style {
return Style{s.Style.PaddingBottom(i)}
}
func (s Style) PaddingLeft(i int) Style {
return Style{s.Style.PaddingLeft(i)}
}
func (s Style) PaddingRight(i int) Style {
return Style{s.Style.PaddingRight(i)}
}
func (s Style) Margin(i ...int) Style {
return Style{s.Style.Margin(i...)}
}
func (s Style) MarginTop(i int) Style {
return Style{s.Style.MarginTop(i)}
}
func (s Style) MarginBottom(i int) Style {
return Style{s.Style.MarginBottom(i)}
}
func (s Style) MarginLeft(i int) Style {
return Style{s.Style.MarginLeft(i)}
}
func (s Style) MarginRight(i int) Style {
return Style{s.Style.MarginRight(i)}
}
func (s Style) Border(b lipgloss.Border, sides ...bool) Style {
return Style{s.Style.Border(b, sides...)}
}
func (s Style) BorderStyle(b lipgloss.Border) Style {
return Style{s.Style.BorderStyle(b)}
}
func (s Style) BorderTop(v bool) Style {
return Style{s.Style.BorderTop(v)}
}
func (s Style) BorderBottom(v bool) Style {
return Style{s.Style.BorderBottom(v)}
}
func (s Style) BorderLeft(v bool) Style {
return Style{s.Style.BorderLeft(v)}
}
func (s Style) BorderRight(v bool) Style {
return Style{s.Style.BorderRight(v)}
}
func (s Style) Align(p ...lipgloss.Position) Style {
return Style{s.Style.Align(p...)}
}
func (s Style) AlignHorizontal(p lipgloss.Position) Style {
return Style{s.Style.AlignHorizontal(p)}
}
func (s Style) AlignVertical(p lipgloss.Position) Style {
return Style{s.Style.AlignVertical(p)}
}
func (s Style) Inline(v bool) Style {
return Style{s.Style.Inline(v)}
}
func (s Style) MaxWidth(n int) Style {
return Style{s.Style.MaxWidth(n)}
}
func (s Style) MaxHeight(n int) Style {
return Style{s.Style.MaxHeight(n)}
}
func (s Style) TabWidth(n int) Style {
return Style{s.Style.TabWidth(n)}
}
func (s Style) UnsetBold() Style {
return Style{s.Style.UnsetBold()}
}
func (s Style) UnsetItalic() Style {
return Style{s.Style.UnsetItalic()}
}
func (s Style) UnsetUnderline() Style {
return Style{s.Style.UnsetUnderline()}
}
func (s Style) UnsetStrikethrough() Style {
return Style{s.Style.UnsetStrikethrough()}
}
func (s Style) UnsetBlink() Style {
return Style{s.Style.UnsetBlink()}
}
func (s Style) UnsetFaint() Style {
return Style{s.Style.UnsetFaint()}
}
func (s Style) UnsetReverse() Style {
return Style{s.Style.UnsetReverse()}
}
func (s Style) Copy() Style {
return Style{s.Style}
}
func (s Style) Inherit(i Style) Style {
return Style{s.Style.Inherit(i.Style)}
}
|