mirror of
https://github.com/diamondburned/cchat-discord.git
synced 2024-12-23 12:56:42 +00:00
29 lines
539 B
Go
29 lines
539 B
Go
package renderer
|
|
|
|
import (
|
|
"github.com/diamondburned/ningen/v2/md"
|
|
)
|
|
|
|
// InlineState assists in keeping a stateful inline segment builder.
|
|
type InlineState struct {
|
|
// TODO: use a stack to allow overlapping
|
|
Start, End int
|
|
Attributes md.Attribute
|
|
}
|
|
|
|
func (i *InlineState) Add(attr md.Attribute) {
|
|
i.Attributes |= attr
|
|
}
|
|
|
|
func (i *InlineState) Remove(attr md.Attribute) {
|
|
i.Attributes &= ^attr
|
|
}
|
|
|
|
func (i InlineState) Copy() InlineState {
|
|
return i
|
|
}
|
|
|
|
func (i InlineState) Empty() bool {
|
|
return i.Attributes == 0 || i.Start < i.End
|
|
}
|