editor

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package editor is base's code editor, a port of NSH's Editor (and GPUI Kit's): syntax highlighting, line numbers, several carets, folding, soft wrap, find and replace, diagnostics and decorations, completion and go to definition, with the keys of code editors. It draws its text itself, a Text per display row of the rows in view, over its own model: lines in a rope, edits as change lists, undo grouped as editors group it. It owns behavior and has no look of its own: Styles gives every part, from the caret to the completion list, its look; only the built-in highlighting colors the text, with NSH's palette.

It is a package of its own because its highlighting links chroma's lexers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bounds

type Bounds struct{ Bounds, PageBounds core.Bounds }

Bounds is a box of the text: Bounds in the editor's box, its scrolling applied, and Page in the root view, which an Overlay anchors to.

type Classes

type Classes struct {
	Gutter, LineNumber, ActiveLineNumber, FoldMarker                   string
	Content, Line, ActiveLine                                          string
	Selection, Caret, Composition                                      string
	SearchMatch, CurrentSearchMatch                                    string
	MatchingBracket, IndentGuide, FoldPlaceholder                      string
	Placeholder                                                        string
	DiagnosticError, DiagnosticWarning, DiagnosticInfo, DiagnosticHint string
	UnnecessaryText, DeprecatedText                                    string
	SelectionHandle                                                    string
	OverviewRuler                                                      string
	CompletionMenu, CompletionItem, SelectedCompletionItem             string
	CompletionMatch, CompletionDetail, CompletionKind                  string
	CompletionDocumentation                                            string
	DefinitionLink                                                     string
	InlineCompletion                                                   string
	Whitespace, Ruler                                                  string
}

Classes are Tailwind classes of the editor's parts, by Styles' names: each goes under its part's style, and a state's part after the part it follows.

type CodeActionRequest

type CodeActionRequest struct {
	Range    Range
	Position Position
	Bounds   *Bounds
}

CodeActionRequest asks for the code actions at Range, the primary selection start first, its caret at Position; Bounds is the caret's box, where a menu opens, nil before the editor is laid out.

type CodeDescription

type CodeDescription struct{ Href string }

CodeDescription is the page that describes a diagnostic's code.

type Command

type Command string

Command is what Ref.Run runs, as its keys do.

const (
	MoveLeft, MoveRight, MoveUp, MoveDown              Command = "moveLeft", "moveRight", "moveUp", "moveDown"
	MoveWordLeft, MoveWordRight                        Command = "moveWordLeft", "moveWordRight"
	MoveSubwordLeft, MoveSubwordRight                  Command = "moveSubwordLeft", "moveSubwordRight"
	MoveLineStart, MoveLineEnd                         Command = "moveLineStart", "moveLineEnd"
	MovePageUp, MovePageDown                           Command = "movePageUp", "movePageDown"
	MoveDocumentStart, MoveDocumentEnd                 Command = "moveDocumentStart", "moveDocumentEnd"
	SelectLeft, SelectRight, SelectUp, SelectDown      Command = "selectLeft", "selectRight", "selectUp", "selectDown"
	SelectWordLeft, SelectWordRight                    Command = "selectWordLeft", "selectWordRight"
	SelectSubwordLeft, SelectSubwordRight              Command = "selectSubwordLeft", "selectSubwordRight"
	SelectLineStart, SelectLineEnd                     Command = "selectLineStart", "selectLineEnd"
	SelectPageUp, SelectPageDown                       Command = "selectPageUp", "selectPageDown"
	SelectDocumentStart, SelectDocumentEnd             Command = "selectDocumentStart", "selectDocumentEnd"
	MoveToMatchingBracket                              Command = "moveToMatchingBracket"
	SelectAll, SelectLine, SelectNextOccurrence        Command = "selectAll", "selectLine", "selectNextOccurrence"
	SelectWord, SelectPreviousOccurrence               Command = "selectWord", "selectPreviousOccurrence"
	SelectAllOccurrences                               Command = "selectAllOccurrences"
	MoveParagraphUp, MoveParagraphDown                 Command = "moveParagraphUp", "moveParagraphDown"
	SelectParagraphUp, SelectParagraphDown             Command = "selectParagraphUp", "selectParagraphDown"
	AddCaretAbove, AddCaretBelow, SingleSelection      Command = "addCaretAbove", "addCaretBelow", "singleSelection"
	DeleteBackward, DeleteForward                      Command = "deleteBackward", "deleteForward"
	DeleteWordLeft, DeleteWordRight                    Command = "deleteWordLeft", "deleteWordRight"
	DeleteToLineStart, DeleteToLineEnd, DeleteLine     Command = "deleteToLineStart", "deleteToLineEnd", "deleteLine"
	Newline, NewlineBelow, NewlineAbove                Command = "newline", "newlineBelow", "newlineAbove"
	Indent, Outdent, ToggleComment, ToggleBlockComment Command = "indent", "outdent", "toggleComment", "toggleBlockComment"
	SortLinesAscending, SortLinesDescending            Command = "sortLinesAscending", "sortLinesDescending"
	TransformToUppercase, TransformToLowercase         Command = "transformToUppercase", "transformToLowercase"
	TransformToTitleCase                               Command = "transformToTitleCase"
	TrimTrailingWhitespace                             Command = "trimTrailingWhitespace"
	MoveLinesUp, MoveLinesDown                         Command = "moveLinesUp", "moveLinesDown"
	DuplicateLinesUp, DuplicateLinesDown               Command = "duplicateLinesUp", "duplicateLinesDown"
	JoinLines, TransposeCharacters                     Command = "joinLines", "transposeCharacters"
	Undo, Redo                                         Command = "undo", "redo"
	Fold, Unfold, FoldAll, UnfoldAll                   Command = "fold", "unfold", "foldAll", "unfoldAll"
	FoldRecursive, UnfoldRecursive, FoldSelection      Command = "foldRecursive", "unfoldRecursive", "foldSelection"
	FindNext, FindPrevious, FindWithSelection          Command = "findNext", "findPrevious", "findWithSelection"
	Copy, Cut, Paste                                   Command = "copy", "cut", "paste"
	ShowCompletions, GoToDefinition, ShowCodeActions   Command = "showCompletions", "goToDefinition", "showCodeActions"
	ExpandSelection, ShrinkSelection                   Command = "expandSelection", "shrinkSelection"
	UndoSelection, RedoSelection                       Command = "undoSelection", "redoSelection"
	SplitSelectionIntoLines                            Command = "splitSelectionIntoLines"
)

The commands.

type CompletionAcceptEvent

type CompletionAcceptEvent struct{ Item CompletionItem }

CompletionAcceptEvent is an accepted completion: the item, as the app presented it, inserted.

type CompletionItem

type CompletionItem struct {
	Label                string
	Kind                 CompletionKind
	Detail               string
	InsertText           string
	FilterText, SortText string
	Documentation        string
	Range                *Range
}

CompletionItem is an item of the completion list: Label shown, after Kind and before Detail; InsertText (Label when empty) replaces Range (from the query's start to the caret when nil); FilterText and SortText filter and order it; Documentation shows beside the list.

type CompletionKind

type CompletionKind string

CompletionKind is what a completion item is, as the Language Server Protocol names its kinds: method, function, variable, class, keyword...

type CompletionRequest

type CompletionRequest struct {
	ID         int
	Offset     int
	Position   Position
	Query      string
	QueryStart int
	Trigger    CompletionTrigger
	Character  string
}

CompletionRequest asks the app for completions at Position, Offset in UTF-16 code units: Query is the word before the caret, from QueryStart, what an item without a Range replaces. The app answers with Ref.PresentCompletions and ID; an answer to an older request is dropped.

type CompletionTrigger

type CompletionTrigger uint8

CompletionTrigger is what asked for completions.

const (
	// CompletionTyping is a word character typed at a word's end.
	CompletionTyping CompletionTrigger = iota
	// CompletionCharacter is one of CompletionTriggerCharacters typed.
	CompletionCharacter
	// CompletionInvoked is the app's ShowCompletions or the command.
	CompletionInvoked
)

type ContextMenuEvent

type ContextMenuEvent struct {
	Position  Position
	At        core.Point
	Selection core.Bounds
}

ContextMenuEvent asks for a menu: at Position in the text and At in the root view; after a long press or a double tap on a touch screen, with Selection the selection's box in the root view to open an edit menu over.

type Decoration

type Decoration struct {
	Range Range
	// Class goes under Style, and LineClass under LineStyle.
	Class, LineClass string
	Style            core.Style
	LineStyle        core.Style
	// Token colors the range as the highlighting colors a token of its
	// kind.
	Token TokenKind
	// Gutter is a mark in the strip before the line numbers, and
	// OverviewRuler one on the strip along the right edge. An empty range
	// keeps its place through edits.
	Gutter        *GutterMark
	OverviewRuler *OverviewRulerMark
}

Decoration styles a range of the text with Style, and the rows of its lines behind the text with LineStyle; Kind, when set, colors its text as the highlighting's kind of that name (keyword, string, comment, number, title, attr, built), the app's own highlighting.

type DefinitionRequest

type DefinitionRequest struct {
	ID       int
	Position Position
	Offset   int
	Range    Range
	Trigger  DefinitionTrigger
}

DefinitionRequest asks the app where the word at Position, Offset in UTF-16 code units, is defined: Range is the word.

type DefinitionTrigger

type DefinitionTrigger uint8

DefinitionTrigger is what asked for a definition.

const (
	// DefinitionHover is the pointer over a word with the command key
	// held: the app answers with Ref.PresentDefinitionLink.
	DefinitionHover DefinitionTrigger = iota
	// DefinitionPress is a press on a word with the command key held.
	DefinitionPress
	// DefinitionKey is F12 at the caret.
	DefinitionKey
)

type Diagnostic

type Diagnostic struct {
	Range              Range
	Severity           Severity
	Message            string
	Source             string
	Code               string
	CodeDescription    *CodeDescription
	Tags               []DiagnosticTag
	RelatedInformation []RelatedInformation
}

Diagnostic is a problem marked in the text, as a language server's: its range, carried through edits until the app sets new ones, its severity's part under its text, and with the tag TagUnnecessary or TagDeprecated the UnnecessaryText or DeprecatedText part over it. CodeDescription is the page describing its Code (a lint rule's), and RelatedInformation the other places that tell about it: a hover hands both to the app's card.

func (*Diagnostic) Has

func (d *Diagnostic) Has(tag DiagnosticTag) bool

Has reports whether d has tag.

type DiagnosticTag

type DiagnosticTag uint8

DiagnosticTag marks a diagnostic's text as a language server's tags do.

const (
	// TagUnnecessary is unused code, faded.
	TagUnnecessary DiagnosticTag = iota + 1
	// TagDeprecated is a deprecated name, struck through.
	TagDeprecated
)

type Edit

type Edit struct {
	Range Range
	Text  string
}

Edit replaces Range of the text with Text.

type Editor

type Editor struct {
	Value        func() string
	DefaultValue string
	OnChange     func(text string)
	// Language is a language's name, alias, extension or file name ("go",
	// "rs", "main.ts", "Dockerfile"): its comments, brackets, indentation
	// and colors. Plain text without one.
	Language    string
	Placeholder string
	ReadOnly    bool
	AutoFocus   bool
	// NoLineNumbers hides the numbers; SoftWrap wraps long lines at the
	// editor's width.
	NoLineNumbers, SoftWrap bool
	// TabSize is the columns of a tab and of an indentation level, and
	// HardTabs indents with tabs; the language's when 0 and false.
	TabSize  int
	HardTabs bool
	// NoFolding removes the fold markers and folds; FoldRanges replaces
	// the folds by indentation with the app's.
	NoFolding  bool
	FoldRanges func() []FoldRange
	// Highlighter gives the app's highlighter for a language's name, nil
	// for the built-in one; it is asked for Language.
	Highlighter func(language string) Highlighter
	// NoHighlighting drops the built-in highlighting; NoAutoClose and
	// NoAutoIndent the closing of brackets and the indentation of new
	// lines; NoActiveLine and NoIndentGuides those parts.
	NoHighlighting, NoAutoClose, NoAutoIndent bool
	NoActiveLine, NoIndentGuides              bool
	// FontFamily (the monospaced font when empty), FontSize (13) and
	// LineHeight (20): the editor measures its text in them.
	FontFamily           string
	FontSize, LineHeight core.Points
	// ShowWhitespaces marks spaces and tabs; Rulers draws a line at each
	// of its columns.
	ShowWhitespaces bool
	Rulers          []int
	// MinRows and MaxRows make the editor as tall as its rows, at least
	// MinRows and at most MaxRows of them, past which the text scrolls;
	// without them the app sizes it.
	MinRows, MaxRows int
	// ScrollBeyondLastLine is the rows the text scrolls on past its last
	// line: a screen when 0, none when negative.
	ScrollBeyondLastLine int
	// CursorSurroundingLines is the rows kept in view around the caret as
	// it moves: 1 when 0.
	CursorSurroundingLines int
	Search                 func() Search
	Diagnostics            func() []Diagnostic
	Decorations            func() []Decoration
	// GutterDecorationsWidth is the gutter's strip of marks, 3 when 0.
	GutterDecorationsWidth core.Points
	// Completion asks for completions as typing goes (OnCompletionRequest)
	// and for an inline completion once it pauses
	// (OnInlineCompletionRequest); ShowCompletions asks without it.
	Completion bool
	// CompletionTriggerCharacters ask for completions as they are typed,
	// with an empty query after them ("." for members, "::"); a word
	// character at a word's end does too.
	CompletionTriggerCharacters []string
	// InlineCompletionDelay is how long typing pauses before
	// OnInlineCompletionRequest asks: 300 ms when 0.
	InlineCompletionDelay time.Duration
	// Classes go under Styles, and Class under Style. Under goes under
	// both, part by part: a look passed whole, as TSX's NSH look.
	Classes    Classes
	Styles     Styles
	StylesFunc func() Styles
	Under      Styles
	Label      string
	Class      string
	Style      core.Style
	StyleFunc  func() core.Style
	Ref        *Ref
	TestID     string
	// OnLayout and Tooltip are its view's, as a core.View's.
	OnLayout func(core.Bounds)
	Tooltip  core.Node

	OnSelectionChange   func([]Selection)
	OnSearchChange      func(SearchResult)
	OnFoldChange        func([]FoldRange)
	OnFocus, OnBlur     func()
	OnCompletionRequest func(CompletionRequest)
	OnCompletionAccept  func(CompletionAcceptEvent)
	// OnInlineCompletionRequest asks for an inline completion once typing
	// pauses with no completion list showing.
	OnInlineCompletionRequest func(InlineCompletionRequest)
	OnDefinitionRequest       func(DefinitionRequest)
	// OnCodeActionRequest asks for the code actions at the primary
	// selection, for the app's menu of a language server's.
	OnCodeActionRequest func(CodeActionRequest)
	OnHover             func(HoverEvent)
	OnHoverEnd          func()
	// OnTextPress receives a press on a character, after the caret moved.
	OnTextPress         func(TextPressEvent)
	OnContextMenu       func(ContextMenuEvent)
	OnLineNumberPress   func(line int)
	OnFindWithSelection func(text string)
}

Editor is a code editor ([package editor]). The text is the app's with Value and OnChange, or its own from DefaultValue.

func (Editor) Render

func (p Editor) Render(cx *core.Scope) core.Node

Render implements core.Node.

type FoldRange

type FoldRange struct{ StartLine, EndLine int }

FoldRange is lines StartLine to EndLine: a fold shows the first and hides the others.

type GutterMark

type GutterMark struct {
	Placement GutterPlacement
	Class     string
	Style     core.Style
}

GutterMark is a Decoration's mark in the gutter's strip: a bar the strip's width beside each line of its range, or a line across the strip between two lines. Its look is Class and Style.

type GutterPlacement

type GutterPlacement uint8

GutterPlacement is where a GutterMark is drawn.

const (
	// GutterLines is a bar beside every line the range covers, an empty
	// range covering its line: added or modified lines, a breakpoint.
	GutterLines GutterPlacement = iota
	// GutterBefore is a line across the strip at the boundary before the
	// range's start: the top of its line when it starts one, else the
	// bottom of its line, for lines deleted there.
	GutterBefore
)

type Highlighter

type Highlighter = syntax.Highlighter

Highlighter is the app's highlighting of a language, in place of the built-in one: a tree-sitter grammar, a parser of the app's. It runs off the engine goroutine; the editor keeps its tokens, moves them with the text as it is edited and asks again for the lines in view.

type HoverEvent

type HoverEvent struct {
	Position     Position
	Offset       int
	Range        Range
	PagePosition core.Point
	PageBounds   core.Bounds
	Modifiers    core.Modifiers
	Diagnostics  []Diagnostic
}

HoverEvent is the mouse resting over a character: its position and UTF-16 offset in the text, its word, the pointer and the word's box on its row in the root view, and the diagnostics there.

type InlineCompletionRequest

type InlineCompletionRequest struct {
	ID       int
	Offset   int
	Position Position
}

InlineCompletionRequest asks the app for text to show at the caret once typing pauses: Offset is the caret's in UTF-16 units of the text. The app answers with Ref.PresentInlineCompletion and ID.

type Location

type Location struct {
	URI   string
	Range Range
}

Location is Range in the document at URI, the editor's own when URI is empty.

type OverviewRulerLane

type OverviewRulerLane uint8

OverviewRulerLane is the part of the ruler's width a mark takes, as Monaco's lanes.

const (
	LaneCenter OverviewRulerLane = iota
	LaneLeft
	LaneRight
	LaneFull
)

type OverviewRulerMark

type OverviewRulerMark struct {
	Lane  OverviewRulerLane
	Class string
	Style core.Style
}

OverviewRulerMark is a Decoration's mark on the overview ruler, the strip along the editor's right edge that maps the whole text to its height: the range's rows scaled to the ruler, at least 6 points tall, in one of its lanes. Its look is Class and Style.

type Position

type Position struct{ Line, Column int }

Position is a place in the text: a line from 0 and a column in UTF-16 units, as a language server's.

type Range

type Range struct{ Start, End Position }

Range is the text from Start to End.

type Ref

type Ref struct {
	// contains filtered or unexported fields
}

Ref is an editor's methods, bound once it mounts.

func (*Ref) Blur

func (r *Ref) Blur()

Blur takes the keyboard from the editor.

func (*Ref) CanRedo

func (r *Ref) CanRedo() bool

CanRedo reports whether there is an undone edit to do again.

func (*Ref) CanUndo

func (r *Ref) CanUndo() bool

CanUndo and CanRedo report whether there is an edit to take back or do again.

func (*Ref) CaretBounds

func (r *Ref) CaretBounds() (b Bounds, ok bool)

CaretBounds returns the primary caret's box; ok is false before the editor is laid out.

func (*Ref) Edit

func (r *Ref) Edit(edits []Edit)

Edit applies edits, ranges of the text as it is, as one step undo takes back; one overlapping an earlier one is skipped. The selections move with the text around them. Code actions and formatting edits go here.

func (*Ref) Focus

func (r *Ref) Focus()

Focus gives the editor the keyboard; Blur takes it.

func (*Ref) Fold

func (r *Ref) Fold(line int)

Fold folds the fold on line (from 0), or the innermost one around it; Unfold unfolds it.

func (*Ref) FoldLevel

func (r *Ref) FoldLevel(level int)

FoldLevel folds every fold at nesting level level, 1 the outermost.

func (*Ref) FoldRange

func (r *Ref) FoldRange(f FoldRange)

FoldRange folds the lines of f, wherever the folds start.

func (*Ref) FoldRecursive

func (r *Ref) FoldRecursive(line int)

FoldRecursive folds the fold on line, or the innermost one around it, and every fold inside it.

func (*Ref) Folds

func (r *Ref) Folds() []FoldRange

Folds returns the folded ranges, nested ones included.

func (*Ref) GoToLine

func (r *Ref) GoToLine(line int)

GoToLine puts the caret at line's start and scrolls it to the middle.

func (*Ref) HideCompletions

func (r *Ref) HideCompletions()

HideCompletions closes the completion list.

func (r *Ref) HideDefinitionLink()

HideDefinitionLink drops the definition link.

func (*Ref) HideInlineCompletion

func (r *Ref) HideInlineCompletion()

HideInlineCompletion clears the inline completion.

func (*Ref) Insert

func (r *Ref) Insert(text string)

Insert types text at each selection as it is.

func (*Ref) OffsetToPosition

func (r *Ref) OffsetToPosition(offset int) Position

OffsetToPosition returns the place at offset, in UTF-16 units of the text, clamped to it.

func (*Ref) PositionToOffset

func (r *Ref) PositionToOffset(p Position) int

PositionToOffset returns p as an offset in UTF-16 units of the text.

func (*Ref) PresentCompletions

func (r *Ref) PresentCompletions(id int, items []CompletionItem, incomplete bool)

PresentCompletions answers completion request id with items, filtered by what is typed since; with incomplete, typing on asks again.

func (r *Ref) PresentDefinitionLink(id int, rng Range)

PresentDefinitionLink answers definition request id, of the pointer, by underlining rng as a link until the command key is released or the pointer leaves it.

func (*Ref) PresentInlineCompletion

func (r *Ref) PresentInlineCompletion(id int, text string)

PresentInlineCompletion answers inline completion request id with text, shown at the caret until Tab inserts it, or Escape, an edit or a move clears it.

func (*Ref) RangeBounds

func (r *Ref) RangeBounds(rng Range) []Bounds

RangeBounds returns the boxes of rng, one per row it covers.

func (*Ref) Replace

func (r *Ref) Replace(with string)

Replace replaces the current match of Search and selects the next.

func (*Ref) ReplaceAll

func (r *Ref) ReplaceAll(with string) int

ReplaceAll replaces every match as one edit and returns how many.

func (*Ref) RevealPosition

func (r *Ref) RevealPosition(p Position, center bool)

RevealPosition scrolls p into view, unfolding what hides it; to the middle with center.

func (*Ref) Run

func (r *Ref) Run(c Command)

Run runs a command, as its keys do.

func (*Ref) ScrollOffset

func (r *Ref) ScrollOffset() core.Point

ScrollOffset returns how far the text is scrolled.

func (*Ref) ScrollToLine

func (r *Ref) ScrollToLine(line int)

ScrollToLine scrolls line into view, unfolding what hides it.

func (*Ref) SelectedText

func (r *Ref) SelectedText() string

SelectedText returns the primary selection's text.

func (*Ref) Selections

func (r *Ref) Selections() []Selection

Selections returns every selection, the primary one last.

func (*Ref) SetFolds

func (r *Ref) SetFolds(folds []FoldRange)

SetFolds folds exactly folds.

func (*Ref) SetScrollOffset

func (r *Ref) SetScrollOffset(p core.Point)

SetScrollOffset scrolls the text to p, as far as it goes.

func (*Ref) SetSelections

func (r *Ref) SetSelections(sels []Selection)

SetSelections sets the selections, the last one primary, and scrolls it into view.

func (*Ref) SetValue

func (r *Ref) SetValue(text string)

SetValue replaces the text, as an edit undo takes back.

func (*Ref) ShowCompletions

func (r *Ref) ShowCompletions()

ShowCompletions asks for completions at the caret.

func (*Ref) Unfold

func (r *Ref) Unfold(line int)

Unfold unfolds the fold on or around line.

func (*Ref) UnfoldRecursive

func (r *Ref) UnfoldRecursive(line int)

UnfoldRecursive unfolds the fold on or around line and every fold inside it.

func (*Ref) Value

func (r *Ref) Value() string

Value returns the text.

func (*Ref) VisibleRange

func (r *Ref) VisibleRange() Range

VisibleRange returns the text the viewport shows, from its first row's start to its last row's end.

type RelatedInformation

type RelatedInformation struct {
	Location Location
	Message  string
}

RelatedInformation is another place that tells about a diagnostic (the first definition of a name defined twice), and what it says there. Its range is passed back as the app gave it, not carried through edits.

type Search struct {
	Query                           string
	Regex, CaseSensitive, WholeWord bool
	InSelection                     bool
}

Search is what to find: Query as text, or as a regular expression with Regex ($1 and ${name} in replacements), whole words only with WholeWord, and only inside what was selected when InSelection turned on.

type SearchResult

type SearchResult struct {
	Count, Current int
	Error          string
}

SearchResult is what a search found: how many matches, which one the primary selection is on (-1 for none) and the expression's error.

type Selection

type Selection struct{ Anchor, Head Position }

Selection is a range from Anchor to Head, the caret.

type Severity

type Severity uint8

Severity is how serious a diagnostic is.

const (
	SeverityError Severity = iota
	SeverityWarning
	SeverityInfo
	SeverityHint
)

type Styles

type Styles struct {
	// Gutter is the column of line numbers and fold markers; LineNumber
	// every number, ActiveLineNumber those of lines with a caret;
	// FoldMarker a fold's marker, ⌄ or › folded.
	Gutter, LineNumber, ActiveLineNumber, FoldMarker core.Style
	// Content is the text area beside the gutter; Line every row;
	// ActiveLine behind the rows of lines with a caret.
	Content, Line, ActiveLine core.Style
	// Selection is behind selected text; Caret each caret, 1 point wide
	// unless it gives a width; Composition the text an input method
	// composes.
	Selection, Caret, Composition core.Style
	// SearchMatch and CurrentSearchMatch are behind the matches of Search
	// and the one the primary selection is on.
	SearchMatch, CurrentSearchMatch core.Style
	// MatchingBracket is the boxes of the bracket at the caret and its
	// partner; IndentGuide the line of each indentation level;
	// FoldPlaceholder what a folded line shows after its text.
	MatchingBracket, IndentGuide, FoldPlaceholder core.Style
	// Placeholder is the placeholder's text.
	Placeholder core.Style
	// The text of each severity's diagnostics, and of tagged ones.
	DiagnosticError, DiagnosticWarning, DiagnosticInfo, DiagnosticHint core.Style
	UnnecessaryText, DeprecatedText                                    core.Style
	// SelectionHandle is the knobs at a touch selection's ends.
	SelectionHandle core.Style
	// The completion list's box, items, selected item, the letters the
	// query matched, an item's detail and kind, and the documentation.
	CompletionMenu, CompletionItem, SelectedCompletionItem core.Style
	CompletionMatch, CompletionDetail, CompletionKind      core.Style
	CompletionDocumentation                                core.Style
	// DefinitionLink is the line under a definition link's text.
	DefinitionLink core.Style
	// InlineCompletion is the text of an inline completion at the caret.
	InlineCompletion core.Style
	// Whitespace is the · of each space and → of each tab with
	// ShowWhitespaces; Ruler the line at each of Rulers' columns, 1 point
	// wide unless it gives a width.
	Whitespace, Ruler core.Style
	// OverviewRuler is the strip of decorations' marks along the right
	// edge, 14 points wide unless it gives a width.
	OverviewRuler core.Style
}

Styles are the styles of the editor's parts, its whole look. A state's part merges over the part it follows.

type TextPressEvent

type TextPressEvent struct {
	Position     Position
	Offset       int
	Range        Range
	PagePosition core.Point
	Modifiers    core.Modifiers
	Clicks       int
}

TextPressEvent is a press on a character, after the editor placed its caret: its position and UTF-16 offset, its word, the pointer in the root view, the modifiers and the presses counted at the place.

type Token

type Token = syntax.Token

Token is a run of a line a Highlighter colors: from byte Start to End, as the highlighting's kind Kind names (comment, keyword, string, number, title, attr, built, deletion).

type TokenKind

type TokenKind string

TokenKind is a kind of token the highlighting colors: comment, keyword, string, number, title, attr, built or deletion.

Jump to

Keyboard shortcuts

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