-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.go
executable file
·76 lines (58 loc) · 2.15 KB
/
style.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
68
69
70
71
72
73
74
75
76
package termios
// Style collects all attributes that can be given to a character in the terminal.
// It includes foreground, background color and more text attributes.
type Style struct {
Foreground Color
Background Color
Extras TextAttribute
}
// TextAttribute sets more styling options on text.
type TextAttribute uint8
const (
// TextDefault unsets all text attributes.
TextDefault TextAttribute = 0
// TextBold makes the text appear bold.
// On some terminals it will create bright text instead.
TextBold TextAttribute = 0x1
// TextDim makes the text appear dim.
TextDim TextAttribute = 0x2
// TextUnderlined underlines the text.
TextUnderlined TextAttribute = 0x4
// TextBlink blinks the text. Does not work on some terminals.
TextBlink TextAttribute = 0x8
// TextReverse reverses foreground and background color.
TextReverse TextAttribute = 0x10
// TextHidden hides the text.
TextHidden TextAttribute = 0x20
// TextCursive prints the text in cursive. Does only work on few terminals.
TextCursive TextAttribute = 0x40
)
// Spectrum specifies the colorspace a color is given in.
type Spectrum uint8
const (
// SpectrumDefault only has one color: the terminal's default color.
SpectrumDefault Spectrum = 0
// Spectrum8 indicates that the spectrum has 8 colors.
// It usually includes red, blue, green and binary combinations of these.
// It needs 3 bits of storage.
Spectrum8 Spectrum = 1
// Spectrum16 indicates that the spectrum has 16 colors.
// It usually adds a bright modifier to the 8 color spectrum.
// It needs 4 bits of storage.
Spectrum16 Spectrum = 2
// Spectrum256 indicates that the spectrum has 256 colors.
// It is usually a terminal-specific gradient.
// It takes 8 bits of storage.
Spectrum256 Spectrum = 3
// SpectrumRGB indicates that the spectrum has all RGB colors.
// Each component can be specified freely between 0 and 255.
// It takes 24 bits of storage.
SpectrumRGB Spectrum = 4
)
// MoreThan tests whether this spectrum has *more* colors than the other.
func (s *Spectrum) MoreThan(other *Spectrum) bool {
return uint8(*s) > uint8(*other)
}
func (s *Spectrum) Equal(other *Spectrum) bool {
return *s == *other
}