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
|
package tui
type Attr uint8
const (
AttrNone Attr = 0
AttrBold Attr = 1 << iota
AttrDim
AttrItalic
AttrUnderline
AttrBlink
AttrReverse
AttrStrikethrough
)
type Style struct {
Fg Color
Bg Color
Attrs Attr
}
func NewStyle() Style {
return Style{}
}
func (s Style) Foreground(c Color) Style {
s.Fg = c
return s
}
func (s Style) Background(c Color) Style {
s.Bg = c
return s
}
func (s Style) Bold() Style {
s.Attrs |= AttrBold
return s
}
func (s Style) Dim() Style {
s.Attrs |= AttrDim
return s
}
func (s Style) Italic() Style {
s.Attrs |= AttrItalic
return s
}
func (s Style) Underline() Style {
s.Attrs |= AttrUnderline
return s
}
func (s Style) Blink() Style {
s.Attrs |= AttrBlink
return s
}
func (s Style) Reverse() Style {
s.Attrs |= AttrReverse
return s
}
func (s Style) Strikethrough() Style {
s.Attrs |= AttrStrikethrough
return s
}
func (s Style) Equal(other Style) bool {
return s.Fg.Equal(other.Fg) && s.Bg.Equal(other.Bg) && s.Attrs == other.Attrs
}
func (s Style) HasAttr(a Attr) bool {
return s.Attrs&a == a
}
|