2020-10-04 04:29:15 +00:00
|
|
|
package text
|
|
|
|
|
|
|
|
// Plain creates a new text.Rich without any formatting segments.
|
|
|
|
func Plain(text string) Rich {
|
|
|
|
return Rich{Content: text}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SolidColor takes in a 24-bit RGB color and overrides the alpha bits with
|
|
|
|
// 0xFF, making the color solid.
|
|
|
|
func SolidColor(rgb uint32) uint32 {
|
2020-10-13 23:46:18 +00:00
|
|
|
return (rgb << 8) | 0xFF
|
2020-10-04 04:29:15 +00:00
|
|
|
}
|
2020-10-09 07:12:02 +00:00
|
|
|
|
2021-03-20 05:40:31 +00:00
|
|
|
// IsEmpty returns true if the given rich segment's content is empty. Note that
|
|
|
|
// a rich text is not necessarily empty if the content is empty, because there
|
|
|
|
// may be images within the segments.
|
2020-10-09 07:12:02 +00:00
|
|
|
func (r Rich) IsEmpty() bool {
|
2021-03-20 05:40:31 +00:00
|
|
|
return r.Content == "" && len(r.Segments) == 0
|
2020-10-09 07:12:02 +00:00
|
|
|
}
|