-
-
Notifications
You must be signed in to change notification settings - Fork 467
Expand file tree
/
Copy paththemes.go
More file actions
78 lines (67 loc) · 1.89 KB
/
Copy paththemes.go
File metadata and controls
78 lines (67 loc) · 1.89 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
package main
import (
"fmt"
"github.com/muesli/termenv"
)
// Theme defines a color theme used for printing tables.
type Theme struct {
colorRed termenv.Color
colorYellow termenv.Color
colorGreen termenv.Color
colorBlue termenv.Color
colorGray termenv.Color
colorMagenta termenv.Color
colorCyan termenv.Color
colorBgRed termenv.Color
colorBgYellow termenv.Color
colorBgGreen termenv.Color
}
func defaultThemeName() string {
if !termenv.HasDarkBackground() {
return "light"
}
return "dark"
}
func loadTheme(theme string) (Theme, error) {
themes := make(map[string]Theme)
themes["dark"] = Theme{
colorRed: env.Color("#E88388"),
colorYellow: env.Color("#DBAB79"),
colorGreen: env.Color("#A8CC8C"),
colorBlue: env.Color("#71BEF2"),
colorGray: env.Color("#B9BFCA"),
colorMagenta: env.Color("#D290E4"),
colorCyan: env.Color("#66C2CD"),
colorBgRed: env.Color("#2d1b1b"),
colorBgYellow: env.Color("#2d2d1b"),
colorBgGreen: env.Color("#1b2d1b"),
}
themes["light"] = Theme{
colorRed: env.Color("#D70000"),
colorYellow: env.Color("#FFAF00"),
colorGreen: env.Color("#005F00"),
colorBlue: env.Color("#000087"),
colorGray: env.Color("#303030"),
colorMagenta: env.Color("#AF00FF"),
colorCyan: env.Color("#0087FF"),
colorBgRed: env.Color("#ffdede"),
colorBgYellow: env.Color("#fff4d0"),
colorBgGreen: env.Color("#e6ffe6"),
}
themes["ansi"] = Theme{
colorRed: env.Color("9"),
colorYellow: env.Color("11"),
colorGreen: env.Color("10"),
colorBlue: env.Color("12"),
colorGray: env.Color("7"),
colorMagenta: env.Color("13"),
colorCyan: env.Color("8"),
colorBgRed: env.Color("1"),
colorBgYellow: env.Color("3"),
colorBgGreen: env.Color("2"),
}
if _, ok := themes[theme]; !ok {
return Theme{}, fmt.Errorf("unknown theme: %s", theme)
}
return themes[theme], nil
}