forked from muesli/duf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
themes.go
54 lines (45 loc) · 1.17 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
package main
import (
"fmt"
"github.com/muesli/termenv"
)
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: term.Color("#E88388"),
colorYellow: term.Color("#DBAB79"),
colorGreen: term.Color("#A8CC8C"),
colorBlue: term.Color("#71BEF2"),
colorGray: term.Color("#B9BFCA"),
colorMagenta: term.Color("#D290E4"),
colorCyan: term.Color("#66C2CD"),
}
themes["light"] = Theme{
colorRed: term.Color("#D70000"),
colorYellow: term.Color("#FFAF00"),
colorGreen: term.Color("#005F00"),
colorBlue: term.Color("#000087"),
colorGray: term.Color("#303030"),
colorMagenta: term.Color("#AF00FF"),
colorCyan: term.Color("#0087FF"),
}
if _, ok := themes[theme]; !ok {
return Theme{}, fmt.Errorf("Unknown theme: %s", theme)
}
return themes[theme], nil
}