Documentation
¶
Overview ¶
Package annotations is the store of the line annotations that extensions put after the end of lines (SPEC §10.30 "Blame", step 24.22; the Editor Decorations API of the extensions): a muted text, a theme color and a hover for a line of a document. The editors read the annotations of their document from it and are told when a document's change.
A set of annotations belongs to an owner (the extension) and a key, and holds the annotations of one document. Setting a key again replaces its set whatever its document was. The store keeps no text of the documents: lines are numbers, and an editor that shows a line the document no longer has does not draw it.
It is safe for use from several goroutines. Subscribers are called from the goroutine that made the change, after the lock is released, and must not call back into the store while they are called from a function that holds it (they do not: no lock is held).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
type Annotation struct {
// Line is the line, counted from 0.
Line int
// Text is the text drawn after the line.
Text string
// Color is the id of the theme color of the text, empty for the default of the editor.
Color string
// Hover is the markdown of the hover, empty for none.
Hover string
// Link is called with the destination of a link of the hover that was clicked. Nil when the hover has no links to follow.
Link func(dest string)
}
Annotation is a text after the end of a line.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds the sets of annotations. The zero value is not ready: make one with New.
func (*Store) ClearOwner ¶
ClearOwner removes every set of the owner (the end of its activation).
func (*Store) For ¶
func (s *Store) For(uri string) []Annotation
For returns the annotations of the document at uri, sorted by line (the annotations of a line in the order of the owner and key of their sets).
func (*Store) Set ¶
func (s *Store) Set(owner, key, uri string, list []Annotation)
Set replaces the set of the owner and key with the annotations of the document at uri; an empty list removes the set. The subscribers are told the documents whose annotations changed (the old document of the set and the new one).