decoration

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Background

type Background struct {
	// Color for background.
	Color color.Color
}

type Border

type Border struct {
	// Color for the stroke.
	Color color.Color
}

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

func (*DecorationTree) Split

func (t *DecorationTree) Split(line layout.Line, runs *[]painter.RenderRun)

Split implements painter.LineSplitter

type Squiggle

type Squiggle struct {
	// Color for the stroke.
	Color color.Color
}

type Strikethrough

type Strikethrough struct {
	// Color for the stroke.
	Color color.Color
}

type Underline

type Underline struct {
	// Color for the stroke.
	Color color.Color
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL