Documentation
¶
Index ¶
- type Background
- type Border
- type Decoration
- type DecorationTree
- func (d *DecorationTree) Insert(decos ...Decoration) error
- func (d *DecorationTree) Query(pos int) []Decoration
- func (d *DecorationTree) QueryRange(start, end int) []Decoration
- func (d *DecorationTree) Refresh()
- func (d *DecorationTree) RemoveAll() error
- func (d *DecorationTree) RemoveBySource(source string) error
- func (t *DecorationTree) Split(line layout.Line, runs *[]painter.RenderRun)
- type Squiggle
- type Strikethrough
- type Underline
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Background ¶
type Decoration ¶
type Decoration struct {
// Source marks where the decoration is from.
Source any
// Priority configures the painting order of the decoration.
Priority int
// Start and End are rune offset in the document.
Start, End int
Background *Background
Underline *Underline
Squiggle *Squiggle
Strikethrough *Strikethrough
Border *Border
Italic bool
Bold bool
// contains filtered or unexported fields
}
A decoration represents styles sharing between a range of text. After added to the editor, the decoration position is dynamically updated, so there is no need to re-create it every time the text changed in the editor.
func (*Decoration) Range ¶ added in v0.4.0
func (d *Decoration) Range() (start, end *buffer.Marker)
Range returns the start and end markers representing the dynamic position of the decoration in the editor.
type DecorationTree ¶
type DecorationTree struct {
// contains filtered or unexported fields
}
DecorationTree leverages a interval tree to stores overlapping decorations.
func NewDecorationTree ¶
func NewDecorationTree(src buffer.TextSource) *DecorationTree
func (*DecorationTree) Insert ¶
func (d *DecorationTree) Insert(decos ...Decoration) error
Insert a new decoration range. start and end are offset in rune in the document.
This method modifies the Decoration objects in the input slice `decos` by calling their `bind` method. It is the caller's responsibility to handle these mutations.
func (*DecorationTree) Query ¶
func (d *DecorationTree) Query(pos int) []Decoration
Query returns all styles at a given character offset
func (*DecorationTree) QueryRange ¶
func (d *DecorationTree) QueryRange(start, end int) []Decoration
QueryRange returns all segments overlapping the range
func (*DecorationTree) Refresh ¶ added in v0.4.0
func (d *DecorationTree) Refresh()
Refresh checks if any decoration range has changed and rebuilds the interval tree if necessary.
func (*DecorationTree) RemoveAll ¶
func (d *DecorationTree) RemoveAll() error
func (*DecorationTree) RemoveBySource ¶
func (d *DecorationTree) RemoveBySource(source string) error