/
style_func.go
67 lines (55 loc) · 1.25 KB
/
style_func.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
66
67
package li
type StyleFunc func(style Style) Style
var SameStyle = StyleFunc(func(style Style) Style {
return style
})
func SetFG(color Color) StyleFunc {
return func(style Style) Style {
return style.Foreground(color)
}
}
func SetBG(color Color) StyleFunc {
return func(style Style) Style {
return style.Background(color)
}
}
func SetBold(bold bool) StyleFunc {
return func(style Style) Style {
return style.Bold(bold)
}
}
func SetUnderline(underline bool) StyleFunc {
return func(style Style) Style {
return style.Underline(underline)
}
}
func (s StyleFunc) SetFG(color Color) StyleFunc {
return func(style Style) Style {
style = s(style)
return style.Foreground(color)
}
}
func (s StyleFunc) SetBG(color Color) StyleFunc {
return func(style Style) Style {
style = s(style)
return style.Background(color)
}
}
func (s StyleFunc) SetBold(bold bool) StyleFunc {
return func(style Style) Style {
style = s(style)
return style.Bold(bold)
}
}
func (s StyleFunc) SetUnderline(underline bool) StyleFunc {
return func(style Style) Style {
style = s(style)
return style.Underline(underline)
}
}
func (s StyleFunc) And(f2 StyleFunc) StyleFunc {
return func(style Style) Style {
return f2(s(style))
}
}
//TODO set darker or lighter