editor

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 59 Imported by: 0 modules, 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 holds the editor widget (SPEC §9).

Index

Constants

View Source
const (
	// SemanticByTheme: the theme's semanticHighlighting decides (editor.semanticHighlighting.enabled "configuredByTheme").
	SemanticByTheme = "configuredByTheme"
	// SemanticOn and SemanticOff: the setting decides for every theme.
	SemanticOn  = "on"
	SemanticOff = "off"
)

The values of LensOptions.Semantic.

View Source
const (
	// MinZoomLevel is the lowest zoom level of the editor font.
	MinZoomLevel = -5.0
	// MaxZoomLevel is the highest zoom level of the editor font.
	MaxZoomLevel = 20.0
)
View Source
const BlinkInterval = 500 * time.Millisecond

BlinkInterval is how long the cursor stays shown or hidden while it blinks.

Ported from VS Code: src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts (BLINK_INTERVAL)

View Source
const (
	// BreadcrumbsHeight is the height of the bar.
	BreadcrumbsHeight = 22.0
)

Metrics of VS Code's breadcrumbs bar and its picker.

View Source
const DefaultParagraphCacheSize = 2000

DefaultParagraphCacheSize is how many paragraphs the cache keeps (SPEC §9.2).

View Source
const ViewStateVersion = 1

ViewStateVersion is the version of the JSON of a ViewState, which the saved state of a window holds (SPEC §10.10). A state with another version is refused with the tag ViewStateVersionUnsupported.

Variables

This section is empty.

Functions

func BindCommands

func BindCommands(r *command.Registry, vm *ViewModel) (unbind func())

BindCommands attaches the handlers of the editor commands to a registry for a view model, and returns the function that takes them off again. An editor binds its commands while it has the focus, so that the keys of a window run them on the editor in front of the user (handlers stack: SPEC §11.2). A command the registry does not know is skipped: the registry of the process lists them all (a test checks it).

func CanExpandSuggestion added in v1.0.0

func CanExpandSuggestion(it *langfeatures.SuggestItem) bool

CanExpandSuggestion is canExpand for the widget.

func CommandIDs

func CommandIDs() []string

CommandIDs are the ids of the commands the editor implements.

func FontFamilies

func FontFamilies(value string) []string

FontFamilies splits the value of editor.fontFamily: comma-separated names, each trimmed and without the quotes around a name with spaces.

func LineHeight

func LineHeight(setting, fontSize float64) float64

LineHeight is the height of a line in pixels for the editor.lineHeight setting and the font size: 0 means round(1.35 × fontSize); a value below 8 is a multiplier of the font size; any other value is the height itself. The result is rounded to whole pixels and is at least 8.

func LineNumberText

func LineNumberText(mode LineNumbersMode, line, cursorLine, lineCount int) (text string, current bool)

LineNumberText is what the gutter shows for a model line (from 0), given the line of the cursor and the number of lines. It is empty when no number is shown. current is true for the cursor's line in relative mode, which VS Code shows left-aligned.

Ported from VS Code: src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts

func MergeRanges added in v1.0.0

func MergeRanges(ranges []buffer.Range) []buffer.Range

MergeRanges sorts the ranges and joins the ones that overlap or touch (VS Code's formatDocumentRangesWithProvider).

func NewLinesView

func NewLinesView(opts LinesViewOpts) widgets.Widget

NewLinesView makes a widget that draws lines of a view model's document (see LinesViewOpts).

func ParseFontWeight

func ParseFontWeight(value string) int

ParseFontWeight reads editor.fontWeight: "normal" and "bold" are 400 and 700, a number from 1 to 1000 is itself, and anything else is normal.

func SymbolIcon added in v1.0.0

func SymbolIcon(colors kit.Colors, kind int) (code int, color ui.Color)

SymbolIcon is the code point of the Codicon of a symbol kind (the LSP's SymbolKind) and its color in the theme.

func SymbolIconCode added in v1.0.0

func SymbolIconCode(kind int) int

SymbolIconCode is the code point of the Codicon of a symbol kind, for the lists that cannot color it.

Types

type ActionBarItem added in v1.0.0

type ActionBarItem struct {
	Label string
	Run   func()
}

ActionBarItem is a link of the bar under the list of actions.

type ActionList added in v1.0.0

type ActionList struct {
	Items []ActionListItem
	// Focus is the row that Enter applies, or -1.
	Focus int
	// Anchor is the position the list hangs from: the line of the cursor or of the light bulb.
	Anchor buffer.Position
	// Bar are the links under the list ("Show Disabled").
	Bar []ActionBarItem
	// contains filtered or unexported fields
}

ActionList is the list of actions that is open.

type ActionListItem added in v1.0.0

type ActionListItem struct {
	// Header says that the row is a group header, with the group's title as Title.
	Header bool
	// Title is the text of the row: the title of the action, or its reason when it is disabled.
	Title string
	// Action is the action of a row that is not a header.
	Action langfeatures.CodeAction
	// Disabled says that the action cannot be applied; the row shows its reason and cannot be chosen.
	Disabled bool
	// Key is the label of the key of the action ("Shift+Alt+O"), or empty.
	Key string
	// Icon is the codepoint of the Codicon in front of the row; 0 is the light bulb in its color.
	Icon int
	// CanPreview says that Ctrl+Enter shows the changes of the action before they are made.
	CanPreview bool
}

ActionListItem is a row of the list of actions: a header, or an action.

type BackgroundMark

type BackgroundMark struct {
	// Range is where the mark is. With WholeLine it is the lines from the one the range starts on to the one it
	// ends on, both included (an empty range is the one line it is on).
	Range buffer.Range
	// WholeLine fills the rows of the lines across the editor with Background; without it Background fills the
	// characters of the range.
	WholeLine bool
	// Background is the fill, Border the outline of a range of characters (drawn inside it); a transparent
	// color draws nothing.
	Background, Border ui.Color
	// Gutter, when it is not transparent, fills the gutter along the rows of the lines of a WholeLine mark.
	Gutter ui.Color
	// BackgroundID and GutterID name theme colors that stand in for Background and Gutter, looked up when the mark is drawn so that the
	// mark follows the theme (the coverage marks use them); a color the theme does not know leaves the plain one.
	BackgroundID, GutterID string
}

BackgroundMark colors part of the text of an editor.

type BracketColors

type BracketColors struct {
	Levels     [6]ui.Color
	Unexpected ui.Color
}

BracketColors are the colors of the brackets (SPEC §8.5): one for each nesting level, which repeat past the sixth, and one for the brackets that have no partner. A transparent color leaves the bracket in the color of its token.

type BreadcrumbEntry struct {
	// Name is the name of the entry in its folder.
	Name string
	// Path is its absolute path.
	Path string
	// Dir tells a folder (or a link to one) from a file.
	Dir bool
}

BreadcrumbEntry is a file or folder that a breadcrumbs picker lists.

func ReadSiblings

func ReadSiblings(ctx context.Context, dir string) ([]BreadcrumbEntry, error)

ReadSiblings lists a folder for a breadcrumbs picker: folders first, then files, each in natural order ignoring case (the explorer's default order). A link is a folder when what it points at is one. The read stops when ctx is cancelled.

type BreadcrumbItem struct {
	// Name is what the bar shows.
	Name string
	// Path is the absolute path of the folder or file the segment stands for.
	Path string
	// Dir tells a folder from the file.
	Dir bool
}

BreadcrumbItem is one segment of the path of a file: a folder or the file.

func BreadcrumbItems(file, root, mode string) []BreadcrumbItem

BreadcrumbItems are the segments of the path of a file, from the outermost folder to the file. With a root (the folder that is open) that contains the file, the first segment is the root, named as its folder is, and the others are relative to it; otherwise the segments are the parts of the absolute path. mode is breadcrumbs.filePath: "on" gives all of them, "last" only the file, anything else none. A relative or empty path has none.

type Breadcrumbs struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Breadcrumbs is the bar above an editor with the path of its file. Each segment opens a picker of its siblings: a folder in the picker is entered, a file is opened through OnOpen. The folders are read in the background with the ctx the bar is made with. After the path it shows the symbols that hold the cursor of its View (breadcrumbs.symbolPath); a symbol opens a picker of the symbols of its level, and choosing one goes to it.

func NewBreadcrumbs

func NewBreadcrumbs(ctx context.Context, file string, options BreadcrumbsOptions, opts ...BreadcrumbsOpts) *Breadcrumbs

NewBreadcrumbs makes the bar for the file at an absolute path ("" for a document without one, which has no bar). It is empty, with no height, when breadcrumbs.enabled is off or the path has no segments. The ctx stops the reading of folders when it is cancelled.

func (b *Breadcrumbs) CreateState() widgets.State

CreateState implements widgets.StatefulWidget.

func (b *Breadcrumbs) Items() []BreadcrumbItem

Items are the segments the bar shows.

type BreadcrumbsOptions struct {
	// Enabled is breadcrumbs.enabled: whether the bar is shown.
	Enabled bool
	// FilePath is breadcrumbs.filePath: "on" shows the whole path, "last" only the file's name and
	// "off" no path.
	FilePath string
	// Icons is breadcrumbs.icons: whether the items have icons.
	Icons bool
	// SymbolPath is breadcrumbs.symbolPath: "on" shows the symbols that hold the cursor after the file, "last" only the
	// innermost, "off" none (also when empty).
	SymbolPath string
	// SymbolSortOrder is breadcrumbs.symbolSortOrder ("position", "name" or "type"): the order of the symbols in the picker of a
	// symbol.
	SymbolSortOrder string
	// DecorationColors and DecorationBadges are explorer.decorations.colors and .badges: whether the files of a picker are drawn in the
	// color of their file decoration and with its badge. The bar itself is not decorated (VS Code's showDecorationColors is false there).
	DecorationColors, DecorationBadges bool
	// HiddenKinds are the symbol kinds the settings breadcrumbs.showXxx turn off, indexed by the LSP's SymbolKind.
	HiddenKinds [langfeatures.SymbolKindCount + 1]bool
}

BreadcrumbsOptions are the settings of the breadcrumbs bar.

func BreadcrumbsOptionsFromSettings(store *settings.Store) BreadcrumbsOptions

BreadcrumbsOptionsFromSettings reads the breadcrumbs settings.

type BreadcrumbsOpts struct {
	// Root is the folder that is open: a file inside it is shown relative to it. Empty when there
	// is no folder.
	Root string
	// OnOpen is called with the path of a file the user chose in a picker.
	OnOpen func(path string)
	// ReadDir lists a folder for a picker; the default is ReadSiblings. The workbench replaces it
	// with one that applies files.exclude.
	ReadDir func(ctx context.Context, dir string) ([]BreadcrumbEntry, error)
	// View is the editor whose symbols the bar shows after the path of the file: the chain of symbols that hold its cursor,
	// each opening a picker of its siblings. Without it the bar has the path only.
	View *ViewModel
}

BreadcrumbsOpts are the options of NewBreadcrumbs.

type BreakpointContext added in v1.0.0

type BreakpointContext int

BreakpointContext is what the breakpoint widget edits; the numbers are the entries of its dropdown.

const (
	// BreakpointCondition is an expression that must be true for the breakpoint to stop (the first entry, "Expression").
	BreakpointCondition BreakpointContext = iota
	// BreakpointHitCount is a condition on the number of hits ("Hit Count").
	BreakpointHitCount
	// BreakpointLogMessage is a message to log instead of stopping ("Log Message").
	BreakpointLogMessage
	// BreakpointTriggerPoint is another breakpoint to wait for ("Wait for Breakpoint").
	BreakpointTriggerPoint
)

The kinds the breakpoint widget edits.

type BreakpointMode added in v1.0.0

type BreakpointMode struct {
	Mode, Label, Description string
}

BreakpointMode is a mode an adapter offers for source breakpoints.

type BreakpointTrigger added in v1.0.0

type BreakpointTrigger struct {
	ID, Label, Description string
}

BreakpointTrigger is a breakpoint a new one can wait for.

type BreakpointWidgetResult added in v1.0.0

type BreakpointWidgetResult struct {
	Condition, HitCondition, LogMessage *string
	// Trigger says that the entry was "Wait for Breakpoint": TriggeredBy is the breakpoint chosen, empty for none, and the other three
	// are nil.
	Trigger     bool
	TriggeredBy string
	// Mode and ModeLabel are the adapter's mode chosen, when it has more than one.
	Mode, ModeLabel string
}

BreakpointWidgetResult is what the breakpoint widget accepted. A nil member is left as it is (or not set).

type BreakpointWidgetSpec added in v1.0.0

type BreakpointWidgetSpec struct {
	// Line is counted from 0; Inline and Col say that the breakpoint is at a column (the byte offset).
	Line, Col int
	Inline    bool
	// Context is the entry shown first.
	Context BreakpointContext
	// Condition, HitCondition, LogMessage and TriggeredBy are the values the breakpoint has now (the empty ones for a new one).
	Condition, HitCondition, LogMessage, TriggeredBy string
	// Triggers are the breakpoints that can be waited for and Modes the adapter's modes (the dropdown of modes shows with two or more).
	Triggers []BreakpointTrigger
	Modes    []BreakpointMode
	Mode     string
	// Accept is called with what was typed when Enter is pressed (or OK, for a trigger).
	Accept func(BreakpointWidgetResult)
	// Closed is called when the widget goes, accepted or not.
	Closed func()
}

BreakpointWidgetSpec describes a breakpoint widget to show.

type Clipboard

type Clipboard interface {
	// Write puts a text on the clipboard.
	Write(text string, done func(error))
	// Read gets the text on the clipboard; it is empty when there is none.
	Read(done func(text string, err error))
	// WritePrimary puts a text on the primary selection.
	WritePrimary(text string, done func(error))
	// ReadPrimary gets the text of the primary selection.
	ReadPrimary(done func(text string, err error))
}

Clipboard is where an editor copies to and pastes from: the system clipboard and the primary selection of the desktop. Every function calls done later, on the UI thread, and never before it has returned (Glutter's clipboard works so).

func NewClipboard

func NewClipboard(ctx context.Context, c *services.Clipboard) Clipboard

NewClipboard makes the Clipboard of Glutter's clipboard service; ctx is the context of the requests to the desktop.

type ClipboardMemory

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

ClipboardMemory remembers how the last text that an editor copied was made, so that pasting it back knows more than the text says: it was a whole line, it came from several cursors, it was a column. When something else has been copied since, the text no longer matches and the memory is forgotten. Editors of a window share one, so that a copy in one can be pasted in another.

Ported from VS Code: src/vs/editor/browser/controller/editContext/clipboardUtils.ts (InMemoryClipboardMetadataManager)

func NewClipboardMemory

func NewClipboardMemory() *ClipboardMemory

NewClipboardMemory makes an empty memory.

type CodeActionOptions added in v1.0.0

type CodeActionOptions struct {
	// Lightbulb is editor.lightbulb.enabled: "off", "onCode" (also when empty) or "on".
	Lightbulb string
	// ShowHeaders is editor.codeActionWidget.showHeaders: the list groups the actions under headers.
	ShowHeaders bool
	// IncludeNearbyQuickFixes is editor.codeActionWidget.includeNearbyQuickFixes: Quick Fix... also lists the fixes of the
	// diagnostics on the cursor's line when there are none at the cursor.
	IncludeNearbyQuickFixes bool
}

CodeActionOptions are the settings of the code actions (editor.lightbulb.enabled and editor.codeActionWidget.*).

type ColumnRuler

type ColumnRuler struct {
	// Column is the number of characters from the left edge of the text.
	Column int
	// Color is the color of the line, or the transparent color when the theme's
	// editorRuler.foreground is used.
	Color ui.Color
}

ColumnRuler is a vertical line drawn after a number of characters (editor.rulers).

type DebugBreakpointMark added in v1.0.0

type DebugBreakpointMark struct {
	// ID is the id of the breakpoint in the debug model.
	ID string
	// Line is the line, counted from 0; Col is the byte column of an inline breakpoint (Inline is true), where it is.
	Line, Col int
	Inline    bool
	Kind      DebugGlyph
	// Enabled and Verified are the state of the breakpoint; Activated is false while the breakpoints as a whole are switched off.
	Enabled, Verified, Activated bool
	// Unsupported is a breakpoint with a condition or message that the adapter cannot honor; Pending a triggered one that waits for
	// another to be hit.
	Unsupported, Pending bool
	// Hover is the Markdown of the hover of the glyph (the adapter's message, or the condition); empty for none.
	Hover string
}

DebugBreakpointMark is a breakpoint in the editor.

type DebugCandidate added in v1.0.0

type DebugCandidate struct {
	Line, Col int
}

DebugCandidate is a place of a line where an inline breakpoint can be set (the adapter's breakpointLocations answer).

type DebugColors added in v1.0.0

type DebugColors struct {
	Breakpoint, BreakpointDisabled, BreakpointUnverified ui.Color
	// StackFrame is the arrow of the top frame in the margin and FocusedFrame the arrow of the others.
	StackFrame, FocusedFrame ui.Color
	// StackFrameLine and FocusedFrameLine are the backgrounds of the lines of the two kinds of frame.
	StackFrameLine, FocusedFrameLine ui.Color
	// Ruler marks: the breakpoints, the top frame and the focused frame on the overview ruler.
	RulerBreakpoint ui.Color
}

DebugColors are the colors of the debug marks.

type DebugException added in v1.0.0

type DebugException struct {
	// ID is the id of the exception (its type), Description what is wrong and StackTrace where.
	ID, Description, StackTrace string
}

DebugException is the exception the program stopped on.

func (DebugException) ExceptionText added in v1.0.0

func (e DebugException) ExceptionText() string

ExceptionText is the text of an exception as Copy puts it on the clipboard.

type DebugFrameMark added in v1.0.0

type DebugFrameMark struct {
	// Line is counted from 0 and Col is the byte column of the frame (0 for the start of the line).
	Line, Col int
	// Top is the top frame of its thread, which has the stronger highlight; the others are the focused frame.
	Top bool
	// Glyph draws the arrow in the glyph margin: the frame belongs to the focused session.
	Glyph bool
}

DebugFrameMark is a stack frame in the editor: the line the program stopped at (Top), or the frame that the user focused.

type DebugGlyph added in v1.0.0

type DebugGlyph int

DebugGlyph is the kind of a breakpoint, which decides its icon.

const (
	// DebugGlyphBreakpoint is a plain breakpoint, DebugGlyphConditional one with a condition or a hit count, DebugGlyphLog a logpoint
	// and DebugGlyphFunction a function breakpoint (shown in the margin where the adapter resolved it).
	DebugGlyphBreakpoint DebugGlyph = iota
	DebugGlyphConditional
	DebugGlyphLog
	DebugGlyphFunction
)

The kinds of breakpoint.

type DebugHost added in v1.0.0

type DebugHost struct {
	// Enabled says whether breakpoints can be set in the document: a debugger is available for its language (VS Code's
	// canSetBreakpointsIn). Without it the glyph margin does nothing.
	Enabled func() bool
	// GlyphPress is a press of the primary or the middle button on the glyph margin of a line (counted from 0); with the right button
	// the menu is asked for (see TakeDebugMenuTarget).
	GlyphPress func(line int, mods MouseModifiers, middle bool)
	// InlinePress is a click on an inline breakpoint or on a candidate: id is the breakpoint, empty for a candidate with none.
	InlinePress func(line, col int, id string)
	// HoverReady says that the debug hover works in this editor: a session is stopped in a frame of this document.
	HoverReady func() bool
	// Evaluate evaluates the expression for the hover (context hover) at the place and calls done on the UI thread with what it shows,
	// or with nil when the expression has no value.
	Evaluate func(expr string, rng buffer.Range, done func(*DebugHoverContent))
}

DebugHost is what the window gives the editor to act on the debugger. Every function is called on the UI thread; any may be nil.

type DebugHoverContent added in v1.0.0

type DebugHoverContent struct {
	// Range is the expression under the pointer; the box stands over its start.
	Range buffer.Range
	// Complex says that the value has children: the box shows the title, the tree and the tip about the Alt key.
	Complex bool
	// Body builds the content of the box.
	Body func(bc widgets.BuildContext) widgets.Widget
	// Width and Height are the size the content wants, to place the box before it is laid out.
	Width, Height float64
}

DebugHoverContent is what the debug hover shows.

type DebugMenuTarget added in v1.0.0

type DebugMenuTarget struct {
	// Line is counted from 0 and Col is the byte column of an inline breakpoint or candidate, -1 for the glyph margin.
	Line, Col int
	// ID is the breakpoint of an inline mark that was pressed.
	ID string
	// InGlyph says that the press was in the glyph margin (or on an inline mark): the window shows the menu of the breakpoints.
	InGlyph bool
}

DebugMenuTarget is where the secondary button was pressed last, for the menu of the glyph margin.

type DebugOptions added in v1.0.0

type DebugOptions struct {
	// InlineValues is debug.inlineValues: "auto", "on" or "off".
	InlineValues string
	// OverviewRuler is debug.showBreakpointsInOverviewRuler.
	OverviewRuler bool
	// InlineCandidates is debug.showInlineBreakpointCandidates.
	InlineCandidates bool
	// MiddleClickAction is debug.gutterMiddleClickAction: "logpoint", "conditionalBreakpoint", "triggeredBreakpoint" or "none".
	MiddleClickAction string
}

DebugOptions are the settings debug.* that the editor reads.

type DevState added in v1.0.0

type DevState struct {
	// InSnippet is the context key inSnippetMode, TabStops the tab stops of the session that are decorations of the document
	// (0 when no session runs: nothing is drawn then).
	InSnippet bool
	TabStops  int
	// SuggestVisible and SignatureVisible tell whether the suggest widget and the parameter hints show.
	SuggestVisible, SignatureVisible bool
	// HoverVisible tells whether the hover box shows.
	HoverVisible bool
}

DevState is what the editor shows of the modes that live in the view model, for the dev server (dev.editor).

type Diagnostic added in v1.0.0

type Diagnostic struct {
	// Range is where the problem is.
	Range buffer.Range
	// Severity is how serious it is.
	Severity DiagnosticSeverity
	// Message is what is wrong; Source says who found it and Code names the problem. CodeHref, when set, is a page that
	// describes the code.
	Message, Source, Code, CodeHref string
	// Unnecessary fades the text of the range (unused code) and Deprecated strikes it through.
	Unnecessary, Deprecated bool
	// Owner is the producer of the diagnostic (the owner of the marker).
	Owner string
	// Related are the places that are part of the problem.
	Related []DiagnosticRelated
	// Data is the diagnostic as its producer wants it back with a request for code actions (a language server's diagnostic as
	// JSON); may be empty.
	Data json.RawMessage
}

Diagnostic is a problem of the document the editor shows: a marker, with its range in byte positions of the text.

type DiagnosticColors added in v1.0.0

type DiagnosticColors struct {
	// Error, Warning, Info and Hint are the colors of the squiggles (the dots for a hint).
	Error, Warning, Info, Hint ui.Color
	// ErrorBorder, WarningBorder, InfoBorder and HintBorder, when they are not transparent, add a double underline (the
	// themes of high contrast).
	ErrorBorder, WarningBorder, InfoBorder, HintBorder ui.Color
	// UnnecessaryOpacity is the opacity of unused code (its alpha) and UnnecessaryBorder the dashed line under it when it is
	// not transparent.
	UnnecessaryOpacity, UnnecessaryBorder ui.Color
}

DiagnosticColors are the colors of the diagnostics in the editor.

type DiagnosticRelated added in v1.0.0

type DiagnosticRelated struct {
	// Resource is the absolute path of the file.
	Resource string
	// Message says why the place is related.
	Message string
	// Line and Column are where the range starts, counted from 1.
	Line, Column int
}

DiagnosticRelated is a place that is part of a diagnostic, in another file or in the same one. Its range counts from 1, in UTF-16 units, as the markers do.

type DiagnosticSeverity added in v1.0.0

type DiagnosticSeverity int

DiagnosticSeverity says how serious a diagnostic is. The values are VS Code's MarkerSeverity, so that a larger value is more serious.

const (
	// DiagnosticHint is a suggestion, drawn as three dots (no mark on the overview ruler).
	DiagnosticHint DiagnosticSeverity = 1
	// DiagnosticInfo is information.
	DiagnosticInfo DiagnosticSeverity = 2
	// DiagnosticWarning is a warning.
	DiagnosticWarning DiagnosticSeverity = 4
	// DiagnosticError is an error.
	DiagnosticError DiagnosticSeverity = 8
)

The severities of a diagnostic.

func (DiagnosticSeverity) String added in v1.0.0

func (s DiagnosticSeverity) String() string

String is the word for the severity as the hover and the tests name it.

type Editor

type Editor struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Editor is the editor widget: the text of a view model with its gutter, its selections, its current line and its cursors, scrolled together by a Scrollable. Input comes with later steps.

func NewEditor

func NewEditor(vm *ViewModel, opts ...EditorOpts) *Editor

NewEditor makes the editor of a view model.

func (*Editor) CreateState

func (e *Editor) CreateState() widgets.State

CreateState implements widgets.StatefulWidget.

func (*Editor) Tokenizer

func (e *Editor) Tokenizer() *tokens.Tokenizer

Tokenizer is the tokenizer of the document the editor shows, or nil. Tests use it to wait for the colors of the text (see testutil.SettleTokens).

func (*Editor) ViewModel

func (e *Editor) ViewModel() *ViewModel

ViewModel is the view model the editor shows.

type EditorFocus

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

EditorFocus lets code outside an editor give it the keyboard focus. Give one to the options of an Editor; it works while that editor is on screen.

func (*EditorFocus) HasFocus

func (f *EditorFocus) HasFocus() bool

HasFocus tells whether the editor has the focus.

func (*EditorFocus) Node added in v1.0.0

func (f *EditorFocus) Node() *widgets.FocusNode

Node is the focus node of the editor, or nil while the editor is not on screen. It tells which context key scope belongs to the editor (kit.FocusScopes) whatever has the focus.

func (*EditorFocus) Request

func (f *EditorFocus) Request() bool

Request gives the focus to the editor. It reports false when the editor is not on screen (yet).

type EditorOpts

type EditorOpts struct {
	// Commands is the registry whose editor commands the editor takes over while it has the
	// focus (see BindCommands).
	Commands *command.Registry
	// Keys is the scope of the context keys the editor makes its own scope in: it sets
	// editorTextFocus, editorFocus, textInputFocus, editorHasSelection,
	// editorHasMultipleSelections, editorColumnSelection, editorReadonly, editorTabMovesFocus
	// and editorLangId there. Without it the editor sets no context keys.
	Keys *contextkey.Scope
	// Scopes registers the editor's focus node with its scope, so that the key dispatcher
	// of the window resolves keys in it while the editor has the focus.
	Scopes *kit.FocusScopes
	// Autofocus asks for the focus when the editor is first shown.
	Autofocus bool
	// OnError is told about the errors of the keyboard input, such as typing into a
	// read-only document. Without it they are dropped.
	OnError func(error)
	// Context is the context of what the editor asks of the desktop (the clipboard); without
	// it that is context.Background().
	Context context.Context
	// Zoom is the zoom of the font that the editors of a window share; without it the editor has
	// its own.
	Zoom *Zoom
	// InputMode is the insert or overtype mode that the editors of the process share; without it the editor has its
	// own.
	InputMode *InputMode
	// ClipboardMemory is what the editors of a window remember of their copies, so that a copy
	// in one can be pasted in another as it was made; without it the editor has its own.
	ClipboardMemory *ClipboardMemory
	// FindMemory is what the editors of a window share of their searches (the switches of the
	// find widget); without it the editor has its own.
	FindMemory *FindMemory
	// Focus lets the caller give the keyboard focus to the editor.
	Focus *EditorFocus
	// OnFocus is called when the editor, or an input of its find widget, gets or loses the keyboard
	// focus; the editor groups of the window follow it to know which group is active.
	OnFocus func(has bool)
}

EditorOpts configure an Editor; every field is optional.

type EmmetOptions

type EmmetOptions struct {
	// TriggerExpansionOnTab makes the Tab key expand the abbreviation before the cursor.
	TriggerExpansionOnTab bool
	// IncludeLanguages, ExcludeLanguages, Variables and SyntaxProfiles are read by core/emmet.
	IncludeLanguages, ExcludeLanguages, Variables, SyntaxProfiles any
}

EmmetOptions are the settings of Emmet that the editor reads: the values of emmet.includeLanguages, emmet.excludeLanguages, emmet.variables and emmet.syntaxProfiles as the settings store holds them, and emmet.triggerExpansionOnTab.

type FindMemory

type FindMemory struct {
	MatchCase, WholeWord, Regex, PreserveCase bool
}

FindMemory holds what the editors of a window share of their searches: the switches stay as the user set them when another editor opens (VS Code keeps them in the workspace storage).

type FindUI

type FindUI struct {
	// FocusFind and FocusReplace give the focus to an input of the widget, FocusEditor to the
	// editor.
	FocusFind, FocusReplace, FocusEditor func()
	// InputFocus says which input of the widget has the focus.
	InputFocus func() (findInput, replaceInput bool)
}

FindUI is what the view model asks of the find widget that the editor shows. Every function is optional.

type FoldingState

type FoldingState int

FoldingState says what the folding control of a line shows.

const (
	// FoldingNone is a line no region starts on.
	FoldingNone FoldingState = iota
	// FoldingExpanded is the first line of a region that is open.
	FoldingExpanded
	// FoldingCollapsed is the first line of a region that is folded.
	FoldingCollapsed
)

type FontFeature

type FontFeature struct {
	Tag   string
	Value int
}

FontFeature is an OpenType feature of a font: a tag and its value (0 is off).

func ParseFontFeatureSettings

func ParseFontFeatureSettings(s string) []FontFeature

ParseFontFeatureSettings reads a CSS font-feature-settings value such as `"liga" 0, 'ss01', "calt" off`: a quoted tag, then an optional integer, "on" or "off" (on is the default). Entries that are not understood are skipped; nil means none were.

type FormatOptions added in v1.0.0

type FormatOptions struct {
	// OnType is editor.formatOnType and OnPaste editor.formatOnPaste.
	OnType, OnPaste bool
	// DefaultFormatter is editor.defaultFormatter: the id of the extension whose formatter is used when a language has several.
	DefaultFormatter string
}

FormatOptions are the settings of the formatting that follows typing and pasting.

type GoConfig added in v1.0.0

type GoConfig struct {
	// Peek opens the peek view whatever the number of results is (the Peek commands).
	Peek bool
	// Side opens the location in the group beside the active one.
	Side bool
	// Mute leaves out the message of a navigation that found nothing.
	Mute bool
	// Run runs a command of the editor by id, for the alternative command of a navigation (a command is run by the actions
	// that call GoTo, which can reach the table of commands); without it there is no alternative command.
	Run func(id string) error
}

GoConfig says how a navigation command behaves.

type GoKind added in v1.0.0

type GoKind int

GoKind is the kind of location a navigation command looks for.

const (
	GoDefinition GoKind = iota
	GoDeclaration
	GoTypeDefinition
	GoImplementation
	GoReferences
)

The kinds of navigation, in the order of the settings editor.gotoLocation.multiple* and alternative*Command.

func (GoKind) Feature added in v1.0.0

func (k GoKind) Feature() langfeatures.Feature

Feature is the feature the providers must offer.

type GotoLocationOptions added in v1.0.0

type GotoLocationOptions struct {
	// Multiple is what a navigation does when it finds several locations, by GoKind: "peek" (also when empty), "gotoAndPeek" or
	// "goto".
	Multiple [goKinds]string
	// Alternative is the command that runs when the only location found is the one the cursor is on, by GoKind; empty for none.
	Alternative [goKinds]string
	// DefinitionLinkOpensInPeek makes the mouse gesture (Ctrl+click) open the peek view.
	DefinitionLinkOpensInPeek bool
}

GotoLocationOptions are the settings editor.gotoLocation.* and editor.definitionLinkOpensInPeek.

type GuideColor

type GuideColor struct {
	Color, Active ui.Color
}

GuideColor is the color of the guides of a level and the one they have when highlighted.

type GuideColors

type GuideColors struct {
	Indent, Bracket []GuideColor
}

GuideColors are the colors of the indent guides and of the bracket pair guides, by level. Only the levels that have a color are listed, and the levels of the guides go round the list.

func NewGuideColors

func NewGuideColors(indentColors, indentActive, pairColors, pairActive, bracketColors [6]ui.Color) GuideColors

NewGuideColors makes the colors of the guides from the colors of a theme. A bracket pair guide with no color of its own takes the color of the brackets of its level, with 30% of its opacity when inactive; a level whose colors are transparent is left out, so that a theme that colors the first three levels has guides of three colors.

Ported from VS Code: indentGuides.ts (registerThemingParticipant)

type GutterColors

type GutterColors struct {
	// LineNumber is the color of a line number.
	LineNumber ui.Color
	// ActiveLineNumber is the color of the number of the cursor's line.
	ActiveLineNumber ui.Color
	// LineHighlight and LineHighlightBorder are the background and the border of the current
	// line when the editor highlights it in the gutter.
	LineHighlight, LineHighlightBorder ui.Color
	// FoldingControl is the color of the folding controls.
	FoldingControl ui.Color
	// QuickDiff are the colors of the stripes of the quick diff.
	QuickDiff QuickDiffColors
	// Test are the colors of the glyphs of the tests in the glyph margin.
	Test TestColors
	// Debug are the colors of the debug marks in the glyph margin.
	Debug DebugColors
}

GutterColors are the colors of the line numbers.

type GutterOptions

type GutterOptions struct {
	LineNumbers         LineNumbersMode
	LineNumbersMinChars int
	// DigitWidth is the width of the widest digit of the editor font.
	DigitWidth float64
	LineHeight float64
	// GlyphMargin says whether there is a glyph margin; it is as wide as a line is high for each of its lanes (GlyphLanes, 1 when 0).
	GlyphMargin bool
	GlyphLanes  int
	// LineDecorationsWidth is the width of the line decorations (10 in VS Code).
	LineDecorationsWidth float64
	// Folding says whether the folding controls take room (16 pixels more).
	Folding bool
}

GutterOptions are what the width of the gutter depends on.

type GutterWidths

type GutterWidths struct {
	// GlyphMargin is the margin for glyphs such as breakpoints.
	GlyphMargin float64
	// LineNumbers is the room for the line numbers.
	LineNumbers float64
	// Decorations is the room for line decorations and the folding controls.
	Decorations float64
}

GutterWidths are the widths of the parts of the gutter, left to right.

func ComputeGutterWidths

func ComputeGutterWidths(o GutterOptions, lineCount int) GutterWidths

ComputeGutterWidths gives the widths of the gutter for a document of lineCount lines. The line numbers have room for the digits of the last line or LineNumbersMinChars, whichever is more.

Ported from VS Code: src/vs/editor/common/config/editorOptions.ts (EditorLayoutInfoComputer)

func (GutterWidths) Total

func (w GutterWidths) Total() float64

Total is the width of the whole gutter.

type Hover added in v1.0.0

type Hover struct {
	Range buffer.Range
	Parts []HoverPart
	// Pinned says that the hover does not go away when the editor scrolls: the hover of a command (F8, Show Hover) stays until
	// the cursor moves or the text changes.
	Pinned bool
	// Complete says that every participant has answered; before that the box may grow.
	Complete bool
	// Focused says that the keys scroll the box (Show Hover pressed again).
	Focused bool
}

Hover is what the hover shows: the parts, and the range of the text they are about (the hover is placed over it).

type HoverAction added in v1.0.0

type HoverAction struct {
	// Label is the text of the link, Run what it does.
	Label string
	Run   func()
}

HoverAction is a link in the row of actions below a part of the hover.

type HoverOptions added in v1.0.0

type HoverOptions struct {
	// Enabled is editor.hover.enabled: "on" (also when empty), "off" or "onKeyboardModifier".
	Enabled string
	// Delay is editor.hover.delay, the milliseconds the pointer rests on the text before the hover shows.
	Delay int
	// Sticky is editor.hover.sticky: the hover stays while the pointer is over it, and HidingDelay (editor.hover.hidingDelay)
	// is the milliseconds it waits to hide after the pointer left the text.
	Sticky      bool
	HidingDelay int
	// Above is editor.hover.above: the hover prefers the place above the line.
	Above bool
}

HoverOptions are the settings of the hover (editor.hover.*).

type HoverPart added in v1.0.0

type HoverPart struct {
	Kind HoverPartKind
	// Diagnostic is the diagnostic of a HoverPartDiagnostic.
	Diagnostic Diagnostic
	// Contents are the texts of a HoverPartMarkdown, one under the other, and Owner the provider that made them.
	Contents []langfeatures.Markup
	Owner    string
	// Loading says that the part is the message "Loading..." of an answer that is late.
	Loading bool
	// Range is what the part is about.
	Range buffer.Range
	// Actions are the links below the part. The diagnostics have "View Problem" and, when a provider has quick fixes for them,
	// "Quick Fix..." (step 12.8).
	Actions []HoverAction
	// Status is the text after the links of a diagnostic: "Checking for quick fixes..." while the providers are asked, and "No
	// quick fixes available" when they have none.
	Status string
	// Links is called with the destination of a link of a Markdown part that names a command (command:...) when it is clicked; with
	// CommandLinks set a link of another kind opens as the links of a hover do. A part with no Links opens every link that way.
	Links        func(dest string)
	CommandLinks bool
	// contains filtered or unexported fields
}

HoverPart is one part of the content of the hover.

type HoverPartKind added in v1.0.0

type HoverPartKind int

HoverPartKind tells what a part of the hover is.

const (
	// HoverPartDiagnostic is a diagnostic under the position: its message, source and code, and the places related to it.
	HoverPartDiagnostic HoverPartKind = iota
	// HoverPartMarkdown is the content of a hover provider: Markdown or plain text, with code blocks in the colors of their
	// language.
	HoverPartMarkdown
)

The kinds of part of the hover.

type HoverScroll added in v1.0.0

type HoverScroll int

HoverScroll is a way to scroll the box of a focused hover.

const (
	HoverScrollUp HoverScroll = iota
	HoverScrollDown
	HoverScrollLeft
	HoverScrollRight
	HoverScrollPageUp
	HoverScrollPageDown
	HoverScrollTop
	HoverScrollBottom
)

The ways to scroll the hover.

type InlayColors added in v1.0.0

type InlayColors struct {
	Foreground, Background                   ui.Color
	TypeForeground, TypeBackground           ui.Color
	ParameterForeground, ParameterBackground ui.Color
}

InlayColors are the colors of the inlay hints: editorInlayHint.*.

type InputMode

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

InputMode is the type mode of the editors: insert, where a typed character is put before the one after the cursor, or overtype, where it replaces that one. The mode is shared by every editor that was given the same InputMode, as VS Code's InputMode singleton is shared by every editor of its window: the app makes one for the process, so the Insert key changes all the editors of all the workspace tabs, and the status bar shows it once.

Ported from VS Code: src/vs/editor/common/inputMode.ts

func NewInputMode

func NewInputMode() *InputMode

NewInputMode makes an input mode in insert mode.

func (*InputMode) AddListener

AddListener calls fn when the mode changes.

func (*InputMode) Overtype

func (m *InputMode) Overtype() bool

Overtype reports whether the mode is overtype.

func (*InputMode) RemoveListener

func (m *InputMode) RemoveListener(h foundation.ListenerHandle)

RemoveListener removes a listener.

func (*InputMode) SetOvertype

func (m *InputMode) SetOvertype(overtype bool)

SetOvertype sets the mode and tells the listeners when it changed.

func (*InputMode) Toggle

func (m *InputMode) Toggle()

Toggle changes insert mode to overtype mode and back (the command editor.action.toggleOvertypeInsertMode).

type LensOptions added in v1.0.0

type LensOptions struct {
	// CodeLens is editor.codeLens, CodeLensFontFamily editor.codeLensFontFamily and CodeLensFontSize editor.codeLensFontSize (0
	// is 90% of the editor's).
	CodeLens           bool
	CodeLensFontFamily string
	CodeLensFontSize   float64
	// InlayHints is editor.inlayHints.enabled: "on", "off", "onUnlessPressed" or "offUnlessPressed" (also when empty: "on").
	InlayHints string
	// InlayFontSize and InlayFontFamily are editor.inlayHints.fontSize (0: 90% of the editor's; a value under 5 or over the
	// editor's is the same) and editor.inlayHints.fontFamily (empty: the editor's); InlayPadding is editor.inlayHints.padding
	// and InlayMaxLength editor.inlayHints.maximumLength (0 for no limit).
	InlayFontSize   float64
	InlayFontFamily string
	InlayPadding    bool
	InlayMaxLength  int
	// Semantic is whether the semantic highlighting is on: SemanticByTheme, SemanticOn or SemanticOff. The setting
	// editor.semanticHighlighting.enabled decides, then the "enabled" of editor.semanticTokenColorCustomizations, then the
	// theme.
	Semantic string
	// SemanticRules are the "rules" of editor.semanticTokenColorCustomizations: styles for semantic tokens that win over the
	// theme's.
	SemanticRules map[string]any
}

LensOptions are the settings of the code lenses, the inlay hints and the semantic highlighting.

type LightBulb added in v1.0.0

type LightBulb struct {
	// Pos is the position the actions were asked at; the bulb is at its line.
	Pos buffer.Position
	// Icon is the plain bulb, or the auto fix one when a valid action is a preferred quick fix.
	Icon LightBulbIcon
	// Title is the tooltip.
	Title string
	// Actions are the actions of the position.
	Actions langfeatures.CodeActionSet
}

LightBulb is what the light bulb shows: it stands at the line of the cursor and opens the actions that came.

type LightBulbIcon added in v1.0.0

type LightBulbIcon int

LightBulbIcon says which icon the light bulb has.

const (
	// LightBulbPlain is the light bulb of actions.
	LightBulbPlain LightBulbIcon = iota
	// LightBulbAutoFix is the light bulb with the sparks of a preferred quick fix.
	LightBulbAutoFix
)

The icons of the light bulb.

type LineAnnotation added in v1.0.0

type LineAnnotation struct {
	// Line is the line, counted from 0.
	Line int
	// Text is the text to draw.
	Text string
	// Color is the id of the theme color of the text; empty, or one the theme does not know, draws it in editorInlayHint.foreground.
	Color string
	// Hover is the markdown of the hover; empty for none.
	Hover string
	// Background is the id of the theme color behind the text, empty for none; Tight puts the text one space after the end of the line
	// instead of the margin of a blame text (the debug inline values).
	Background string
	Tight      bool
	// Link is called with the destination of a link of the hover that names a command (command:<id>?<arguments>); other links open
	// as the links of every hover do. Nil lets such a link do nothing.
	Link func(dest string)
}

LineAnnotation is a text after the end of a line.

type LineBlock

type LineBlock struct {
	// StartLine is the first line and EndLine the line after the last.
	StartLine, EndLine int
	// Color is the color of the border and Width its width in pixels (1 when zero or less).
	Color ui.Color
	Width float64
}

LineBlock is a border around the lines [StartLine, EndLine) of an editor, counted from 0 as the lines of the document are; the two are equal for a block with no line, which is drawn as a line at the top of StartLine (at the end of the text when the line is past it).

type LineNumbersMode

type LineNumbersMode int

LineNumbersMode is the value of the editor.lineNumbers setting.

const (
	// LineNumbersOn shows the number of each line.
	LineNumbersOn LineNumbersMode = iota
	// LineNumbersOff shows none, and the gutter has no room for them.
	LineNumbersOff
	// LineNumbersRelative shows the distance in lines to the cursor; the cursor's own line
	// shows its number.
	LineNumbersRelative
	// LineNumbersInterval shows the number of the cursor's line, of every tenth line and of
	// the last line.
	LineNumbersInterval
)

The ways to show line numbers.

func ParseLineNumbersMode

func ParseLineNumbersMode(s string) LineNumbersMode

ParseLineNumbersMode reads the value of editor.lineNumbers; an unknown value is "on".

type LinesViewOpts

type LinesViewOpts struct {
	// Source is the view model whose document, tokens, options and brackets give the lines. Its projection is
	// not used: line n is row n.
	Source *ViewModel
	// FirstLine is the first line shown (counted from 0) and Count how many lines: each is one row, the rows
	// being as high as the widget is divided by Count.
	FirstLine, Count int
	// ScrollWith, when it is not nil, is the editor whose horizontal scroll position the text follows, so that
	// the lines stay under the text of the editor the zone is in.
	ScrollWith *ViewModel
	// Marks color the lines (WholeLine: the rows across the widget) and characters, in the lines of the source's
	// document (counted from 0); marks outside the lines shown are ignored.
	Marks []BackgroundMark
}

LinesViewOpts describe a LinesView.

type Link struct {
	Range buffer.Range
	// Count is the number of definitions found.
	Count int
}

Link is the link under the pointer: the range of the word that has a definition, underlined while the modifier is held.

type MinimapColors

type MinimapColors struct {
	// Background is the minimap's own background (transparent: the editor's), EditorBackground
	// the editor's, Foreground the color of text with no token color and ForegroundOpacity the
	// opacity of the blocks (its alpha).
	Background, EditorBackground, Foreground, ForegroundOpacity ui.Color
	// Selection colors the selections, FindMatch the matches of the find widget and
	// SelectionOccurrence the text that equals the selection.
	Selection, FindMatch, SelectionOccurrence ui.Color
	// Error, Warning and Info mark the diagnostics.
	Error, Warning, Info ui.Color
	// Slider, SliderHover and SliderActive color the slider when the pointer is away, over the
	// minimap and pressing it.
	Slider, SliderHover, SliderActive ui.Color
	// QuickDiff are the colors of the marks of the quick diff in the gutter of the minimap.
	QuickDiff quickDiffMinimapColors
}

MinimapColors are the colors of the minimap.

type MinimapOptions

type MinimapOptions struct {
	// Enabled is editor.minimap.enabled.
	Enabled bool
	// Side is editor.minimap.side: "right" or "left".
	Side string
	// Size is editor.minimap.size: "proportional", "fill" or "fit".
	Size string
	// ShowSlider is editor.minimap.showSlider: "always" or "mouseover".
	ShowSlider string
	// Scale is editor.minimap.scale, from 1 to 3.
	Scale int
	// MaxColumn is editor.minimap.maxColumn.
	MaxColumn int
}

MinimapOptions are the settings of the minimap (editor.minimap.*).

type MouseEvent

type MouseEvent struct {
	// Position is the position of the document under the pointer.
	Position buffer.Position
	// VisualColumn is the column under the pointer counted in characters of the font, also
	// past the end of the line; a column selection reaches up to it.
	VisualColumn int
	// Clicks counts the presses in a row at the same place: 1 for a click, 2 for a double
	// click, 3 for a triple click, 4 or more select everything.
	Clicks int
	// Mods are the modifiers held when the button went down.
	Mods MouseModifiers
	// OnLineNumbers says the press started on the line numbers: the selection goes by lines.
	OnLineNumbers bool
	// Drag says the pointer moved with the button down, after the press the event came from.
	Drag bool
	// Middle says the middle button made the event.
	Middle bool
	// NoReveal keeps the editor from scrolling to the cursor: the event comes from the scrolling
	// of a drag past the edge.
	NoReveal bool
}

MouseEvent is a press or a drag of the primary mouse button on the text or on the line numbers: where it is and what the user asked for with it (SPEC §9.3).

type MouseModifiers

type MouseModifiers struct {
	Shift, Ctrl, Alt, Meta bool
}

MouseModifiers are the keys held while the mouse button goes down.

type NavTarget struct {
	URI document.URI
	// Range is the range to select: the name of the symbol for a link, else the range of the location.
	Range buffer.Range
}

NavTarget is a place a navigation found.

type Notice

type Notice struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Notice is what the editor area shows in place of an editor when a file is not shown, with the reason and, optionally, a button that does the thing the user can do about it: a binary file shows "The file is not displayed in the editor because it is either binary or uses an unsupported text encoding." and "Open Anyway".

Ported from VS Code: src/vs/workbench/browser/parts/editor/binaryEditor.ts

func NewNotice

func NewNotice(message string, opts ...NoticeOpts) *Notice

NewNotice makes a notice that shows a message.

func (*Notice) CreateState

func (n *Notice) CreateState() widgets.State

CreateState implements widgets.StatefulWidget.

func (*Notice) Message

func (n *Notice) Message() string

Message is the text of the notice.

type NoticeOpts

type NoticeOpts struct {
	// Action is the label of the button below the message ("Open Anyway"); without it there is
	// no button.
	Action string
	// OnAction is called when the button is pressed (a click, or Enter or Space while the notice has
	// the focus).
	OnAction func()
}

NoticeOpts configure a Notice.

type OpenLocation added in v1.0.0

type OpenLocation struct {
	// Side opens it in the group beside the active one.
	Side bool
	// Pinned keeps the editor instead of replacing the preview editor.
	Pinned bool
	// After is called on the UI thread with the view model of the editor that shows the location, once it does.
	After func(target *ViewModel)
}

OpenLocation says how the window shows a location.

type Options

type Options struct {
	// FontFamilies are the font families in the order to try; the first is the family and
	// the rest are the fallback.
	FontFamilies []string
	// FontSize is the font size in pixels.
	FontSize float64
	// FontWeight is the weight of the font, from 1 to 1000 (400 is normal, 700 bold); 0 is
	// normal.
	FontWeight int
	// LetterSpacing is the space between letters, in pixels.
	LetterSpacing float64
	// LineHeight is the height of a row in pixels (see LineHeight).
	LineHeight float64
	// TabSize is the distance between tab stops in characters.
	TabSize int
	// FontFeatures are OpenType features such as "liga" 0; nil leaves the font's own.
	FontFeatures []FontFeature
	// LineNumbers says how line numbers are shown.
	LineNumbers LineNumbersMode
	// LineNumbersMinChars is the least width of the line numbers in characters.
	LineNumbersMinChars int
	// GlyphMargin says whether the gutter has a glyph margin.
	GlyphMargin bool
	// LineDecorationsWidth is the width of the line decorations.
	LineDecorationsWidth float64
	// Folding is editor.folding: whether lines can be folded.
	Folding bool
	// ShowFoldingControls is editor.showFoldingControls: "always", "mouseover" or "never"; with
	// "never" the gutter has no room for the controls.
	ShowFoldingControls string
	// FoldingHighlight is editor.foldingHighlight: the folded lines have a background.
	FoldingHighlight bool
	// UnfoldOnClickAfterEndOfLine is editor.unfoldOnClickAfterEndOfLine.
	UnfoldOnClickAfterEndOfLine bool
	// ScrollBeyondLastLine lets the last line be scrolled up to the top of the editor.
	ScrollBeyondLastLine bool
	// RenderLineHighlight is where the current line is highlighted: "none", "gutter", "line"
	// or "all".
	RenderLineHighlight string
	// RenderLineHighlightOnlyWhenFocus highlights the current line only while the editor has
	// the focus.
	RenderLineHighlightOnlyWhenFocus bool
	// RoundedSelection gives selections rounded corners.
	RoundedSelection bool
	// CursorWidth is the width of the cursor in pixels; 0 means 2.
	CursorWidth float64
	// CursorBlinking is the style of the cursor animation: "blink", "smooth", "phase",
	// "expand" or "solid".
	CursorBlinking string
	// CursorStyle is the shape of the cursor: "line", "block", "underline", "line-thin",
	// "block-outline" or "underline-thin".
	CursorStyle string
	// OvertypeCursorStyle is the shape of the cursor in overtype mode (editor.overtypeCursorStyle), in the
	// values of CursorStyle; empty means "block".
	OvertypeCursorStyle string
	// OvertypeOnPaste is editor.overtypeOnPaste: in overtype mode a paste replaces the characters after the
	// cursor.
	OvertypeOnPaste bool
	// MouseWheelZoom zooms the font with Control and the mouse wheel.
	MouseWheelZoom bool
	// MultiCursorModifier is the key that adds cursors with the mouse: "alt" or "ctrlCmd".
	MultiCursorModifier string
	// ColumnSelection makes a selection with the mouse a column selection.
	ColumnSelection bool
	// MouseStyle is the mouse pointer over the text: "text", "default" or "copy".
	MouseStyle string
	// MouseWheelScrollSensitivity multiplies the distance the mouse wheel and the touchpad
	// scroll.
	MouseWheelScrollSensitivity float64
	// FastScrollSensitivity multiplies it again while Alt is held.
	FastScrollSensitivity float64
	// SmoothScrolling animates the scrolling of the mouse wheel.
	SmoothScrolling bool
	// DragAndDrop lets a selection be moved with the mouse.
	DragAndDrop bool
	// SelectionClipboard makes the selection the primary selection of the desktop, and the
	// middle button paste it.
	SelectionClipboard bool
	// MultiCursorPaste is "spread" (a text of as many lines as there are cursors goes line by
	// line to the cursors) or "full" (every cursor pastes the whole text).
	MultiCursorPaste string
	// Emmet are the settings emmet.* that abbreviation expansion reads (SPEC §9.10.2).
	Emmet EmmetOptions
	// TabCompletion is "off", "on" or "onlySnippets": with the last the Tab key inserts the snippet
	// whose prefix is before the cursor. ("on" needs the suggestions of area 3 and does nothing.)
	TabCompletion string
	// EmptySelectionClipboard makes a copy or a cut without a selection take the line.
	EmptySelectionClipboard bool
	// MatchBrackets is editor.matchBrackets: "always" highlights the brackets of the pair
	// around a cursor too, "near" only the match of a bracket next to it, "never" nothing.
	MatchBrackets string
	// BracketPairColorization colors the brackets by their nesting level
	// (editor.bracketPairColorization.enabled).
	BracketPairColorization bool
	// IndependentColorPool counts the levels for each type of bracket on its own
	// (editor.bracketPairColorization.independentColorPoolPerBracketType).
	IndependentColorPool bool
	// Guides are the options editor.guides.*.
	Guides indent.GuideOptions
	// AutoIndent is editor.autoIndent: "none", "keep", "brackets", "advanced" or "full".
	AutoIndent string
	// AutoIndentOnPaste is editor.autoIndentOnPaste.
	AutoIndentOnPaste bool
	// AutoIndentOnPasteWithinString is editor.autoIndentOnPasteWithinString.
	AutoIndentOnPasteWithinString bool
	// AutoClosingBrackets, AutoClosingComments and AutoClosingQuotes are editor.autoClosingBrackets,
	// editor.autoClosingComments and editor.autoClosingQuotes: "languageDefined", "beforeWhitespace",
	// "always" or "never" (SPEC §8.6.4).
	AutoClosingBrackets, AutoClosingComments, AutoClosingQuotes string
	// AutoClosingDelete and AutoClosingOvertype are editor.autoClosingDelete and
	// editor.autoClosingOvertype: "auto", "always" or "never".
	AutoClosingDelete, AutoClosingOvertype string
	// AutoSurround is editor.autoSurround: "languageDefined", "quotes", "brackets" or "never".
	AutoSurround string
	// CommentsInsertSpace and CommentsIgnoreEmptyLines are editor.comments.insertSpace and
	// editor.comments.ignoreEmptyLines.
	CommentsInsertSpace, CommentsIgnoreEmptyLines bool
	// WordSeparators is editor.wordSeparators; empty means VS Code's default.
	WordSeparators string
	// FindSeedSearchStringFromSelection is editor.find.seedSearchStringFromSelection ("never",
	// "always" or "selection"), FindAutoInSelection editor.find.autoFindInSelection ("never",
	// "always" or "multiline"), FindCloseOnResult editor.find.closeOnResult, FindCursorMoveOnType
	// editor.find.cursorMoveOnType and FindLoop editor.find.loop.
	FindSeedSearchStringFromSelection, FindAutoInSelection string
	FindCloseOnResult, FindCursorMoveOnType, FindLoop      bool
	// ReadOnly makes this editor refuse every edit of its document without making the document
	// read-only for the other editors that show it (VS Code's readOnly editor option; the diff editor's
	// original side). The editorReadonly context key is true for it.
	ReadOnly bool
	// WordWrap is editor.wordWrap ("off", "on", "wordWrapColumn" or "bounded"), WordWrapColumn
	// editor.wordWrapColumn, WrappingIndent editor.wrappingIndent ("none", "same", "indent" or
	// "deepIndent"), WrappingStrategy editor.wrappingStrategy ("simple" or "advanced") and
	// StopRenderingLineAfter editor.stopRenderingLineAfter (negative: no limit).
	WordWrap                         string
	WordWrapColumn                   int
	WrappingIndent, WrappingStrategy string
	StopRenderingLineAfter           int
	// RenderWhitespace is editor.renderWhitespace ("none", "boundary", "selection", "trailing" or
	// "all"; empty is "none"), RenderControlCharacters editor.renderControlCharacters and Rulers
	// editor.rulers, sorted by column.
	RenderWhitespace        string
	RenderControlCharacters bool
	Rulers                  []ColumnRuler
	// OccurrencesHighlight is editor.occurrencesHighlight ("off", "singleFile" or "multiFile"),
	// OccurrencesHighlightDelay editor.occurrencesHighlightDelay in milliseconds, SelectionHighlight
	// editor.selectionHighlight, SelectionHighlightMaxLength editor.selectionHighlightMaxLength and
	// SelectionHighlightMultiline editor.selectionHighlightMultiline.
	OccurrencesHighlight        string
	OccurrencesHighlightDelay   int
	SelectionHighlight          bool
	SelectionHighlightMaxLength int
	SelectionHighlightMultiline bool
	// ShowUnused is editor.showUnused (fade the text of unused code) and ShowDeprecated editor.showDeprecated (strike through
	// the text of deprecated code).
	ShowUnused, ShowDeprecated bool
	// Debug are the settings debug.* the editor reads (debug.go).
	Debug DebugOptions
	// Hover are the settings of the hover (editor.hover.*).
	Hover HoverOptions
	// ParameterHints are the settings of the parameter hints (editor.parameterHints.*).
	ParameterHints ParameterHintsOptions
	// CodeActions are the settings of the light bulb and of the list of code actions (editor.lightbulb.enabled,
	// editor.codeActionWidget.*).
	CodeActions CodeActionOptions
	// Format are the settings of the formatting that follows typing and pasting (editor.formatOnType, editor.formatOnPaste,
	// editor.defaultFormatter).
	Format FormatOptions
	// RenamePreview is editor.rename.enablePreview: the rename box and the list of actions can show the changes before they are
	// made.
	RenamePreview bool
	// Suggest are the settings of the suggest widget (editor.suggest.* and the options around it).
	Suggest SuggestOptions
	// Minimap are the settings of the minimap (editor.minimap.*).
	Minimap MinimapOptions
	// StickyScroll are the settings of sticky scroll (editor.stickyScroll.*).
	StickyScroll StickyScrollOptions
	// QuickDiff are the settings of the quick diff marks (scm.diffDecorations*, step 24.11).
	QuickDiff QuickDiffOptions
	// GotoLocation are the settings of go to definition and its kin (editor.gotoLocation.*).
	GotoLocation GotoLocationOptions
	// Lens are the settings of the code lenses, the inlay hints and the semantic highlighting (editor.codeLens*,
	// editor.inlayHints.*, editor.semanticHighlighting.enabled, editor.semanticTokenColorCustomizations; step 12.9).
	Lens LensOptions
	// FoldingStrategy is editor.foldingStrategy: "auto" uses the folding ranges of a language server when there is one,
	// "indentation" always folds by indentation. FoldingImportsByDefault is editor.foldingImportsByDefault.
	FoldingStrategy         string
	FoldingImportsByDefault bool
}

Options are the settings an editor reads, resolved for one document. The widget makes them from the settings store; a view model takes them as plain values, so that it is tested without a window.

func OptionsFromSettings

func OptionsFromSettings(store *settings.Store, languageID, desktopMonospace string, tabSize int) Options

OptionsFromSettings reads the options of an editor from the settings for a language. desktopMonospace is the desktop's monospace font (PlatformDispatcher.MonospaceFont), tried when editor.fontFamily is empty; tabSize is the document's (its indentation settings are applied to the document, not read here).

The font families are those of editor.fontFamily in order, then the desktop's monospace font when the setting is empty, then the generic monospace family (SPEC D14).

type OverlayColors

type OverlayColors struct {
	// Background is the color of the editor, used to cut reversed corners into selections.
	Background ui.Color
	// Selection is the color of a selection in the editor that has the focus.
	Selection ui.Color
	// InactiveSelection is the color of a selection in an editor without the focus.
	InactiveSelection ui.Color
	// LineHighlight is the background of the current line.
	LineHighlight ui.Color
	// LineHighlightBorder is the border of the current line.
	LineHighlightBorder ui.Color
	// Cursor is the color of the cursors.
	Cursor ui.Color
	// CursorText is the color of the character a block cursor, or a wide line cursor, covers:
	// the opposite of the cursor's color.
	CursorText ui.Color
	// Foreground is the color of the text, for the text an input method composes.
	Foreground ui.Color
	// BracketMatch and BracketMatchBorder are the background and the border of the brackets
	// that match.
	BracketMatch, BracketMatchBorder ui.Color
	// Guides are the colors of the indent guides and of the bracket pair guides.
	Guides GuideColors
	// FoldBackground is the background of a folded line and FoldPlaceholder the color of the
	// "…" after it.
	FoldBackground, FoldPlaceholder ui.Color
	// FindMatch and FindMatchBorder color the current match of the find widget,
	// FindMatchHighlight and its border the other matches, FindRangeHighlight and its border the
	// lines of the current match and the range the search is limited to.
	FindMatch, FindMatchBorder                   ui.Color
	FindMatchHighlight, FindMatchHighlightBorder ui.Color
	FindRangeHighlight, FindRangeHighlightBorder ui.Color
	// RangeHighlight and its border color the line that go to line shows while the user types.
	RangeHighlight, RangeHighlightBorder ui.Color
	// Whitespace is the color of the dots and arrows of editor.renderWhitespace and Ruler the
	// color of the rulers that have none of their own.
	Whitespace, Ruler ui.Color
	// SelectionHighlight and its border color the text that equals the selection, WordHighlight
	// and its border the other occurrences of the word at the cursor.
	SelectionHighlight, SelectionHighlightBorder ui.Color
	WordHighlight, WordHighlightBorder           ui.Color
	// WordHighlightRead and WordHighlightWrite, with their borders, color the occurrences a provider says are read and written.
	WordHighlightRead, WordHighlightReadBorder   ui.Color
	WordHighlightWrite, WordHighlightWriteBorder ui.Color
	// PeekMatch and its border color the references in the editor of a peek view, and Link the underline of the link that
	// Ctrl+hover draws.
	PeekMatch, PeekMatchBorder ui.Color
	Link                       ui.Color
	// SnippetTabstop and its border color the tab stops of a snippet that is being filled in,
	// SnippetFinalTabstop and its border the final one.
	SnippetTabstop, SnippetTabstopBorder           ui.Color
	SnippetFinalTabstop, SnippetFinalTabstopBorder ui.Color
	// Diagnostics are the colors of the squiggles and of the unused code.
	Diagnostics DiagnosticColors
}

OverlayColors are the colors of the layers drawn above and below the text.

type ParagraphCache

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

ParagraphCache keeps the laid-out paragraphs of rows, so that a row whose text and look did not change is not shaped again. It drops the least recently used paragraph when it holds more than its capacity. It is used on the UI thread only.

func NewParagraphCache

func NewParagraphCache(capacity int) *ParagraphCache

NewParagraphCache makes a cache of the given capacity; zero or less means DefaultParagraphCacheSize.

func (*ParagraphCache) Builds

func (c *ParagraphCache) Builds() int

Builds is how many times a paragraph had to be built.

func (*ParagraphCache) Clear

func (c *ParagraphCache) Clear()

Clear forgets every paragraph (the counters stay).

func (*ParagraphCache) Hits

func (c *ParagraphCache) Hits() int

Hits is how many times a paragraph was found in the cache.

func (*ParagraphCache) Len

func (c *ParagraphCache) Len() int

Len is the number of paragraphs held.

type ParameterHintsOptions added in v1.0.0

type ParameterHintsOptions struct {
	// Enabled is editor.parameterHints.enabled: typing a trigger character asks for the hints. The command always does.
	Enabled bool
	// Cycle is editor.parameterHints.cycle: Down on the last signature goes to the first, instead of closing the hints.
	Cycle bool
}

ParameterHintsOptions are the settings of the parameter hints (editor.parameterHints.*).

type PeekFile added in v1.0.0

type PeekFile struct {
	URI  document.URI
	Name string
	// Dir is the folder of the file.
	Dir          string
	First, Count int
}

PeekFile is the locations of one file: Count references from Refs[First].

type PeekRef added in v1.0.0

type PeekRef struct {
	URI   document.URI
	Range buffer.Range
	// Before, Match and After are the text of the line of the range, once it is read: the text before the range with its
	// leading blanks cut, the text in it and the text after; Loaded says that they are known.
	Before, Match, After string
	Loaded               bool
}

PeekRef is a location of the peek view.

type PeekView added in v1.0.0

type PeekView struct {
	Kind GoKind
	// Title is the name of the file of the selected location, Dir its folder and Meta the number of locations ("3 references").
	Title, Dir, Meta string
	Files            []PeekFile
	Refs             []PeekRef
	// Selected is the index of the selected location in Refs.
	Selected int
	// Current is the editor over the selected location, and CurrentURI its file; Current is nil while the editor is being made.
	Current    *ViewModel
	CurrentURI document.URI
	// Loading says that the editor is being made; Failed is the reason it could not be.
	Loading bool
	Failed  string
	// Rows is the height of the zone in rows of the editor.
	Rows int
}

PeekView is what the peek view shows.

type Preedit

type Preedit struct {
	// Text is the composed text.
	Text string
	// Begin and End are the selection inside it in bytes: the part the method highlights, or
	// where its cursor is (equal for a caret).
	Begin, End int
}

Preedit is the text an input method is composing: shown at the primary cursor, underlined, until the method commits it. It is not in the document, so it never enters the undo history (SPEC §9.3).

type PreviewChange added in v1.0.0

type PreviewChange struct {
	// Line is the line of the change, counted from 1.
	Line int
	// Before is the text of the line before the change (cut at its start), Old the text that is replaced, New the text that
	// replaces it, and After the rest of the line (cut at its end).
	Before, Old, New, After string
	// Checked says that Apply makes the change.
	Checked bool
}

PreviewChange is one change of a file in the preview.

type PreviewFile added in v1.0.0

type PreviewFile struct {
	// Name is the name of the file and Dir the folder it is in, as the window writes it.
	Name, Dir string
	// Operation is "create", "rename" or "delete" for a file operation, and empty for changes to the text.
	Operation string
	// Target is the new name of a renamed file.
	Target string
	// Changes are the changes to the text, and Checked says that the file operation is made.
	Changes []PreviewChange
	Checked bool
	// contains filtered or unexported fields
}

PreviewFile is a file with the changes made to it, or a file operation.

type PreviewRow added in v1.0.0

type PreviewRow struct {
	File, Change int
}

PreviewRow is a row of the preview: a file (Change is -1), or a change of a file.

type PreviewUI added in v1.0.0

type PreviewUI struct {
	Focus, Return func()
}

PreviewUI is what the widget gives the view model to move the focus into the preview and back.

type Projection

type Projection interface {
	// RowCount is the number of rows, at least 1.
	RowCount() int
	// LineRows is the first row of a model line and the number of rows the line has; a
	// folded line has none (count 0).
	LineRows(line int) (first, count int)
	// RowSpan tells what a row shows: the model line and the byte columns of the line from
	// start up to end. An end of -1 means the end of the line.
	RowSpan(row int) (line, start, end int)
	// RowTop is the y of the top of a row from the top of the document.
	RowTop(row int) float64
	// RowHeight is the height of a row.
	RowHeight(row int) float64
	// RowAt is the row at a y from the top of the document, clamped to the first and the
	// last row.
	RowAt(y float64) int
	// Height is the height of all the rows.
	Height() float64

	// RowZone tells whether a row belongs to a view zone (SPEC §9.1): the zone and the index of
	// the row inside it. A row of a zone shows no text; RowSpan gives it the line it follows and
	// an empty range.
	RowZone(row int) (id ZoneID, index int, ok bool)
	// LineZoneRows is the first row and the number of rows of the zones that follow a line, which
	// come after the rows LineRows tells; none for a hidden line.
	LineZoneRows(line int) (first, count int)
	// ZoneRows is the first row and the number of rows of a zone; a zone that is not shown has
	// none.
	ZoneRows(id ZoneID) (first, count int)
	// ZonesIn lists the zones that have a row among the rows first to last, in order.
	ZonesIn(first, last int) []ZoneID
	// ZoneRowsBefore is the number of rows of zones among the rows before a row.
	ZoneRowsBefore(row int) int
}

Projection maps the lines of the document to the rows of the screen (SPEC §9.1). Layout, scrolling, hit testing and vertical movement go through it, so that folding, word wrap and view zones can change what a row is without the callers noticing. Rows are numbered from 0 and stack from the top of the document; a row has a height of its own.

type QuickDiffColors added in v1.0.0

type QuickDiffColors struct {
	// Added, Modified and Deleted are the colors of the primary provider's changes; the Secondary ones those of a secondary provider's.
	Added, Modified, Deleted                            ui.Color
	AddedSecondary, ModifiedSecondary, DeletedSecondary ui.Color
}

QuickDiffColors are the colors of the quick diff stripes in the gutter.

type QuickDiffMark added in v1.0.0

type QuickDiffMark struct {
	// Type is added, modified or deleted lines.
	Type quickdiff.ChangeType
	// Start and End are the lines of the change in the text, counted from 1 (Change.ModifiedStart and ModifiedEnd): a deleted change has
	// End 0 and Start the line the lines were deleted after (0 for the start of the text).
	Start, End int
	// Secondary draws the mark in the secondary colors (the change of a secondary provider).
	Secondary bool
}

QuickDiffMark is a change the editor marks.

type QuickDiffOptions added in v1.0.0

type QuickDiffOptions struct {
	// Decorations says where the marks are shown: "all", "gutter", "overview", "minimap" or "none" (scm.diffDecorations).
	Decorations string
	// GutterWidth is the width of the stripe in pixels, 1 to 5 (scm.diffDecorationsGutterWidth; anything else is 3).
	GutterWidth int
	// Visibility is "always", or "hover" to show the gutter marks only while the pointer is over the gutter
	// (scm.diffDecorationsGutterVisibility).
	Visibility string
	// PatternAdded and PatternModified draw the stripe of added and of modified lines as a hatch instead of a fill
	// (scm.diffDecorationsGutterPattern).
	PatternAdded, PatternModified bool
	// GutterAction is "diff" to open the peek of a change with a click on its stripe, or "none" (scm.diffDecorationsGutterAction).
	GutterAction string
}

QuickDiffOptions are the settings scm.diffDecorations*.

type QuickDiffPeeker added in v1.0.0

type QuickDiffPeeker interface {
	// Step opens the peek at the next (or previous) change after (before) the cursor, or moves an open peek to the next (previous) one.
	Step(next bool)
	// Click is a click on the stripe of the change at the line, counted from 1: it opens the peek on the change, or closes it when it
	// shows that change already.
	Click(line int)
	// Close closes the peek.
	Close()
	// ToggleFocus moves the keyboard into the peek, or back to the editor.
	ToggleFocus()
	// Visible says that the peek is open (the context key dirtyDiffVisible).
	Visible() bool
}

QuickDiffPeeker is the peek of a change under its lines (SPEC §10.30 "The peek", step 24.12): the window makes it for an editor of a file (internal/gui/quickdiffpeek) and the editor runs its commands and its clicks on the stripe, so the editor knows nothing of how it looks. Its methods are called on the UI thread.

type QuickSuggestions added in v1.0.0

type QuickSuggestions struct{ Other, Comments, Strings string }

QuickSuggestions are the values of editor.quickSuggestions for the code outside strings and comments, the comments and the strings: "on", "inline", "off" or "offWhenInlineCompletions".

func ParseQuickSuggestions added in v1.0.0

func ParseQuickSuggestions(v any) QuickSuggestions

ParseQuickSuggestions reads the value of editor.quickSuggestions: a boolean, a string for all three, or an object. A value that is not understood is VS Code's default.

Ported from VS Code: src/vs/editor/common/config/editorOptions.ts (EditorQuickSuggestions.validate)

type RefactorPreview added in v1.0.0

type RefactorPreview struct {
	// Label says what is changed ("Renaming 'a' to 'b'").
	Label string
	Files []*PreviewFile
	// Focus is the index of the row with the keyboard focus.
	Focus int
	// contains filtered or unexported fields
}

RefactorPreview is the preview that shows.

func (*RefactorPreview) Checked added in v1.0.0

func (p *RefactorPreview) Checked(r PreviewRow) (checked, partial bool)

Checked tells whether a row is checked and, for a file, whether only some of its changes are.

func (*RefactorPreview) Rows added in v1.0.0

func (p *RefactorPreview) Rows() []PreviewRow

Rows are the rows of the list: each file followed by its changes.

type RenameBox added in v1.0.0

type RenameBox struct {
	// Range is the symbol and Text its name; the box starts with the name selected.
	Range buffer.Range
	Text  string
	// Input is what the box holds now.
	Input string
	// Preview says that the key of the preview is offered (editor.rename.enablePreview): the box tells so under the name.
	Preview bool
	// Revision counts the times the box was opened, so that the widget selects the name once.
	Revision int
	// contains filtered or unexported fields
}

RenameBox is the box over the symbol that is renamed.

type RenameUI added in v1.0.0

type RenameUI struct {
	// Focus gives the focus to the input of the box and selects its text; Return gives it back to the editor.
	Focus, Return func()
}

RenameUI is what the widget gives the view model to move the focus into the box.

type RenderEditorGutter

type RenderEditorGutter struct {
	rendering.RenderBox
	// contains filtered or unexported fields
}

RenderEditorGutter is the gutter of the editor: the line numbers of the visible rows, in the same offset as the text. It is a repaint boundary of its own.

func NewRenderEditorGutter

func NewRenderEditorGutter(vm *ViewModel, offset rendering.ViewportOffset, factory ui.ParagraphFactory, colors GutterColors) *RenderEditorGutter

NewRenderEditorGutter makes the gutter of a view model.

func (*RenderEditorGutter) Attach

func (r *RenderEditorGutter) Attach(owner *rendering.PipelineOwner)

Attach implements rendering.RenderObject.

func (*RenderEditorGutter) ComputeDryLayout

func (r *RenderEditorGutter) ComputeDryLayout(c rendering.BoxConstraints) ui.Size

ComputeDryLayout implements rendering.RenderBox.

func (*RenderEditorGutter) ComputeMaxIntrinsicHeight

func (r *RenderEditorGutter) ComputeMaxIntrinsicHeight(float64) float64

ComputeMaxIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorGutter) ComputeMaxIntrinsicWidth

func (r *RenderEditorGutter) ComputeMaxIntrinsicWidth(float64) float64

ComputeMaxIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorGutter) ComputeMinIntrinsicHeight

func (r *RenderEditorGutter) ComputeMinIntrinsicHeight(float64) float64

ComputeMinIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorGutter) ComputeMinIntrinsicWidth

func (r *RenderEditorGutter) ComputeMinIntrinsicWidth(float64) float64

ComputeMinIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorGutter) Detach

func (r *RenderEditorGutter) Detach()

Detach implements rendering.RenderObject.

func (*RenderEditorGutter) IsRepaintBoundary

func (r *RenderEditorGutter) IsRepaintBoundary() bool

IsRepaintBoundary implements rendering.RenderObject.

func (*RenderEditorGutter) Paint

func (r *RenderEditorGutter) Paint(context *rendering.PaintingContext, offset ui.Offset)

Paint draws the highlight of the current line and the numbers of the visible rows. A line that is cut into several rows has its number on the first one only.

func (*RenderEditorGutter) PerformLayout

func (r *RenderEditorGutter) PerformLayout()

PerformLayout implements rendering.RenderBox; the gutter has nothing to lay out.

func (*RenderEditorGutter) SizedByParent

func (r *RenderEditorGutter) SizedByParent() bool

SizedByParent implements rendering.RenderObject.

func (*RenderEditorGutter) Update

func (r *RenderEditorGutter) Update(vm *ViewModel, offset rendering.ViewportOffset, factory ui.ParagraphFactory, colors GutterColors)

Update copies the configuration of a widget.

type RenderEditorMinimap

type RenderEditorMinimap struct {
	rendering.RenderBox
	// contains filtered or unexported fields
}

RenderEditorMinimap draws the minimap: the text as colored blocks, the marks of the selections and the matches over them and the slider that shows what the editor shows (SPEC §9.5). The pixels of the blocks are kept between frames and only the lines that changed are drawn again.

func NewRenderEditorMinimap

func NewRenderEditorMinimap(vm *ViewModel, scroll foundation.Listenable, colors MinimapColors, tokens *theme.TokenTheme) *RenderEditorMinimap

NewRenderEditorMinimap makes the minimap of a view model.

func (*RenderEditorMinimap) Attach

func (r *RenderEditorMinimap) Attach(owner *rendering.PipelineOwner)

Attach implements rendering.RenderObject.

func (*RenderEditorMinimap) ComputeDryLayout

func (r *RenderEditorMinimap) ComputeDryLayout(c rendering.BoxConstraints) ui.Size

ComputeDryLayout implements rendering.RenderBox.

func (*RenderEditorMinimap) ComputeMaxIntrinsicHeight

func (r *RenderEditorMinimap) ComputeMaxIntrinsicHeight(float64) float64

ComputeMaxIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorMinimap) ComputeMaxIntrinsicWidth

func (r *RenderEditorMinimap) ComputeMaxIntrinsicWidth(float64) float64

ComputeMaxIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorMinimap) ComputeMinIntrinsicHeight

func (r *RenderEditorMinimap) ComputeMinIntrinsicHeight(float64) float64

ComputeMinIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorMinimap) ComputeMinIntrinsicWidth

func (r *RenderEditorMinimap) ComputeMinIntrinsicWidth(float64) float64

ComputeMinIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorMinimap) Detach

func (r *RenderEditorMinimap) Detach()

Detach implements rendering.RenderObject.

func (*RenderEditorMinimap) HitTestSelf

func (r *RenderEditorMinimap) HitTestSelf(ui.Offset) bool

HitTestSelf implements rendering.RenderBox.

func (*RenderEditorMinimap) IsRepaintBoundary

func (r *RenderEditorMinimap) IsRepaintBoundary() bool

IsRepaintBoundary implements rendering.RenderObject.

func (*RenderEditorMinimap) Paint

func (r *RenderEditorMinimap) Paint(context *rendering.PaintingContext, offset ui.Offset)

Paint draws the minimap.

func (*RenderEditorMinimap) PerformLayout

func (r *RenderEditorMinimap) PerformLayout()

PerformLayout implements rendering.RenderBox; the layer has nothing to lay out.

func (*RenderEditorMinimap) SizedByParent

func (r *RenderEditorMinimap) SizedByParent() bool

SizedByParent implements rendering.RenderObject.

func (*RenderEditorMinimap) Update

func (r *RenderEditorMinimap) Update(vm *ViewModel, scroll foundation.Listenable, colors MinimapColors, tokens *theme.TokenTheme)

Update copies the configuration of a widget.

type RenderEditorOverlay

type RenderEditorOverlay struct {
	rendering.RenderBox
	// contains filtered or unexported fields
}

RenderEditorOverlay is a layer of the editor that draws decorations of the text without touching it: the one below the text has the current line and the selections, the one above has the cursors. Each is a repaint boundary, so that the blinking of the cursors repaints only the cursor layer and a new selection does not repaint the text (SPEC §9.1).

func NewRenderEditorOverlay

func NewRenderEditorOverlay(kind overlayKind, vm *ViewModel, offset rendering.ViewportOffset, factory ui.ParagraphFactory, colors OverlayColors) *RenderEditorOverlay

NewRenderEditorOverlay makes the layer of a kind for a view model.

func (*RenderEditorOverlay) Attach

func (r *RenderEditorOverlay) Attach(owner *rendering.PipelineOwner)

Attach implements rendering.RenderObject.

func (*RenderEditorOverlay) ComputeDryLayout

func (r *RenderEditorOverlay) ComputeDryLayout(c rendering.BoxConstraints) ui.Size

ComputeDryLayout implements rendering.RenderBox.

func (*RenderEditorOverlay) ComputeMaxIntrinsicHeight

func (r *RenderEditorOverlay) ComputeMaxIntrinsicHeight(float64) float64

ComputeMaxIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorOverlay) ComputeMaxIntrinsicWidth

func (r *RenderEditorOverlay) ComputeMaxIntrinsicWidth(float64) float64

ComputeMaxIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorOverlay) ComputeMinIntrinsicHeight

func (r *RenderEditorOverlay) ComputeMinIntrinsicHeight(float64) float64

ComputeMinIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorOverlay) ComputeMinIntrinsicWidth

func (r *RenderEditorOverlay) ComputeMinIntrinsicWidth(float64) float64

ComputeMinIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorOverlay) Detach

func (r *RenderEditorOverlay) Detach()

Detach implements rendering.RenderObject.

func (*RenderEditorOverlay) HitTestSelf

func (r *RenderEditorOverlay) HitTestSelf(ui.Offset) bool

HitTestSelf implements rendering.RenderBox: the layer lets the pointer through to the text.

func (*RenderEditorOverlay) IsRepaintBoundary

func (r *RenderEditorOverlay) IsRepaintBoundary() bool

IsRepaintBoundary implements rendering.RenderObject.

func (*RenderEditorOverlay) Paint

func (r *RenderEditorOverlay) Paint(context *rendering.PaintingContext, offset ui.Offset)

Paint draws the decorations of the visible rows.

func (*RenderEditorOverlay) PerformLayout

func (r *RenderEditorOverlay) PerformLayout()

PerformLayout implements rendering.RenderBox; the layer has nothing to lay out.

func (*RenderEditorOverlay) SizedByParent

func (r *RenderEditorOverlay) SizedByParent() bool

SizedByParent implements rendering.RenderObject.

func (*RenderEditorOverlay) Update

func (r *RenderEditorOverlay) Update(vm *ViewModel, offset rendering.ViewportOffset, factory ui.ParagraphFactory, colors OverlayColors)

Update copies the configuration of a widget.

type RenderEditorRuler

type RenderEditorRuler struct {
	rendering.RenderBox
	// contains filtered or unexported fields
}

RenderEditorRuler draws the overview ruler: one mark for every place of the whole document where the find widget found something, at the height that place has in the document scaled to the height of the editor (SPEC §9.8). It lets the pointer through to the scrollbar.

func NewRenderEditorRuler

func NewRenderEditorRuler(vm *ViewModel, colors RulerColors) *RenderEditorRuler

NewRenderEditorRuler makes the ruler of a view model.

func (*RenderEditorRuler) Attach

func (r *RenderEditorRuler) Attach(owner *rendering.PipelineOwner)

Attach implements rendering.RenderObject.

func (*RenderEditorRuler) ComputeDryLayout

func (r *RenderEditorRuler) ComputeDryLayout(c rendering.BoxConstraints) ui.Size

ComputeDryLayout implements rendering.RenderBox.

func (*RenderEditorRuler) ComputeMaxIntrinsicHeight

func (r *RenderEditorRuler) ComputeMaxIntrinsicHeight(float64) float64

ComputeMaxIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorRuler) ComputeMaxIntrinsicWidth

func (r *RenderEditorRuler) ComputeMaxIntrinsicWidth(float64) float64

ComputeMaxIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorRuler) ComputeMinIntrinsicHeight

func (r *RenderEditorRuler) ComputeMinIntrinsicHeight(float64) float64

ComputeMinIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorRuler) ComputeMinIntrinsicWidth

func (r *RenderEditorRuler) ComputeMinIntrinsicWidth(float64) float64

ComputeMinIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorRuler) Detach

func (r *RenderEditorRuler) Detach()

Detach implements rendering.RenderObject.

func (*RenderEditorRuler) HitTestSelf

func (r *RenderEditorRuler) HitTestSelf(ui.Offset) bool

HitTestSelf implements rendering.RenderBox.

func (*RenderEditorRuler) IsRepaintBoundary

func (r *RenderEditorRuler) IsRepaintBoundary() bool

IsRepaintBoundary implements rendering.RenderObject.

func (*RenderEditorRuler) Paint

func (r *RenderEditorRuler) Paint(context *rendering.PaintingContext, offset ui.Offset)

Paint implements rendering.RenderObject.

func (*RenderEditorRuler) PerformLayout

func (r *RenderEditorRuler) PerformLayout()

PerformLayout implements rendering.RenderBox.

func (*RenderEditorRuler) SizedByParent

func (r *RenderEditorRuler) SizedByParent() bool

SizedByParent implements rendering.RenderObject.

func (*RenderEditorRuler) Update

func (r *RenderEditorRuler) Update(vm *ViewModel, colors RulerColors)

Update copies the configuration of a widget.

type RenderEditorSticky

type RenderEditorSticky struct {
	rendering.RenderBox
	// contains filtered or unexported fields
}

RenderEditorSticky draws the lines that stick to the top of the editor: for each scope that has scrolled away, the line that starts it, with its line number and folding icon, over the text. Its height is that of its lines, and it has none when no line sticks.

func NewRenderEditorSticky

func NewRenderEditorSticky(vm *ViewModel, scroll foundation.Listenable, factory ui.ParagraphFactory, colors StickyColors, tokens *theme.TokenTheme, inset float64) *RenderEditorSticky

NewRenderEditorSticky makes the sticky lines of a view model.

func (*RenderEditorSticky) Attach

func (r *RenderEditorSticky) Attach(owner *rendering.PipelineOwner)

Attach implements rendering.RenderObject.

func (*RenderEditorSticky) ComputeDryLayout

func (r *RenderEditorSticky) ComputeDryLayout(c rendering.BoxConstraints) ui.Size

ComputeDryLayout implements rendering.RenderBox.

func (*RenderEditorSticky) ComputeMaxIntrinsicHeight

func (r *RenderEditorSticky) ComputeMaxIntrinsicHeight(float64) float64

ComputeMaxIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorSticky) ComputeMaxIntrinsicWidth

func (r *RenderEditorSticky) ComputeMaxIntrinsicWidth(float64) float64

ComputeMaxIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorSticky) ComputeMinIntrinsicHeight

func (r *RenderEditorSticky) ComputeMinIntrinsicHeight(float64) float64

ComputeMinIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorSticky) ComputeMinIntrinsicWidth

func (r *RenderEditorSticky) ComputeMinIntrinsicWidth(float64) float64

ComputeMinIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorSticky) Detach

func (r *RenderEditorSticky) Detach()

Detach implements rendering.RenderObject.

func (*RenderEditorSticky) HitTestSelf

func (r *RenderEditorSticky) HitTestSelf(p ui.Offset) bool

HitTestSelf implements rendering.RenderBox: the lines take the pointer, the room of the shadow does not.

func (*RenderEditorSticky) IsRepaintBoundary

func (r *RenderEditorSticky) IsRepaintBoundary() bool

IsRepaintBoundary implements rendering.RenderObject.

func (*RenderEditorSticky) Paint

func (r *RenderEditorSticky) Paint(context *rendering.PaintingContext, offset ui.Offset)

Paint draws the lines.

func (*RenderEditorSticky) PerformLayout

func (r *RenderEditorSticky) PerformLayout()

PerformLayout implements rendering.RenderBox: the lines that stick at the scroll position decide the height.

func (*RenderEditorSticky) Update

func (r *RenderEditorSticky) Update(vm *ViewModel, scroll foundation.Listenable, factory ui.ParagraphFactory, colors StickyColors, tokens *theme.TokenTheme, inset float64)

Update copies the configuration of a widget.

type RenderEditorText

type RenderEditorText struct {
	rendering.RenderBox
	// contains filtered or unexported fields
}

RenderEditorText is the text layer of the editor (SPEC §9.1): a leaf render box driven by the vertical offset of a Scrollable and the horizontal offset of the view model. It lays out and paints only the visible rows plus a margin, one cached paragraph per row, and is a repaint boundary, so that Glutter's raster cache keeps the text when only a cursor moves.

func NewRenderEditorText

func NewRenderEditorText(vm *ViewModel, offset rendering.ViewportOffset, factory ui.ParagraphFactory, color ui.Color) *RenderEditorText

NewRenderEditorText makes the render object for a view model. The paragraphs are made by factory (the platform's text engine) in color.

func (*RenderEditorText) AnnotationAt added in v1.0.0

func (r *RenderEditorText) AnnotationAt(local ui.Offset) (annotationHit, bool)

AnnotationAt finds the annotation at a point of the text layer, given in the layer's own coordinates: the line of the annotation and its place among those of the line; false when the point is not on the text of an annotation.

func (*RenderEditorText) Attach

func (r *RenderEditorText) Attach(owner *rendering.PipelineOwner)

Attach implements rendering.RenderObject.

func (*RenderEditorText) CharWidth

func (r *RenderEditorText) CharWidth() float64

CharWidth is the width of a character of the font.

func (*RenderEditorText) ComputeDryLayout

func (r *RenderEditorText) ComputeDryLayout(c rendering.BoxConstraints) ui.Size

ComputeDryLayout implements rendering.RenderBox: the biggest size the constraints allow.

func (*RenderEditorText) ComputeMaxIntrinsicHeight

func (r *RenderEditorText) ComputeMaxIntrinsicHeight(float64) float64

ComputeMaxIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorText) ComputeMaxIntrinsicWidth

func (r *RenderEditorText) ComputeMaxIntrinsicWidth(float64) float64

ComputeMaxIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorText) ComputeMinIntrinsicHeight

func (r *RenderEditorText) ComputeMinIntrinsicHeight(float64) float64

ComputeMinIntrinsicHeight implements rendering.RenderBox.

func (*RenderEditorText) ComputeMinIntrinsicWidth

func (r *RenderEditorText) ComputeMinIntrinsicWidth(float64) float64

ComputeMinIntrinsicWidth implements rendering.RenderBox.

func (*RenderEditorText) DebugInlineAt added in v1.0.0

func (r *RenderEditorText) DebugInlineAt(local ui.Offset) (line, col int, id string, ok bool)

DebugInlineAt finds the inline mark at a point of the text layer (in the layer's coordinates): the breakpoint or candidate under it.

func (*RenderEditorText) Detach

func (r *RenderEditorText) Detach()

Detach implements rendering.RenderObject.

func (*RenderEditorText) HintAt added in v1.0.0

func (r *RenderEditorText) HintAt(local ui.Offset) (entryID, part int, ok bool)

HintAt finds the inlay hint at a point of the text layer, given in the layer's own coordinates, and the label part it is on (-1 on its padding); false when the point is not on a hint.

func (*RenderEditorText) HitTestSelf

func (r *RenderEditorText) HitTestSelf(ui.Offset) bool

HitTestSelf implements rendering.RenderBox: every point of the editor is the editor's.

func (*RenderEditorText) IsRepaintBoundary

func (r *RenderEditorText) IsRepaintBoundary() bool

IsRepaintBoundary implements rendering.RenderObject.

func (*RenderEditorText) Paint

func (r *RenderEditorText) Paint(context *rendering.PaintingContext, offset ui.Offset)

Paint draws the visible rows.

func (*RenderEditorText) PerformLayout

func (r *RenderEditorText) PerformLayout()

PerformLayout tells the offset the size of the viewport and of the content, and prepares the paragraphs of the visible rows and the margin around them.

func (*RenderEditorText) PositionAt

func (r *RenderEditorText) PositionAt(local ui.Offset) buffer.Position

PositionAt is the position of the document nearest to a point of the text layer, given in the layer's own coordinates: the row from the projection, then the column from the paragraph of the row, or from the width of a character for plain ASCII in a monospace font. A point above or below the rows is the first or last row, and one past the end of a line is its end.

func (*RenderEditorText) RectOf

func (r *RenderEditorText) RectOf(p buffer.Position) ui.Rect

RectOf is the rectangle of the character at a position, in the layer's own coordinates: as high as the row and as wide as the character, or one character at the end of a line. It can lie outside the layer when the position is scrolled out of view.

func (*RenderEditorText) SetAnnotationColors added in v1.0.0

func (r *RenderEditorText) SetAnnotationColors(fallback ui.Color, named func(id string) (ui.Color, bool))

SetAnnotationColors gives the layer the colors of the annotations: fallback is the color of an annotation that names none the theme knows, named finds the color of a theme color id.

func (*RenderEditorText) SetBracketColors

func (r *RenderEditorText) SetBracketColors(c BracketColors)

SetBracketColors changes the colors of the brackets.

func (*RenderEditorText) SetColor

func (r *RenderEditorText) SetColor(color ui.Color)

SetColor changes the color of the text.

func (*RenderEditorText) SetFactory

func (r *RenderEditorText) SetFactory(factory ui.ParagraphFactory)

SetFactory changes the text engine.

func (*RenderEditorText) SetOffset

func (r *RenderEditorText) SetOffset(offset rendering.ViewportOffset)

SetOffset changes the vertical offset.

func (*RenderEditorText) SetTokenTheme

func (r *RenderEditorText) SetTokenTheme(t *theme.TokenTheme)

SetTokenTheme changes the theme that colors the tokens; nil makes the text one color.

func (*RenderEditorText) SetViewModel

func (r *RenderEditorText) SetViewModel(vm *ViewModel)

SetViewModel changes the view model.

func (*RenderEditorText) SizedByParent

func (r *RenderEditorText) SizedByParent() bool

SizedByParent implements rendering.RenderObject: the editor fills the space it is given.

func (*RenderEditorText) VisualColumnAt

func (r *RenderEditorText) VisualColumnAt(local ui.Offset) int

VisualColumnAt is the visual column nearest to a point of the text layer, given in the layer's own coordinates, counted in characters of the font and also past the end of a line.

func (*RenderEditorText) ZoneAt

func (r *RenderEditorText) ZoneAt(local ui.Offset) (ZoneHit, bool)

ZoneAt tells which view zone is at a point of the text layer, given in the layer's own coordinates, if one is.

type RenderLinesView

type RenderLinesView struct {
	rendering.RenderBox
	// contains filtered or unexported fields
}

RenderLinesView is the render object of a LinesView.

func (*RenderLinesView) Attach

func (r *RenderLinesView) Attach(owner *rendering.PipelineOwner)

Attach implements rendering.RenderObject.

func (*RenderLinesView) ComputeDryLayout

func (r *RenderLinesView) ComputeDryLayout(c rendering.BoxConstraints) ui.Size

ComputeDryLayout implements rendering.RenderBox: the biggest size the constraints allow.

func (*RenderLinesView) ComputeMaxIntrinsicHeight

func (r *RenderLinesView) ComputeMaxIntrinsicHeight(float64) float64

ComputeMaxIntrinsicHeight implements rendering.RenderBox.

func (*RenderLinesView) ComputeMaxIntrinsicWidth

func (r *RenderLinesView) ComputeMaxIntrinsicWidth(float64) float64

ComputeMaxIntrinsicWidth implements rendering.RenderBox.

func (*RenderLinesView) ComputeMinIntrinsicHeight

func (r *RenderLinesView) ComputeMinIntrinsicHeight(float64) float64

ComputeMinIntrinsicHeight implements rendering.RenderBox.

func (*RenderLinesView) ComputeMinIntrinsicWidth

func (r *RenderLinesView) ComputeMinIntrinsicWidth(float64) float64

ComputeMinIntrinsicWidth implements rendering.RenderBox.

func (*RenderLinesView) Detach

func (r *RenderLinesView) Detach()

Detach implements rendering.RenderObject.

func (*RenderLinesView) HitTestSelf

func (r *RenderLinesView) HitTestSelf(ui.Offset) bool

HitTestSelf implements rendering.RenderBox: the lines take no pointer events (the editor under the zone sees them).

func (*RenderLinesView) Paint

func (r *RenderLinesView) Paint(context *rendering.PaintingContext, offset ui.Offset)

Paint draws the marks and then the lines.

func (*RenderLinesView) PerformLayout

func (r *RenderLinesView) PerformLayout()

PerformLayout implements rendering.RenderBox; there are no children.

func (*RenderLinesView) SizedByParent

func (r *RenderLinesView) SizedByParent() bool

SizedByParent implements rendering.RenderBox.

func (*RenderLinesView) Update

func (r *RenderLinesView) Update(opts LinesViewOpts, factory ui.ParagraphFactory, color ui.Color, tokens *theme.TokenTheme, brackets BracketColors)

Update copies the configuration of the widget.

type RulerColors

type RulerColors struct {
	// FindMatch marks the matches of the find widget, in the middle lane; RangeHighlight marks
	// the lines of the current match, across all three lanes.
	FindMatch, RangeHighlight ui.Color
	// Error, Warning and Info mark the diagnostics, in the right lane (hints have no mark).
	Error, Warning, Info ui.Color
	// Added, Modified and Deleted mark the changes of the quick diff, in the left lane.
	Added, Modified, Deleted ui.Color
}

RulerColors are the colors of the marks on the overview ruler.

type SignatureKeys added in v1.0.0

type SignatureKeys struct {
	// Visible is parameterHintsVisible, Multiple parameterHintsMultipleSignatures and HasProvider editorHasSignatureHelpProvider.
	Visible, Multiple, HasProvider bool
}

SignatureKeys are the context keys of the parameter hints.

type SnippetPicker

type SnippetPicker struct {
	// Items are the rows: a label and, for a snippet, its description.
	Items []SnippetPickerItem
	// Filterable lets the user type to filter the rows.
	Filterable bool
	// Accept is called with the index of the row the user chose; Dismiss when the user gave up.
	// Either one closes the picker.
	Accept  func(index int)
	Dismiss func()
}

SnippetPicker is a short list the editor asks its widget to show at the caret: the options of a choice (`${1|a,b|}`) or the snippets that the Tab key could insert, as a kit.ListOverlay (VS Code shows them as suggestions). The snippets to pick for Insert Snippet are a quick pick instead (SetQuickPick).

type SnippetPickerItem

type SnippetPickerItem struct {
	Label, Description string
}

SnippetPickerItem is one row of a SnippetPicker.

type StickyColors

type StickyColors struct {
	// Background is the background of the lines, GutterBackground that of the gutter part, Hover
	// that of the line under the pointer, Border the line under the widget and Shadow its shadow.
	Background, GutterBackground, Hover, Border, Shadow ui.Color
	// LineNumber is the color of the line numbers and FoldingControl that of the folding icons.
	LineNumber, FoldingControl ui.Color
}

StickyColors are the colors of sticky scroll.

type StickyScrollOptions

type StickyScrollOptions struct {
	// Enabled is editor.stickyScroll.enabled.
	Enabled bool
	// MaxLineCount is editor.stickyScroll.maxLineCount.
	MaxLineCount int
	// ScrollWithEditor is editor.stickyScroll.scrollWithEditor: the lines follow the horizontal
	// scroll of the text.
	ScrollWithEditor bool
	// DefaultModel is editor.stickyScroll.defaultModel: "outlineModel" (also when empty) builds the scopes from the document
	// symbols when there are any and else from the folding regions; "foldingProviderModel" and "indentationModel" use the
	// folding regions (Emetos has one folding model).
	DefaultModel string
}

StickyScrollOptions are the settings of sticky scroll (editor.stickyScroll.*).

type SuggestDetails added in v1.0.0

type SuggestDetails struct {
	// Detail is the text above the documentation, Documentation the documentation (nil for none).
	Detail        string
	Documentation *langfeatures.Markup
	// Loading says that the details are being asked for.
	Loading bool
}

SuggestDetails is what the details pane shows for the focused item.

type SuggestHost added in v1.0.0

type SuggestHost struct {
	// Ctx ends every request of the editor with the window tab.
	Ctx context.Context
	// Features is the registry of the completion providers (and the resolvers) of the tab.
	Features *langfeatures.Registry
	// Shared is the state the editors of the tab share; the editor makes one when nil.
	Shared *SuggestShared
	// Execute runs the command of an accepted item, on the UI thread: the command of a language server goes to it, the others
	// to the commands of the window. Without it a command is ignored.
	Execute func(ctx context.Context, cmd langfeatures.Command) error
	// Report shows a failure to the user (an item that cannot be inserted, a command that failed); without it failures are not
	// shown. Log writes the failure of a provider to the log: a provider that fails on a keystroke is not shown on every one.
	Report func(err error)
	Log    func(message string, err error)
	// Tokenize gives the tokens of a code block of a language, named as a fence names it ("go"); false when the language has no
	// grammar. The hover and the parameter hints use it (and the registry above) to color the code of their Markdown.
	Tokenize func(language, text string) ([][]extension.Token, bool)

	// The means of navigation (step 12.7).
	//
	// Symbols is the cache of the document symbols that the editors of the window share; an editor shows no symbols without it.
	Symbols *langfeatures.SymbolCache
	// Open shows a location in an editor of the window, as a jump of the navigation history (OpenLocation says how).
	Open func(loc langfeatures.Location, o OpenLocation)
	// Embedded makes the editor that a peek view shows a file in, without a tab: done is called on the UI thread with its view
	// model and the function that lets go of it (or the error). The view model has no navigation host of its own.
	Embedded func(ctx context.Context, uri document.URI, done func(vm *ViewModel, release func(), err error))
	// Texts reads the text of a document that is not this editor's, for the rows of the peek view.
	Texts langfeatures.TextSource
	// DirLabel is how the peek view writes the folder of a file: relative to the folder of the window, with the home folder as
	// "~"; without it the absolute folder.
	DirLabel func(dir string) string
	// JumpTo moves the cursor of an editor to a position as a navigation of the history (choosing a symbol of the outline or of
	// a picker); without it the cursor just moves.
	JumpTo func(vm *ViewModel, p buffer.Position)

	// The means of the changes the language features make (step 12.8).
	//
	// ApplyEdit makes a workspace edit (a code action's, a rename's) on the UI thread, with the cursors of the editors following
	// the text, and fails with the reason; the window applies it with langfeatures.Apply.
	ApplyEdit func(ctx context.Context, we *langfeatures.WorkspaceEdit) error
	// KeyLabel gives the label of the key of a command ("Ctrl+."), or empty when it has none: the tooltip of the light bulb and
	// the keys in the list of actions show them.
	KeyLabel func(command string) string

	// Semantic is the cache of the semantic tokens that the editors of the window share (step 12.9); an editor has no semantic
	// highlighting without it.
	Semantic *langfeatures.SemanticTokensCache
}

SuggestHost is what a window gives the editor to complete with.

type SuggestKeys added in v1.0.0

type SuggestKeys struct {
	Visible, HasFocused, DetailsVisible, Multiple, MakesTextEdit, HasInsertAndReplace, CanResolve bool
	InsertMode                                                                                    string
	AcceptOnEnter                                                                                 bool
}

SuggestKeys are the context keys of the widget.

type SuggestOptions added in v1.0.0

type SuggestOptions struct {
	// QuickSuggestions is editor.quickSuggestions and QuickSuggestionsDelay editor.quickSuggestionsDelay (milliseconds).
	QuickSuggestions      QuickSuggestions
	QuickSuggestionsDelay int
	// SuggestOnTriggerCharacters is editor.suggestOnTriggerCharacters.
	SuggestOnTriggerCharacters bool
	// AcceptSuggestionOnEnter is editor.acceptSuggestionOnEnter ("on", "smart", "off") and AcceptSuggestionOnCommitCharacter
	// editor.acceptSuggestionOnCommitCharacter.
	AcceptSuggestionOnEnter           string
	AcceptSuggestionOnCommitCharacter bool
	// SuggestSelection is editor.suggestSelection: "first", "recentlyUsed" or "recentlyUsedByPrefix".
	SuggestSelection string
	// SnippetSuggestions is editor.snippetSuggestions: "top", "bottom", "inline" or "none".
	SnippetSuggestions string
	// WordBasedSuggestions is editor.wordBasedSuggestions; the window gives it to the provider of words.
	WordBasedSuggestions string
	// FontSize and LineHeight are editor.suggestFontSize and editor.suggestLineHeight; 0 is the editor's.
	FontSize, LineHeight int
	// InsertMode is editor.suggest.insertMode: "insert" or "replace".
	InsertMode string
	// FilterGraceful, LocalityBonus, SnippetsPreventQuickSuggestions, ShowIcons, ShowStatusBar, Preview, ShowInlineDetails,
	// ShowDeprecated and MatchOnWordStartOnly are the editor.suggest.* settings of those names; SelectionMode is
	// editor.suggest.selectionMode.
	FilterGraceful, LocalityBonus, SnippetsPreventQuickSuggestions bool
	ShowIcons, ShowStatusBar, Preview, ShowInlineDetails           bool
	ShowDeprecated, MatchOnWordStartOnly                           bool
	SelectionMode                                                  string
	// HiddenKinds are the kinds (the LSP numbers) that editor.suggest.show<Kind> turned off.
	HiddenKinds map[int]bool
}

SuggestOptions are the settings of the suggest widget.

type SuggestShared added in v1.0.0

type SuggestShared struct {
	Memory         *langfeatures.SuggestMemory
	DetailsVisible bool
}

SuggestShared is what the editors of a window tab share about the suggest widget: the memory of the accepted suggestions and whether the details pane is open (VS Code keeps the second in the storage of the workspace, as "expandSuggestionDocs").

func NewSuggestShared added in v1.0.0

func NewSuggestShared() *SuggestShared

NewSuggestShared makes the shared state of a window tab.

type SuggestState added in v1.0.0

type SuggestState int

SuggestState is what the suggest widget is showing.

const (
	// SuggestHidden: nothing shows.
	SuggestHidden SuggestState = iota
	// SuggestLoading: the request is slow and the widget says "Loading...".
	SuggestLoading
	// SuggestEmpty: a request that was asked for by the user has no items: "No suggestions."
	SuggestEmpty
	// SuggestOpen: the list shows.
	SuggestOpen
	// SuggestFrozen: the list shows and no longer follows what is typed (the user asked for it and what they typed since
	// matches nothing).
	SuggestFrozen
)

The states of the suggest widget.

type SuggestView added in v1.0.0

type SuggestView struct {
	State SuggestState
	// Items are the rows and Focus the focused one (-1 for none); Top is the first row in view.
	Items      []*langfeatures.SuggestItem
	Focus, Top int
	// Anchor is the place of the text the widget hangs from: the start of the word that is being completed.
	Anchor buffer.Position
	// Details is the pane next to the list, or nil when it is closed or the focused item has nothing to show.
	Details *SuggestDetails
	// Options are the settings of the widget.
	Options SuggestOptions
}

SuggestView is what the suggest widget draws.

type TestColors added in v1.0.0

type TestColors struct {
	// Fallback is the color of a glyph that names none, or one the theme does not have.
	Fallback ui.Color
	// Lookup finds a theme color by id; nil finds none.
	Lookup func(id string) (ui.Color, bool)
}

TestColors are the colors of the test marks: the theme colors the glyphs name, found by id.

func (TestColors) Named added in v1.0.0

func (c TestColors) Named(id string, fallback ui.Color) ui.Color

Named is the color of the theme color with the id, else the fallback.

type TestGlyphMark added in v1.0.0

type TestGlyphMark struct {
	// Line is the line, counted from 0.
	Line int
	// IDs are the tests the glyph runs, in the order of the line.
	IDs []string
	// Icon is the Codicon (a fonts.Codicon... constant) and ColorID the id of the theme color it is drawn in; an empty id draws it in the
	// foreground of the editor.
	Icon    int
	ColorID string
	// Hover is the Markdown of the hover of the glyph.
	Hover string
	// Failed says that the state of the glyph is a failure, which marks the overview ruler.
	Failed bool
}

TestGlyphMark is the glyph of the tests that start on a line: the icon of the run or of the state of the last result.

type TestHost added in v1.0.0

type TestHost struct {
	// Enabled says whether the glyphs show (testing.gutterEnabled).
	Enabled func() bool
	// GlyphPress is a press of the primary button on a glyph.
	GlyphPress func(TestPress)
}

TestHost is what the window gives the editor to act on the tests. Every function is called on the UI thread; any may be nil.

type TestMenuTarget added in v1.0.0

type TestMenuTarget struct {
	// Line is counted from 0 and IDs are the tests of the glyph; InGlyph says that the press was on a test glyph.
	Line    int
	IDs     []string
	InGlyph bool
}

TestMenuTarget is where the secondary button was pressed last, for the menu of a test glyph.

type TestMessageMark added in v1.0.0

type TestMessageMark struct {
	// Line is the line, counted from 0, and Text the text after it (its first line).
	Line int
	Text string
	// Hover is the Markdown of the hover of the message; empty for none.
	Hover string
	// Info says that the message is a logged output, not a failure.
	Info bool
}

TestMessageMark is a message of a test shown after the end of its line.

type TestPress added in v1.0.0

type TestPress struct {
	// Line is counted from 0 and IDs are the tests of the glyph.
	Line int
	IDs  []string
	// Mods are the modifiers held; Alt asks for the alternate action.
	Mods MouseModifiers
	// At is the place of the pointer in the window, where a menu opens.
	At ui.Offset
}

TestPress is a press of the primary button on a test glyph.

type TimerFunc

type TimerFunc func(d time.Duration, fn func()) (cancel func())

TimerFunc runs fn once on the UI thread after d and returns the function that cancels it. The editor widget gives the view model the timers of the window's binding (so that tests drive them with a fake clock); the view model does not blink without one.

type ViewModel

type ViewModel struct {
	foundation.ChangeNotifier
	// contains filtered or unexported fields
}

ViewModel is the state of one editor over one document: the cursors, the scroll position, the projection from lines to rows and the cache of paragraphs. Several editors of one document each have a view model (SPEC §9.1). It is used on the UI thread only, and tells its listeners (render objects) when something that is drawn changed.

func NewViewModel

func NewViewModel(doc *document.Document, opts Options, cache *ParagraphCache) *ViewModel

NewViewModel makes the view model of a document with the cursor at its start.

func (*ViewModel) AcceptBreakpointWidget added in v1.0.0

func (vm *ViewModel) AcceptBreakpointWidget()

AcceptBreakpointWidget accepts what is typed in the breakpoint widget and closes it.

Ported from VS Code: breakpointWidget.ts (close(true))

func (*ViewModel) AddBlinkListener

func (vm *ViewModel) AddBlinkListener(fn func()) foundation.ListenerHandle

AddBlinkListener calls fn whenever the cursors are shown or hidden by the blinking.

func (*ViewModel) AddCodeActionListener added in v1.0.0

func (vm *ViewModel) AddCodeActionListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddCodeActionListener calls fn when the light bulb or the list of actions shows, changes or goes.

func (*ViewModel) AddDebugHoverListener added in v1.0.0

func (vm *ViewModel) AddDebugHoverListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddDebugHoverListener calls fn when the debug hover shows or hides.

func (*ViewModel) AddFindListener

func (vm *ViewModel) AddFindListener(fn func()) foundation.ListenerHandle

AddFindListener calls fn whenever the state of the find widget or its matches change.

func (*ViewModel) AddHoverListener added in v1.0.0

func (vm *ViewModel) AddHoverListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddHoverListener calls fn when the hover shows, changes or hides.

func (*ViewModel) AddMetricsListener

func (vm *ViewModel) AddMetricsListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddMetricsListener calls fn when the sizes of the text area or of the content change. fn can be called during layout.

func (*ViewModel) AddPeekListener added in v1.0.0

func (vm *ViewModel) AddPeekListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddPeekListener calls fn when the peek view opens, closes or changes.

func (*ViewModel) AddPreviewListener added in v1.0.0

func (vm *ViewModel) AddPreviewListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddPreviewListener calls fn when the preview shows, changes or goes.

func (*ViewModel) AddRenameListener added in v1.0.0

func (vm *ViewModel) AddRenameListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddRenameListener calls fn when the rename box shows, changes or goes.

func (*ViewModel) AddScrollListener

func (vm *ViewModel) AddScrollListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddScrollListener calls fn when the editor scrolls, vertically or horizontally (the diff editor keeps its two editors scrolled together with it). fn is called on the UI thread, possibly during layout.

func (*ViewModel) AddSelectionListener

func (vm *ViewModel) AddSelectionListener(fn func()) foundation.ListenerHandle

AddSelectionListener calls fn whenever the selections, the focus or the document change.

func (*ViewModel) AddSignatureListener added in v1.0.0

func (vm *ViewModel) AddSignatureListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddSignatureListener calls fn when the parameter hints show, change or close.

func (*ViewModel) AddSuggestListener added in v1.0.0

func (vm *ViewModel) AddSuggestListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddSuggestListener calls fn when what the suggest widget shows changes.

func (*ViewModel) AddSymbolsListener added in v1.0.0

func (vm *ViewModel) AddSymbolsListener(fn foundation.VoidCallback) foundation.ListenerHandle

AddSymbolsListener calls fn when the symbols change.

func (*ViewModel) AddZone

func (vm *ViewModel) AddZone(spec ZoneSpec) (ZoneID, error)

AddZone adds a view zone and gives its id. The rows of the zone are inserted after the line it comes after (unless a fold hides the line after it), and move with that line when the document is edited: lines inserted above push it down, and when the line it comes after is deleted it goes after the line before the deleted ones.

func (*ViewModel) ApplyCodeAction added in v1.0.0

func (vm *ViewModel) ApplyCodeAction(a langfeatures.CodeAction, retrigger, preview bool)

ApplyCodeAction applies an action: it asks the provider for the edit when the action has none and the provider can resolve it (codeAction/resolve), makes the edit (after showing it when preview is set), and then runs the command. With retrigger the light bulb asks again afterwards. Everything but the edit and the command happens off the UI thread.

Ported from VS Code: codeAction.ts (applyCodeAction)

func (*ViewModel) ApplySaveParticipants

func (vm *ViewModel) ApplySaveParticipants(p edit.SaveParticipants, autoSave bool) error

ApplySaveParticipants makes the edits of a save to the text of the editor's document (trim trailing whitespace, insert the final newline, trim the final newlines; SPEC §6.3): one undo step of their own, with the cursors of the editor kept in place as far as the text allows. With autoSave the white space in front of a cursor stays. It does nothing when no participant is on or the text needs none of them.

Ported from VS Code: src/vs/workbench/contrib/codeEditor/browser/saveParticipants.ts

func (*ViewModel) ApplySaveParticipantsJoined added in v1.0.0

func (vm *ViewModel) ApplySaveParticipantsJoined(p edit.SaveParticipants, autoSave bool) error

ApplySaveParticipantsJoined is ApplySaveParticipants for the participants of a save that are made one undo step with the edits of the language features: the edits join the undo group that is open, and the caller closes it.

func (*ViewModel) ApplyTextEdits added in v1.0.0

func (vm *ViewModel) ApplyTextEdits(edits []langfeatures.TextEdit, join bool) error

ApplyTextEdits makes the edits of a formatter or a server in the document of the editor as one undo step, and the cursors follow the text they were in. With join the edits are part of the undo group that is open (the participants of a save make one); otherwise they are a step of their own, which typing before and after does not join. An edit that is not valid for the text fails with the document's error and changes nothing.

Ported from VS Code: formattingEdit.ts (FormattingEdit.execute)

func (*ViewModel) AtBottom

func (vm *ViewModel) AtBottom() bool

AtBottom tells whether the editor shows the end of its text: it is scrolled to the end, or has not been laid out yet. A viewer that tails a text (the Output panel) follows it only while this holds.

func (*ViewModel) BackgroundMarks

func (vm *ViewModel) BackgroundMarks() []BackgroundMark

BackgroundMarks are the marks of the editor as they are now (their ranges moved with the edits of the document), in order of position.

func (*ViewModel) Brackets

func (vm *ViewModel) Brackets() *brackets.Index

Brackets are the bracket pairs of the document, or nil.

func (*ViewModel) BreakpointWidgetContext added in v1.0.0

func (vm *ViewModel) BreakpointWidgetContext() BreakpointContext

BreakpointWidgetContext is the entry the breakpoint widget shows now.

func (*ViewModel) BreakpointWidgetFocused added in v1.0.0

func (vm *ViewModel) BreakpointWidgetFocused() bool

BreakpointWidgetFocused tells whether the input of the breakpoint widget has the keyboard (the key inBreakpointWidget).

func (*ViewModel) BreakpointWidgetOpen added in v1.0.0

func (vm *ViewModel) BreakpointWidgetOpen() bool

BreakpointWidgetOpen tells whether the breakpoint widget shows (the key breakpointWidgetVisible).

func (*ViewModel) BreakpointWidgetSetContext added in v1.0.0

func (vm *ViewModel) BreakpointWidgetSetContext(c BreakpointContext)

BreakpointWidgetSetContext picks the entry of the dropdown of the breakpoint widget.

func (*ViewModel) BreakpointWidgetSetText added in v1.0.0

func (vm *ViewModel) BreakpointWidgetSetText(text string)

BreakpointWidgetSetText types into the input of the breakpoint widget (for the tests and the commands).

func (*ViewModel) CancelGoTo added in v1.0.0

func (vm *ViewModel) CancelGoTo()

CancelGoTo ends the navigation that is being asked for; its answer is dropped.

func (*ViewModel) ChangeZone

func (vm *ViewModel) ChangeZone(id ZoneID, fn func(*ZoneSpec)) error

ChangeZone changes a zone: fn is given a copy of it. A zone that would be invalid is not changed.

func (*ViewModel) ChangeZones

func (vm *ViewModel) ChangeZones(fn func(ZoneChanges) error) error

ChangeZones makes several changes of the zones at once: the editor is told of them, and lays out again, when fn returns (VS Code's changeViewZones). The changes that were made before fn returns an error stay.

func (*ViewModel) ClearRangeHighlight

func (vm *ViewModel) ClearRangeHighlight()

ClearRangeHighlight takes the shading of SetRangeHighlight away.

func (*ViewModel) CodeActionHide added in v1.0.0

func (vm *ViewModel) CodeActionHide()

CodeActionHide closes the list of actions.

func (*ViewModel) CodeActionList added in v1.0.0

func (vm *ViewModel) CodeActionList() *ActionList

CodeActionList is the list of actions that is open, or nil.

func (*ViewModel) CodeActionMenuAccept added in v1.0.0

func (vm *ViewModel) CodeActionMenuAccept(preview bool)

CodeActionMenuAccept applies the focused action, or shows its changes first with preview.

func (*ViewModel) CodeActionMenuClick added in v1.0.0

func (vm *ViewModel) CodeActionMenuClick(i int)

CodeActionMenuClick applies the action of a row.

func (*ViewModel) CodeActionMenuFocus added in v1.0.0

func (vm *ViewModel) CodeActionMenuFocus(i int)

CodeActionMenuFocus focuses a row, as the pointer moving over it does.

func (*ViewModel) CodeActionMenuMove added in v1.0.0

func (vm *ViewModel) CodeActionMenuMove(dir int)

CodeActionMenuMove moves the focus of the list to the next (1) or the previous (-1) row that can be chosen.

func (*ViewModel) CodeActionMenuVisible added in v1.0.0

func (vm *ViewModel) CodeActionMenuVisible() bool

CodeActionMenuVisible tells whether the list is open (the key codeActionMenuVisible).

func (*ViewModel) CodeActionsHasProvider added in v1.0.0

func (vm *ViewModel) CodeActionsHasProvider() bool

CodeActionsHasProvider tells whether a code action provider matches the document (the key editorHasCodeActionsProvider).

func (*ViewModel) CodeLensCount added in v1.0.0

func (vm *ViewModel) CodeLensCount() int

CodeLensCount is how many lens rows (lines with lenses) the editor shows.

func (*ViewModel) CodeLensRunAt added in v1.0.0

func (vm *ViewModel) CodeLensRunAt(zone ZoneID, index int) bool

CodeLensRunAt runs the command of the lens that has a title in the row of the zone, as a click on it does; false when there is none.

func (*ViewModel) CodeLensTitles added in v1.0.0

func (vm *ViewModel) CodeLensTitles() [][]string

CodeLensTitles are the titles of the resolved lenses of the rows, in order, one list per row (for a test and for the accessibility of the editor).

func (*ViewModel) CodeLensZones added in v1.0.0

func (vm *ViewModel) CodeLensZones() []ZoneID

CodeLensZones are the view zones of the lens rows, in order.

func (*ViewModel) ContentHeight

func (vm *ViewModel) ContentHeight() float64

ContentHeight is the height the content scrolls through: the text area plus how far it scrolls.

func (*ViewModel) ContentWidth

func (vm *ViewModel) ContentWidth() float64

ContentWidth is the width of the content: the widest row laid out so far and room for a few more characters, or the text area when that is wider.

Ported from VS Code: src/vs/editor/common/viewLayout/viewLayout.ts (scrollWidth, scrollBeyondLastColumn, isViewportWrapping)

func (*ViewModel) ContextKeysForTest added in v1.0.0

func (vm *ViewModel) ContextKeysForTest() map[string]any

ContextKeysForTest gives the context keys the window and the diff editor gave the editor, as they would be set in its scope.

func (*ViewModel) CoverageAnnotations added in v1.0.0

func (vm *ViewModel) CoverageAnnotations() map[int][]string

CoverageAnnotations are the counts of the editor as they are now, by line (counted from 0); the lines moved with the edits.

func (*ViewModel) CoverageMarks added in v1.0.0

func (vm *ViewModel) CoverageMarks() []BackgroundMark

CoverageMarks are the marks of the coverage as they are now (their ranges moved with the edits), in order of position.

func (*ViewModel) CursorFrame

func (vm *ViewModel) CursorFrame() (opacity, scaleY float64)

CursorFrame is how opaque the cursors are and how much of their height is left, in the animated styles of editor.cursorBlinking.

func (*ViewModel) Cursors

func (vm *ViewModel) Cursors() *edit.Cursors

Cursors are the cursors of the editor.

func (*ViewModel) CursorsVisible

func (vm *ViewModel) CursorsVisible() bool

CursorsVisible tells whether the cursors are drawn now: the editor has the focus and the blinking is in its shown half.

func (*ViewModel) DebugBreakpoints added in v1.0.0

func (vm *ViewModel) DebugBreakpoints() []DebugBreakpointMark

DebugBreakpoints are the breakpoints of the editor as they are now (moved by the edits), in the order of the document.

func (*ViewModel) DebugCloseBreakpointWidget added in v1.0.0

func (vm *ViewModel) DebugCloseBreakpointWidget()

DebugCloseBreakpointWidget closes the breakpoint widget without accepting it.

func (*ViewModel) DebugCloseException added in v1.0.0

func (vm *ViewModel) DebugCloseException()

DebugCloseException closes the exception widget.

func (*ViewModel) DebugExceptionInfo added in v1.0.0

func (vm *ViewModel) DebugExceptionInfo() (DebugException, bool)

DebugExceptionInfo is the exception the widget shows.

func (*ViewModel) DebugExceptionOpen added in v1.0.0

func (vm *ViewModel) DebugExceptionOpen() bool

DebugExceptionOpen tells whether the exception widget shows (the key exceptionWidgetVisible).

func (*ViewModel) DebugFrames added in v1.0.0

func (vm *ViewModel) DebugFrames() []DebugFrameMark

DebugFrames are the frames of the editor as they are now.

func (*ViewModel) DebugGlyphHint added in v1.0.0

func (vm *ViewModel) DebugGlyphHint() (line int, shown bool)

DebugGlyphHint is the line the faint breakpoint hint shows on, and whether it shows.

func (*ViewModel) DebugHideHover added in v1.0.0

func (vm *ViewModel) DebugHideHover()

DebugHideHover hides the debug hover and cancels the one that is coming.

func (*ViewModel) DebugHostSet added in v1.0.0

func (vm *ViewModel) DebugHostSet() bool

DebugHostSet tells whether the editor has a debug host.

func (*ViewModel) DebugHover added in v1.0.0

func (vm *ViewModel) DebugHover() *DebugHoverContent

DebugHover is the debug hover that shows now, or nil.

func (*ViewModel) DebugHoverBoxEntered added in v1.0.0

func (vm *ViewModel) DebugHoverBoxEntered(in bool)

DebugHoverBoxEntered tells the hover that the pointer entered or left its box: a sticky hover stays while the pointer is in it; one that left hides unless the pointer is on the expression.

func (*ViewModel) DebugHoverPointer added in v1.0.0

func (vm *ViewModel) DebugHoverPointer(p buffer.Position, alt bool) bool

DebugHoverPointer tells the debug hover that the pointer rests on the text at a position. It says whether the debug hover has the pointer (the hover of the language does not start): a session is stopped in this document and Alt is not held. The expression is evaluated after the delay; a pointer that stays in the expression keeps the box, one that goes into the box (the hover is sticky) too.

func (*ViewModel) DebugPointerLeft added in v1.0.0

func (vm *ViewModel) DebugPointerLeft()

DebugPointerLeft tells the debug hover that the pointer left the text: a box the pointer is not in goes.

func (*ViewModel) DebugShowException added in v1.0.0

func (vm *ViewModel) DebugShowException(line int, info DebugException, copy func(text string), closed func()) error

DebugShowException shows the exception widget under a line (counted from 0): a title with the id of the exception, Copy and Close, the description and the stack trace. One that is open goes first. copy is what Copy does with the text; closed is called when the user closes the widget.

func (*ViewModel) DebugShowHover added in v1.0.0

func (vm *ViewModel) DebugShowHover(p buffer.Position) bool

DebugShowHover shows the debug hover at once at a position (the command Debug: Show Hover). It says whether there is an expression.

func (*ViewModel) DevState added in v1.0.0

func (vm *ViewModel) DevState() DevState

DevState reads the modes of the editor.

func (*ViewModel) DiagnosticCount added in v1.0.0

func (vm *ViewModel) DiagnosticCount() int

DiagnosticCount is the number of diagnostics the editor holds.

func (*ViewModel) Diagnostics added in v1.0.0

func (vm *ViewModel) Diagnostics() []Diagnostic

Diagnostics are the diagnostics as they are now (their ranges moved with the edits), in order of position.

func (*ViewModel) DiagnosticsAt added in v1.0.0

func (vm *ViewModel) DiagnosticsAt(p buffer.Position) []Diagnostic

DiagnosticsAt are the diagnostics under a position, the most serious first: a position is under a diagnostic when it is inside its range, or at its start when the range is empty.

func (*ViewModel) DispatchMouse

func (vm *ViewModel) DispatchMouse(ev MouseEvent) error

DispatchMouse does what a press or a drag of the mouse button means for the cursors: it moves them, selects by word or line, adds a cursor or selects a column. It runs like a command, so the sessions of the column selection go on while the mouse drags.

Ported from VS Code: src/vs/editor/browser/view/viewController.ts (ViewController.dispatchMouse)

func (*ViewModel) DisposeCodeLenses added in v1.0.0

func (vm *ViewModel) DisposeCodeLenses()

DisposeCodeLenses stops following the document and takes the lenses away.

func (*ViewModel) DisposeCoverage added in v1.0.0

func (vm *ViewModel) DisposeCoverage()

DisposeCoverage takes the coverage off the editor.

func (*ViewModel) DisposeDebug added in v1.0.0

func (vm *ViewModel) DisposeDebug()

DisposeDebug takes the debug marks and the widgets off the editor.

func (*ViewModel) DisposeDiagnostics added in v1.0.0

func (vm *ViewModel) DisposeDiagnostics()

DisposeDiagnostics takes the diagnostics off the document.

func (*ViewModel) DisposeFind

func (vm *ViewModel) DisposeFind()

DisposeFind drops the find model, its decorations and the state; the view model starts again with a closed widget when it is asked for the state.

func (*ViewModel) DisposeHighlights

func (vm *ViewModel) DisposeHighlights()

DisposeHighlights stops the highlights and takes their decorations away.

func (*ViewModel) DisposeInlayHints added in v1.0.0

func (vm *ViewModel) DisposeInlayHints()

DisposeInlayHints stops following the document and takes the hints away.

func (*ViewModel) DisposeInlineValues added in v1.0.0

func (vm *ViewModel) DisposeInlineValues()

DisposeInlineValues takes the debug inline values off the document.

func (*ViewModel) DisposeLineAnnotations added in v1.0.0

func (vm *ViewModel) DisposeLineAnnotations()

DisposeLineAnnotations takes the line annotations off the document.

func (*ViewModel) DisposeMarks

func (vm *ViewModel) DisposeMarks()

DisposeMarks takes the background marks off the document.

func (*ViewModel) DisposeQuickDiff added in v1.0.0

func (vm *ViewModel) DisposeQuickDiff()

DisposeQuickDiff takes the quick diff marks off the document.

func (*ViewModel) DisposeSemanticTokens added in v1.0.0

func (vm *ViewModel) DisposeSemanticTokens()

DisposeSemanticTokens stops following the document and drops the tokens.

func (*ViewModel) DisposeSymbols added in v1.0.0

func (vm *ViewModel) DisposeSymbols()

DisposeSymbols stops following the document.

func (*ViewModel) DisposeTesting added in v1.0.0

func (vm *ViewModel) DisposeTesting()

DisposeTesting takes the test marks off the editor.

func (*ViewModel) DisposeWrap

func (vm *ViewModel) DisposeWrap()

DisposeWrap stops the word wrap: no more steps and no more following of the document.

func (*ViewModel) DisposeZones

func (vm *ViewModel) DisposeZones()

DisposeZones stops following the document. The zones stay.

func (*ViewModel) Document

func (vm *ViewModel) Document() *document.Document

Document is the document the editor shows.

func (*ViewModel) DocumentChanged

func (vm *ViewModel) DocumentChanged()

DocumentChanged tells the view model that the document changed: the projection is made again and the layers are redrawn. The unchanged rows keep their paragraphs in the cache.

func (*ViewModel) DropCaret

func (vm *ViewModel) DropCaret() (buffer.Position, bool)

DropCaret is where dropped text would go while text is being dragged; the second result is false when no text is dragged or the pointer is over the dragged text itself.

func (*ViewModel) EffectiveCursorStyle

func (vm *ViewModel) EffectiveCursorStyle() string

EffectiveCursorStyle is the style the cursors are drawn in: editor.overtypeCursorStyle in overtype mode (block when the option is empty), else editor.cursorStyle.

Ported from VS Code: src/vs/editor/common/config/editorOptions.ts (EffectiveCursorStyle)

func (*ViewModel) FeaturesChanged added in v1.0.0

func (vm *ViewModel) FeaturesChanged()

FeaturesChanged tells the editor that what the providers offer changed (a language server started or stopped): the symbols and the highlights are asked for again, and the keys that say what the language has are set again. It runs on the UI thread.

func (*ViewModel) FeaturesRefreshed added in v1.0.0

func (vm *ViewModel) FeaturesRefreshed(f langfeatures.Feature)

FeaturesRefreshed tells the editor that a language server wants the answers of a feature asked for again (the refresh requests of the semantic tokens, the code lenses and the inlay hints). It runs on the UI thread.

func (*ViewModel) FindRevealed

func (vm *ViewModel) FindRevealed() bool

FindRevealed says whether the find widget is open.

func (*ViewModel) FindState

func (vm *ViewModel) FindState() *find.State

FindState is the state of the find widget of the editor (what is searched for and found).

func (*ViewModel) FocusHover added in v1.0.0

func (vm *ViewModel) FocusHover() bool

FocusHover gives the keys to the hover box (the command Show Hover pressed while the hover shows); it says whether there was a hover to focus.

func (*ViewModel) Focused

func (vm *ViewModel) Focused() bool

Focused tells whether the editor has the focus: only then it has cursors that are shown, and its selections have the active color.

func (*ViewModel) FoldedLine

func (vm *ViewModel) FoldedLine(line int) bool

FoldedLine says whether a line is shown with a folded range after it.

func (*ViewModel) FoldingModel

func (vm *ViewModel) FoldingModel() *folding.Model

FoldingModel is the folding model, or nil when the editor does not fold.

func (*ViewModel) FoldingStateOf

func (vm *ViewModel) FoldingStateOf(line int) FoldingState

FoldingStateOf is what the folding control of a line shows.

func (*ViewModel) FormatDocument added in v1.0.0

func (vm *ViewModel) FormatDocument() bool

FormatDocument formats the whole document with the formatter of its language (editor.action.formatDocument). It says whether a request was made.

Ported from VS Code: formatActions.ts (FormatDocumentAction), format.ts (formatDocumentWithSelectedProvider)

func (*ViewModel) FormatSelection added in v1.0.0

func (vm *ViewModel) FormatSelection() bool

FormatSelection formats the selections, each empty one as its whole line (editor.action.formatSelection). It says whether a request was made.

Ported from VS Code: formatActions.ts (FormatSelectionAction), format.ts (formatDocumentRangesWithProvider)

func (*ViewModel) FormattingOptions added in v1.0.0

func (vm *ViewModel) FormattingOptions() langfeatures.FormattingOptions

FormattingOptions are the options a formatter is given: the indentation of the document.

func (*ViewModel) GoTo added in v1.0.0

func (vm *ViewModel) GoTo(kind GoKind, cfg GoConfig) bool

GoTo asks the providers for the locations of the symbol at the cursor and does what the settings say with them. It says whether a request was made.

func (*ViewModel) GoToPosition

func (vm *ViewModel) GoToPosition(p buffer.Position)

GoToPosition puts a single cursor at a position, scrolls it into the middle of the editor and makes the range highlight go away.

func (*ViewModel) GuideLevels

func (vm *ViewModel) GuideLevels() *indent.Levels

GuideLevels are the indentation levels the guides are drawn from, or nil.

func (*ViewModel) GutterWidths

func (vm *ViewModel) GutterWidths(factory ui.ParagraphFactory) GutterWidths

GutterWidths gives the widths of the gutter for the document of the view model, in the font of its options. The width of a digit is measured through the paragraph cache.

func (*ViewModel) HasDocumentFormatter added in v1.0.0

func (vm *ViewModel) HasDocumentFormatter() bool

HasDocumentFormatter tells whether a formatter matches the document (the key editorHasDocumentFormattingProvider).

func (*ViewModel) HasNavigation added in v1.0.0

func (vm *ViewModel) HasNavigation(k GoKind) bool

HasNavigation tells whether a provider offers the kind of navigation for the document (the keys editorHasDefinitionProvider and its kin).

func (*ViewModel) HasRangeFormatter added in v1.0.0

func (vm *ViewModel) HasRangeFormatter() bool

HasRangeFormatter tells whether a formatter that formats ranges matches the document (the key editorHasDocumentSelectionFormattingProvider).

func (*ViewModel) HasRenameProvider added in v1.0.0

func (vm *ViewModel) HasRenameProvider() bool

HasRenameProvider tells whether a rename provider matches the document (the key editorHasRenameProvider).

func (*ViewModel) HasSnippetCompletions

func (vm *ViewModel) HasSnippetCompletions() bool

HasSnippetCompletions tells whether the Tab key would insert a snippet (hasSnippetCompletions).

func (*ViewModel) HiddenSpan

func (vm *ViewModel) HiddenSpan(line int) (first, last int, ok bool)

HiddenSpan is the span of hidden lines that has a line; ok is false for a line that is shown.

func (*ViewModel) HideHover added in v1.0.0

func (vm *ViewModel) HideHover()

HideHover hides the hover, stops its computation and cancels the waits.

func (*ViewModel) HintClick added in v1.0.0

func (vm *ViewModel) HintClick(entryID, part int, m MouseModifiers) bool

HintClick handles a click on a part of an inlay hint with the modifier of the links held (Ctrl): the location of the part is shown, or its command run. It reports whether it did something, so that the click does not move the cursors; a hint the server left unresolved is resolved first.

func (*ViewModel) Hover added in v1.0.0

func (vm *ViewModel) Hover() *Hover

Hover is the hover that shows now, or nil.

func (*ViewModel) HoverAnnotationMoved added in v1.0.0

func (vm *ViewModel) HoverAnnotationMoved(hit annotationHit)

HoverAnnotationMoved tells the hover that the pointer rests on an annotation: after editor.hover.delay the markdown of its hover shows. An annotation with no hover shows nothing. A hover that shows for the annotation keeps showing.

func (*ViewModel) HoverBoxEntered added in v1.0.0

func (vm *ViewModel) HoverBoxEntered(in bool)

HoverBoxEntered tells the hover that the pointer entered or left its box. With editor.hover.sticky a pointer in the box keeps the hover; one that left it starts the wait to hide.

func (*ViewModel) HoverFocused added in v1.0.0

func (vm *ViewModel) HoverFocused() bool

HoverFocused tells whether the keys scroll the hover (the key editorHoverFocused).

func (*ViewModel) HoverHintMoved added in v1.0.0

func (vm *ViewModel) HoverHintMoved(entryID, part int)

HoverHintMoved tells the hover that the pointer rests on a part of the inlay hint with an id: after editor.hover.delay the tooltip of the part shows. A hover that shows for the part keeps showing.

func (*ViewModel) HoverPointerLeft added in v1.0.0

func (vm *ViewModel) HoverPointerLeft()

HoverPointerLeft tells the hover that the pointer left the text: a hover that shows hides after editor.hover.hidingDelay, unless the pointer went into it, and one that was still to come does not come.

func (*ViewModel) HoverPointerMoved added in v1.0.0

func (vm *ViewModel) HoverPointerMoved(p buffer.Position)

HoverPointerMoved tells the hover that the pointer rests on the text at a position. A hover that shows for the place keeps showing. Otherwise, with a sticky hover on screen the pointer is given editor.hover.hidingDelay to get into the box before the hover reacts (VS Code's grace period); then the hover of the place before starts to go (it hides) and the one of the place starts to be computed, to show after editor.hover.delay.

func (*ViewModel) HoverVisible added in v1.0.0

func (vm *ViewModel) HoverVisible() bool

HoverVisible tells whether a hover shows (the key editorHoverVisible).

func (*ViewModel) Indenter

func (vm *ViewModel) Indenter() *indent.Indenter

Indenter is what applies the indentation rules of the languages, or nil.

func (*ViewModel) InlayColorsSet added in v1.0.0

func (vm *ViewModel) InlayColorsSet(c InlayColors)

InlayColorsSet gives the editor the colors of the hints (the widget sets them).

func (*ViewModel) InlayHintCount added in v1.0.0

func (vm *ViewModel) InlayHintCount() int

InlayHintCount is how many inlay hints the editor holds, shown or not.

func (*ViewModel) InlayHintsShown added in v1.0.0

func (vm *ViewModel) InlayHintsShown() bool

InlayHintsShown tells whether the inlay hints are drawn now: the mode of editor.inlayHints.enabled, and for the modes that depend on the keys, whether Ctrl+Alt are held.

func (*ViewModel) InlayModifiersChanged added in v1.0.0

func (vm *ViewModel) InlayModifiersChanged(m MouseModifiers)

InlayModifiersChanged tells the editor which modifier keys are held. The modes onUnlessPressed and offUnlessPressed follow Ctrl+Alt (without Shift and Meta).

Ported from VS Code: inlayHintsController.ts (ModifierKeyEmitter: e.altKey && e.ctrlKey && !(e.shiftKey || e.metaKey))

func (*ViewModel) InlineValues added in v1.0.0

func (vm *ViewModel) InlineValues() map[int]string

InlineValues are the debug inline values of the editor as they are now, by line (counted from 0); the lines moved with the edits.

func (*ViewModel) InputMode

func (vm *ViewModel) InputMode() *InputMode

InputMode is the input mode of the editor: the one it shares with the other editors when the widget was given one.

func (*ViewModel) InsertSnippet

func (vm *ViewModel) InsertSnippet(template string, opts snippet.InsertOptions) error

InsertSnippet inserts a snippet text at the cursors and starts the session of its tab stops. ClipboardText is for CLIPBOARD; the caller reads the clipboard first when the snippet needs it. The cursors and the view are updated as after a command.

func (*ViewModel) IsEmbedded added in v1.0.0

func (vm *ViewModel) IsEmbedded() bool

IsEmbedded tells whether the view model is the editor of a peek view.

func (*ViewModel) Layout

func (vm *ViewModel) Layout() edit.LineLayout

Layout is the edit.LineLayout of the editor: how cursor movement sees the rows. Every line is one row, and the lines a fold hides have none.

func (*ViewModel) LightBulb added in v1.0.0

func (vm *ViewModel) LightBulb() *LightBulb

LightBulb is the light bulb that shows now, or nil.

func (*ViewModel) LightBulbClick added in v1.0.0

func (vm *ViewModel) LightBulbClick()

LightBulbClick opens the list of the actions of the light bulb.

func (*ViewModel) LineAnnotationCount added in v1.0.0

func (vm *ViewModel) LineAnnotationCount() int

LineAnnotationCount is the number of line annotations the editor holds.

func (*ViewModel) LineAnnotations added in v1.0.0

func (vm *ViewModel) LineAnnotations() []LineAnnotation

LineAnnotations are the annotations of the editor on the lines they are on now, in the order of the lines.

func (*ViewModel) LineBlocks

func (vm *ViewModel) LineBlocks() []LineBlock

LineBlocks are the line blocks of the editor.

func (vm *ViewModel) Link() *Link

Link is the link that shows, or nil.

func (*ViewModel) LinkClear added in v1.0.0

func (vm *ViewModel) LinkClear()

LinkClear takes the link away and cancels the request for it.

func (*ViewModel) LinkClick added in v1.0.0

func (vm *ViewModel) LinkClick(pos buffer.Position, m MouseModifiers) bool

LinkClick handles a press of the primary button with the modifier of the link held: it puts the cursor at the position and goes to the definition of the word there (the peek view with editor.definitionLinkOpensInPeek; beside with the second key). It says whether it handled the press: it does not when the language has no definition provider or the press is not on a word, and the press is an ordinary one then.

Ported from VS Code: goToDefinitionAtPosition.ts (GotoDefinitionAtPositionEditorContribution.gotoDefinition)

func (*ViewModel) LinkModifierChanged added in v1.0.0

func (vm *ViewModel) LinkModifierChanged(held bool)

LinkModifierChanged tells the editor that the key of the link went down or up while the pointer rested.

func (*ViewModel) LinkPointerLeft added in v1.0.0

func (vm *ViewModel) LinkPointerLeft()

LinkPointerLeft tells the editor that the pointer left the text.

func (*ViewModel) LinkPointerMoved added in v1.0.0

func (vm *ViewModel) LinkPointerMoved(pos buffer.Position, m MouseModifiers)

LinkPointerMoved tells the editor that the pointer rests on the text at a position, with the modifiers held. With the modifier of the link held over a word, the providers are asked for its definition and the word is underlined when they find one; without it the link goes. The request is cancelled when the pointer goes to another word.

func (*ViewModel) MaxScrollLeft

func (vm *ViewModel) MaxScrollLeft() float64

MaxScrollLeft is how far the content scrolls horizontally.

func (*ViewModel) MinimapHover

func (vm *ViewModel) MinimapHover(over bool)

MinimapHover tells the view model that the pointer entered or left the minimap.

func (*ViewModel) MinimapPointerDown

func (vm *ViewModel) MinimapPointerDown(y float64) bool

MinimapPointerDown handles a press of the primary button at a height of the minimap, in pixels of the window: on the slider it starts to drag it; elsewhere, in a proportional minimap it scrolls so that the line pressed is in the middle of the editor, and in the others it drags the slider from its middle. It says whether the press was taken.

Ported from VS Code: minimap.ts (InnerMinimap, the pointer down handlers)

func (*ViewModel) MinimapPointerMove

func (vm *ViewModel) MinimapPointerMove(y float64)

MinimapPointerMove follows the pointer while the slider is dragged: the editor scrolls as far as the slider moved.

func (*ViewModel) MinimapPointerUp

func (vm *ViewModel) MinimapPointerUp()

MinimapPointerUp ends a drag of the slider.

func (*ViewModel) OpenBreakpointWidget added in v1.0.0

func (vm *ViewModel) OpenBreakpointWidget(spec BreakpointWidgetSpec) error

OpenBreakpointWidget shows the breakpoint widget in a zone under the line of the breakpoint, with the keyboard in its input; one that is open goes first.

func (*ViewModel) OpenPeek added in v1.0.0

func (vm *ViewModel) OpenPeek(kind GoKind, targets []NavTarget)

OpenPeek opens the peek view over the locations of a navigation (sorted, as sortTargets leaves them) at the line of the cursor, with the location nearest to the cursor selected. A peek that is open closes first.

func (*ViewModel) OpenTarget added in v1.0.0

func (vm *ViewModel) OpenTarget(t NavTarget, o OpenLocation)

OpenTarget shows a location: the window opens its file (a preview editor, or the group beside) and puts the cursor at the start of the range, which is a jump of the navigation history. Without a window the location of this document is gone to here.

func (*ViewModel) Options

func (vm *ViewModel) Options() Options

Options are the settings of the editor.

func (*ViewModel) Paragraphs

func (vm *ViewModel) Paragraphs() *ParagraphCache

Paragraphs is the cache of paragraphs, shared by the layers of the editor.

func (*ViewModel) PastePrimary

func (vm *ViewModel) PastePrimary() error

PastePrimary pastes the primary selection of the desktop at the cursors (what the middle button does), when it has arrived.

func (*ViewModel) PasteText

func (vm *ViewModel) PasteText(text string) error

PasteText puts a text at the cursors as a paste does, as one change that undo takes back at once. What the editor knows of the text, when it was the last thing it copied, makes a copied line go above the cursor's line, the pieces of several cursors go to as many cursors, and a column go down the lines; with several cursors a text of as many lines goes line by line (editor.multiCursorPaste).

Ported from VS Code: src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts (the paste handler) and src/vs/editor/common/cursor/cursorTypeEditOperations.ts (PasteOperation)

func (*ViewModel) Peek added in v1.0.0

func (vm *ViewModel) Peek() *PeekView

Peek is what the peek view shows, or nil when it is closed. It is the model's own: do not change it.

func (*ViewModel) PeekClearMatches added in v1.0.0

func (vm *ViewModel) PeekClearMatches()

PeekClearMatches takes the marks of the references away.

func (*ViewModel) PeekClose added in v1.0.0

func (vm *ViewModel) PeekClose()

PeekClose closes the peek view and lets go of its editors.

func (*ViewModel) PeekMove added in v1.0.0

func (vm *ViewModel) PeekMove(delta int)

PeekMove selects the next (1) or the previous (-1) location, going round at the ends.

func (*ViewModel) PeekOpenSelected added in v1.0.0

func (vm *ViewModel) PeekOpenSelected(side, pinned bool)

PeekOpenSelected closes the peek view and shows the selected location in an editor of the window (a preview editor unless pinned; in the group beside with side). VS Code keeps the peek view open at the new place; here it closes (a decision of SPEC §9.12 "As built (step 12.7)").

func (*ViewModel) PeekSelect added in v1.0.0

func (vm *ViewModel) PeekSelect(i int)

PeekSelect selects a location of the peek view and shows it in the editor.

func (*ViewModel) PeekVisible added in v1.0.0

func (vm *ViewModel) PeekVisible() bool

PeekVisible tells whether the peek view is open (the key referenceSearchVisible).

func (*ViewModel) PlaceCursor added in v1.0.0

func (vm *ViewModel) PlaceCursor(p buffer.Position)

PlaceCursor puts the only cursor at a position without scrolling, for a peek that scrolls itself.

func (*ViewModel) Preedit

func (vm *ViewModel) Preedit() (Preedit, bool)

Preedit is the text being composed, and whether there is any.

func (*ViewModel) PreviewApply added in v1.0.0

func (vm *ViewModel) PreviewApply()

PreviewApply makes the checked changes and closes the preview. The edit fails as a whole when a document changed since the preview was made (the version each change names), and the user is told.

func (*ViewModel) PreviewDiscard added in v1.0.0

func (vm *ViewModel) PreviewDiscard()

PreviewDiscard closes the preview and makes nothing.

func (*ViewModel) PreviewEdit added in v1.0.0

func (vm *ViewModel) PreviewEdit(label string, we *langfeatures.WorkspaceEdit, done func(error))

PreviewEdit shows the changes of an edit before they are made. The edit is expanded off the UI thread, with the text of the documents it touches; done, when set, is called with nil once the checked changes were made, and with the error when they could not be, or with context.Canceled when the user discarded the preview.

func (*ViewModel) PreviewFocus added in v1.0.0

func (vm *ViewModel) PreviewFocus(i int)

PreviewFocus focuses a row, as a click does.

func (*ViewModel) PreviewMove added in v1.0.0

func (vm *ViewModel) PreviewMove(dir int)

PreviewMove moves the focus to the next (1) or previous (-1) row.

func (*ViewModel) PreviewToggle added in v1.0.0

func (vm *ViewModel) PreviewToggle(i int)

PreviewToggle checks or unchecks a row: a change, or all the changes of a file, which are checked unless all are.

func (*ViewModel) PreviewToggleFocused added in v1.0.0

func (vm *ViewModel) PreviewToggleFocused()

PreviewToggleFocused toggles the focused row.

func (*ViewModel) Projection

func (vm *ViewModel) Projection() Projection

Projection is the projection of lines to rows, brought up to date with the document.

func (*ViewModel) QuickDiffCount added in v1.0.0

func (vm *ViewModel) QuickDiffCount() int

QuickDiffCount is the number of marks the editor holds (the context key quickDiffDecorationCount).

func (*ViewModel) QuickDiffGoTo added in v1.0.0

func (vm *ViewModel) QuickDiffGoTo(next bool) bool

QuickDiffGoTo puts the cursor on the first line of the next (or previous) change after (before) the cursor's line, wrapping round at the ends, and scrolls it into the middle of the editor. It does nothing and returns false when the editor has no marks.

func (*ViewModel) QuickDiffMarks added in v1.0.0

func (vm *ViewModel) QuickDiffMarks() []QuickDiffMark

QuickDiffMarks are the marks on the lines they are on now, in the order of the lines.

func (*ViewModel) QuickDiffPeekChanged added in v1.0.0

func (vm *ViewModel) QuickDiffPeekChanged()

QuickDiffPeekChanged tells the editor that the peek opened or closed, so that the context keys follow.

func (*ViewModel) QuickDiffPeekVisible added in v1.0.0

func (vm *ViewModel) QuickDiffPeekVisible() bool

QuickDiffPeekVisible tells whether the peek of a change is open (the context key dirtyDiffVisible).

func (*ViewModel) RangeHighlight

func (vm *ViewModel) RangeHighlight() (line int, ok bool)

RangeHighlight is the line SetRangeHighlight shaded, and whether there is one.

func (*ViewModel) ReadOnly

func (vm *ViewModel) ReadOnly() bool

ReadOnly tells whether the editor refuses edits: its option ReadOnly is set (the original side of the diff editor), or its document is read-only. Commands that only read still work.

func (*ViewModel) RefactorPreview added in v1.0.0

func (vm *ViewModel) RefactorPreview() *RefactorPreview

RefactorPreview is the preview that shows now, or nil.

func (*ViewModel) RefreshFolding added in v1.0.0

func (vm *ViewModel) RefreshFolding()

RefreshFolding computes the folding regions again at once: a language server that has folding ranges started or stopped.

func (*ViewModel) RemoveBlinkListener

func (vm *ViewModel) RemoveBlinkListener(h foundation.ListenerHandle)

RemoveBlinkListener removes a listener of AddBlinkListener.

func (*ViewModel) RemoveCodeActionListener added in v1.0.0

func (vm *ViewModel) RemoveCodeActionListener(h foundation.ListenerHandle)

RemoveCodeActionListener removes a listener of AddCodeActionListener.

func (*ViewModel) RemoveDebugHoverListener added in v1.0.0

func (vm *ViewModel) RemoveDebugHoverListener(h foundation.ListenerHandle)

RemoveDebugHoverListener removes a listener of AddDebugHoverListener.

func (*ViewModel) RemoveFindListener

func (vm *ViewModel) RemoveFindListener(h foundation.ListenerHandle)

RemoveFindListener removes a listener of AddFindListener.

func (*ViewModel) RemoveHoverListener added in v1.0.0

func (vm *ViewModel) RemoveHoverListener(h foundation.ListenerHandle)

RemoveHoverListener removes a listener of AddHoverListener.

func (*ViewModel) RemoveMetricsListener

func (vm *ViewModel) RemoveMetricsListener(h foundation.ListenerHandle)

RemoveMetricsListener removes a listener of AddMetricsListener.

func (*ViewModel) RemovePeekListener added in v1.0.0

func (vm *ViewModel) RemovePeekListener(h foundation.ListenerHandle)

RemovePeekListener removes a listener of AddPeekListener.

func (*ViewModel) RemovePreviewListener added in v1.0.0

func (vm *ViewModel) RemovePreviewListener(h foundation.ListenerHandle)

RemovePreviewListener removes a listener of AddPreviewListener.

func (*ViewModel) RemoveRenameListener added in v1.0.0

func (vm *ViewModel) RemoveRenameListener(h foundation.ListenerHandle)

RemoveRenameListener removes a listener of AddRenameListener.

func (*ViewModel) RemoveScrollListener

func (vm *ViewModel) RemoveScrollListener(h foundation.ListenerHandle)

RemoveScrollListener removes a listener of AddScrollListener.

func (*ViewModel) RemoveSelectionListener

func (vm *ViewModel) RemoveSelectionListener(h foundation.ListenerHandle)

RemoveSelectionListener removes a listener of AddSelectionListener.

func (*ViewModel) RemoveSignatureListener added in v1.0.0

func (vm *ViewModel) RemoveSignatureListener(h foundation.ListenerHandle)

RemoveSignatureListener removes a listener of AddSignatureListener.

func (*ViewModel) RemoveSuggestListener added in v1.0.0

func (vm *ViewModel) RemoveSuggestListener(h foundation.ListenerHandle)

RemoveSuggestListener removes a listener of AddSuggestListener.

func (*ViewModel) RemoveSymbolsListener added in v1.0.0

func (vm *ViewModel) RemoveSymbolsListener(h foundation.ListenerHandle)

RemoveSymbolsListener removes a listener of AddSymbolsListener.

func (*ViewModel) RemoveZone

func (vm *ViewModel) RemoveZone(id ZoneID) error

RemoveZone removes a zone.

func (*ViewModel) RenameAccept added in v1.0.0

func (vm *ViewModel) RenameAccept(preview bool)

RenameAccept takes the name in the box: the providers are asked for the edit, which is made at once, or shown first when preview is set. A name that is empty or the old one closes the box and renames nothing.

Ported from VS Code: renameWidget.ts (acceptInput), rename.ts (RenameController.run)

func (*ViewModel) RenameBox added in v1.0.0

func (vm *ViewModel) RenameBox() *RenameBox

RenameBox is the box that shows now, or nil.

func (*ViewModel) RenameCancel added in v1.0.0

func (vm *ViewModel) RenameCancel()

RenameCancel closes the box, or ends the request for the symbol, and gives the focus back to the editor.

func (*ViewModel) RenameSetInput added in v1.0.0

func (vm *ViewModel) RenameSetInput(text string)

RenameSetInput tells the box what the user typed.

func (*ViewModel) RenameStart added in v1.0.0

func (vm *ViewModel) RenameStart() bool

RenameStart starts a rename at the cursor (editor.action.rename): the providers are asked, off the UI thread, for the symbol there. It says whether a request was made.

Ported from VS Code: rename.ts (RenameController.run)

func (*ViewModel) RenameVisible added in v1.0.0

func (vm *ViewModel) RenameVisible() bool

RenameVisible tells whether the box shows (the key renameInputVisible).

func (*ViewModel) RestoreView

func (vm *ViewModel) RestoreView(s ViewState) error

RestoreView is RestoreViewState for the editor that is on screen: it also scrolls the editor to the saved position now (RestoreViewState leaves that to the next layout). Go to line puts the editor back with it when the user gives up.

func (*ViewModel) RestoreViewState

func (vm *ViewModel) RestoreViewState(s ViewState) error

RestoreViewState puts the editor back as the state says: the folds are applied (when the ranges of the document are not known yet, as soon as they are), the selections are moved into the text, and the scroll position is used the next time the editor is laid out. A fold that cannot be restored is dropped; the error says why.

func (*ViewModel) RevealEnd

func (vm *ViewModel) RevealEnd()

RevealEnd scrolls the editor, if it has to, so that the end of the text is in view. The scroll goes as far as the last layout allowed, so after text was added it is done once the editor has been laid out again.

func (*ViewModel) RevealLineInCenterIfOutsideViewport

func (vm *ViewModel) RevealLineInCenterIfOutsideViewport(line int)

RevealLineInCenterIfOutsideViewport scrolls so that a line is in the middle of the editor, unless it is on the screen already.

func (*ViewModel) RevealPosition

func (vm *ViewModel) RevealPosition(p buffer.Position)

RevealPosition scrolls the editor, if it has to, so that the row of a position is in view, and clear of the sticky lines.

func (*ViewModel) RevealPositionInCenter

func (vm *ViewModel) RevealPositionInCenter(p buffer.Position)

RevealPositionInCenter scrolls so that the row of a position is in the middle of the editor.

func (*ViewModel) RevealPositionInCenterIfOutsideViewport added in v1.0.0

func (vm *ViewModel) RevealPositionInCenterIfOutsideViewport(p buffer.Position)

RevealPositionInCenterIfOutsideViewport scrolls a position into the middle of the editor only when it is not on screen; a position in view stays where it is (a jump of the same file: VS Code's revealRangeInCenterIfOutsideViewport).

func (*ViewModel) RevealPrimary

func (vm *ViewModel) RevealPrimary()

RevealPrimary scrolls the editor, if it has to, so that the row of the primary cursor is in view: the row goes to the nearest edge it left through.

func (*ViewModel) RevealRangeInCenterIfOutsideViewport

func (vm *ViewModel) RevealRangeInCenterIfOutsideViewport(r buffer.Range)

RevealRangeInCenterIfOutsideViewport scrolls the editor, if the first row of a range is not in view, so that the row is in the middle.

Ported from VS Code: src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts (revealRangeInCenterIfOutsideViewport)

func (*ViewModel) RevealStickyPosition

func (vm *ViewModel) RevealStickyPosition(p buffer.Position)

RevealStickyPosition moves the cursor to a position that a click on a sticky line chose and scrolls so that its row is in view and not under the sticky lines.

Ported from VS Code: stickyScrollController.ts (_revealPosition)

func (*ViewModel) RevealSymbol added in v1.0.0

func (vm *ViewModel) RevealSymbol(sym *langfeatures.DocumentSymbol)

RevealSymbol puts the cursor at the name of a symbol and scrolls it into view (the breadcrumbs and the Outline use it). The move is a jump of the navigation history when the host says how (the window sets it).

func (*ViewModel) RevealZone added in v1.0.0

func (vm *ViewModel) RevealZone(id ZoneID, pos buffer.Position)

RevealZone scrolls so that the line of a position and the whole zone below it are in view, if they fit; nothing moves when they are.

func (*ViewModel) RowOfPosition

func (vm *ViewModel) RowOfPosition(p buffer.Position) int

RowOfPosition is the row that shows a position of the document.

func (*ViewModel) Run

func (vm *ViewModel) Run(act action, args any) error

Run does an action: it forgets the sessions of the commands that go on with each other (the column selection, the occurrences, the expansion of the selection) when something else moved the cursors since, runs it, and shows the cursors again.

func (*ViewModel) RunCommand

func (vm *ViewModel) RunCommand(id string, args any) error

RunCommand runs a command of the editor on a view model, for callers that have no registry (the tests, the dev commands). It fails with the tag EditorCommandUnknown for an id that is not an editor command.

func (*ViewModel) ScrollHover added in v1.0.0

func (vm *ViewModel) ScrollHover(how HoverScroll)

ScrollHover scrolls the box of a focused hover.

func (*ViewModel) ScrollLeft

func (vm *ViewModel) ScrollLeft() float64

ScrollLeft is the horizontal scroll position in pixels.

func (*ViewModel) ScrollTo

func (vm *ViewModel) ScrollTo(top float64)

ScrollTo scrolls the editor vertically to a position in pixels, through the widget; an editor that is not on screen does not scroll.

func (*ViewModel) ScrollTop

func (vm *ViewModel) ScrollTop() float64

ScrollTop is the vertical scroll position in pixels.

func (*ViewModel) SelectionRangesCancel added in v1.0.0

func (vm *ViewModel) SelectionRangesCancel()

SelectionRangesCancel ends the request for the ranges of an expansion that is starting.

func (*ViewModel) SelectionsChanged

func (vm *ViewModel) SelectionsChanged()

SelectionsChanged tells the view model that the cursors moved or the selections changed: the layers of the selections, the current line and the cursors are drawn again, and the cursors are shown and start blinking anew.

func (*ViewModel) SemanticHighlightingOn added in v1.0.0

func (vm *ViewModel) SemanticHighlightingOn() bool

SemanticHighlightingOn tells whether semantic highlighting is on: the setting, else the theme.

func (*ViewModel) SemanticTokenCount added in v1.0.0

func (vm *ViewModel) SemanticTokenCount() int

SemanticTokenCount is how many semantic tokens the editor holds.

func (*ViewModel) SetAnimator

func (vm *ViewModel) SetAnimator(start func())

SetAnimator gives the view model the function that runs the animation of the cursors every frame; it is called whenever the animation begins again. The editor widget sets it.

func (*ViewModel) SetAutoClosing

func (vm *ViewModel) SetAutoClosing(l *autoclose.Language)

SetAutoClosing gives the view model the auto-closing pairs and the surrounding pairs of the language of its document (SPEC §8.6.4); with nil nothing is closed and nothing is surrounded.

func (*ViewModel) SetBackgroundMarks

func (vm *ViewModel) SetBackgroundMarks(marks []BackgroundMark)

SetBackgroundMarks replaces the background marks of the editor. The marks are decorations of the document that this editor owns, so another editor of the same document does not show them.

func (*ViewModel) SetBrackets

func (vm *ViewModel) SetBrackets(ix *brackets.Index)

SetBrackets gives the view model the bracket pairs of its document, which the commands of the brackets, the highlight of the matching bracket and the colors of the brackets use; nil takes them away. The view model does not own them. The index is kept up to date by whoever made it (brackets.Attach); the view model repaints with the document and the tokens.

func (*ViewModel) SetClipboard

func (vm *ViewModel) SetClipboard(c Clipboard, memory *ClipboardMemory, report func(error))

SetClipboard gives the view model the clipboard of its window, the memory of the copies shared by the editors of the window (nil for one of its own) and where the errors of the requests that finish later go (nil drops them). The editor widget calls it; a nil clipboard takes it away.

func (*ViewModel) SetComments

func (vm *ViewModel) SetComments(l comment.Languages)

SetComments gives the view model the comment tokens of the languages (SPEC §8.6.5); without them the comment commands do nothing.

func (*ViewModel) SetContextKeys added in v1.0.0

func (vm *ViewModel) SetContextKeys(owner string, fn func() map[string]any)

SetContextKeys gives the editor context keys of the thing that holds it, set in its scope each time the keys are worked out: the window gives resourceScheme, the diff editor isInDiffRightEditor and the like. fn is asked on the UI thread; owner names the one that set it, so that setting again replaces the keys and nil takes them away.

func (*ViewModel) SetCoverageAnnotations added in v1.0.0

func (vm *ViewModel) SetCoverageAnnotations(list []LineAnnotation)

SetCoverageAnnotations replaces the counts written after the lines: line annotations of a group of their own, drawn after the messages of the tests and before the other annotations.

func (*ViewModel) SetCoverageMarks added in v1.0.0

func (vm *ViewModel) SetCoverageMarks(marks []BackgroundMark)

SetCoverageMarks replaces the background marks of the coverage: whole-line marks with a gutter color, and marks of characters. They are drawn with the background marks of the editor.

func (*ViewModel) SetDebugBreakpoints added in v1.0.0

func (vm *ViewModel) SetDebugBreakpoints(list []DebugBreakpointMark)

SetDebugBreakpoints replaces the breakpoints the editor shows. A breakpoint of a line the document does not have is not kept. A breakpoint of a whole line sits at the first character of the line that is not a space (a decoration needs a width), an inline one at its column.

func (*ViewModel) SetDebugCandidates added in v1.0.0

func (vm *ViewModel) SetDebugCandidates(list []DebugCandidate)

SetDebugCandidates replaces the places the adapter says an inline breakpoint can be set at, for the lines that have a breakpoint.

func (*ViewModel) SetDebugColors added in v1.0.0

func (vm *ViewModel) SetDebugColors(c DebugColors)

SetDebugColors gives the editor the colors of the debug marks (the widget sets them every build).

func (*ViewModel) SetDebugFocus added in v1.0.0

func (vm *ViewModel) SetDebugFocus(f func())

SetDebugFocus gives the editor the function that returns the keyboard to it, which the breakpoint widget calls as it closes (the widget sets it).

func (*ViewModel) SetDebugFrames added in v1.0.0

func (vm *ViewModel) SetDebugFrames(list []DebugFrameMark)

SetDebugFrames replaces the stack frames the editor shows (the top frame and the focused one).

func (*ViewModel) SetDebugGutterPointer added in v1.0.0

func (vm *ViewModel) SetDebugGutterPointer(y float64, inGlyph bool)

SetDebugGutterPointer tells the editor where the pointer is in the gutter: y is the distance from the top of the gutter (the scroll is added here). A line with no breakpoint shows the faint hint of one; -1 as y (the pointer left) takes it away.

Ported from VS Code: breakpointEditorContribution.ts (ensureBreakpointHintDecoration, onMouseMove)

func (*ViewModel) SetDebugHost added in v1.0.0

func (vm *ViewModel) SetDebugHost(h *DebugHost)

SetDebugHost gives the editor the means to act on the debugger; nil takes them away.

func (*ViewModel) SetDebugInputFocus added in v1.0.0

func (vm *ViewModel) SetDebugInputFocus(f func(*widgets.FocusNode))

SetDebugInputFocus gives the editor the function that gives the keyboard to the input of a widget as soon as it is on screen (the widget sets it).

func (*ViewModel) SetDiagnostics added in v1.0.0

func (vm *ViewModel) SetDiagnostics(ds []Diagnostic)

SetDiagnostics replaces the diagnostics of the editor. The diagnostics are decorations of the document that this editor owns, so another editor of the same document does not show them, and they move with the edits.

func (*ViewModel) SetEmbedded added in v1.0.0

func (vm *ViewModel) SetEmbedded(on bool)

SetEmbedded marks the view model as the editor of a peek view: a navigation in it does not open another peek view. The window sets it when it makes the editor.

func (*ViewModel) SetFindMemory

func (vm *ViewModel) SetFindMemory(m *FindMemory)

SetFindMemory gives the view model the switches the editors of the window share; nil makes them its own.

func (*ViewModel) SetFindUI

func (vm *ViewModel) SetFindUI(ui FindUI)

SetFindUI gives the view model the means to move the focus into and out of the find widget.

func (*ViewModel) SetFocused

func (vm *ViewModel) SetFocused(focused bool)

SetFocused tells the view model that the editor got or lost the focus. Without the focus the cursors are hidden and no timer runs.

func (*ViewModel) SetFoldingMarkers

func (vm *ViewModel) SetFoldingMarkers(m *folding.Markers)

SetFoldingMarkers gives the commands that fold by kind the patterns of the lines that start and end a region in the language of the document (nil for none).

func (*ViewModel) SetFramer

func (vm *ViewModel) SetFramer(f framer)

SetFramer gives the view model the means to run a function after each frame, which the dev commands that type and scroll use to spread their work over frames.

func (*ViewModel) SetGlyphPointer added in v1.0.0

func (vm *ViewModel) SetGlyphPointer(x, y float64)

SetGlyphPointer tells the editor where the pointer is in the gutter (x from its left edge, y from its top; y -1 when it left): over a test glyph its hover shows, elsewhere the breakpoint hint and hover of the debugger.

func (*ViewModel) SetGuides

func (vm *ViewModel) SetGuides(levels *indent.Levels, offSide bool)

SetGuides gives the view model the indentation of the lines of its document, which the guides are drawn from, and whether the language is indented to nest (folding.offSide); nil takes the guides away. The view model does not own the levels: whoever made them (indent.AttachLevels) keeps them up to date.

func (*ViewModel) SetHoverScroller added in v1.0.0

func (vm *ViewModel) SetHoverScroller(fn func(HoverScroll))

SetHoverScroller gives the hover the means to scroll its box (the widget sets it).

func (*ViewModel) SetIndentationDefaults

func (vm *ViewModel) SetIndentationDefaults(defaults func() (tabSize int, insertSpaces bool))

SetIndentationDefaults gives the view model what a new document of its language starts with, editor.tabSize and editor.insertSpaces, which Detect Indentation falls back on when the text says nothing. Without it the defaults are those of document.NewOptions.

func (*ViewModel) SetIndenter

func (vm *ViewModel) SetIndenter(ix *indent.Indenter, languageCode int)

SetIndenter gives the view model the indentation rules of the languages (SPEC §8.6.2) and the code of the language of its document; with nil a new line keeps the indentation of the line it starts on and nothing is re-indented while typing.

func (*ViewModel) SetInlineValues added in v1.0.0

func (vm *ViewModel) SetInlineValues(list []LineAnnotation)

SetInlineValues replaces the debug inline values of the editor with the list: line annotations of a group of their own, drawn before the others on their line, so that Git blame and the values show together.

func (*ViewModel) SetInputMode

func (vm *ViewModel) SetInputMode(m *InputMode)

SetInputMode makes the editor follow an input mode, usually the one of the process; the editor is redrawn when the mode it shows changes. With nil the editor goes back to a mode of its own, in silence: the widget does this when it is disposed (or no longer shows the editor), so that a shared mode does not keep the editor alive and nothing is told while the widgets are being taken down.

func (*ViewModel) SetLineAnnotations added in v1.0.0

func (vm *ViewModel) SetLineAnnotations(list []LineAnnotation)

SetLineAnnotations replaces the line annotations of the editor with the list. A line the document does not have is not kept. The annotations are decorations that this editor owns, so another editor of the same document is given its own list.

func (*ViewModel) SetLineBlocks

func (vm *ViewModel) SetLineBlocks(blocks []LineBlock)

SetLineBlocks replaces the line blocks of the editor. The editor does not move them when the text changes.

func (*ViewModel) SetMinimap

func (vm *ViewModel) SetMinimap(info minimapLayoutInfo, in minimapInput)

SetMinimap tells the view model where the minimap is, as the editor widget worked it out from the size of the editor: nil input leaves it as it is. A minimap that is not shown (off, or a large file) has no layout.

func (*ViewModel) SetNamedColors added in v1.0.0

func (vm *ViewModel) SetNamedColors(lookup func(id string) (ui.Color, bool))

SetNamedColors gives the editor the means to find a theme color by its id, for the marks that name their colors; the widget sets it each time it is built.

func (*ViewModel) SetOpeners added in v1.0.0

func (vm *ViewModel) SetOpeners(openURI func(uri string), openAt func(resource string, line, column int))

SetOpeners gives the hover what its links open: openURI a web page (the code of a diagnostic), openAt a place in a file (a place related to a diagnostic) with a line and a column counted from 1.

func (*ViewModel) SetOptions

func (vm *ViewModel) SetOptions(opts Options)

SetOptions changes the settings. A change of the line height makes a new projection; the paragraph cache needs no clearing, since its keys hold everything that changes a paragraph.

func (*ViewModel) SetPoster

func (vm *ViewModel) SetPoster(post func(func()))

SetPoster gives the view model the means to run a function on the UI thread, which it needs to repaint when the background tokenizer is done with lines. Without it the repaint happens on the goroutine of the tokenizer, which only a test without a window wants.

func (*ViewModel) SetPreedit

func (vm *ViewModel) SetPreedit(p Preedit)

SetPreedit shows the text an input method composes; an empty text ends it. The layers that draw the cursors and the caret are told.

func (*ViewModel) SetPreviewUI added in v1.0.0

func (vm *ViewModel) SetPreviewUI(ui PreviewUI)

SetPreviewUI gives the view model the widget's means to move the focus.

func (*ViewModel) SetQuickDiffMarks added in v1.0.0

func (vm *ViewModel) SetQuickDiffMarks(marks []QuickDiffMark)

SetQuickDiffMarks replaces the quick diff marks of the editor. A mark whose lines the document does not have is not kept.

func (*ViewModel) SetQuickDiffPeeker added in v1.0.0

func (vm *ViewModel) SetQuickDiffPeeker(p QuickDiffPeeker)

SetQuickDiffPeeker gives the editor the peek of its changes; nil takes it away.

func (*ViewModel) SetQuickPick

func (vm *ViewModel) SetQuickPick(show func(quickinput.PickOptions))

SetQuickPick gives the editor the quick input that Insert Snippet picks a snippet in. Without it Insert Snippet does nothing when it has no snippet text or name to insert.

func (*ViewModel) SetRangeHighlight

func (vm *ViewModel) SetRangeHighlight(line int)

SetRangeHighlight shades the whole line of a position (zero-based line), as go to line does while the user types a line number.

func (*ViewModel) SetRenameUI added in v1.0.0

func (vm *ViewModel) SetRenameUI(ui RenameUI)

SetRenameUI gives the view model the widget's means to move the focus.

func (*ViewModel) SetScrollLeft

func (vm *ViewModel) SetScrollLeft(left float64)

SetScrollLeft sets the horizontal scroll position, within the content once the text layer has measured it, and repaints.

func (*ViewModel) SetScrollTop

func (vm *ViewModel) SetScrollTop(top float64)

SetScrollTop sets the vertical scroll position; the render object follows it through the scrollable's offset, and the view model records what it was told. The scroll listeners are told when the position changed.

func (*ViewModel) SetScroller

func (vm *ViewModel) SetScroller(scroll func(top float64))

SetScroller gives the view model the function that scrolls the editor vertically; without it commands do not scroll.

func (*ViewModel) SetSemanticTheme added in v1.0.0

func (vm *ViewModel) SetSemanticTheme(t *theme.TokenTheme)

SetSemanticTheme gives the editor the token theme (the text layer sets it): its semantic part says whether the theme asks for semantic highlighting and how the classes are styled.

func (*ViewModel) SetSnippetWorkspace

func (vm *ViewModel) SetSnippetWorkspace(w snippet.WorkspaceResolver)

SetSnippetWorkspace tells the editor which folder is open, for WORKSPACE_NAME, WORKSPACE_FOLDER and RELATIVE_FILEPATH.

func (*ViewModel) SetSnippets

func (vm *ViewModel) SetSnippets(svc *snippet.Service)

SetSnippets gives the editor the snippet files it offers for Insert Snippet and for the Tab key.

func (*ViewModel) SetSuggest added in v1.0.0

func (vm *ViewModel) SetSuggest(h *SuggestHost)

SetSuggest gives the editor the means to complete (SPEC §9.12): without a host the editor has no suggest widget.

func (*ViewModel) SetSuggestRows added in v1.0.0

func (vm *ViewModel) SetSuggestRows(n int)

SetSuggestRows tells the view model how many rows the widget shows at once, which the page keys and the scrolling use.

func (*ViewModel) SetTestGlyphs added in v1.0.0

func (vm *ViewModel) SetTestGlyphs(list []TestGlyphMark)

SetTestGlyphs replaces the glyphs of the tests the editor shows. A glyph of a line the document does not have is not kept. A glyph sits at the first character of its line that is not a space (a decoration needs a width).

func (*ViewModel) SetTestHost added in v1.0.0

func (vm *ViewModel) SetTestHost(h *TestHost)

SetTestHost gives the editor the means to act on the tests; nil takes them away.

func (*ViewModel) SetTestMessages added in v1.0.0

func (vm *ViewModel) SetTestMessages(list []TestMessageMark)

SetTestMessages replaces the messages of the tests written after their lines: line annotations of a group of their own, drawn after the inline values of the debugger and before the other annotations.

func (*ViewModel) SetTextEngine

func (vm *ViewModel) SetTextEngine(factory ui.ParagraphFactory, monospace bool)

SetTextEngine gives the view model the text engine that breaks the lines whose characters do not all have the width of a column (SPEC §9.2), and says whether the font is monospace. The editor widget does it after every layout.

func (*ViewModel) SetTextMetrics

func (vm *ViewModel) SetTextMetrics(viewportW, viewportH, scrollExtent, widestRow, charWidth float64)

SetTextMetrics records what the layout of the text layer measured: the size of the text area, how far the content scrolls vertically, the width of the widest row it laid out and the width of a character. The widest row only grows until the document or the font changes. The listeners of the metrics (the scrollbars) are told when something changed.

func (*ViewModel) SetTimer

func (vm *ViewModel) SetTimer(after TimerFunc)

SetTimer gives the view model the source of timers for the blinking (the editor widget passes the timers of the window's binding); nil stops the blinking.

func (*ViewModel) SetTokenizer

func (vm *ViewModel) SetTokenizer(t *tokens.Tokenizer)

SetTokenizer gives the view model the tokenizer of its document, whose tokens the text layer draws in the colors of the theme; nil takes it away. The view model does not own it: whoever made it closes it. The tokenizer tells from any goroutine that lines were tokenized, and the view model repaints when those are on the screen.

func (*ViewModel) SetViewProblem added in v1.0.0

func (vm *ViewModel) SetViewProblem(fn func(p buffer.Position))

SetViewProblem gives the hover the function that "View Problem" runs, with the start of the diagnostic: the window shows the problem in the editor (what the marker navigation does for the marker at the position).

func (*ViewModel) SetViewportHeight

func (vm *ViewModel) SetViewportHeight(h float64)

SetViewportHeight records the height of the viewport, which sets the size of a page.

func (*ViewModel) SetWordWrapOverride

func (vm *ViewModel) SetWordWrapOverride(mode string)

SetWordWrapOverride makes the editor wrap with a mode of editor.wordWrap whatever the setting says; "" goes back to the setting.

func (*ViewModel) SetZoneAfterLine

func (vm *ViewModel) SetZoneAfterLine(id ZoneID, afterLine int) error

SetZoneAfterLine moves a zone to come after another line.

func (*ViewModel) SetZonePressHandler

func (vm *ViewModel) SetZonePressHandler(fn func(ZoneHit))

SetZonePressHandler sets the function that is told when the primary button is pressed on a row of a zone: such a press does not move the cursor (VS Code's CONTENT_VIEW_ZONE target).

func (*ViewModel) SetZoneRows

func (vm *ViewModel) SetZoneRows(id ZoneID, rows int) error

SetZoneRows changes the height of a zone.

func (*ViewModel) SetZoom

func (vm *ViewModel) SetZoom(z *Zoom)

SetZoom makes the editor follow a zoom, usually the one of its window.

func (*ViewModel) ShowHoverAt added in v1.0.0

func (vm *ViewModel) ShowHoverAt(p buffer.Position) bool

ShowHoverAt shows the hover at a position as the command Show Hover and the marker navigation do: at once, and until the cursor moves or the text changes. It says whether there is something that can show: a diagnostic at the position, or a hover provider to ask (its answer comes later).

func (*ViewModel) ShowMessage added in v1.0.0

func (vm *ViewModel) ShowMessage(text string)

ShowMessage shows a message next to the cursor until it moves (VS Code's MessageController): "No definition found for 'x'". It is the hover of a command, with the text as its only part.

func (*ViewModel) SignatureCancel added in v1.0.0

func (vm *ViewModel) SignatureCancel()

SignatureCancel closes the hints (the command Close Parameter Hints, Escape) and stops what waits to open them.

func (*ViewModel) SignatureHints added in v1.0.0

func (vm *ViewModel) SignatureHints() *langfeatures.SignatureHelp

SignatureHints are the hints that show now, or nil. The active signature is within the signatures.

func (*ViewModel) SignatureKeys added in v1.0.0

func (vm *ViewModel) SignatureKeys() SignatureKeys

SignatureKeys are the context keys of the parameter hints now.

func (*ViewModel) SignatureNext added in v1.0.0

func (vm *ViewModel) SignatureNext()

SignatureNext shows the next signature (Down); on the last it goes to the first with editor.parameterHints.cycle, else the hints close.

Ported from VS Code: parameterHintsModel.ts (next)

func (*ViewModel) SignaturePrevious added in v1.0.0

func (vm *ViewModel) SignaturePrevious()

SignaturePrevious shows the previous signature (Up).

Ported from VS Code: parameterHintsModel.ts (previous)

func (*ViewModel) SignatureTrigger added in v1.0.0

func (vm *ViewModel) SignatureTrigger()

SignatureTrigger asks for the parameter hints at the cursor now (the command Trigger Parameter Hints, Ctrl+Shift+Space).

func (*ViewModel) SnippetPicker

func (vm *ViewModel) SnippetPicker() *SnippetPicker

SnippetPicker is the list the widget has to show at the caret, or nil.

func (*ViewModel) SnippetState

func (vm *ViewModel) SnippetState() snippet.State

SnippetState is the snippet mode of the editor, which the context keys inSnippetMode, hasNextTabstop, hasPrevTabstop and inSnippetChoice show.

func (*ViewModel) StartFolding

func (vm *ViewModel) StartFolding(provider folding.Provider, delay time.Duration) (stop func())

StartFolding makes the folding model of the document: its regions are the ones the provider finds in the background after every pause of the editing (a nil provider finds none, which is for a test that gives the regions with UpdateFolding). The returned function stops the folding and unfolds everything; it must be called on the UI thread.

func (*ViewModel) StickyHover

func (vm *ViewModel) StickyHover(line int)

StickyHover tells the view model that the pointer is over the sticky lines (at a line from 0, or -1 when it left them).

func (*ViewModel) SuggestAccept added in v1.0.0

func (vm *ViewModel) SuggestAccept(i int)

SuggestAccept accepts the row i (a click on it).

func (*ViewModel) SuggestHasProvider added in v1.0.0

func (vm *ViewModel) SuggestHasProvider() bool

SuggestHasProvider tells whether a completion provider matches the document (the key editorHasCompletionItemProvider).

func (*ViewModel) SuggestKeys added in v1.0.0

func (vm *ViewModel) SuggestKeys() SuggestKeys

SuggestKeys are the context keys of the suggest widget now.

func (*ViewModel) SuggestScroll added in v1.0.0

func (vm *ViewModel) SuggestScroll(rows int)

SuggestScroll scrolls the list by rows without moving the focus.

func (*ViewModel) SuggestToggleDetails added in v1.0.0

func (vm *ViewModel) SuggestToggleDetails()

SuggestToggleDetails opens or closes the details pane (the "read more" icon of the focused row).

func (*ViewModel) SuggestView added in v1.0.0

func (vm *ViewModel) SuggestView() *SuggestView

SuggestView is what the suggest widget shows now, or nil when it is hidden.

func (*ViewModel) SuggestVisible added in v1.0.0

func (vm *ViewModel) SuggestVisible() bool

SuggestVisible tells whether the widget shows (the key suggestWidgetVisible).

func (*ViewModel) SupportedCodeActions added in v1.0.0

func (vm *ViewModel) SupportedCodeActions() string

SupportedCodeActions is the key supportedCodeAction: the kinds the providers answer, joined by spaces.

func (*ViewModel) SymbolPath added in v1.0.0

func (vm *ViewModel) SymbolPath(keep func(langfeatures.DocumentSymbol) bool) []*langfeatures.DocumentSymbol

SymbolPath is the chain of symbols that enclose the cursor, the outermost first, without the kinds keep refuses.

func (*ViewModel) Symbols added in v1.0.0

func (vm *ViewModel) Symbols() ([]langfeatures.DocumentSymbol, bool)

Symbols are the symbols of the document as the providers last answered, and whether a provider answered at all (an editor whose language has no symbol provider has none). They are for SymbolsVersion of the document, which may be older than the document by the edits made since.

func (*ViewModel) SymbolsVersion added in v1.0.0

func (vm *ViewModel) SymbolsVersion() int

SymbolsVersion is the version of the document the symbols were made for.

func (*ViewModel) Sync

func (vm *ViewModel) Sync() bool

Sync makes the projection match the document; it reports whether it changed.

func (*ViewModel) TakeDebugMenuTarget added in v1.0.0

func (vm *ViewModel) TakeDebugMenuTarget() DebugMenuTarget

TakeDebugMenuTarget gives the place of the last secondary press and forgets it: the window asks when it opens the context menu, and shows the menu of the breakpoints when the press was in the glyph margin or on an inline mark.

func (*ViewModel) TakeTestMenuTarget added in v1.0.0

func (vm *ViewModel) TakeTestMenuTarget() TestMenuTarget

TakeTestMenuTarget gives the place of the last secondary press and forgets it: the window asks when it opens the context menu, and shows the menu of the test when the press was on a test glyph.

func (*ViewModel) TestGlyphs added in v1.0.0

func (vm *ViewModel) TestGlyphs() []TestGlyphMark

TestGlyphs are the glyphs of the editor as they are now (moved by the edits), in the order of the document.

func (*ViewModel) TestHostSet added in v1.0.0

func (vm *ViewModel) TestHostSet() bool

TestHostSet tells whether the editor has a test host.

func (*ViewModel) TestMessages added in v1.0.0

func (vm *ViewModel) TestMessages() map[int]string

TestMessages are the messages of the editor as they are now, by line (counted from 0); the lines moved with the edits.

func (*ViewModel) ToggleFoldAt

func (vm *ViewModel) ToggleFoldAt(line int, controlClicked, surrounding, recursive bool)

ToggleFoldAt folds or unfolds the region that starts on a line, as a click on its control does: Alt works on the regions that are not around it, and Shift (or the middle button) on the regions inside it too. It does nothing when no region starts there.

Ported from VS Code: src/vs/editor/contrib/folding/browser/folding.ts (onEditorMouseUp)

func (*ViewModel) Tokenizer

func (vm *ViewModel) Tokenizer() *tokens.Tokenizer

Tokenizer is the tokenizer of the document, or nil.

func (*ViewModel) TrackCursors added in v1.0.0

func (vm *ViewModel) TrackCursors() (restore func())

TrackCursors follows the cursors through the edits that someone else makes to the document from now on (a workspace edit of a server, a code action); the function it returns puts the cursors where the text took them. A document that did not change leaves the cursors alone.

func (*ViewModel) TriggerCodeActions added in v1.0.0

func (vm *ViewModel) TriggerCodeActions(trig langfeatures.CodeActionTrigger, notAvailable string)

TriggerCodeActions asks for the actions at the cursor for a command and does what the trigger says with them (VS Code's manualTriggerAtCurrentPosition): applies the only one or the first when the trigger says so, tells the user when there are none (notAvailable), or opens the list. The answer is dropped when the cursor moved or the text changed meanwhile.

func (*ViewModel) UpdateFolding

func (vm *ViewModel) UpdateFolding(regions *folding.Regions) error

UpdateFolding makes the regions a provider found the regions of the model, keeping what is folded and what the user made; a region with a cursor in it that changed is unfolded. It applies the folded state of a view state that waits for the regions.

func (*ViewModel) ViewState

func (vm *ViewModel) ViewState() ViewState

ViewState reads what to remember about the editor.

func (*ViewModel) ViewportSize

func (vm *ViewModel) ViewportSize() (width, height float64)

ViewportSize is the size of the text area as the last layout measured it.

func (*ViewModel) WrapColumn

func (vm *ViewModel) WrapColumn() int

WrapColumn is the number of columns of a row now, or 0 when the lines are not wrapped.

func (*ViewModel) WrapPending

func (vm *ViewModel) WrapPending() int

WrapPending is the number of lines whose breaks are not known yet.

func (*ViewModel) Wrapping

func (vm *ViewModel) Wrapping() bool

Wrapping says whether the lines are split into rows.

func (*ViewModel) Zone

func (vm *ViewModel) Zone(id ZoneID) (ZoneSpec, bool)

Zone is a zone by its id.

func (*ViewModel) ZoneAtRow

func (vm *ViewModel) ZoneAtRow(row int) (ZoneHit, bool)

ZoneAtRow tells which zone has a row, if one does.

func (*ViewModel) ZoneAtY

func (vm *ViewModel) ZoneAtY(y float64) (ZoneHit, bool)

ZoneAtY tells which zone is at a height from the top of the document, if one is. Above the first row and below the last there is none.

func (*ViewModel) Zones

func (vm *ViewModel) Zones() []ZoneInfo

Zones lists the zones in the order of the projection (by the line they come after, then by ordinal, then in the order they were added) with the rows they have now.

func (*ViewModel) Zoom

func (vm *ViewModel) Zoom() *Zoom

Zoom is the zoom of the editor, the one it shares with the other editors of its window when the widget was given one.

type ViewState

type ViewState struct {
	// Selections are the selections, the primary first.
	Selections []buffer.Selection
	// ScrollTop is the vertical scroll position in pixels.
	ScrollTop float64
	// ScrollLeft is the horizontal scroll position in pixels.
	ScrollLeft float64
	// Folds are the folded and the user-made ranges, or nil.
	Folds folding.Memento
}

ViewState is what the editor remembers about a document to come back to it: the selections, the scroll position and the folded ranges (SPEC §9.1).

func (ViewState) MarshalJSON

func (s ViewState) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler: the view state with a version field. A scroll position that is not a number is written as 0.

func (*ViewState) UnmarshalJSON

func (s *ViewState) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. A document that is not a view state has the tag ViewStateInvalid, one with another version ViewStateVersionUnsupported. Negative positions and scroll positions are made 0; RestoreViewState moves positions into the text.

type ZoneChanges

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

ZoneChanges adds, changes and removes the zones inside ChangeZones.

func (ZoneChanges) Add

func (z ZoneChanges) Add(spec ZoneSpec) (ZoneID, error)

Add adds a zone; see ViewModel.AddZone.

func (ZoneChanges) Change

func (z ZoneChanges) Change(id ZoneID, fn func(*ZoneSpec)) error

Change changes a zone; see ViewModel.ChangeZone.

func (ZoneChanges) Remove

func (z ZoneChanges) Remove(id ZoneID) error

Remove removes a zone; see ViewModel.RemoveZone.

type ZoneHit

type ZoneHit struct {
	// ID is the zone.
	ID ZoneID
	// Index is the row inside the zone, from 0.
	Index int
	// FirstRow and Rows are the rows of the zone.
	FirstRow, Rows int
}

ZoneHit is a row of a zone, as the hit test finds it.

type ZoneID

type ZoneID int

ZoneID names a view zone of a view model. The ids of a view model are never 0.

type ZoneInfo

type ZoneInfo struct {
	// ID is the id of the zone.
	ID ZoneID
	// ZoneSpec is the zone as it was asked for; its AfterLine follows the edits of the document.
	ZoneSpec
	// FirstRow and ShownRows are where the zone is in the rows of the editor: ShownRows is 0 when
	// the zone is hidden by a fold.
	FirstRow, ShownRows int
}

ZoneInfo is a zone and where the editor shows it now.

type ZoneSpec

type ZoneSpec struct {
	// AfterLine is the number of lines above the zone: the zone comes after the line with that
	// number, counted from 1. 0 puts it above the first line, and the number of lines of the
	// document after the last line.
	AfterLine int
	// Rows is the height of the zone in rows of the editor (at least 1).
	Rows int
	// Ordinal orders the zones that come after the same line: the lower first, and zones with the
	// same ordinal in the order they were added.
	Ordinal int
	// ShowInHiddenAreas shows the zone also when the line after it is hidden by a fold; a zone
	// is hidden then otherwise (VS Code's showInHiddenAreas).
	ShowInHiddenAreas bool
	// Widget is drawn in the rows of the zone, as wide as the text area; nil leaves the rows empty.
	// A zone's widget does not scroll sideways with the text.
	Widget widgets.Widget
	// Gutter, when it is not transparent, fills the gutter along the rows of the zone (VS Code's margin of a
	// view zone: the diff editor colors the margin of the deleted lines of its inline view).
	Gutter ui.Color
	// GutterGlyph, when it is not 0, is the Codicon (its code point) drawn at the right of the line
	// decorations column on every row of the zone, in the color of the line numbers: the minus sign of the
	// deleted lines of the inline diff.
	GutterGlyph int
}

ZoneSpec is a view zone: whole rows inserted into the editor after a line of the document, as VS Code's view zones (whitespace) are (SPEC §9.1). The diff editor fills the side that has fewer lines with them, and shows deleted lines in them.

type Zoom

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

Zoom is the zoom level of the font of the editors of a window: every level makes the font and the lines a tenth larger (or smaller). It is shared, so that the commands and the mouse wheel zoom all the editors of the window together, as VS Code's EditorZoom does.

Ported from VS Code: src/vs/editor/common/config/editorZoom.ts

func NewZoom

func NewZoom() *Zoom

NewZoom makes a zoom at level 0.

func (*Zoom) AddListener

AddListener calls fn when the level changes.

func (*Zoom) Level

func (z *Zoom) Level() float64

Level is the zoom level, from MinZoomLevel to MaxZoomLevel.

func (*Zoom) RemoveListener

func (z *Zoom) RemoveListener(h foundation.ListenerHandle)

RemoveListener removes a listener.

func (*Zoom) Set

func (z *Zoom) Set(level float64)

Set changes the zoom level, within its bounds, and tells the listeners when it changed.

Jump to

Keyboard shortcuts

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