mirror of https://github.com/gdamore/tcell.git
Added a function to Style that sets its attributes. Also fixed some comments.
This commit is contained in:
parent
260932a7ea
commit
1575526e4d
21
style.go
21
style.go
|
@ -14,23 +14,13 @@
|
||||||
|
|
||||||
package tcell
|
package tcell
|
||||||
|
|
||||||
// Style represents a complete text style, including both foreground
|
// Style represents a complete text style, including both foreground color,
|
||||||
// and background color. We encode it in a 64-bit int for efficiency.
|
// background color, and additional attributes such as "bold" or "underline".
|
||||||
// The coding is (MSB): <7b flags><1b><24b fgcolor><7b attr><1b><24b bgcolor>.
|
|
||||||
// The <1b> is set true to indicate that the color is an RGB color, rather
|
|
||||||
// than a named index.
|
|
||||||
//
|
|
||||||
// This gives 24bit color options, if it ever becomes truly necessary.
|
|
||||||
// However, applications must not rely on this encoding.
|
|
||||||
//
|
//
|
||||||
// Note that not all terminals can display all colors or attributes, and
|
// Note that not all terminals can display all colors or attributes, and
|
||||||
// many might have specific incompatibilities between specific attributes
|
// many might have specific incompatibilities between specific attributes
|
||||||
// and color combinations.
|
// and color combinations.
|
||||||
//
|
//
|
||||||
// The intention is to extend styles to support paletting, in which case
|
|
||||||
// some flag bit(s) would be set, and the foreground and background colors
|
|
||||||
// would be replaced with a palette number and palette index.
|
|
||||||
//
|
|
||||||
// To use Style, just declare a variable of its type.
|
// To use Style, just declare a variable of its type.
|
||||||
type Style struct {
|
type Style struct {
|
||||||
fg Color
|
fg Color
|
||||||
|
@ -135,3 +125,10 @@ func (s Style) Underline(on bool) Style {
|
||||||
func (s Style) StrikeThrough(on bool) Style {
|
func (s Style) StrikeThrough(on bool) Style {
|
||||||
return s.setAttrs(AttrStrikeThrough, on)
|
return s.setAttrs(AttrStrikeThrough, on)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attributes returns a new style based on s, with its attributes set as
|
||||||
|
// specified.
|
||||||
|
func (s Style) Attributes(attrs AttrMask) Style {
|
||||||
|
s.attrs = attrs
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue