-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.go
More file actions
351 lines (341 loc) · 5.97 KB
/
Copy paththeme.go
File metadata and controls
351 lines (341 loc) · 5.97 KB
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
package main
import (
"fmt"
"strconv"
"strings"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
type AppTheme struct {
Name string
TView tview.Theme
Bg tcell.Color
PanelBg tcell.Color
Border tcell.Color
Text tcell.Color
Muted tcell.Color
Accent tcell.Color
Success tcell.Color
Warning tcell.Color
Error tcell.Color
SelectBg tcell.Color
SelectFg tcell.Color
HeaderBg tcell.Color
FooterBg tcell.Color
Label tcell.Color
KeyChipFg tcell.Color
MarkupAccent string
MarkupSuccess string
MarkupWarning string
MarkupError string
}
func DefaultThemes() []AppTheme {
return []AppTheme{
newTheme(
"Dark",
"#1a1b26",
"#1f2335",
"#3b4261",
"#c0caf5",
"#9aa5ce",
"#7aa2f7",
"#9ece6a",
"#e0af68",
"#f7768e",
"#283457",
"#ffffff",
"#1a1b26",
"#1a1b26",
"#7dcfff",
"#c0caf5",
),
newTheme(
"Light",
"#f7f7f7",
"#ffffff",
"#d0d7de",
"#24292e",
"#6e7781",
"#0969da",
"#1a7f37",
"#9a6700",
"#cf222e",
"#ddf4ff",
"#24292e",
"#f7f7f7",
"#f7f7f7",
"#0550ae",
"#24292e",
),
newTheme(
"Neutral",
"#2b2f37",
"#313640",
"#434a56",
"#d7dae0",
"#a0a6b2",
"#8ab4f8",
"#7ee787",
"#f2cc60",
"#ff7b72",
"#3b4252",
"#ffffff",
"#2b2f37",
"#2b2f37",
"#9ecbff",
"#d7dae0",
),
newTheme(
"Solarized Dark",
"#002b36",
"#073642",
"#586e75",
"#839496",
"#93a1a1",
"#268bd2",
"#859900",
"#b58900",
"#dc322f",
"#073642",
"#fdf6e3",
"#002b36",
"#002b36",
"#268bd2",
"#93a1a1",
),
newTheme(
"Solarized Light",
"#fdf6e3",
"#eee8d5",
"#93a1a1",
"#657b83",
"#839496",
"#268bd2",
"#859900",
"#b58900",
"#dc322f",
"#eee8d5",
"#002b36",
"#fdf6e3",
"#fdf6e3",
"#268bd2",
"#657b83",
),
newTheme(
"Gruvbox Dark",
"#282828",
"#3c3836",
"#504945",
"#ebdbb2",
"#a89984",
"#fb4934",
"#b8bb26",
"#fabd2f",
"#cc241d",
"#3c3836",
"#fbf1c7",
"#282828",
"#282828",
"#fb4934",
"#ebdbb2",
),
newTheme(
"Gruvbox Light",
"#fbf1c7",
"#f2e5bc",
"#d5c4a1",
"#3c3836",
"#7c6f64",
"#b57614",
"#98971a",
"#b57614",
"#cc241d",
"#f2e5bc",
"#3c3836",
"#fbf1c7",
"#fbf1c7",
"#b57614",
"#3c3836",
),
newTheme(
"Dracula",
"#282a36",
"#44475a",
"#6272a4",
"#f8f8f2",
"#6272a4",
"#bd93f9",
"#50fa7b",
"#f1fa8c",
"#ff79c6",
"#44475a",
"#f8f8f2",
"#282a36",
"#282a36",
"#bd93f9",
"#f8f8f2",
),
newTheme(
"Nord",
"#2e3440",
"#3b4252",
"#4c566a",
"#d8dee9",
"#88c0d0",
"#81a1c1",
"#a3be8c",
"#ebcb8b",
"#bf616a",
"#3b4252",
"#eceff4",
"#2e3440",
"#2e3440",
"#81a1c1",
"#d8dee9",
),
newTheme(
"Oceanic",
"#1b2b34",
"#223b44",
"#2b6f77",
"#d3e0ea",
"#7aa2c6",
"#2ac3de",
"#9ad66a",
"#f6c177",
"#ff6b6b",
"#223b44",
"#eaf6ff",
"#1b2b34",
"#1b2b34",
"#2ac3de",
"#d3e0ea",
),
newTheme(
"Monokai",
"#272822",
"#3e3d32",
"#5f5a60",
"#f8f8f2",
"#a39e9a",
"#fd971f",
"#a6e22e",
"#e6db74",
"#f92672",
"#3e3d32",
"#272822",
"#272822",
"#272822",
"#fd971f",
"#f8f8f2",
),
newTheme(
"HighContrast",
"#000000",
"#000000",
"#ffffff",
"#ffffff",
"#bfbfbf",
"#00ff00",
"#00ffff",
"#ffff00",
"#ff0000",
"#ffffff",
"#000000",
"#000000",
"#000000",
"#00ff00",
"#00ff00",
),
}
}
func newTheme(
name string,
bg string,
panel string,
border string,
text string,
muted string,
accent string,
success string,
warning string,
error string,
selectBg string,
selectFg string,
headerBg string,
footerBg string,
label string,
keyChipFg string,
) AppTheme {
bgColor := hexColor(bg)
panelColor := hexColor(panel)
borderColor := hexColor(border)
textColor := hexColor(text)
mutedColor := hexColor(muted)
accentColor := hexColor(accent)
successColor := hexColor(success)
warningColor := hexColor(warning)
errorColor := hexColor(error)
selectBgColor := hexColor(selectBg)
selectFgColor := hexColor(selectFg)
headerBgColor := hexColor(headerBg)
footerBgColor := hexColor(footerBg)
labelColor := hexColor(label)
keyChipFgColor := hexColor(keyChipFg)
return AppTheme{
Name: name,
Bg: bgColor,
PanelBg: panelColor,
Border: borderColor,
Text: textColor,
Muted: mutedColor,
Accent: accentColor,
Success: successColor,
Warning: warningColor,
Error: errorColor,
SelectBg: selectBgColor,
SelectFg: selectFgColor,
HeaderBg: headerBgColor,
FooterBg: footerBgColor,
Label: labelColor,
KeyChipFg: keyChipFgColor,
TView: tview.Theme{
PrimitiveBackgroundColor: bgColor,
ContrastBackgroundColor: panelColor,
MoreContrastBackgroundColor: selectBgColor,
BorderColor: borderColor,
TitleColor: accentColor,
GraphicsColor: accentColor,
PrimaryTextColor: textColor,
SecondaryTextColor: mutedColor,
TertiaryTextColor: successColor,
InverseTextColor: selectFgColor,
ContrastSecondaryTextColor: warningColor,
},
MarkupAccent: accent,
MarkupSuccess: success,
MarkupWarning: warning,
MarkupError: error,
}
}
func hexColor(value string) tcell.Color {
clean := strings.TrimPrefix(value, "#")
if len(clean) != 6 {
return tcell.ColorDefault
}
parsed, err := strconv.ParseInt(clean, 16, 32)
if err != nil {
return tcell.ColorDefault
}
r := int32((parsed >> 16) & 0xff)
g := int32((parsed >> 8) & 0xff)
b := int32(parsed & 0xff)
return tcell.NewRGBColor(r, g, b)
}
func ASCIILogo() string {
return strings.TrimRight(fmt.Sprintf(`[#7aa2f7] ______ ______ __ _[-:-:-]
[#9ece6a] | ____|| ____|| |_| |[-:-:-]
[#e0af68] |___ \|___ \| _ |[-:-:-]
[#f7768e] |______/|______/|__| |_|[-:-:-]
`), "\n")
}