Documentation
¶
Overview ¶
Package editorgroup holds editor inputs, editor groups and their grid, as data (SPEC §10.3).
An EditorInput is what a tab stands for: a text file, later a diff, a merge or a settings page. A Model is the editors of one group: their order, the preview editor, the pinned and sticky ones, the active one and the most recently used order.
Ported from VS Code: src/vs/workbench/common/editor/editorGroupModel.ts (the model), src/vs/workbench/common/editor/editorInput.ts (the input) and src/vs/base/common/labels.ts (shorten, for the descriptions of tabs that share a name).
Index ¶
- Constants
- func DecoratedTitle(e EditorInput, title string) string
- func DocumentName(doc *document.Document) string
- func DropAllowed(from, onto *Group, copied bool) bool
- func EditedDocument(e EditorInput) *document.Document
- func IsDeleted(e EditorInput) bool
- func ParseDiffInput(value string) (original, modified document.URI, err error)
- func Shorten(paths []string) []string
- func TabDropIndex(tabs []Span, x float64) int
- func ZoneRect(z DropZone, width, height float64) (left, top, w, h float64)
- type BaseInput
- type Capabilities
- type ChangeEvent
- type ChangeKind
- type CloseContext
- type CloseResult
- type CloseTarget
- type CloseUnasked
- type ClosedEditor
- type ClosedEditors
- func (c *ClosedEditors) Clear()
- func (c *ClosedEditors) Len() int
- func (c *ClosedEditors) List() []ClosedEditor
- func (c *ClosedEditors) NewBatch() int
- func (c *ClosedEditors) Record(e ClosedEditor)
- func (c *ClosedEditors) RemoveResource(uri document.URI)
- func (c *ClosedEditors) TakeLastBatch() []ClosedEditor
- type Copier
- type DeletedState
- type DiffInput
- func (d *DiffInput) Capabilities() Capabilities
- func (d *DiffInput) CopyInput() EditorInput
- func (d *DiffInput) Description() string
- func (d *DiffInput) Dirty() bool
- func (d *DiffInput) Dispose()
- func (d *DiffInput) EditedDocument() *document.Document
- func (d *DiffInput) Matches(other EditorInput) bool
- func (d *DiffInput) Modified() *document.Document
- func (d *DiffInput) Name() string
- func (d *DiffInput) Original() *document.Document
- func (d *DiffInput) Proposal() *DiffProposal
- func (d *DiffInput) Refresh()
- func (d *DiffInput) Resource() (document.URI, bool)
- func (d *DiffInput) Serialize() (string, bool)
- func (d *DiffInput) SetName(name string)
- func (d *DiffInput) SetProposal(p *DiffProposal)
- func (d *DiffInput) TabKey() string
- func (d *DiffInput) Title() string
- func (d *DiffInput) TypeID() string
- type DiffProposal
- type Direction
- type DocumentEditor
- type DropZone
- type EditorInput
- type EditorsOrder
- type EventSharingInput
- func (e *EventSharingInput) Capabilities() Capabilities
- func (e *EventSharingInput) Description() string
- func (e *EventSharingInput) Dirty() bool
- func (e *EventSharingInput) Matches(other EditorInput) bool
- func (e *EventSharingInput) Name() string
- func (e *EventSharingInput) Resource() (document.URI, bool)
- func (e *EventSharingInput) Serialize() (string, bool)
- func (e *EventSharingInput) Title() string
- func (e *EventSharingInput) TypeID() string
- type ExtensionTabInput
- func (e *ExtensionTabInput) Busy() bool
- func (e *ExtensionTabInput) CanSave() bool
- func (e *ExtensionTabInput) Capabilities() Capabilities
- func (e *ExtensionTabInput) CloseUnasked() bool
- func (e *ExtensionTabInput) CopyInput() EditorInput
- func (e *ExtensionTabInput) Description() string
- func (e *ExtensionTabInput) Dirty() bool
- func (e *ExtensionTabInput) Dispose()
- func (e *ExtensionTabInput) Extension() string
- func (e *ExtensionTabInput) ID() string
- func (e *ExtensionTabInput) Icon() string
- func (e *ExtensionTabInput) IconColor() string
- func (e *ExtensionTabInput) IsMirror() bool
- func (e *ExtensionTabInput) Kind() string
- func (e *ExtensionTabInput) Matches(other EditorInput) bool
- func (e *ExtensionTabInput) Mirror() *ExtensionTabInput
- func (e *ExtensionTabInput) Name() string
- func (e *ExtensionTabInput) Resource() (document.URI, bool)
- func (e *ExtensionTabInput) Save(done func(saved bool))
- func (e *ExtensionTabInput) Serialize() (string, bool)
- func (e *ExtensionTabInput) SetBusy(busy bool)
- func (e *ExtensionTabInput) SetCopier(copier func() *ExtensionTabInput)
- func (e *ExtensionTabInput) SetDirty(dirty bool)
- func (e *ExtensionTabInput) SetHint(hint string)
- func (e *ExtensionTabInput) SetIcon(icon, color string)
- func (e *ExtensionTabInput) SetSaver(save func(done func(saved bool)))
- func (e *ExtensionTabInput) SetTitle(title string)
- func (e *ExtensionTabInput) TabKey() string
- func (e *ExtensionTabInput) Title() string
- func (e *ExtensionTabInput) TypeID() string
- type ExtensionsInput
- func (e *ExtensionsInput) Capabilities() Capabilities
- func (e *ExtensionsInput) Description() string
- func (e *ExtensionsInput) Dirty() bool
- func (e *ExtensionsInput) Matches(other EditorInput) bool
- func (e *ExtensionsInput) Name() string
- func (e *ExtensionsInput) Resource() (document.URI, bool)
- func (e *ExtensionsInput) Serialize() (string, bool)
- func (e *ExtensionsInput) Title() string
- func (e *ExtensionsInput) TypeID() string
- type FileEditorInput
- func (e *FileEditorInput) Capabilities() Capabilities
- func (e *FileEditorInput) CopyInput() EditorInput
- func (e *FileEditorInput) Description() string
- func (e *FileEditorInput) Dirty() bool
- func (e *FileEditorInput) Editor() string
- func (e *FileEditorInput) Matches(other EditorInput) bool
- func (e *FileEditorInput) Name() string
- func (e *FileEditorInput) Path() string
- func (e *FileEditorInput) Resource() (document.URI, bool)
- func (e *FileEditorInput) RestoredState() json.RawMessage
- func (e *FileEditorInput) Serialize() (string, bool)
- func (e *FileEditorInput) SetState(state json.RawMessage)
- func (e *FileEditorInput) SetStateFunc(f func() json.RawMessage)
- func (e *FileEditorInput) State() json.RawMessage
- func (e *FileEditorInput) Title() string
- func (e *FileEditorInput) TypeID() string
- type GoFilter
- type Grid
- func (g *Grid) Activate(grp *Group) error
- func (g *Grid) Active() *Group
- func (g *Grid) AddGroup(at *Group, dir Direction) (*Group, error)
- func (g *Grid) ApplyLayout(l Layout) error
- func (g *Grid) CopyEditor(from *Group, editor EditorInput, to *Group, opts MoveOptions) (EditorInput, bool, error)
- func (g *Grid) CopyGroup(grp, at *Group, dir Direction) (*Group, error)
- func (g *Grid) Count() int
- func (g *Grid) Dispose()
- func (g *Grid) DistributeSizes()
- func (g *Grid) DropOnTabs(from *Group, editor EditorInput, onto *Group, index int, copied bool) error
- func (g *Grid) DropOnZone(from *Group, editor EditorInput, onto *Group, zone DropZone, copied bool) (*Group, error)
- func (g *Grid) ExitMaximized()
- func (g *Grid) FindByDirection(source *Group, dir Direction, wrap bool) *Group
- func (g *Grid) FindByLocation(source *Group, loc Location, wrap bool) *Group
- func (g *Grid) FocusIndex(n int, preferred Direction) (*Group, error)
- func (g *Grid) Group(id int) *Group
- func (g *Grid) Groups(order GroupsOrder) []*Group
- func (g *Grid) Hidden(grp *Group) bool
- func (g *Grid) Index(grp *Group) int
- func (g *Grid) Layout() Layout
- func (g *Grid) Maximize(grp *Group) error
- func (g *Grid) Maximized() *Group
- func (g *Grid) MergeAllGroups(target *Group) error
- func (g *Grid) MergeGroup(grp, target *Group) (bool, error)
- func (g *Grid) MoveEditor(from *Group, editor EditorInput, to *Group, opts MoveOptions) (bool, error)
- func (g *Grid) MoveGroup(grp, target *Group, dir Direction) error
- func (g *Grid) MoveOrCopyTarget(source *Group, to Target, value int, preferred Direction) (*Group, error)
- func (g *Grid) OnChange(fn func(GridEvent)) (unsubscribe func())
- func (g *Grid) Options() GridOptions
- func (g *Grid) Orientation() Orientation
- func (g *Grid) RemoveGroup(grp *Group) (bool, error)
- func (g *Grid) Serialize() SerializedGrid
- func (g *Grid) SerializeWith(state InputStateFunc) SerializedGrid
- func (g *Grid) SetOptions(opts GridOptions)
- func (g *Grid) SetSizes(path []int, sizes []float64)
- func (g *Grid) Sizes(path []int) []float64
- func (g *Grid) SplitEditor(grp *Group, editor EditorInput, dir Direction) (*Group, error)
- func (g *Grid) SplitGroup(grp *Group, dir Direction) (*Group, error)
- func (g *Grid) ToggleMaximize(grp *Group) error
- func (g *Grid) Tree() Node
- func (g *Grid) Version() int
- type GridChangeKind
- type GridEvent
- type GridOptions
- type Group
- type GroupsOrder
- type History
- func (h *History) ActiveEditorChanged(p Pane)
- func (h *History) Back(f GoFilter)
- func (h *History) Clear()
- func (h *History) Closed() *ClosedEditors
- func (h *History) EditorClosed(groupID int, input EditorInput)
- func (h *History) Follow(follow func(document.URI) (nu document.URI, exists bool))
- func (h *History) Forward(f GoFilter)
- func (h *History) GroupRemoved(groupID int)
- func (h *History) InputDisposed(input EditorInput)
- func (h *History) Last(f GoFilter)
- func (h *History) Locations(f GoFilter) (locs []NavLocation, index int)
- func (h *History) OnChange(fn func()) (unsubscribe func())
- func (h *History) Previous(f GoFilter)
- func (h *History) RemoveResource(uri document.URI)
- func (h *History) Scope() NavigationScope
- func (h *History) SelectionChanged(p Pane, reason SelectionReason)
- func (h *History) SetScope(scope NavigationScope)
- func (h *History) State() NavState
- type InputEvent
- type InputEventKind
- type InputStateFunc
- type KeybindingsInput
- func (k *KeybindingsInput) Capabilities() Capabilities
- func (k *KeybindingsInput) Description() string
- func (k *KeybindingsInput) Dirty() bool
- func (k *KeybindingsInput) Matches(other EditorInput) bool
- func (k *KeybindingsInput) Name() string
- func (k *KeybindingsInput) Resource() (document.URI, bool)
- func (k *KeybindingsInput) Serialize() (string, bool)
- func (k *KeybindingsInput) SetViewState(st KeybindingsViewState)
- func (k *KeybindingsInput) Title() string
- func (k *KeybindingsInput) TypeID() string
- func (k *KeybindingsInput) ViewState() KeybindingsViewState
- type KeybindingsViewState
- type Layout
- type LayoutNode
- type Location
- type MergeInput
- func (m *MergeInput) Capabilities() Capabilities
- func (m *MergeInput) Description() string
- func (m *MergeInput) Dirty() bool
- func (m *MergeInput) Dispose()
- func (m *MergeInput) EditedDocument() *document.Document
- func (m *MergeInput) Matches(other EditorInput) bool
- func (m *MergeInput) Name() string
- func (m *MergeInput) Refresh()
- func (m *MergeInput) Resource() (document.URI, bool)
- func (m *MergeInput) Result() *document.Document
- func (m *MergeInput) Serialize() (string, bool)
- func (m *MergeInput) Source() MergeSource
- func (m *MergeInput) TabKey() string
- func (m *MergeInput) Title() string
- func (m *MergeInput) TypeID() string
- type MergeKind
- type MergeSource
- type Model
- func (m *Model) ActiveEditor() EditorInput
- func (m *Model) Clone(id int, dup func(EditorInput) EditorInput) *Model
- func (m *Model) CloseEditor(candidate EditorInput, context CloseContext, openNext bool) *CloseResult
- func (m *Model) Contains(candidate EditorInput) bool
- func (m *Model) ContainsStrict(candidate EditorInput) bool
- func (m *Model) Count() int
- func (m *Model) Dispose()
- func (m *Model) EditorAt(index int) EditorInput
- func (m *Model) Editors(order EditorsOrder, excludeSticky bool) []EditorInput
- func (m *Model) Find(candidate EditorInput) (editor EditorInput, index int, ok bool)
- func (m *Model) ID() int
- func (m *Model) IndexOf(candidate EditorInput) int
- func (m *Model) IndexOfStrict(candidate EditorInput) int
- func (m *Model) IsActive(candidate EditorInput) bool
- func (m *Model) IsFirst(candidate EditorInput) bool
- func (m *Model) IsLast(candidate EditorInput) bool
- func (m *Model) IsPinned(editor EditorInput) bool
- func (m *Model) IsPinnedAt(index int) bool
- func (m *Model) IsSticky(editor EditorInput) bool
- func (m *Model) IsStickyAt(index int) bool
- func (m *Model) MoveEditor(candidate EditorInput, toIndex int) EditorInput
- func (m *Model) OnChange(fn func(ChangeEvent)) (unsubscribe func())
- func (m *Model) OpenEditor(candidate EditorInput, opts OpenOptions) (editor EditorInput, isNew bool)
- func (m *Model) Options() Options
- func (m *Model) Pin(candidate EditorInput) EditorInput
- func (m *Model) PreviewEditor() EditorInput
- func (m *Model) Serialize() SerializedModel
- func (m *Model) SerializeWith(state InputStateFunc) SerializedModel
- func (m *Model) SetActive(candidate EditorInput) EditorInput
- func (m *Model) SetOptions(opts Options)
- func (m *Model) Stick(candidate EditorInput) EditorInput
- func (m *Model) StickyCount() int
- func (m *Model) Unpin(candidate EditorInput) EditorInput
- func (m *Model) Unstick(candidate EditorInput) EditorInput
- type MoveOptions
- type MultiDiffInput
- func (m *MultiDiffInput) Capabilities() Capabilities
- func (m *MultiDiffInput) Description() string
- func (m *MultiDiffInput) Dirty() bool
- func (m *MultiDiffInput) Failure() string
- func (m *MultiDiffInput) Fixed() bool
- func (m *MultiDiffInput) Items() []MultiDiffItem
- func (m *MultiDiffInput) Key() string
- func (m *MultiDiffInput) Kind() string
- func (m *MultiDiffInput) Loaded() bool
- func (m *MultiDiffInput) Matches(other EditorInput) bool
- func (m *MultiDiffInput) Name() string
- func (m *MultiDiffInput) Resource() (document.URI, bool)
- func (m *MultiDiffInput) Serialize() (string, bool)
- func (m *MultiDiffInput) SetFailure(message string)
- func (m *MultiDiffInput) SetItems(items []MultiDiffItem)
- func (m *MultiDiffInput) SetTitle(title string)
- func (m *MultiDiffInput) TabKey() string
- func (m *MultiDiffInput) Title() string
- func (m *MultiDiffInput) TypeID() string
- type MultiDiffItem
- type NavLocation
- type NavSelection
- type NavState
- type NavigationScope
- type Node
- type OpenOptions
- type OpenPositioning
- type Opener
- type Options
- type Orientation
- type Pane
- type RecentStack
- type Ref
- type SelectionCompare
- type SelectionReason
- type SerializedGrid
- type SerializedInput
- type SerializedModel
- type SerializedNode
- type SettingsInput
- func (s *SettingsInput) Capabilities() Capabilities
- func (s *SettingsInput) Description() string
- func (s *SettingsInput) Dirty() bool
- func (s *SettingsInput) Matches(other EditorInput) bool
- func (s *SettingsInput) Name() string
- func (s *SettingsInput) Resource() (document.URI, bool)
- func (s *SettingsInput) Serialize() (string, bool)
- func (s *SettingsInput) SetViewState(st SettingsViewState)
- func (s *SettingsInput) Title() string
- func (s *SettingsInput) TypeID() string
- func (s *SettingsInput) ViewState() SettingsViewState
- type SettingsTarget
- type SettingsViewState
- type Span
- type SplitSizing
- type SystemCheckInput
- func (e *SystemCheckInput) Capabilities() Capabilities
- func (e *SystemCheckInput) Description() string
- func (e *SystemCheckInput) Dirty() bool
- func (e *SystemCheckInput) Matches(other EditorInput) bool
- func (e *SystemCheckInput) Name() string
- func (e *SystemCheckInput) Resource() (document.URI, bool)
- func (e *SystemCheckInput) Serialize() (string, bool)
- func (e *SystemCheckInput) Title() string
- func (e *SystemCheckInput) TypeID() string
- type TabKeyed
- type TabLabel
- type Target
- type TextInput
- func (t *TextInput) Capabilities() Capabilities
- func (t *TextInput) CopyInput() EditorInput
- func (t *TextInput) Deleted() bool
- func (t *TextInput) Description() string
- func (t *TextInput) Dirty() bool
- func (t *TextInput) Dispose()
- func (t *TextInput) Document() *document.Document
- func (t *TextInput) EditedDocument() *document.Document
- func (t *TextInput) Matches(other EditorInput) bool
- func (t *TextInput) Name() string
- func (t *TextInput) Refresh()
- func (t *TextInput) Resource() (document.URI, bool)
- func (t *TextInput) Serialize() (string, bool)
- func (t *TextInput) SetName(name string)
- func (t *TextInput) Title() string
- func (t *TextInput) TypeID() string
- type TextInputOpts
- type Unsaved
- type ZoneOptions
Constants ¶
const DeletedTooltip = "Deleted"
DeletedTooltip is what the tooltip of a deleted editor adds to its title (VS Code's file decoration, from src/vs/workbench/services/textfile/browser/textFileService.ts: strikethrough and the tooltip "Deleted").
const DiffInputTypeID = "emetos.diff"
DiffInputTypeID is the TypeID of a DiffInput.
const DiffSeparator = " ↔ "
DiffSeparator is what a compare editor writes between the names of its two sides, in its name, description and title ("a.go ↔ b.go").
const EventSharingInputTypeID = "emetos.extensions.eventSharing"
EventSharingInputTypeID is the TypeID of an EventSharingInput.
const ExtensionTabInputTypeID = "emetos.extensionTab"
ExtensionTabInputTypeID is the TypeID of an ExtensionTabInput.
const ExtensionsInputTypeID = "emetos.extensions"
ExtensionsInputTypeID is the TypeID of an ExtensionsInput.
const FileEditorInputTypeID = "emetos.fileEditor"
FileEditorInputTypeID is the TypeID of a FileEditorInput.
const KeybindingsInputTypeID = "emetos.keybindings"
KeybindingsInputTypeID is the TypeID of a KeybindingsInput.
MaxNavigationStack is the number of locations a stack keeps (VS Code's MAX_STACK_SIZE).
const MaxRecentlyClosedEditors = 20
MaxRecentlyClosedEditors is the number of closed editors that Reopen Closed Editor remembers (VS Code's MAX_RECENTLY_CLOSED_EDITORS).
const MergeInputTypeID = "emetos.merge"
MergeInputTypeID is the TypeID of a MergeInput.
const MergeNamePrefix = "Merging: "
MergeNamePrefix is what the name of a merge editor starts with ("Merging: result.go", VS Code's `localize('name', "Merging: {0}", ...)`).
const MultiDiffInputTypeID = "emetos.multiDiff"
MultiDiffInputTypeID is the TypeID of a MultiDiffInput.
const SelectionThreshold = 10
SelectionThreshold is the number of lines the selection of a text editor has to move to count as a significant change (VS Code's TEXT_EDITOR_SELECTION_THRESHOLD).
const SettingsInputTypeID = "emetos.settings"
SettingsInputTypeID is the TypeID of a SettingsInput.
const SystemCheckInputTypeID = "emetos.systemCheck"
SystemCheckInputTypeID is the TypeID of a SystemCheckInput.
const TextInputTypeID = "emetos.textEditor"
TextInputTypeID is the TypeID of a TextInput.
Variables ¶
This section is empty.
Functions ¶
func DecoratedTitle ¶
func DecoratedTitle(e EditorInput, title string) string
DecoratedTitle is the tooltip of an editor: its title, and "Deleted" after a bullet while its file is gone (VS Code's src/vs/workbench/browser/labels.ts adds the tooltip of the decoration like that).
func DocumentName ¶
DocumentName is the name a tab gives a document: its label, else the name of its file. The question that asks whether to save a document names it so.
func DropAllowed ¶
DropAllowed says whether an editor of a group can be dropped on the editor area of a group. An editor that moves (does not copy) onto its own group would leave it empty when it is the only one: that is refused.
Ported from VS Code: editorDropTarget.ts (the check in onDragOver)
func EditedDocument ¶
func EditedDocument(e EditorInput) *document.Document
EditedDocument is the document the editor of an input changes, or nil for an input that has none.
func IsDeleted ¶
func IsDeleted(e EditorInput) bool
IsDeleted tells whether the resource of an input was deleted by another program.
func ParseDiffInput ¶
ParseDiffInput reads what Serialize gave: the URIs of the original and the modified document (the window opens the documents and makes the input again with NewDiffInput). A value that is not that has the tag DiffInputInvalid.
func Shorten ¶
Shorten gives, for each path, the shortest part of it that none of the others has, with an ellipsis for what is left out: ["/a/b/x", "/a/b/y"] gives ["/a/…/x", "/a/…/y"]. A path with no part of its own is kept as it is, and an empty one becomes "./". Paths are written with "/" and may start with "/" or "~".
Ported from VS Code: src/vs/base/common/labels.ts (shorten)
func TabDropIndex ¶
TabDropIndex is the place in a group a tab dropped with the pointer at x goes to: before the tab the pointer is over when it is in its left half (or on the middle), after it when it is in its right half; at the end when the pointer is past the last tab. The tabs are given left to right.
Ported from VS Code: multiEditorTabsControl.ts (getTabDragOverLocation, the onDrop of the tab)
Types ¶
type BaseInput ¶
type BaseInput struct {
// contains filtered or unexported fields
}
BaseInput is the part of an EditorInput that sends the events. An input embeds it and calls Emit when its state changes; Dispose sends InputWillDispose and forgets the listeners.
func (*BaseInput) Dispose ¶
func (b *BaseInput) Dispose()
Dispose sends InputWillDispose, once, and removes the listeners. An input that embeds BaseInput calls it from its own Dispose.
func (*BaseInput) Emit ¶
func (b *BaseInput) Emit(kind InputEventKind)
Emit sends an event to the listeners, unless the input is disposed.
func (*BaseInput) Subscribe ¶
func (b *BaseInput) Subscribe(fn func(InputEvent)) (unsubscribe func())
Subscribe implements EditorInput.
type Capabilities ¶
type Capabilities uint
Capabilities are the things an editor input can or cannot do (VS Code's EditorInputCapabilities).
const ( // CapReadonly marks an input whose content cannot be changed. CapReadonly Capabilities = 1 << iota // CapUntitled marks an input that has no file yet. CapUntitled // CapCanSplit marks an input that can be shown in several groups at once (steps 6.9, 6.10); a // text editor can. CapCanSplit // CapCannotClose marks an input that has no close button and that the user cannot close. CapCannotClose )
func (Capabilities) Has ¶
func (c Capabilities) Has(c2 Capabilities) bool
Has tells whether every capability of c2 is in c.
type ChangeEvent ¶
type ChangeEvent struct {
Kind ChangeKind
Editor EditorInput
// Index is the place of Editor (after the change, except for a close).
Index int
// OldIndex is where a moved editor was.
OldIndex int
// Context is why an editor closed.
Context CloseContext
// Sticky tells whether a closed editor was sticky.
Sticky bool
}
ChangeEvent tells that a Model changed.
type ChangeKind ¶
type ChangeKind int
ChangeKind says what changed in a Model (VS Code's GroupModelChangeKind, without the group kinds and the selection).
const ( // EditorOpen is an editor added; Index is its place. EditorOpen ChangeKind = iota // EditorClose is an editor removed; Index is the place it had, Context why it closed and // Sticky whether it was sticky. EditorClose // EditorMove is an editor moved; OldIndex is where it was and Index where it is. EditorMove // EditorActive is a new active editor; Index is its place. EditorActive // EditorPin is an editor pinned or unpinned (made the preview editor); IsPinned says which. EditorPin // EditorSticky is an editor made sticky or not sticky; IsSticky says which. EditorSticky // EditorDirty is a change of the dirty mark of an editor. EditorDirty // EditorLabel is a change of the name, the description or the title of an editor. EditorLabel // EditorCapabilities is a change of the capabilities of an editor. EditorCapabilities // EditorWillDispose is sent when an editor of the model is about to be disposed. EditorWillDispose )
type CloseContext ¶
type CloseContext int
CloseContext says why an editor closes (VS Code's EditorCloseContext).
const ( // CloseUnknown is a close that the user asked for, or that nothing else explains. CloseUnknown CloseContext = iota // CloseReplace is the close of a preview editor that another editor replaces. CloseReplace // CloseMove is the close of an editor that moves to another group. CloseMove // CloseUnpin is the close of a preview editor that another editor became the preview of. CloseUnpin )
type CloseResult ¶
type CloseResult struct {
Editor EditorInput
Index int
Sticky bool
Context CloseContext
}
CloseResult is what CloseEditor reports about the editor it closed.
type CloseTarget ¶
type CloseTarget struct {
// Group is the group the editors are in.
Group *Group
// Editors are the inputs of the group that close.
Editors []EditorInput
}
CloseTarget is a set of editors of one group that are about to close.
func AllTargets ¶
func AllTargets(grid *Grid) []CloseTarget
AllTargets makes the targets that close every editor of every group of the grid, in the order of the groups on screen. Sticky editors are included.
type CloseUnasked ¶ added in v1.0.0
type CloseUnasked interface {
CloseUnasked() bool
}
CloseUnasked is implemented by an input whose dirty mark is only a mark: closing it never asks, because what it holds is kept some other way (the state an extension tab saves with the window). The editors of extension tabs are like that.
type ClosedEditor ¶
type ClosedEditor struct {
// Resource is the file of the editor.
Resource document.URI
// GroupID is the group it was closed in and Index the place it had there.
GroupID, Index int
// Sticky tells that it was pinned (a tab with the pin icon).
Sticky bool
// Batch groups the editors that closed together: Close All Editors closes a batch, and Reopen Closed
// Editor opens it again at once.
Batch int
// ViewState is what the window kept of the editor (the cursors, the scroll position, the folds), to give
// back when it is opened again. The history does not look into it.
ViewState any
}
ClosedEditor is an editor that was closed and can be opened again.
type ClosedEditors ¶
type ClosedEditors struct {
// contains filtered or unexported fields
}
ClosedEditors is the list of the editors closed last, the newest last, at most MaxRecentlyClosedEditors.
func NewClosedEditors ¶
func NewClosedEditors() *ClosedEditors
NewClosedEditors makes an empty list.
func (*ClosedEditors) List ¶
func (c *ClosedEditors) List() []ClosedEditor
List is the closed editors, the oldest first.
func (*ClosedEditors) NewBatch ¶
func (c *ClosedEditors) NewBatch() int
NewBatch starts a batch: the editors recorded until the next call are one batch. It gives its number.
func (*ClosedEditors) Record ¶
func (c *ClosedEditors) Record(e ClosedEditor)
Record adds an editor as the last closed one. An older entry of the same file goes away first, and the oldest entry when the list is full.
func (*ClosedEditors) RemoveResource ¶
func (c *ClosedEditors) RemoveResource(uri document.URI)
RemoveResource forgets the closed editors of a file.
func (*ClosedEditors) TakeLastBatch ¶
func (c *ClosedEditors) TakeLastBatch() []ClosedEditor
TakeLastBatch removes the editors of the last batch and gives them in the order they were closed.
type Copier ¶
type Copier interface {
CopyInput() EditorInput
}
Copier is implemented by an input that can be shown in several groups at once: CopyInput gives another input for the same thing, which the other group owns (VS Code's EditorInput.copy). An input without it is shown in one group only, as a singleton editor is, and a split or a copy leaves it out.
type DeletedState ¶
type DeletedState interface {
Deleted() bool
}
DeletedState is implemented by an input whose resource another program can delete: Deleted tells that it did (the document is orphaned, SPEC §3.1 "Files"). The input keeps its content; the tab and the Open Editors list show it struck through.
type DiffInput ¶
type DiffInput struct {
BaseInput
// contains filtered or unexported fields
}
DiffInput is the input of the diff editor (SPEC §9.11): the original document on the left, read-only, and the modified document on the right, which can be edited when it is a file. The input is dirty when the modified document is, and saving it saves that document. It does not own the documents (as a TextInput does not): the window counts a use of each for as long as the editor is open.
func NewDiffInput ¶
func NewDiffInput(original, modified *document.Document, opts TextInputOpts) *DiffInput
NewDiffInput makes the input that compares two documents. It follows the modified document until Dispose.
func (*DiffInput) Capabilities ¶
func (d *DiffInput) Capabilities() Capabilities
Capabilities implements EditorInput: it can be shown in several groups; it is read-only when the modified side is, and untitled while the modified side has no file yet.
func (*DiffInput) CopyInput ¶
func (d *DiffInput) CopyInput() EditorInput
CopyInput implements Copier: another comparison of the same documents.
func (*DiffInput) Description ¶
Description implements EditorInput: the folders of the two sides, or the one they share.
func (*DiffInput) Dispose ¶
func (d *DiffInput) Dispose()
Dispose implements EditorInput: it stops following the documents.
func (*DiffInput) EditedDocument ¶
EditedDocument implements DocumentEditor: the modified document.
func (*DiffInput) Matches ¶
func (d *DiffInput) Matches(other EditorInput) bool
Matches implements EditorInput: a comparison of the same two documents.
func (*DiffInput) Name ¶
Name implements EditorInput: the names of the two sides, "<original> ↔ <modified>", or the name an opener gave the input.
func (*DiffInput) Proposal ¶ added in v1.0.0
func (d *DiffInput) Proposal() *DiffProposal
Proposal is the proposal the input reviews, or nil for an ordinary comparison.
func (*DiffInput) Refresh ¶
func (d *DiffInput) Refresh()
Refresh sends an event when the dirty mark of the modified document is not the one the input last had.
func (*DiffInput) Resource ¶
Resource implements EditorInput: a compare editor shows no one resource (VS Code's side by side inputs have one only when both sides are the same), so it is not found as the editor of a file.
func (*DiffInput) Serialize ¶
Serialize implements EditorInput: the URIs of the two documents as JSON. A side that is neither a file, an untitled document nor a virtual one cannot come back.
func (*DiffInput) SetName ¶ added in v1.0.0
SetName gives the tab a name of the opener's in place of "<original> ↔ <modified>" ("loader.go (Working Tree)", VS Code's title argument of vscode.diff). It is not saved with the window. Call it before the input is shown.
func (*DiffInput) SetProposal ¶ added in v1.0.0
func (d *DiffInput) SetProposal(p *DiffProposal)
SetProposal makes the input the review of a proposed change. It is called once, before the input is shown. A proposal is not saved with the window (Serialize says no), cannot be split, is never dirty and edits no document for saving, so that closing it asks nothing.
func (*DiffInput) TabKey ¶
TabKey implements TabKeyed: the two sides, so that two comparisons with the same name are two tabs.
type DiffProposal ¶ added in v1.0.0
type DiffProposal struct {
// Title is the name of the tab and its tooltip.
Title string
// contains filtered or unexported fields
}
DiffProposal makes a diff editor the review of a change that someone proposes to a file (SPEC §10.16 "As built (step 13.3)"): the modified side is the proposed text, which the user may edit, and the editor ends with an answer, Accept or Reject. Closing the editor, in any way, is Reject. The modified document is the proposal's own, never a file: nothing is saved, asked about when the editor closes, backed up or restored.
func NewDiffProposal ¶ added in v1.0.0
func NewDiffProposal(title string, settle func(accepted bool)) *DiffProposal
NewDiffProposal makes a proposal with the title. settle is called once, with true for Accept and false for Reject, when the proposal is settled with Settle or when the input is disposed.
func (*DiffProposal) Cancel ¶ added in v1.0.0
func (p *DiffProposal) Cancel() bool
Cancel ends the proposal without an answer: the function of the proposal is never called. It reports whether the proposal was still open.
func (*DiffProposal) Settle ¶ added in v1.0.0
func (p *DiffProposal) Settle(accepted bool) bool
Settle answers the proposal, once: the first call calls the function of the proposal and reports true, later ones do nothing and report false.
func (*DiffProposal) Settled ¶ added in v1.0.0
func (p *DiffProposal) Settled() bool
Settled tells whether the proposal was answered or cancelled.
type Direction ¶
type Direction int
Direction is a side of a group (VS Code's GroupDirection).
func (Direction) Orientation ¶
func (d Direction) Orientation() Orientation
Orientation is the axis a direction lies on: left and right are horizontal.
type DocumentEditor ¶
DocumentEditor is implemented by an input whose editor changes one document and saves it: a text editor, and a diff editor (its modified side). The input is dirty when the document is, a save and a revert act on the document, and a close that would lose the document's changes asks about it unless another input shows the same document.
type DropZone ¶
type DropZone int
DropZone is the part of the editor area of a group that a dragged editor is over.
const ( // DropNone is no zone: the editor cannot be dropped here. DropNone DropZone = iota // DropCenter moves the editor into the group. DropCenter // DropLeft splits the group on its left and moves the editor into the new group. DropLeft // DropRight splits the group on its right. DropRight // DropUp splits the group above. DropUp // DropDown splits the group below. DropDown )
func ZoneAt ¶
func ZoneAt(x, y, width, height float64, o ZoneOptions) DropZone
ZoneAt is the zone of the editor area of a size that the pointer at (x, y) in it is over. The middle of the area (all but a ring of a tenth of the width and the height) is the center. In the ring, the area is divided in thirds along the preferred axis (left, the middle, right) and the middle third in halves (up and down); with the other preference the thirds run from top to bottom.
Ported from VS Code: editorDropTarget.ts (DropOverlay.positionOverlay)
type EditorInput ¶
type EditorInput interface {
// TypeID names the kind of the input, such as "emetos.textEditor"; it chooses the deserializer
// of a restored input.
TypeID() string
// Resource is what the input shows, such as a file; false when it shows no resource.
Resource() (document.URI, bool)
// Name is the label of the tab: the name of the file.
Name() string
// Description is the dimmer text after the name: the folder of the file. A tab shows it only
// while another tab has the same name (see TabLabels).
Description() string
// Title is the text of the tooltip of the tab: the full path.
Title() string
// Dirty tells whether the input has changes that are not saved.
Dirty() bool
// Matches tells whether other is the same editor as the input.
Matches(other EditorInput) bool
// Capabilities says what the input can do.
Capabilities() Capabilities
// Serialize gives the text that Deserialize-ing code (the factory of RestoreModel) makes the
// input again from; false for an input that cannot be restored (step 7.5).
Serialize() (string, bool)
// Subscribe calls fn on the changes of the input; it gives the function that stops the calls.
Subscribe(fn func(InputEvent)) (unsubscribe func())
// Dispose releases what the input holds. It sends InputWillDispose first.
Dispose()
}
EditorInput is what an editor tab stands for: a thing that can be opened in an editor group (SPEC §10.3). The model compares inputs with Matches, so two inputs for the same file are the same editor. An input is used on the UI thread only, and must be a pointer (the model also compares inputs with ==).
Saving and reverting are not part of the interface: the window saves the documents of its text inputs (SPEC §6.3) and the inputs of other kinds, which have nothing to save yet, get it when they exist.
type EditorsOrder ¶
type EditorsOrder int
EditorsOrder is the order Editors lists the editors in.
const ( // Sequential lists the editors as the tabs are, left to right. Sequential EditorsOrder = iota // MostRecentlyActive lists the active editor first, then the one active before it, and so on. MostRecentlyActive )
type EventSharingInput ¶ added in v1.0.0
type EventSharingInput struct {
BaseInput
}
EventSharingInput is the input of the page "Extensions > Event Sharing" (SPEC §10.15, step 11.3): like the Extensions page it shows no resource and holds no content, so it is never dirty and closing it never asks, and opening it again reveals the one that is open. The links it shows belong to the process, not to the page, so Serialize has nothing to keep and the state of the window only records that the page was open.
func NewEventSharingInput ¶ added in v1.0.0
func NewEventSharingInput() *EventSharingInput
NewEventSharingInput makes the input of an Event Sharing page.
func (*EventSharingInput) Capabilities ¶ added in v1.0.0
func (e *EventSharingInput) Capabilities() Capabilities
Capabilities implements EditorInput: none (it cannot be split, saved or reverted).
func (*EventSharingInput) Description ¶ added in v1.0.0
func (e *EventSharingInput) Description() string
Description implements EditorInput.
func (*EventSharingInput) Dirty ¶ added in v1.0.0
func (e *EventSharingInput) Dirty() bool
Dirty implements EditorInput: the page is never dirty.
func (*EventSharingInput) Matches ¶ added in v1.0.0
func (e *EventSharingInput) Matches(other EditorInput) bool
Matches implements EditorInput: any Event Sharing input is the same page.
func (*EventSharingInput) Name ¶ added in v1.0.0
func (e *EventSharingInput) Name() string
Name implements EditorInput.
func (*EventSharingInput) Resource ¶ added in v1.0.0
func (e *EventSharingInput) Resource() (document.URI, bool)
Resource implements EditorInput: the page shows no resource.
func (*EventSharingInput) Serialize ¶ added in v1.0.0
func (e *EventSharingInput) Serialize() (string, bool)
Serialize implements EditorInput: an empty object.
func (*EventSharingInput) Title ¶ added in v1.0.0
func (e *EventSharingInput) Title() string
Title implements EditorInput.
func (*EventSharingInput) TypeID ¶ added in v1.0.0
func (e *EventSharingInput) TypeID() string
TypeID implements EditorInput.
type ExtensionTabInput ¶ added in v1.0.0
type ExtensionTabInput struct {
BaseInput
// contains filtered or unexported fields
}
ExtensionTabInput is the input of an editor tab that an extension contributes (SPEC §10.15 "Editor tab", step 11.6): a tab with no file, of a kind the extension declares, with an instance id of its own so that several can be open. Its title, icon and marks (dirty, busy) are set by the extension through the host; what the tab shows and the state it saves are the extension's, and live in the host (the input only names the tab). A dirty mark is a mark only unless the tab has a saver (SetSaver): then closing it while dirty asks, as for a document. Without a saver closing a dirty tab asks nothing, because the data of the tab is the extension's own and is kept in the state it saves.
func NewExtensionTabInput ¶ added in v1.0.0
func NewExtensionTabInput(ext, kind, id, title, icon string) *ExtensionTabInput
NewExtensionTabInput makes the input of the tab with the instance id of a kind of an extension. icon is the name of a Codicon; it may be empty.
func ParseExtensionTabInput ¶ added in v1.0.0
func ParseExtensionTabInput(value string) (*ExtensionTabInput, error)
ParseExtensionTabInput makes the input again from the value Serialize gave. The error has the tag ExtensionTabInputInvalid.
func (*ExtensionTabInput) Busy ¶ added in v1.0.0
func (e *ExtensionTabInput) Busy() bool
Busy tells whether the extension marked the tab as busy.
func (*ExtensionTabInput) CanSave ¶ added in v1.0.0
func (e *ExtensionTabInput) CanSave() bool
CanSave tells whether the tab has a saver, that is whether closing it while dirty asks.
func (*ExtensionTabInput) Capabilities ¶ added in v1.0.0
func (e *ExtensionTabInput) Capabilities() Capabilities
Capabilities implements EditorInput: the tab can be split; its mirror on another screen cannot (the copy would be a tab of that screen alone).
func (*ExtensionTabInput) CloseUnasked ¶ added in v1.0.0
func (e *ExtensionTabInput) CloseUnasked() bool
CloseUnasked implements CloseUnasked: the dirty mark of an extension tab without a saver is only a mark; one with a saver is asked about like a document.
func (*ExtensionTabInput) CopyInput ¶ added in v1.0.0
func (e *ExtensionTabInput) CopyInput() EditorInput
CopyInput implements Copier: another instance of the same kind, made by the host with the state of this one. A tab without a host (a restored tab whose scope is gone) cannot be copied.
func (*ExtensionTabInput) Description ¶ added in v1.0.0
func (e *ExtensionTabInput) Description() string
Description implements EditorInput.
func (*ExtensionTabInput) Dirty ¶ added in v1.0.0
func (e *ExtensionTabInput) Dirty() bool
Dirty implements EditorInput: the mark the extension set.
func (*ExtensionTabInput) Dispose ¶
func (e *ExtensionTabInput) Dispose()
Dispose implements EditorInput: a mirror stops following the input it was made from, and an input lets go of its mirrors (they keep what they show).
func (*ExtensionTabInput) Extension ¶ added in v1.0.0
func (e *ExtensionTabInput) Extension() string
Extension is the id of the extension the tab belongs to, Kind the id of its kind and ID the instance.
func (*ExtensionTabInput) ID ¶ added in v1.0.0
func (e *ExtensionTabInput) ID() string
ID is the instance id of the tab, unique in the workspace.
func (*ExtensionTabInput) Icon ¶ added in v1.0.0
func (e *ExtensionTabInput) Icon() string
Icon is the name of the Codicon of the tab; empty for none.
func (*ExtensionTabInput) IconColor ¶ added in v1.0.0
func (e *ExtensionTabInput) IconColor() string
IconColor is the id of the theme color of the icon of the tab; empty for the color of the text.
func (*ExtensionTabInput) IsMirror ¶
func (e *ExtensionTabInput) IsMirror() bool
IsMirror tells whether the input is the mirror of a tab on another screen (Mirror).
func (*ExtensionTabInput) Kind ¶ added in v1.0.0
func (e *ExtensionTabInput) Kind() string
Kind is the id of the kind of the tab.
func (*ExtensionTabInput) Matches ¶ added in v1.0.0
func (e *ExtensionTabInput) Matches(other EditorInput) bool
Matches implements EditorInput: the same instance.
func (*ExtensionTabInput) Mirror ¶
func (e *ExtensionTabInput) Mirror() *ExtensionTabInput
Mirror makes the input of the same tab for another screen of the workspace: the view of a client of a hosted workspace shows the tabs of the kinds that are shared between screens (SPEC §10.18 "Tabs of extensions in the view"), each with an input of its own in the groups of that view. A mirror has the id of the tab, so the host knows it for the same one (Matches), and follows the title, the hint, the icon and the marks the extension sets on this input for as long as it is not disposed. It is not saved with the window and cannot be split: the tab is the host's.
func (*ExtensionTabInput) Name ¶ added in v1.0.0
func (e *ExtensionTabInput) Name() string
Name implements EditorInput.
func (*ExtensionTabInput) Resource ¶ added in v1.0.0
func (e *ExtensionTabInput) Resource() (document.URI, bool)
Resource implements EditorInput: the tab shows no resource.
func (*ExtensionTabInput) Save ¶ added in v1.0.0
func (e *ExtensionTabInput) Save(done func(saved bool))
Save asks the tab to save its changes and calls done, on the UI thread, with whether they are saved. A tab without a saver calls done(false) at once.
func (*ExtensionTabInput) Serialize ¶ added in v1.0.0
func (e *ExtensionTabInput) Serialize() (string, bool)
Serialize implements EditorInput. A mirror is not saved: the tab is saved with the window of the host.
func (*ExtensionTabInput) SetBusy ¶ added in v1.0.0
func (e *ExtensionTabInput) SetBusy(busy bool)
SetBusy sets the busy mark.
func (*ExtensionTabInput) SetCopier ¶ added in v1.0.0
func (e *ExtensionTabInput) SetCopier(copier func() *ExtensionTabInput)
SetCopier sets the function that makes another input for a copy of the tab (a split); the host sets it.
func (*ExtensionTabInput) SetDirty ¶ added in v1.0.0
func (e *ExtensionTabInput) SetDirty(dirty bool)
SetDirty sets the dirty mark.
func (*ExtensionTabInput) SetHint ¶ added in v1.0.0
func (e *ExtensionTabInput) SetHint(hint string)
SetHint sets the text of the tooltip of the tab (the title when empty).
func (*ExtensionTabInput) SetIcon ¶ added in v1.0.0
func (e *ExtensionTabInput) SetIcon(icon, color string)
SetIcon sets the Codicon of the tab and the id of the theme color of its icon (empty for the color of the text).
func (*ExtensionTabInput) SetSaver ¶ added in v1.0.0
func (e *ExtensionTabInput) SetSaver(save func(done func(saved bool)))
SetSaver sets the function that saves the changes of the tab (the host sets it from extension.EditorTabContent.Save). A tab with a saver is asked about when it is closed while dirty, like a document; without one the dirty mark is only a mark.
func (*ExtensionTabInput) SetTitle ¶ added in v1.0.0
func (e *ExtensionTabInput) SetTitle(title string)
SetTitle sets the name of the tab.
func (*ExtensionTabInput) TabKey ¶ added in v1.0.0
func (e *ExtensionTabInput) TabKey() string
TabKey implements TabKeyed: the instance, so that two tabs with the same title are two tabs.
func (*ExtensionTabInput) Title ¶ added in v1.0.0
func (e *ExtensionTabInput) Title() string
Title implements EditorInput.
func (*ExtensionTabInput) TypeID ¶ added in v1.0.0
func (e *ExtensionTabInput) TypeID() string
TypeID implements EditorInput.
type ExtensionsInput ¶ added in v1.0.0
type ExtensionsInput struct {
BaseInput
}
ExtensionsInput is the input of the page "Extensions" (SPEC §10.15, step 11.1): like the settings input it shows no resource and holds no content, so it is never dirty and closing it never asks, and opening it again reveals the one that is open. The page keeps no state of its own, so Serialize has nothing to keep and the state of the window only records that the page was open.
func NewExtensionsInput ¶ added in v1.0.0
func NewExtensionsInput() *ExtensionsInput
NewExtensionsInput makes the input of an Extensions page.
func (*ExtensionsInput) Capabilities ¶ added in v1.0.0
func (e *ExtensionsInput) Capabilities() Capabilities
Capabilities implements EditorInput: none (it cannot be split, saved or reverted).
func (*ExtensionsInput) Description ¶ added in v1.0.0
func (e *ExtensionsInput) Description() string
Description implements EditorInput.
func (*ExtensionsInput) Dirty ¶ added in v1.0.0
func (e *ExtensionsInput) Dirty() bool
Dirty implements EditorInput: there is nothing to save.
func (*ExtensionsInput) Matches ¶ added in v1.0.0
func (e *ExtensionsInput) Matches(other EditorInput) bool
Matches implements EditorInput: any Extensions input is the same page.
func (*ExtensionsInput) Name ¶ added in v1.0.0
func (e *ExtensionsInput) Name() string
Name implements EditorInput.
func (*ExtensionsInput) Resource ¶ added in v1.0.0
func (e *ExtensionsInput) Resource() (document.URI, bool)
Resource implements EditorInput: the page shows no resource.
func (*ExtensionsInput) Serialize ¶ added in v1.0.0
func (e *ExtensionsInput) Serialize() (string, bool)
Serialize implements EditorInput: an empty object, which ParseExtensionsInput accepts.
func (*ExtensionsInput) Title ¶ added in v1.0.0
func (e *ExtensionsInput) Title() string
Title implements EditorInput.
func (*ExtensionsInput) TypeID ¶ added in v1.0.0
func (e *ExtensionsInput) TypeID() string
TypeID implements EditorInput.
type FileEditorInput ¶
type FileEditorInput struct {
BaseInput
// contains filtered or unexported fields
}
FileEditorInput is the input of a file shown in a file editor of an extension (SPEC §10.37 "File editors", step 36.1): the tab of a file (its name as the title, its path as the tooltip, a file resource for Copy Path and the reveals) whose content an extension makes. It is never dirty: the file editors only show. Two inputs of the same file are the same tab, whatever their editor. The state the editor saves (its zoom, its page) is kept in the serialized value, read through the state function the window sets.
func NewFileEditorInput ¶
func NewFileEditorInput(path, editorID string) *FileEditorInput
NewFileEditorInput makes the input of the file at path shown in the file editor with the id.
func ParseFileEditorInput ¶
func ParseFileEditorInput(value string) (*FileEditorInput, error)
ParseFileEditorInput makes the input again from the value Serialize gave, with the state it held. The error has the tag FileEditorInputInvalid.
func (*FileEditorInput) Capabilities ¶
func (e *FileEditorInput) Capabilities() Capabilities
Capabilities implements EditorInput: the tab can be split.
func (*FileEditorInput) CopyInput ¶
func (e *FileEditorInput) CopyInput() EditorInput
CopyInput implements Copier: the same file in the same editor, starting with the state of this one.
func (*FileEditorInput) Description ¶
func (e *FileEditorInput) Description() string
Description implements EditorInput: the folder of the file.
func (*FileEditorInput) Dirty ¶
func (e *FileEditorInput) Dirty() bool
Dirty implements EditorInput: a file editor only shows.
func (*FileEditorInput) Editor ¶
func (e *FileEditorInput) Editor() string
Editor is the id of the file editor.
func (*FileEditorInput) Matches ¶
func (e *FileEditorInput) Matches(other EditorInput) bool
Matches implements EditorInput: an input of the same file, in any file editor.
func (*FileEditorInput) Name ¶
func (e *FileEditorInput) Name() string
Name implements EditorInput: the name of the file.
func (*FileEditorInput) Path ¶
func (e *FileEditorInput) Path() string
Path is the path of the file.
func (*FileEditorInput) Resource ¶
func (e *FileEditorInput) Resource() (document.URI, bool)
Resource implements EditorInput: the file.
func (*FileEditorInput) RestoredState ¶
func (e *FileEditorInput) RestoredState() json.RawMessage
RestoredState is the state the input was made with (restored, or copied), which the editor starts from.
func (*FileEditorInput) Serialize ¶
func (e *FileEditorInput) Serialize() (string, bool)
Serialize implements EditorInput: the path, the editor and its state.
func (*FileEditorInput) SetState ¶
func (e *FileEditorInput) SetState(state json.RawMessage)
SetState sets the state the editor starts from (a copy of another tab's).
func (*FileEditorInput) SetStateFunc ¶
func (e *FileEditorInput) SetStateFunc(f func() json.RawMessage)
SetStateFunc sets the function that reads the state of the editor; the window sets it.
func (*FileEditorInput) State ¶
func (e *FileEditorInput) State() json.RawMessage
State is the state the editor saved: what the state function gives, else what the input was restored with.
func (*FileEditorInput) Title ¶
func (e *FileEditorInput) Title() string
Title implements EditorInput: the path.
func (*FileEditorInput) TypeID ¶
func (e *FileEditorInput) TypeID() string
TypeID implements EditorInput.
type GoFilter ¶
type GoFilter int
GoFilter says which locations a stack of the history holds (VS Code's GoFilter).
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid is the editor groups of a window as data (SPEC §10.3): a tree of splits whose leaves are groups, the active group and the most-recently-used order of the groups. It is a port of the behavior of VS Code's Grid, GridView and EditorPart (the sizes are shares of the extent of the split instead of pixels). It is used on the UI thread only.
Not ported: groups in auxiliary windows, locked groups, the centered layout, and sizes in pixels (the view that shows the grid keeps the least sizes).
Ported from VS Code: src/vs/workbench/browser/parts/editor/editorPart.ts, src/vs/base/browser/ui/grid/grid.ts and src/vs/base/browser/ui/grid/gridview.ts
func NewGrid ¶
func NewGrid(opts GridOptions) *Grid
NewGrid makes a grid of one empty group, which is the active group.
func RestoreGrid ¶
func RestoreGrid(data SerializedGrid, opts GridOptions, create func(typeID, value string) (EditorInput, bool)) (*Grid, error)
RestoreGrid makes a grid from the state Serialize gave. create makes the input of a saved editor, or reports false when it cannot (see RestoreModel). A state that is not a tree of groups fails with the tag GridStateInvalid.
func RestoreGridWith ¶
func RestoreGridWith(data SerializedGrid, opts GridOptions, create func(SerializedInput) (EditorInput, bool)) (*Grid, error)
RestoreGridWith is RestoreGrid with a factory that is given the whole saved input, State included.
func (*Grid) Activate ¶
Activate makes a group the active group. A maximized group that is not the one activated stops being maximized.
func (*Grid) AddGroup ¶
AddGroup adds an empty group next to a group, on the side dir. A group that was the only one makes the root split run along that side. The new group is not activated.
Ported from VS Code: EditorPart.addGroup
func (*Grid) ApplyLayout ¶
ApplyLayout rebuilds the grid in the shape of a layout, keeping the groups: they take the places of the layout in the order of the grid. If the layout has fewer places, the editors of the extra groups move to the last place; if it has more, empty groups are added.
Ported from VS Code: EditorPart.applyLayout
func (*Grid) CopyEditor ¶
func (g *Grid) CopyEditor(from *Group, editor EditorInput, to *Group, opts MoveOptions) (EditorInput, bool, error)
CopyEditor shows an editor of a group in another group as well: a copy of its input is opened in the target (pinned). It gives the editor of the target, and false when the input cannot be copied (it does not implement Copier). Within one group it moves the editor to Index.
Ported from VS Code: EditorGroupView.copyEditor
func (*Grid) CopyGroup ¶
CopyGroup adds a group next to a group at, on the side dir, with a copy of the editors of the group grp in the same state (workbench.action.duplicateActiveEditorGroupRight and its siblings). An editor that cannot be copied is left out. The new group is not activated.
Ported from VS Code: EditorPart.copyGroup
func (*Grid) Dispose ¶
func (g *Grid) Dispose()
Dispose stops following the models. It does not dispose the inputs of the editors.
func (*Grid) DistributeSizes ¶
func (g *Grid) DistributeSizes()
DistributeSizes makes all the groups of every split equal (workbench.action.evenEditorWidths).
Ported from VS Code: GridView.distributeViewSizes
func (*Grid) DropOnTabs ¶
func (g *Grid) DropOnTabs(from *Group, editor EditorInput, onto *Group, index int, copied bool) error
DropOnTabs drops an editor of a group on the tab strip of a group, at a place of the strip (a TabDropIndex): it moves there, or a copy of it is opened there when copied. Within a group the editor keeps the order of the other tabs (the place counts the tab itself). The target group becomes the active group.
Ported from VS Code: multiEditorTabsControl.ts (onDrop)
func (*Grid) DropOnZone ¶
func (g *Grid) DropOnZone(from *Group, editor EditorInput, onto *Group, zone DropZone, copied bool) (*Group, error)
DropOnZone drops an editor of a group on a zone of the editor area of a group: the center moves the editor into the group (a copy is opened there when copied), a side adds a group next to it and moves or copies the editor into that. When the editor is the last one of its group, the groups close when they empty, and it moves rather than copies, the group moves instead (with all it has). It gives the group the editor is in then and activates it; nil when nothing was done (no zone, or a drop that DropAllowed refuses, or one into the group the editor is in).
Ported from VS Code: editorDropTarget.ts (DropOverlay.handleDrop)
func (*Grid) ExitMaximized ¶
func (g *Grid) ExitMaximized()
ExitMaximized shows the groups that were hidden by Maximize.
func (*Grid) FindByDirection ¶
FindByDirection is the group next to a group on one side: the groups whose edge touches the edge of the group on that side, the most recently active first. With wrap a group at the edge of the grid finds the groups at the opposite edge (a group alone finds itself). It gives nil when there is none.
Ported from VS Code: Grid.getNeighborViews and EditorPart.doFindGroupByDirection
func (*Grid) FindByLocation ¶
FindByLocation is the first, last, next or previous group in the order of GridAppearance. With wrap, the next of the last group is the first and the previous of the first is the last. It gives nil when there is none.
Ported from VS Code: EditorPart.doFindGroupByLocation
func (*Grid) FocusIndex ¶
FocusIndex finds the group that the key Ctrl+n focuses: the group at the place n (counted from 1) in the order of the grid. The one after the last group is added, next to the last group on the preferred side; a place further away finds nothing.
Ported from VS Code: editor.contribution.ts (the focus group by index commands)
func (*Grid) Groups ¶
func (g *Grid) Groups(order GroupsOrder) []*Group
Groups lists the groups in an order.
func (*Grid) Index ¶
Index is the place of a group in GridAppearance order, counted from 0; -1 for a group that is not in the grid.
func (*Grid) Maximize ¶
Maximize hides every other group and gives all the room to a group; Unmaximize shows them again at the sizes they had. It does nothing with a single group.
Ported from VS Code: GridView.maximizeView
func (*Grid) MergeAllGroups ¶
MergeAllGroups merges every other group into a group (workbench.action.joinAllGroups).
Ported from VS Code: EditorPart.mergeAllGroups
func (*Grid) MergeGroup ¶
MergeGroup moves all the editors of a group to the end of another group, and removes the group when it is empty then. An editor stays inactive in the target unless it is the active editor of the active group. It tells whether the group was removed.
Ported from VS Code: EditorPart.mergeGroup
func (*Grid) MoveEditor ¶
func (g *Grid) MoveEditor(from *Group, editor EditorInput, to *Group, opts MoveOptions) (bool, error)
MoveEditor moves an editor of a group to another group. The very same input is opened in the target (pinned, and sticky when it was) and then closed in the source with CloseMove; when the target holds a matching editor already, that one is used and the input is only closed in the source. Within one group it moves the editor to Index.
Ported from VS Code: EditorGroupView.moveEditor
func (*Grid) MoveGroup ¶
MoveGroup moves a group next to another one, on the side dir. Moving a group within its own split (next to a sibling along the split's axis) reorders it, keeping the sizes.
Ported from VS Code: Grid.moveView and EditorPart.moveGroup
func (*Grid) MoveOrCopyTarget ¶
func (g *Grid) MoveOrCopyTarget(source *Group, to Target, value int, preferred Direction) (*Group, error)
MoveOrCopyTarget finds the group that editors of a group move or are copied to. Left, right, up and down find the neighbor on that side, or add a group there; previous and next go by the order of the grid, and add a group (on the opposite of the preferred side, or on it) when the source is the first or the last group; center and position (value counts from 1) pick a group by its place. It gives nil when there is no such group.
Ported from VS Code: editorCommands.ts (moveCopyEditorsToGroup)
func (*Grid) OnChange ¶
OnChange calls fn for every change of the grid and of the models of its groups, and gives the function that stops the calls.
func (*Grid) Options ¶
func (g *Grid) Options() GridOptions
Options are the settings the grid follows.
func (*Grid) Orientation ¶
func (g *Grid) Orientation() Orientation
Orientation is the orientation of the root split.
func (*Grid) RemoveGroup ¶
RemoveGroup removes a group. A group with editors moves them to the most recently active other group first; the last group cannot be removed (false).
Ported from VS Code: EditorPart.removeGroup
func (*Grid) Serialize ¶
func (g *Grid) Serialize() SerializedGrid
Serialize gives the state of the grid to save: the tree, the sizes and the editors of each group that can be serialized, the active group and the order of the groups.
func (*Grid) SerializeWith ¶
func (g *Grid) SerializeWith(state InputStateFunc) SerializedGrid
SerializeWith is Serialize with the State of each input given by state.
func (*Grid) SetOptions ¶
func (g *Grid) SetOptions(opts GridOptions)
SetOptions changes the settings the grid follows, and those of the models of its groups.
func (*Grid) SetSizes ¶
SetSizes sets the shares of the children of the split at a path, as the user dragged a sash. The sizes are made to add up to 1 and do not count as a change of Version. A wrong number of sizes, or a size that is not positive, is ignored.
func (*Grid) Sizes ¶
Sizes are the shares of the children of the split at a path (the indexes of the children from the root; an empty path is the root), or nil for a path that is not a split.
func (*Grid) SplitEditor ¶
SplitEditor is SplitGroup for an editor of the group that is not the active one (the Split Right of the menu of a tab): the new group shows a copy of that editor. Without an editor (nil) the new group stays empty.
Ported from VS Code: editorCommands.ts (splitEditor)
func (*Grid) SplitGroup ¶
SplitGroup adds a group next to a group on the side dir, copies the active editor of the group into it and activates it (the commands workbench.action.splitEditorRight and its siblings). An editor that cannot be copied is not shown in the new group.
Ported from VS Code: editorCommands.ts (splitEditor)
func (*Grid) ToggleMaximize ¶
ToggleMaximize unmaximizes when a group is maximized, else maximizes a group (EditorPart.toggleMaximizeGroup).
func (*Grid) Version ¶
Version counts the changes of the tree and the sizes that the grid itself made (a group added, removed or moved, sizes made even, a layout applied); a view that shows the grid starts over from the sizes of the grid when it changes. Sizes that the user dragged (SetSizes) and the maximized group do not count.
type GridChangeKind ¶
type GridChangeKind int
GridChangeKind says what changed in a Grid.
const ( // GroupAdded tells that a group was added; Group is it. GroupAdded GridChangeKind = iota // GroupRemoved tells that a group was removed; Group is it, no longer in the grid. GroupRemoved // GroupMoved tells that a group moved in the tree; Group is it. GroupMoved // ActiveGroupChanged tells that another group is the active group; Group is it. ActiveGroupChanged // GroupEditorsChanged forwards a change of the model of a group; Group and Change say which. GroupEditorsChanged // LayoutChanged tells that the tree, the sizes, the orientation or the maximized group changed. LayoutChanged )
type GridEvent ¶
type GridEvent struct {
Kind GridChangeKind
Group *Group
// Change is the change of the model, for GroupEditorsChanged.
Change ChangeEvent
}
GridEvent tells that a Grid changed.
type GridOptions ¶
type GridOptions struct {
// Model are the options of the group models.
Model Options
// CloseEmptyGroups is `workbench.editor.closeEmptyGroups`: a group whose last editor closes
// closes too, unless it is the only group.
CloseEmptyGroups bool
// SplitSizing is `workbench.editor.splitSizing`; empty is SizingAuto.
SplitSizing SplitSizing
}
GridOptions are the settings a Grid follows.
func DefaultGridOptions ¶
func DefaultGridOptions() GridOptions
DefaultGridOptions are VS Code's defaults of the settings the grid follows.
type Group ¶
type Group struct {
// Model holds the editors of the group.
Model *Model
// contains filtered or unexported fields
}
Group is a leaf of the grid: the editors of one group (SPEC §10.3).
type GroupsOrder ¶
type GroupsOrder int
GroupsOrder is the order Groups lists the groups in (VS Code's GroupsOrder).
const ( // CreationTime lists the groups in the order they were made. CreationTime GroupsOrder = iota // MostRecentlyActiveGroups lists the active group first, then the one that was active before it, // and so on; groups that were never active come last, in creation order. MostRecentlyActiveGroups // GridAppearance lists the groups as they appear in the grid: depth first, left to right and top // to bottom. The numbers of "focus group 1..8" and of dev.openFile's group count in this order. GridAppearance )
type History ¶
type History struct {
// Recent is the recently used editors across the groups, and RecentInGroup those of one group.
Recent, RecentInGroup RecentStack
// contains filtered or unexported fields
}
History is the history service of a window: the locations that Back, Forward and Go to Last Edit NavLocation go to, the editors that were used last, and the editors that were closed last (Reopen Closed Editor). It is used on the UI thread only, and it follows what the window tells it: ActiveEditorChanged, SelectionChanged, EditorClosed, GroupRemoved, the file operations.
func NewHistory ¶
func NewHistory(opener Opener, scope NavigationScope) *History
NewHistory makes the history of a window; the opener shows the locations.
func (*History) ActiveEditorChanged ¶
ActiveEditorChanged tells the history that another editor is shown in the active group (or none, with a nil input). It does nothing when the editor is the same one as the last time.
func (*History) Clear ¶
func (h *History) Clear()
Clear forgets the locations and the closed editors (Clear Editor History).
func (*History) Closed ¶
func (h *History) Closed() *ClosedEditors
Closed are the editors that Reopen Closed Editor brings back.
func (*History) EditorClosed ¶
func (h *History) EditorClosed(groupID int, input EditorInput)
EditorClosed tells the history that an editor closed in a group: with the scope of the editor its history goes away.
func (*History) Follow ¶
Follow gives the locations and the closed editors of the files the path that follow says they moved to: follow returns the new URI of a URI (the same URI when it did not move) and false when the file is gone. A file that is gone is removed.
func (*History) GroupRemoved ¶
GroupRemoved tells the history that a group is gone: its locations are dropped.
func (*History) InputDisposed ¶
func (h *History) InputDisposed(input EditorInput)
InputDisposed drops the locations of an editor that has no file and is disposed.
func (*History) Last ¶
Last goes to the last location of the stack: Go to Last Edit NavLocation with GoEdits.
func (*History) Locations ¶
func (h *History) Locations(f GoFilter) (locs []NavLocation, index int)
Locations are the locations of the selections stack of the active editor and the place in it; tests and the window's logs read them.
func (*History) OnChange ¶
func (h *History) OnChange(fn func()) (unsubscribe func())
OnChange calls fn when what the history can do may have changed.
func (*History) Previous ¶
Previous goes to the location the place was at before it moved (VS Code's goPrevious).
func (*History) RemoveResource ¶
RemoveResource drops what the history knows of a file: its locations, and its closed editors (the file was deleted).
func (*History) Scope ¶
func (h *History) Scope() NavigationScope
Scope is the scope of the history.
func (*History) SelectionChanged ¶
func (h *History) SelectionChanged(p Pane, reason SelectionReason)
SelectionChanged tells the history that the selection of the active editor changed.
func (*History) SetScope ¶
func (h *History) SetScope(scope NavigationScope)
SetScope changes workbench.editor.navigationScope; the histories start empty.
type InputEvent ¶
type InputEvent struct {
Kind InputEventKind
}
InputEvent tells that something about an input changed.
type InputEventKind ¶
type InputEventKind int
InputEventKind says what changed in an input.
const ( // InputDirty is a change of the dirty mark. InputDirty InputEventKind = iota // InputLabel is a change of the name, the description or the title. InputLabel // InputCapabilities is a change of the capabilities. InputCapabilities // InputWillDispose is sent once, just before the input is disposed. InputWillDispose )
type InputStateFunc ¶
type InputStateFunc func(EditorInput) json.RawMessage
InputStateFunc gives the State of an input when a model or a grid is serialized; nil or an empty result leaves the input without one.
type KeybindingsInput ¶
type KeybindingsInput struct {
BaseInput
// contains filtered or unexported fields
}
KeybindingsInput is the input of the keybindings editor (SPEC §11.3, "Keyboard Shortcuts"): like the settings input it shows no resource and holds no content, so it is never dirty and closing it never asks, and opening it again reveals the one that is open. The editor writes its view state into the input, and Serialize keeps it for the state of the window (step 7.5).
func NewKeybindingsInput ¶
func NewKeybindingsInput(state KeybindingsViewState) *KeybindingsInput
NewKeybindingsInput makes the input of a keybindings editor with a view state.
func ParseKeybindingsInput ¶
func ParseKeybindingsInput(value string) (*KeybindingsInput, error)
ParseKeybindingsInput makes the input again from what Serialize gave. A text that is not the state of an input fails with the tag KeybindingsInputInvalid.
func (*KeybindingsInput) Capabilities ¶
func (k *KeybindingsInput) Capabilities() Capabilities
Capabilities implements EditorInput: none (it cannot be split, saved or reverted).
func (*KeybindingsInput) Description ¶
func (k *KeybindingsInput) Description() string
Description implements EditorInput.
func (*KeybindingsInput) Dirty ¶
func (k *KeybindingsInput) Dirty() bool
Dirty implements EditorInput: the editor writes keybindings.json as the user edits, there is nothing to save.
func (*KeybindingsInput) Matches ¶
func (k *KeybindingsInput) Matches(other EditorInput) bool
Matches implements EditorInput: any keybindings input is the same editor.
func (*KeybindingsInput) Name ¶
func (k *KeybindingsInput) Name() string
Name implements EditorInput.
func (*KeybindingsInput) Resource ¶
func (k *KeybindingsInput) Resource() (document.URI, bool)
Resource implements EditorInput: the keybindings editor shows no resource.
func (*KeybindingsInput) Serialize ¶
func (k *KeybindingsInput) Serialize() (string, bool)
Serialize implements EditorInput: the view state as JSON.
func (*KeybindingsInput) SetViewState ¶
func (k *KeybindingsInput) SetViewState(st KeybindingsViewState)
SetViewState replaces the state of the view; the editor calls it when the user changes the search or the row.
func (*KeybindingsInput) Title ¶
func (k *KeybindingsInput) Title() string
Title implements EditorInput.
func (*KeybindingsInput) TypeID ¶
func (k *KeybindingsInput) TypeID() string
TypeID implements EditorInput.
func (*KeybindingsInput) ViewState ¶
func (k *KeybindingsInput) ViewState() KeybindingsViewState
ViewState is the state of the view the input keeps.
type KeybindingsViewState ¶
type KeybindingsViewState struct {
// Query is the text of the search box.
Query string `json:"query,omitempty"`
// Command is the id of the command of the selected row, and Key the keybinding of the row as keybindings.json
// writes it (empty for a row without one); together they find the row again.
Command string `json:"command,omitempty"`
Key string `json:"key,omitempty"`
}
KeybindingsViewState is what the keybindings editor remembers of its view, and what Serialize keeps of the input: the text of the search and the row that was selected.
type Layout ¶
type Layout struct {
Orientation Orientation `json:"orientation"`
Groups []LayoutNode `json:"groups"`
}
Layout describes the shape of the grid without its editors (VS Code's EditorGroupLayout, what `vscode.setEditorLayout` and `vscode.getEditorLayout` carry). The orientation is the axis of Groups.
type LayoutNode ¶
type LayoutNode struct {
// Size is the weight of the node among its siblings; nodes without one share what the sized
// nodes leave.
Size float64 `json:"size,omitempty"`
// Groups are the nodes of a split; a node without them is a group. A split of one node is that
// node.
Groups []LayoutNode `json:"groups,omitempty"`
}
LayoutNode is a node of a Layout: a group, or a split of nodes along the orthogonal axis of its parent (VS Code's GroupLayoutArgument).
type Location ¶
type Location int
Location is a place in the order the groups appear in the grid (VS Code's GroupLocation).
type MergeInput ¶
type MergeInput struct {
BaseInput
// contains filtered or unexported fields
}
MergeInput is the input of the merge editor (SPEC §9.11): a merge whose result is a document, which the editor edits. The input is dirty when the result document is, saving it saves that document, and closing it asks about that document as a text editor does (it is a DocumentEditor). It does not own the document: the window counts a use of it for as long as the editor is open. The inputs and the base of the merge are made from the files by the window when the editor opens; the input names them so that they can be made again when it is restored.
func NewMergeInput ¶
func NewMergeInput(result *document.Document, source MergeSource, opts TextInputOpts) *MergeInput
NewMergeInput makes the input of a merge whose result is a document. It follows the document until Dispose.
func (*MergeInput) Capabilities ¶
func (m *MergeInput) Capabilities() Capabilities
Capabilities implements EditorInput: a merge editor is shown in one group (it cannot be split), and it is untitled while the result has no file yet.
func (*MergeInput) Description ¶
func (m *MergeInput) Description() string
Description implements EditorInput: the folder of the result file.
func (*MergeInput) Dirty ¶
func (m *MergeInput) Dirty() bool
Dirty implements EditorInput: the result document has unsaved changes.
func (*MergeInput) Dispose ¶
func (m *MergeInput) Dispose()
Dispose implements EditorInput: it stops following the document.
func (*MergeInput) EditedDocument ¶
func (m *MergeInput) EditedDocument() *document.Document
EditedDocument implements DocumentEditor: the result document.
func (*MergeInput) Matches ¶
func (m *MergeInput) Matches(other EditorInput) bool
Matches implements EditorInput: the merge of the same result.
func (*MergeInput) Name ¶
func (m *MergeInput) Name() string
Name implements EditorInput: "Merging: " and the name of the result file.
func (*MergeInput) Refresh ¶
func (m *MergeInput) Refresh()
Refresh sends an event when the dirty mark of the result document is not the one the input last had.
func (*MergeInput) Resource ¶
func (m *MergeInput) Resource() (document.URI, bool)
Resource implements EditorInput: a merge editor shows no one resource (it is not found as the editor of a file, and the history of locations skips it), as a compare editor does not.
func (*MergeInput) Result ¶
func (m *MergeInput) Result() *document.Document
Result is the document that holds the result of the merge.
func (*MergeInput) Serialize ¶
func (m *MergeInput) Serialize() (string, bool)
Serialize implements EditorInput: the kind of the merge and the files it was made from as JSON; the result is a URI of a file. A merge whose result is not a file cannot come back.
func (*MergeInput) Source ¶
func (m *MergeInput) Source() MergeSource
Source names the files of the merge.
func (*MergeInput) TabKey ¶
func (m *MergeInput) TabKey() string
TabKey implements TabKeyed: the result, so that the merges of two files are two tabs.
func (*MergeInput) Title ¶
func (m *MergeInput) Title() string
Title implements EditorInput: "Merging: " and the path of the result file.
type MergeKind ¶
type MergeKind string
MergeKind says where the three texts of a merge come from.
const ( // MergeMarkers is a file with conflict markers: the inputs and the base are made from the markers (SPEC // §9.11 (a)), and the file itself is the result. MergeMarkers MergeKind = "markers" // MergeFiles is `emetos --merge <path1> <path2> <base> <result>` (SPEC §9.11 (b)): four files. MergeFiles MergeKind = "files" )
The kinds of merge.
type MergeSource ¶
type MergeSource struct {
// Kind is where the texts come from.
Kind MergeKind
// Input1 (incoming), Input2 (current) and Base are the paths of the files of a MergeFiles merge.
Input1, Input2, Base string
// Result is the path of the file that holds the result: the file with the markers, or the fourth path of
// --merge.
Result string
}
MergeSource names the files of a merge; it is what a MergeInput keeps and serializes. For a marker file only Result is set.
func ParseMergeInput ¶
func ParseMergeInput(value string) (MergeSource, document.URI, error)
ParseMergeInput reads what Serialize gave: the source of the merge and the URI of the result (the window opens the result document and makes the input again with NewMergeInput). A value that is not JSON has the tag MergeInputInvalid, one without a kind or a result MergeInputIncomplete, a merge of files without all its paths MergeInputFilesIncomplete and a result that is not a file MergeInputResultNotFile.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the editors of one group, as data: their order, the preview editor, the sticky ones (kept at the left), the active one and the most recently used order. It is used on the UI thread only.
Not ported from VS Code's EditorGroupModel: the selection of several tabs, transient editors, locking, cloning, side by side matching and the group's own events (index, label, active).
Ported from VS Code: src/vs/workbench/common/editor/editorGroupModel.ts
func RestoreModel ¶
func RestoreModel(data SerializedModel, opts Options, create func(typeID, value string) (EditorInput, bool)) *Model
RestoreModel makes a model from the state Serialize gave. create makes the input of a saved editor, or reports false when it cannot (an unknown type, a file that is gone): the editor is left out, and so it is from the order, the preview editor and the sticky editors.
func RestoreModelWith ¶
func RestoreModelWith(data SerializedModel, opts Options, create func(SerializedInput) (EditorInput, bool)) *Model
RestoreModelWith is RestoreModel with a factory that is given the whole saved input, State included.
func (*Model) ActiveEditor ¶
func (m *Model) ActiveEditor() EditorInput
ActiveEditor is the active editor, or nil when the group is empty.
func (*Model) Clone ¶
func (m *Model) Clone(id int, dup func(EditorInput) EditorInput) *Model
Clone makes a model with the same editors in the same state (order, preview, sticky, active and most recently used order), under another id. dup gives the input the clone holds for an input of this model: nil leaves the editor out of the clone; a nil dup shares all the inputs, as VS Code shares the inputs of a cloned group. The clone follows the events of its inputs.
Ported from VS Code: EditorGroupModel.clone
func (*Model) CloseEditor ¶
func (m *Model) CloseEditor(candidate EditorInput, context CloseContext, openNext bool) *CloseResult
CloseEditor removes an editor (or the one that matches it). When it was the active editor and openNext is set, another one becomes active: the most recently used, or the one at its right without FocusRecentEditorAfterClose. It gives nil when the model has no such editor.
func (*Model) Contains ¶
func (m *Model) Contains(candidate EditorInput) bool
Contains tells whether an editor matches the candidate.
func (*Model) ContainsStrict ¶
func (m *Model) ContainsStrict(candidate EditorInput) bool
ContainsStrict tells whether the very same input is in the model.
func (*Model) Dispose ¶
func (m *Model) Dispose()
Dispose stops following the inputs. It does not dispose the inputs.
func (*Model) EditorAt ¶
func (m *Model) EditorAt(index int) EditorInput
EditorAt gives the editor at an index, or nil when there is none.
func (*Model) Editors ¶
func (m *Model) Editors(order EditorsOrder, excludeSticky bool) []EditorInput
Editors lists the editors in an order. ExcludeSticky leaves the sticky ones out.
func (*Model) Find ¶
func (m *Model) Find(candidate EditorInput) (editor EditorInput, index int, ok bool)
Find gives the editor that matches the candidate, with its index.
func (*Model) IndexOf ¶
func (m *Model) IndexOf(candidate EditorInput) int
IndexOf is the index of an editor that matches the candidate, or -1.
func (*Model) IndexOfStrict ¶
func (m *Model) IndexOfStrict(candidate EditorInput) int
IndexOfStrict is IndexOf for the very same input only.
func (*Model) IsActive ¶
func (m *Model) IsActive(candidate EditorInput) bool
IsActive tells whether an editor (or one that matches it) is the active one.
func (*Model) IsFirst ¶
func (m *Model) IsFirst(candidate EditorInput) bool
IsFirst tells whether the candidate matches the first editor.
func (*Model) IsLast ¶
func (m *Model) IsLast(candidate EditorInput) bool
IsLast tells whether the candidate matches the last editor.
func (*Model) IsPinned ¶
func (m *Model) IsPinned(editor EditorInput) bool
IsPinned tells whether an editor is a regular editor, not the preview editor.
func (*Model) IsPinnedAt ¶
IsPinnedAt is IsPinned for the editor at an index.
func (*Model) IsSticky ¶
func (m *Model) IsSticky(editor EditorInput) bool
IsSticky tells whether an editor is sticky.
func (*Model) IsStickyAt ¶
IsStickyAt tells whether the editor at an index is sticky.
func (*Model) MoveEditor ¶
func (m *Model) MoveEditor(candidate EditorInput, toIndex int) EditorInput
MoveEditor moves an editor to an index (kept within the editors). Moving it into the sticky range makes it sticky, and out of it not sticky. It gives the editor, or nil when nothing moved.
func (*Model) OnChange ¶
func (m *Model) OnChange(fn func(ChangeEvent)) (unsubscribe func())
OnChange calls fn for every change of the model, and gives the function that stops the calls.
func (*Model) OpenEditor ¶
func (m *Model) OpenEditor(candidate EditorInput, opts OpenOptions) (editor EditorInput, isNew bool)
OpenEditor adds an editor, or finds the one that matches it. It gives the editor that is in the model (the existing one, when there is one) and whether it was added. An editor opened with no option is the preview editor and replaces the preview editor there is; opening an existing editor with Pinned pins it, and with Active activates it.
func (*Model) Pin ¶
func (m *Model) Pin(candidate EditorInput) EditorInput
Pin makes a preview editor a regular editor. It gives the editor of the model, or nil.
func (*Model) PreviewEditor ¶
func (m *Model) PreviewEditor() EditorInput
PreviewEditor is the preview editor, or nil when there is none.
func (*Model) Serialize ¶
func (m *Model) Serialize() SerializedModel
Serialize gives the state of the model to save. The editors that cannot be serialized are left out, and so are they from the most recently used order, the preview editor and the sticky editors.
func (*Model) SerializeWith ¶
func (m *Model) SerializeWith(state InputStateFunc) SerializedModel
SerializeWith is Serialize with the State of each input given by state.
func (*Model) SetActive ¶
func (m *Model) SetActive(candidate EditorInput) EditorInput
SetActive makes an editor the active one. It gives the editor of the model, or nil when the model has none that matches.
func (*Model) SetOptions ¶
SetOptions changes the settings the model follows.
func (*Model) Stick ¶
func (m *Model) Stick(candidate EditorInput) EditorInput
Stick pins an editor and moves it to the end of the sticky editors. It gives the editor of the model, or nil.
func (*Model) StickyCount ¶
StickyCount is the number of sticky editors.
func (*Model) Unpin ¶
func (m *Model) Unpin(candidate EditorInput) EditorInput
Unpin makes a regular editor the preview editor; the preview editor there was closes. It gives the editor of the model, or nil.
func (*Model) Unstick ¶
func (m *Model) Unstick(candidate EditorInput) EditorInput
Unstick moves a sticky editor to the start of the editors that are not sticky. It gives the editor of the model, or nil.
type MoveOptions ¶
type MoveOptions struct {
// Index is the place of the editor in the target group, when HasIndex is set.
Index int
HasIndex bool
// Inactive keeps the editor from becoming the active editor of the target group.
Inactive bool
// Sticky makes the editor sticky in the target group. A move keeps the sticky state the
// editor had; a copy never does.
Sticky bool
}
MoveOptions say how an editor moves or is copied to a group (VS Code's IEditorOpenOptions).
type MultiDiffInput ¶ added in v1.0.0
type MultiDiffInput struct {
BaseInput
// contains filtered or unexported fields
}
MultiDiffInput is the input of the multi-file diff editor (SPEC §10.30): the changes of many files in one scrolling editor. A set that an extension's provider makes is named by its Kind and Key, which is all that is saved with the window; a restored input has no items until the window has asked the provider (Loaded). A fixed set (no Kind) holds its items and is not saved. The input owns no document: the sections open and let go of theirs as they come near the viewport.
func NewFixedMultiDiffInput ¶ added in v1.0.0
func NewFixedMultiDiffInput(id, title string, items []MultiDiffItem) *MultiDiffInput
NewFixedMultiDiffInput makes the input of a fixed set; id tells it from the other fixed sets of the window.
func NewMultiDiffInput ¶ added in v1.0.0
func NewMultiDiffInput(kind, key, title string) *MultiDiffInput
NewMultiDiffInput makes the input of the set of a provider: it has no items until SetItems.
func ParseMultiDiffInput ¶ added in v1.0.0
func ParseMultiDiffInput(value string) (*MultiDiffInput, error)
ParseMultiDiffInput makes the input of a saved set again from the value Serialize gave. The error has the tag MultiDiffInputInvalid.
func (*MultiDiffInput) Capabilities ¶ added in v1.0.0
func (m *MultiDiffInput) Capabilities() Capabilities
Capabilities implements EditorInput: the editor is shown in one group (it cannot be split).
func (*MultiDiffInput) Description ¶ added in v1.0.0
func (m *MultiDiffInput) Description() string
Description implements EditorInput.
func (*MultiDiffInput) Dirty ¶ added in v1.0.0
func (m *MultiDiffInput) Dirty() bool
Dirty implements EditorInput: the editor changes nothing.
func (*MultiDiffInput) Failure ¶ added in v1.0.0
func (m *MultiDiffInput) Failure() string
Failure is the message of the provider's last failure, empty after an answer.
func (*MultiDiffInput) Fixed ¶ added in v1.0.0
func (m *MultiDiffInput) Fixed() bool
Fixed tells whether the set is a fixed list that no provider makes (and that is not saved).
func (*MultiDiffInput) Items ¶ added in v1.0.0
func (m *MultiDiffInput) Items() []MultiDiffItem
Items are the files of the set, as the provider made them last; none before the first answer.
func (*MultiDiffInput) Key ¶ added in v1.0.0
func (m *MultiDiffInput) Key() string
Key is the key of the set among the sets of its kind.
func (*MultiDiffInput) Kind ¶ added in v1.0.0
func (m *MultiDiffInput) Kind() string
Kind and Key name the set of a provider; both are empty for a fixed set.
func (*MultiDiffInput) Loaded ¶ added in v1.0.0
func (m *MultiDiffInput) Loaded() bool
Loaded tells whether the provider has answered at least once (a fixed set always has).
func (*MultiDiffInput) Matches ¶ added in v1.0.0
func (m *MultiDiffInput) Matches(other EditorInput) bool
Matches implements EditorInput: the same set of the same kind, or the same fixed set.
func (*MultiDiffInput) Name ¶ added in v1.0.0
func (m *MultiDiffInput) Name() string
Name implements EditorInput: the title and the number of files ("Git: Changes (3 files)").
func (*MultiDiffInput) Resource ¶ added in v1.0.0
func (m *MultiDiffInput) Resource() (document.URI, bool)
Resource implements EditorInput: the editor shows no one resource.
func (*MultiDiffInput) Serialize ¶ added in v1.0.0
func (m *MultiDiffInput) Serialize() (string, bool)
Serialize implements EditorInput: the kind, the key and the title; a fixed set is not saved.
func (*MultiDiffInput) SetFailure ¶ added in v1.0.0
func (m *MultiDiffInput) SetFailure(message string)
SetFailure records that the provider could not make the files; the editor shows the message.
func (*MultiDiffInput) SetItems ¶ added in v1.0.0
func (m *MultiDiffInput) SetItems(items []MultiDiffItem)
SetItems gives the input the files the provider made. The tab shows their number.
func (*MultiDiffInput) SetTitle ¶ added in v1.0.0
func (m *MultiDiffInput) SetTitle(title string)
SetTitle sets the title of the opener's.
func (*MultiDiffInput) TabKey ¶ added in v1.0.0
func (m *MultiDiffInput) TabKey() string
TabKey implements TabKeyed: the set, so that two sets with the same title are two tabs.
func (*MultiDiffInput) Title ¶ added in v1.0.0
func (m *MultiDiffInput) Title() string
Title implements EditorInput: the title without the count.
func (*MultiDiffInput) TypeID ¶ added in v1.0.0
func (m *MultiDiffInput) TypeID() string
TypeID implements EditorInput.
type MultiDiffItem ¶ added in v1.0.0
type MultiDiffItem struct {
// Original and Modified are the URIs of the two documents; an empty one is a file that does not exist on that side.
Original, Modified string
// Path is the path of the file for the header, with slashes: the last element is the name and the rest the folder.
Path string
// File is the file URI that gives the header its icon and decorations and that Open File shows; empty for none.
File string
// Letter, Color and Tooltip are the mark of the status at the end of the header.
Letter, Color, Tooltip string
// Context holds the context keys of the file's actions, and Args is what their commands run with.
Context map[string]any
Args any
}
MultiDiffItem is one file of a multi-file diff editor (SPEC §10.30 "Diffs of changes"): its two documents and what the header of its section shows. It is plain data; the window turns it into a section.
func (MultiDiffItem) Key ¶ added in v1.0.0
func (m MultiDiffItem) Key() string
Key identifies the item among the items of an editor: a section keeps its collapsed mark and its measured height while the same key comes back after the set was asked for again.
type NavLocation ¶
type NavLocation struct {
GroupID int
// Resource is the file of the editor, when HasResource is set.
Input EditorInput
Selection *NavSelection
}
NavLocation is a place in an editor: the entry of a navigation stack. An editor with a file is remembered by the file, so that a location of a closed editor opens the file again; an editor with no file is kept as it is and goes away when it is disposed.
func NavLocationOf ¶
func NavLocationOf(groupID int, input EditorInput, sel *NavSelection) NavLocation
NavLocationOf makes the location of an editor of a group.
type NavSelection ¶
type NavSelection struct {
NavSelection is the selection of a text editor as the history remembers it.
func (NavSelection) Compare ¶
func (s NavSelection) Compare(other NavSelection) SelectionCompare
Compare says how far apart two selections are, counting the first line of each (VS Code's TextEditorPaneSelection.compare): the same line is identical, less than SelectionThreshold lines apart is similar.
type NavState ¶
type NavState struct {
NavState tells what the history can do now; the window sets the context keys canNavigateBack, canNavigateForward, canNavigateBackInNavigationLocations, canNavigateForwardInNavigationLocations, canNavigateToLastNavigationLocation, canNavigateBackInEditLocations, canNavigateForwardInEditLocations, canNavigateToLastEditLocation and canReopenClosedEditor from it.
type NavigationScope ¶
type NavigationScope string
NavigationScope is workbench.editor.navigationScope: how far one history of locations reaches.
const ( // ScopeDefault is one history for the window. ScopeDefault NavigationScope = "default" // ScopeEditorGroup is one history for each group. ScopeEditorGroup NavigationScope = "editorGroup" // ScopeEditor is one history for each editor of a group. ScopeEditor NavigationScope = "editor" )
The values of workbench.editor.navigationScope.
type Node ¶
type Node struct {
// Size is the share of the extent of the parent split that the node takes (the root has 1).
Size float64
// Group is the group of a leaf; nil for a split.
Group *Group
// Orientation is the axis the children of a split lie along.
Orientation Orientation
// Children are the nodes of a split.
Children []Node
}
Node is a node of the tree of splits as a value, for the view that shows the grid.
type OpenOptions ¶
type OpenOptions struct {
// Pinned opens the editor as a regular editor; without it the editor is the preview editor,
// which the next preview open replaces.
Pinned bool
// Sticky also pins the editor and puts it among the sticky editors, at the left (VS Code's
// "pinned" tabs, the ones with the pin icon).
Sticky bool
// Active makes the editor the active one. The first editor of a group is always active, and so
// is one that replaces an active preview editor.
Active bool
// Index is the place of the editor, when HasIndex is set.
Index int
HasIndex bool
}
OpenOptions say how an editor is opened (VS Code's IEditorOpenOptions).
type OpenPositioning ¶
type OpenPositioning string
OpenPositioning says where a new editor goes (`workbench.editor.openPositioning`).
const ( // PositionRight puts the editor right of the active one. PositionRight OpenPositioning = "right" // PositionLeft puts it left of the active one. PositionLeft OpenPositioning = "left" // PositionFirst puts it first. PositionFirst OpenPositioning = "first" // PositionLast puts it last. PositionLast OpenPositioning = "last" )
The values of `workbench.editor.openPositioning`.
type Opener ¶
type Opener interface {
// OpenLocation shows a location: it activates the editor in the group of the location (the group is the
// active group when it is gone), opens the file when the editor is closed, and puts the cursor where the
// location says. It must call done once the editor is shown, which may be later when the file has to be
// read: the history ignores the changes that showing the location causes until then.
OpenLocation(loc NavLocation, done func())
// ActivePane is the active editor of the active group.
ActivePane() Pane
}
Opener is what the history needs of the window to show a location.
type Options ¶
type Options struct {
// OpenPositioning is `workbench.editor.openPositioning`; empty is PositionRight.
OpenPositioning OpenPositioning
// FocusRecentEditorAfterClose is `workbench.editor.focusRecentEditorAfterClose`: closing the
// active editor activates the most recently used one, else the one at its right.
FocusRecentEditorAfterClose bool
}
Options are the settings a Model follows.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions are VS Code's defaults of the settings the model follows.
type Orientation ¶
type Orientation int
Orientation is the axis along which the children of a split lie.
const ( // Horizontal puts the children side by side (VS Code's GroupOrientation.HORIZONTAL, 0): the // sashes between them are vertical lines. Horizontal Orientation = iota // Vertical stacks the children from top to bottom (GroupOrientation.VERTICAL, 1). Vertical )
type Pane ¶
type Pane struct {
// GroupID is the group.
GroupID int
// Input is the active editor of the group; nil when the group is empty.
Input EditorInput
// SelectionAware tells that the editor has a selection (a text editor does).
SelectionAware bool
// Selection is the selection of the editor, nil when it has none.
Selection *NavSelection
}
Pane is the editor that is shown in a group, as the history sees it.
type RecentStack ¶
type RecentStack struct {
// contains filtered or unexported fields
}
RecentStack is the list that Open Next Recently Used Editor and Open Previous Recently Used Editor walk: the editors in the order they were used, taken when the walk starts and kept while it goes on, with the place in it. Any other change of the order of use ends the walk (Reset), as VS Code's history service does unless the walk itself caused it (Navigating).
func (*RecentStack) Reset ¶
func (r *RecentStack) Reset()
Reset ends the walk: the next step takes the list again. It does nothing while the walk activates an editor.
func (*RecentStack) SetNavigating ¶
func (r *RecentStack) SetNavigating(on bool)
SetNavigating says that the walk is activating an editor.
func (*RecentStack) Step ¶
func (r *RecentStack) Step(fresh func() []Ref, delta int) (Ref, bool)
Step moves the place by delta (the next editor is -1, the previous one +1) in the list that fresh gives when no walk is on, keeping it inside the list, and gives the editor there; false when the list is empty.
type SelectionCompare ¶
type SelectionCompare int
SelectionCompare is the result of comparing two selections (VS Code's EditorPaneSelectionCompareResult).
const ( // SelectionIdentical is two selections on the same line. SelectionIdentical SelectionCompare = iota // SelectionSimilar is two selections that are near each other: less than SelectionThreshold lines apart. SelectionSimilar // SelectionDifferent is two selections that are far apart. SelectionDifferent )
The results of Compare.
type SelectionReason ¶
type SelectionReason int
SelectionReason says why the selection of an editor changed (VS Code's EditorPaneSelectionChangeReason).
const ( // ReasonNone is no reason: the active editor changed. ReasonNone SelectionReason = iota // ReasonProgrammatic is a change by code: a selection restored from a saved view, for example. ReasonProgrammatic // ReasonUser is a change by the user with the mouse or the keyboard. ReasonUser // ReasonEdit is a change made by editing. ReasonEdit ReasonNavigation // ReasonJump is a change by a jump from inside the editor: go to line, go to definition. A jump always // has a source and a target, so the place it came from is a navigation location too. ReasonJump )
The reasons a selection changes.
type SerializedGrid ¶
type SerializedGrid struct {
// Orientation is the axis of Root.
Orientation Orientation `json:"orientation"`
// Root are the children of the root split.
Root []SerializedNode `json:"root"`
// Active is the id of the active group, MRU the ids of the groups from the most recently
// active.
Active int `json:"active"`
MRU []int `json:"mru"`
// Maximized is the id of the maximized group, or 0.
Maximized int `json:"maximized,omitempty"`
// NextID is the id the next group gets.
NextID int `json:"nextId"`
}
SerializedGrid is a Grid in the saved state of a window (step 7.5): VS Code's ISerializedGrid with the state of the editor part.
type SerializedInput ¶
type SerializedInput struct {
// TypeID is the TypeID of the input; Value is what its Serialize gave.
TypeID string `json:"id"`
Value string `json:"value"`
// State is what the window keeps of the editor of the input besides the input: its view state (the
// cursors, the scroll position and the folds). The model does not look into it.
State json.RawMessage `json:"state,omitempty"`
}
SerializedInput is an editor input in the saved state of a window (step 7.5).
type SerializedModel ¶
type SerializedModel struct {
ID int `json:"id"`
Editors []SerializedInput `json:"editors"`
// MRU is the most recently used order, as indexes into Editors.
MRU []int `json:"mru"`
// Preview is the index of the preview editor in Editors.
Preview *int `json:"preview,omitempty"`
// Sticky is the index in Editors of the last sticky editor.
Sticky *int `json:"sticky,omitempty"`
}
SerializedModel is a Model in the saved state of a window: VS Code's ISerializedEditorGroupModel without the lock.
type SerializedNode ¶
type SerializedNode struct {
// Size is the share of the node among its siblings.
Size float64 `json:"size"`
// Groups are the nodes of a split.
Groups []SerializedNode `json:"groups,omitempty"`
// Model is the group, for a leaf.
Model *SerializedModel `json:"model,omitempty"`
}
SerializedNode is a node of a SerializedGrid: a group with its editors, or a split.
type SettingsInput ¶
type SettingsInput struct {
BaseInput
// contains filtered or unexported fields
}
SettingsInput is the input of the settings editor (SPEC §11.1): it shows no resource and holds no content, so it is never dirty and closing it never asks. There is one per group (it is a singleton as VS Code's settings editor input is: opening it again reveals the one that is open). The editor writes its view state into the input, and Serialize keeps it for the state of the window (step 7.5).
func NewSettingsInput ¶
func NewSettingsInput(state SettingsViewState) *SettingsInput
NewSettingsInput makes the input of a settings editor with a view state.
func ParseSettingsInput ¶
func ParseSettingsInput(value string) (*SettingsInput, error)
ParseSettingsInput makes the input again from what Serialize gave. A text that is not the state of an input fails with the tag SettingsInputInvalid.
func (*SettingsInput) Capabilities ¶
func (s *SettingsInput) Capabilities() Capabilities
Capabilities implements EditorInput: none (it cannot be split, saved or reverted).
func (*SettingsInput) Description ¶
func (s *SettingsInput) Description() string
Description implements EditorInput.
func (*SettingsInput) Dirty ¶
func (s *SettingsInput) Dirty() bool
Dirty implements EditorInput: the editor writes the settings as they change, there is nothing to save.
func (*SettingsInput) Matches ¶
func (s *SettingsInput) Matches(other EditorInput) bool
Matches implements EditorInput: any settings input is the same editor.
func (*SettingsInput) Resource ¶
func (s *SettingsInput) Resource() (document.URI, bool)
Resource implements EditorInput: the settings editor shows no resource.
func (*SettingsInput) Serialize ¶
func (s *SettingsInput) Serialize() (string, bool)
Serialize implements EditorInput: the view state as JSON.
func (*SettingsInput) SetViewState ¶
func (s *SettingsInput) SetViewState(st SettingsViewState)
SetViewState replaces the state of the view; the editor calls it when the user changes the tab, the category or the scroll position.
func (*SettingsInput) TypeID ¶
func (s *SettingsInput) TypeID() string
TypeID implements EditorInput.
func (*SettingsInput) ViewState ¶
func (s *SettingsInput) ViewState() SettingsViewState
ViewState is the state of the view the input keeps.
type SettingsTarget ¶
type SettingsTarget string
SettingsTarget names the tab of the settings editor: the user's settings or the workspace's.
const ( // SettingsUser is the User tab. SettingsUser SettingsTarget = "user" // SettingsWorkspace is the Workspace tab. SettingsWorkspace SettingsTarget = "workspace" )
The tabs of the settings editor.
type SettingsViewState ¶
type SettingsViewState struct {
// Target is the tab; the User tab when empty.
Target SettingsTarget `json:"target,omitempty"`
// Category is the id of the selected group of the tree ("editor/font"); the first group when empty.
Category string `json:"category,omitempty"`
// Scroll is how far the list of settings is scrolled, in pixels.
Scroll float64 `json:"scroll,omitempty"`
// Query is the text of the search box (step 8.2 fills it from the arguments of the command).
Query string `json:"query,omitempty"`
}
SettingsViewState is what a settings editor remembers of its view, and what Serialize keeps of the input: the tab, the group of the category tree that is selected and how far the list is scrolled.
type Span ¶
type Span struct {
// Start and End are the left and right edges, in the same coordinates as the pointer.
Start, End float64
}
Span is the extent of a tab along the tab strip.
type SplitSizing ¶
type SplitSizing string
SplitSizing is `workbench.editor.splitSizing`: how the groups are sized when a group is added or removed.
const ( // SizingAuto splits the group to equal parts, unless all the groups of the split are of equal // size already; then all are made equal. SizingAuto SplitSizing = "auto" // SizingDistribute makes all the groups of the split equal. SizingDistribute SplitSizing = "distribute" // SizingSplit splits the group that the new one is added next to to equal parts. SizingSplit SplitSizing = "split" )
type SystemCheckInput ¶
type SystemCheckInput struct {
BaseInput
}
SystemCheckInput is the input of the page "System Check" (SPEC §10.36 "The Check System page", step 34.5): like the Extensions page it shows no resource and holds no content, so it is never dirty and closing it never asks, and opening it again reveals the one that is open. The results it shows belong to the window, so Serialize has nothing to keep and the state of the window only records that the page was open.
func NewSystemCheckInput ¶
func NewSystemCheckInput() *SystemCheckInput
NewSystemCheckInput makes the input of a System Check page.
func ParseSystemCheckInput ¶
func ParseSystemCheckInput(value string) (*SystemCheckInput, error)
ParseSystemCheckInput reads what Serialize wrote: a JSON object (its fields are ignored, so a later version may add some). Anything else is SystemCheckInputInvalid.
func (*SystemCheckInput) Capabilities ¶
func (e *SystemCheckInput) Capabilities() Capabilities
Capabilities implements EditorInput: none (it cannot be split, saved or reverted).
func (*SystemCheckInput) Description ¶
func (e *SystemCheckInput) Description() string
Description implements EditorInput.
func (*SystemCheckInput) Dirty ¶
func (e *SystemCheckInput) Dirty() bool
Dirty implements EditorInput: the page is never dirty.
func (*SystemCheckInput) Matches ¶
func (e *SystemCheckInput) Matches(other EditorInput) bool
Matches implements EditorInput: any System Check input is the same page.
func (*SystemCheckInput) Name ¶
func (e *SystemCheckInput) Name() string
Name implements EditorInput.
func (*SystemCheckInput) Resource ¶
func (e *SystemCheckInput) Resource() (document.URI, bool)
Resource implements EditorInput: the page shows no resource.
func (*SystemCheckInput) Serialize ¶
func (e *SystemCheckInput) Serialize() (string, bool)
Serialize implements EditorInput: an empty object, which ParseSystemCheckInput accepts.
func (*SystemCheckInput) Title ¶
func (e *SystemCheckInput) Title() string
Title implements EditorInput.
func (*SystemCheckInput) TypeID ¶
func (e *SystemCheckInput) TypeID() string
TypeID implements EditorInput.
type TabKeyed ¶
type TabKeyed interface {
TabKey() string
}
TabKeyed is implemented by an input that shows no resource but needs a tab key of its own: two diff editors with the same name are two tabs.
type TabLabel ¶
type TabLabel struct {
// Name is the name of the editor.
Name string
// Description is the dimmer text after the name; it is empty unless another editor has the
// same name.
Description string
// Title is the text of the tooltip.
Title string
}
TabLabel is what a tab shows of an editor.
func TabLabels ¶
func TabLabels(editors []EditorInput) []TabLabel
TabLabels gives the labels of editors, in the order of the editors. An editor that shares its name with another gets a description, the shortest part of its folder that tells it from the others (VS Code's `workbench.editor.labelFormat` "default").
Ported from VS Code: src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts (computeTabLabels)
type Target ¶
type Target string
Target says where editors go for MoveOrCopyTarget: the "to" of VS Code's moveActiveEditor and copyActiveEditor.
const ( TargetLeft Target = "left" TargetRight Target = "right" TargetUp Target = "up" TargetDown Target = "down" TargetFirst Target = "first" TargetLast Target = "last" TargetPrevious Target = "previous" TargetNext Target = "next" TargetCenter Target = "center" TargetPosition Target = "position" )
The values of Target.
type TextInput ¶
type TextInput struct {
BaseInput
// contains filtered or unexported fields
}
TextInput is the input of a text editor: a document. Documents are shared (the same file shown in two groups is one document with two inputs, each with the view state of its own, which the window keeps), so the input does not own the document: whoever opens it releases it.
func NewTextInput ¶
func NewTextInput(doc *document.Document, opts TextInputOpts) *TextInput
NewTextInput makes the input of a document. It follows the document's dirty mark until Dispose.
func (*TextInput) Capabilities ¶
func (t *TextInput) Capabilities() Capabilities
Capabilities implements EditorInput.
func (*TextInput) CopyInput ¶
func (t *TextInput) CopyInput() EditorInput
CopyInput implements Copier: another input for the same document, with the same options.
func (*TextInput) Deleted ¶
Deleted implements DeletedState: the file of the document was deleted by another program.
func (*TextInput) Description ¶
Description implements EditorInput: the folder of the file, relative to the folder of the window when it is below it, else with the home folder written "~". It is empty for a document that has no file.
func (*TextInput) Dispose ¶
func (t *TextInput) Dispose()
Dispose implements EditorInput: it stops following the document.
func (*TextInput) EditedDocument ¶
EditedDocument implements DocumentEditor.
func (*TextInput) Matches ¶
func (t *TextInput) Matches(other EditorInput) bool
Matches implements EditorInput: another text input of the same document.
func (*TextInput) Name ¶
Name implements EditorInput: the name of the file, Untitled-n, or the label of a virtual document ("Default Settings"), or the name an opener gave the input (SetName).
func (*TextInput) Refresh ¶
func (t *TextInput) Refresh()
Refresh sends an event when the dirty mark of the document is not the one the input last had. The input calls it after every change of the document and after every save, which changes no text.
func (*TextInput) Serialize ¶
Serialize implements EditorInput: the URI of a file, of an untitled document ("untitled:3"), which the backup of the document (hot exit, SPEC §10.10) is named by, or of a virtual document, which comes back when a provider still makes it (SPEC §7.1).
func (*TextInput) SetName ¶ added in v1.0.0
SetName gives the tab a name of the opener's in place of the document's ("loader.go (HEAD)" for the HEAD version of a file, VS Code's title argument of vscode.open). It is not saved with the window. Call it before the input is shown.
type TextInputOpts ¶
type TextInputOpts struct {
// Folder is the folder open in the window; the description of a file below it is its folder
// relative to it, and a file elsewhere is described by its folder.
Folder string
// Home is the home folder of the user, which a description writes as "~".
Home string
}
TextInputOpts are the options of NewTextInput.
type Unsaved ¶
type Unsaved struct {
// Group is the group of the first of the editors that show the changes.
Group *Group
// Input is that editor.
Input EditorInput
}
Unsaved is a dirty editor whose changes would be lost by a close.
func PlanClose ¶
func PlanClose(grid *Grid, targets []CloseTarget) []Unsaved
PlanClose lists what a close would lose: the editors among the targets that have unsaved changes and whose changes no editor that stays open shows. A document that is open in two editors is lost when the last of them closes, so it is listed once, for the first editor of the targets (in the order of the targets) and not at all while an editor of it stays in any group of the grid. An editor that is not in its group any more is left out. Nothing is changed.
Ported from VS Code: src/vs/workbench/browser/parts/editor/editorGroupView.ts (doHandleCloseConfirmation)
type ZoneOptions ¶
type ZoneOptions struct {
// Split lets the sides split the group (`workbench.editor.splitOnDragAndDrop`); without it the
// whole area is the center.
Split bool
// PreferVertical gives the sides left and right the larger zones (`openSideBySideDirection` is
// "right"); otherwise up and down have them.
PreferVertical bool
}
ZoneOptions say how the editor area is divided into zones.
Source Files
¶
- closed.go
- closeplan.go
- diffinput.go
- doc.go
- droptarget.go
- eventsharinginput.go
- extensionsinput.go
- exttabinput.go
- fileeditorinput.go
- grid.go
- grid_editors.go
- grid_state.go
- history.go
- input.go
- keybindingsinput.go
- labels.go
- mergeinput.go
- model.go
- multidiffinput.go
- navstack.go
- serialize.go
- settingsinput.go
- systemcheckinput.go
- textinput.go