-
-
Notifications
You must be signed in to change notification settings - Fork 404
/
themes.go
65 lines (55 loc) · 1.46 KB
/
themes.go
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
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
}
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"),
}
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"),
}
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"),
}
if _, ok := themes[theme]; !ok {
return Theme{}, fmt.Errorf("unknown theme: %s", theme)
}
return themes[theme], nil
}