Documentation
¶
Overview ¶
Package workbench holds the workbench: layout parts, editor group views, the title bar row (the menu and the workspace tabs), the activity bar and the status bar (SPEC §10).
So far it has the layout (SPEC §10.1): Layout is the model of which parts are shown, how large the side bar and the panel are and where they are, and Workbench is the widget that lays the parts out with kit.SplitView, binds the commands that show, hide, move and focus them, and sets their context keys. TitleInput makes the title of the window from window.title.
Ported from VS Code: src/vs/workbench/browser/layout.ts, src/vs/workbench/browser/parts/ and src/vs/workbench/browser/parts/titlebar/windowTitle.ts
Index ¶
- Constants
- Variables
- func ActivityItemKey(containerID string) foundation.Key
- func BannersKey() foundation.Key
- func BellPriority() float64
- func CharacterCount(text buffer.Snapshot, s buffer.Selection, eol fileio.LineEnding) int
- func EOLLabel(le fileio.LineEnding) string
- func EncodingLabel(id string) string
- func ExpandTemplate(template string, values map[string]string, separator string) string
- func IndentationLabel(tabSize int, insertSpaces bool) string
- func PanelBadgeKey(id string) foundation.Key
- func PartKey(p Part) foundation.Key
- func ProblemsText(c ProblemCounts) string
- func ProblemsTooltip(c ProblemCounts) string
- func SelectionLabel(selections, line, column, characters int) string
- func SelectionStatus(text buffer.Snapshot, selections []buffer.Selection, primary buffer.Selection, ...) string
- func StatusItemKey(id string) foundation.Key
- func ViewHeaderKey(viewID string) foundation.Key
- type ActivityBadge
- type ActivityIcons
- type Banner
- type BannerAction
- type Banners
- type Bell
- type BellState
- type Layout
- func (l *Layout) CenteredLayout() bool
- func (l *Layout) EnterZen(hideActivityBar, hideStatusBar bool)
- func (l *Layout) ExitZen() ZenState
- func (l *Layout) FollowSettings(s *settings.Store, post func(func())) (stop func())
- func (l *Layout) OnChange(fn func()) (unsubscribe func())
- func (l *Layout) PanelMaximized() bool
- func (l *Layout) PanelSize() float64
- func (l *Layout) Restore(state LayoutState)
- func (l *Layout) SetActivityBarVisible(v bool)
- func (l *Layout) SetCenteredLayout(v bool)
- func (l *Layout) SetPanelOpensMaximized(v PanelOpensMaximized)
- func (l *Layout) SetPanelPosition(p PanelPosition)
- func (l *Layout) SetPanelSize(size float64)
- func (l *Layout) SetPanelVisible(v bool)
- func (l *Layout) SetSideBarPosition(p SideBarPosition)
- func (l *Layout) SetSideBarVisible(v bool)
- func (l *Layout) SetSideBarWidth(w float64)
- func (l *Layout) SetStatusBarVisible(v bool)
- func (l *Layout) SetZenTransitions(fullScreen, centered, doNotDisturb bool)
- func (l *Layout) State() LayoutState
- func (l *Layout) ToggleMaximizedPanel()
- func (l *Layout) TogglePanel()
- func (l *Layout) ToggleSideBar()
- func (l *Layout) UpdateZen(hideActivityBar, hideStatusBar bool)
- func (l *Layout) Visible(p Part) bool
- func (l *Layout) ZenActive() bool
- type LayoutState
- type ManageButton
- type ManageController
- type MenuSource
- func (m *MenuSource) BarIndex(menu string) int
- func (m *MenuSource) BarMenus() []kit.MenuBarMenu
- func (m *MenuSource) Items(menu string, ctx contextkey.Context) []kit.MenuItem
- func (m *MenuSource) ItemsWithout(menu string, ctx contextkey.Context, drop func(command.MenuEntry) bool) []kit.MenuItem
- func (m *MenuSource) ManageItems() []kit.MenuItem
- func (m *MenuSource) Run(item kit.MenuItem)
- type MenuSourceOptions
- type NewMenuController
- type NotificationsHost
- type NotificationsOptions
- type Options
- type PanelOpensMaximized
- type PanelPosition
- type PanelTab
- type Part
- type ProblemCounts
- type SideBarPosition
- type SideBarViews
- type SideBarViewsOpts
- type StatusAccessor
- type StatusAlignment
- type StatusBar
- func (b *StatusBar) Add(id string, alignment StatusAlignment, priority float64, entry StatusEntry) *StatusAccessor
- func (b *StatusBar) Get(id string) (StatusItem, bool)
- func (b *StatusBar) Inherit(parent *StatusBar, keep func(id string) bool)
- func (b *StatusBar) Items(alignment StatusAlignment) []StatusItem
- func (b *StatusBar) OnChange(fn func()) (remove func())
- type StatusBarOptions
- type StatusEntry
- type StatusItem
- type StatusKind
- type StatusTextRun
- type TabLabel
- type TitleBarOptions
- type TitleInput
- type Views
- func (v *Views) Active() string
- func (v *Views) ActiveContainer() (command.ViewContainer, bool)
- func (v *Views) ActivePanel() string
- func (v *Views) Badge(container string) (ActivityBadge, bool)
- func (v *Views) Changed()
- func (v *Views) ClosePanel(id string) (hidden bool)
- func (v *Views) IsCollapsed(viewID string) bool
- func (v *Views) IsHidden(viewID string) bool
- func (v *Views) OnChange(fn func()) (unsubscribe func())
- func (v *Views) Open(id string)
- func (v *Views) OpenPanel(id string)
- func (v *Views) Registry() *command.ViewRegistry
- func (v *Views) SetBadge(container string, b ActivityBadge)
- func (v *Views) SetCollapsed(viewID string, collapsed bool)
- func (v *Views) SetHidden(viewID string, hidden bool)
- func (v *Views) Toggle(id string)
- func (v *Views) TogglePanel(id string) (shown bool)
- type Workbench
- type WorkspaceTab
- type ZenState
Constants ¶
const ( // ActivityBarWidth is the width of the activity bar, which has no other. ActivityBarWidth = 48.0 // SideBarDefaultWidth and SideBarMinWidth are the width the side bar starts with and the least it // can have. SideBarDefaultWidth = 300.0 SideBarMinWidth = 170.0 // PanelDefaultSize is the height of a panel above or below the editors, or the width of a panel // beside them, when nothing else was set. PanelMinHeight and PanelMinWidth are the least each can be. PanelDefaultSize = 300.0 PanelMinHeight = 77.0 PanelMinWidth = 300.0 // EditorMinWidth and EditorMinHeight are the least size of the editor area. EditorMinWidth = 220.0 EditorMinHeight = 70.0 // StatusBarHeight is the height of the status bar. StatusBarHeight = 22.0 // MenuBarHeight is the height of the row of its own that holds the menu in full screen mode (the title bar row, // TitleBarHeight, holds it otherwise). MenuBarHeight = 30.0 // PartTitleHeight is the height of the title of the side bar and of the panel. PartTitleHeight = 35.0 )
The sizes of the parts, in logical pixels: VS Code's.
Ported from VS Code: src/vs/workbench/browser/parts/{activitybar/activitybarPart.ts, sidebar/sidebarPart.ts, panel/panelPart.ts, statusbar/statusbarPart.ts, editor/editorPart.ts}, src/vs/workbench/browser/layout.ts (LayoutStateKeys)
const BannerHeight = 34.0
BannerHeight is the height of one banner.
const NoFolderTabName = "No Folder"
NoFolderTabName is the name of the tab of a workspace that has no folder.
const TitleBarHeight = kit.TabHeight
TitleBarHeight is the height of the title bar row.
const TitleDirty = "● "
TitleDirty is the indicator `${dirty}` stands for when the active editor has unsaved changes.
const ViewHeaderHeight = 22.0
ViewHeaderHeight is the height of the header of a view in the side bar.
Ported from VS Code: src/vs/base/browser/ui/splitview/paneview.ts (Pane.HEADER_SIZE)
Variables ¶
var ManageKey = foundation.NewValueKey("workbench:manage")
ManageKey is the key of the Manage button, which a test finds it by.
var PanelOverflowKey = foundation.NewValueKey("workbench:panel-overflow")
PanelOverflowKey is the key of the "..." button of the title strip of the panel, which a test finds it by.
Functions ¶
func ActivityItemKey ¶
func ActivityItemKey(containerID string) foundation.Key
ActivityItemKey is the key of the icon of a view container in the activity bar.
func BannersKey ¶ added in v1.0.0
func BannersKey() foundation.Key
BannersKey is the key of the column that holds the banners; it is in the tree only while there is a banner.
func BellPriority ¶
func BellPriority() float64
BellPriority is the priority of the bell: the last item on the right side (VS Code uses negative infinity).
func CharacterCount ¶
CharacterCount is the number of characters in a selection, as VS Code counts them: every code point is one and every line break is the length of the line ending of the document (VS Code's getCharacterCountInRange).
func EOLLabel ¶
func EOLLabel(le fileio.LineEnding) string
EOLLabel is the text of the "Editor End of Line" item: CRLF or LF.
func EncodingLabel ¶
EncodingLabel is the text of the "Editor Encoding" item: the short label of the encoding ("UTF-8", "Windows 1252"), or the id itself for an encoding that has none.
func ExpandTemplate ¶
ExpandTemplate fills the `${name}` variables of a template with values, and `${separator}` with the separator where there is text on both sides of it (and not twice in a row). A name without a value is left out. It is VS Code's `template`.
Ported from VS Code: src/vs/base/common/labels.ts (template)
func IndentationLabel ¶
IndentationLabel is the text of the "Editor Indentation" item: "Spaces: 4" for a document that indents with spaces and "Tab Size: 4" for one that indents with tabs. (VS Code adds the tab size in brackets when its indent size is another; Emetos has one size for both.)
func PanelBadgeKey ¶
func PanelBadgeKey(id string) foundation.Key
PanelBadgeKey is the key of the count after the title of a tab of the panel, which a test finds it by.
func PartKey ¶
func PartKey(p Part) foundation.Key
PartKey is the key of the widget of a part, which a test finds it by. The widget of a part that is hidden is off stage.
func ProblemsText ¶
func ProblemsText(c ProblemCounts) string
ProblemsText is the text of the Problems item: the errors and the warnings, and the infos when there are any.
Ported from VS Code: src/vs/workbench/contrib/markers/browser/markers.contribution.ts (MarkersStatusBarContributions)
func ProblemsTooltip ¶
func ProblemsTooltip(c ProblemCounts) string
ProblemsTooltip is the hover text of the Problems item: the counts that are not zero, or "No Problems".
func SelectionLabel ¶
SelectionLabel is the text of the "Editor Selection" item: the line and the column of the cursor, with the number of characters selected, or the number of selections for several cursors. It is empty without a cursor.
func SelectionStatus ¶
func SelectionStatus(text buffer.Snapshot, selections []buffer.Selection, primary buffer.Selection, tabSize int, eol fileio.LineEnding) string
SelectionStatus makes the text of the "Editor Selection" item for the selections of a text and its primary one. The column is the one the status bar shows (edit.StatusbarColumn: a tab goes to the next tab stop and every other code point is one column), and the characters are the code points of the selections, a line break counting as many as the line ending of the document has (two for CRLF).
func StatusItemKey ¶
func StatusItemKey(id string) foundation.Key
StatusItemKey is the key of the widget of an item of the status bar, which a test finds it by.
func ViewHeaderKey ¶
func ViewHeaderKey(viewID string) foundation.Key
ViewHeaderKey is the key of the header of a view, which a test finds it by.
Types ¶
type ActivityBadge ¶ added in v1.0.0
type ActivityBadge struct {
// Count is the number; a badge of 0 is not drawn.
Count int
// Tooltip is the text of the hover of the icon while the badge shows ("3 pending changes"); the title of the container when empty.
Tooltip string
}
ActivityBadge is the number on the icon of a view container in the activity bar (VS Code's NumberBadge of the activity service, SPEC §10.4): a pill with a count, and the text of its tooltip.
type ActivityIcons ¶
type ActivityIcons struct {
widgets.StatefulWidget
// contains filtered or unexported fields
}
ActivityIcons is the top of the activity bar: an icon for each view container of the side bar, in the order of the registry, with a tooltip of the container's title (SPEC §10.4). A click opens the container in the side bar, or hides the side bar when the container is open already. The icon of the container that the side bar shows is active; none is while the side bar is hidden.
Ported from VS Code: src/vs/workbench/browser/parts/activitybar/activitybarPart.ts and src/vs/workbench/browser/parts/compositeBar.ts
func NewActivityIcons ¶
func NewActivityIcons(views *Views, layout *Layout) *ActivityIcons
NewActivityIcons makes the icons of the view containers of views; layout is the layout of the window, whose side bar they show.
func (*ActivityIcons) CreateState ¶
func (a *ActivityIcons) CreateState() widgets.State
CreateState implements widgets.StatefulWidget.
type Banner ¶ added in v1.0.0
type Banner struct {
// Text is the message and Icon the name of the Codicon before it; empty for none.
Text, Icon string
// Actions are the buttons at the right end.
Actions []BannerAction
}
Banner is a bar across the top of the workbench, under the title bar: an icon, a line of text and buttons. The extensions show them for something that goes on in the window and that the user should always see and be able to end (SPEC §10.15, Remote Work's "connected" banner).
type BannerAction ¶ added in v1.0.0
type BannerAction struct {
// Label is the text of the button.
Label string
// Run is called on the UI thread when the button is pressed.
Run func()
}
BannerAction is a button of a banner.
type Banners ¶ added in v1.0.0
type Banners struct {
// contains filtered or unexported fields
}
Banners is the model of the banners of one window tab: the workbench shows them in the order they were added and follows the changes. It is safe for concurrent use; the listeners run on the goroutine that changed it.
func (*Banners) Add ¶ added in v1.0.0
Add shows a banner at the end of the list and returns the function that replaces it and the one that takes it away.
type Bell ¶
type Bell struct {
// contains filtered or unexported fields
}
Bell follows a notification presenter and keeps the item of the notifications bell up to date. It is used on the UI thread only.
func NewBell ¶
NewBell adds the bell to a status bar and makes it follow the presenter: a notification that is added while the center is closed is unread until the center opens, and one that is closed is no longer unread. post hands a function to the UI thread (the events of the service come from any goroutine); nil runs it at once.
func (*Bell) HandleEvent ¶
HandleEvent counts an event of the service: an added notification is unread while the center is closed, and a removed one is read.
type BellState ¶
type BellState struct {
// Total is the number of notifications there are.
Total int
// New is the number of unread notifications: those that came while the notification center was
// closed and that were not closed since.
New int
// InProgress is the number of notifications with a progress that runs, counted only while neither the
// toasts nor the center show (so that the bell still tells that something runs).
InProgress int
// CenterVisible is whether the notification center is open.
CenterVisible bool
// DoNotDisturb is whether the do not disturb mode is on.
DoNotDisturb bool
}
BellState is what the notifications bell of the status bar shows (SPEC §10.7).
func (BellState) Entry ¶
func (s BellState) Entry() StatusEntry
Entry is the item of the bell: $(bell), or $(bell-dot) with something unread or running, and the bell-slash ones in do not disturb mode. A click opens the center, or closes it when it is open.
Ported from VS Code: src/vs/workbench/browser/parts/notifications/notificationsStatus.ts
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout is the model of the layout of the workbench: which parts are shown, the sizes of the side bar and the panel, and where they are. The widgets show it and the commands change it; it has no widget. Its methods belong to the UI thread; State and Restore are how it is kept between runs (step 7.5 writes it).
func NewLayout ¶
func NewLayout(state LayoutState) *Layout
NewLayout makes a layout from a state (see Restore for what is made of a state that is not right).
func (*Layout) CenteredLayout ¶
CenteredLayout says whether the centered layout was asked for.
func (*Layout) EnterZen ¶
EnterZen turns zen mode on: it remembers which of the side bar, the panel, the activity bar and the status bar are shown, and hides the side bar and the panel always and the activity bar and the status bar when the arguments say so (zenMode.hideActivityBar, zenMode.hideStatusBar). It does nothing when zen mode is on already. The caller sets what else it did with SetZenTransitions.
Ported from VS Code: src/vs/workbench/browser/layout.ts (toggleZenMode)
func (*Layout) ExitZen ¶
ExitZen turns zen mode off and shows again what zen mode hid and the user has not changed since. It returns what zen mode had recorded (ZenState), for the caller to undo what is not the layout's. It does nothing, and returns the zero state, when zen mode is off.
Ported from VS Code: src/vs/workbench/browser/layout.ts (toggleZenMode)
func (*Layout) FollowSettings ¶
FollowSettings applies the settings that decide the layout now, and whenever they change: the position of the side bar, the visibility of the activity bar (workbench.activityBar.location) and of the status bar, and what showing the panel does to its maximized state. apply runs on the goroutine that changed the settings, so a caller that is not on the UI thread posts it. It returns the function that stops following.
func (*Layout) OnChange ¶
func (l *Layout) OnChange(fn func()) (unsubscribe func())
OnChange registers fn to be called, on the UI thread, after the layout changed. The returned function removes it.
func (*Layout) PanelMaximized ¶
PanelMaximized says whether the panel is shown and takes the place of the editor area.
func (*Layout) PanelSize ¶
PanelSize is the size of the panel along the axis it is laid out on: its height above or below the editors, its width beside them. While the panel is maximized it is the size it comes back to.
func (*Layout) Restore ¶
func (l *Layout) Restore(state LayoutState)
Restore replaces the layout by a state that was kept: positions it does not know become the defaults and sizes below the least become the least.
func (*Layout) SetActivityBarVisible ¶
SetActivityBarVisible shows or hides the activity bar.
func (*Layout) SetCenteredLayout ¶
SetCenteredLayout asks for the editor area to be centered between two margins, or not. Whether the margins show depends on the groups too (VS Code's workbench.editor.centeredLayoutAutoResize, which the shell applies).
func (*Layout) SetPanelOpensMaximized ¶
func (l *Layout) SetPanelOpensMaximized(v PanelOpensMaximized)
SetPanelOpensMaximized sets what showing the panel does to its maximized state (workbench.panel.opensMaximized).
func (*Layout) SetPanelPosition ¶
func (l *Layout) SetPanelPosition(p PanelPosition)
SetPanelPosition moves the panel (and shows it, as VS Code does). Ignored for a position that is not one of the four.
func (*Layout) SetPanelSize ¶
SetPanelSize records the size the panel has now along its axis (a drag of its sash). It is ignored while the panel is hidden or maximized, when its size is not its own.
func (*Layout) SetPanelVisible ¶
SetPanelVisible shows or hides the panel. Showing it brings back its maximized state, or sets it as workbench.panel.opensMaximized says.
func (*Layout) SetSideBarPosition ¶
func (l *Layout) SetSideBarPosition(p SideBarPosition)
SetSideBarPosition moves the side bar and the activity bar to a side.
func (*Layout) SetSideBarVisible ¶
SetSideBarVisible shows or hides the side bar.
func (*Layout) SetSideBarWidth ¶
SetSideBarWidth records the width the side bar has now (a drag of its sash); a width below the least is the least.
func (*Layout) SetStatusBarVisible ¶
SetStatusBarVisible shows or hides the status bar.
func (*Layout) SetZenTransitions ¶
SetZenTransitions records what the caller did when it turned zen mode on: went to full screen, turned the centered layout on, turned do not disturb on. Ending zen mode asks for them to be undone (ZenState).
func (*Layout) State ¶
func (l *Layout) State() LayoutState
State is the part of the layout that is kept.
func (*Layout) ToggleMaximizedPanel ¶
func (l *Layout) ToggleMaximizedPanel()
ToggleMaximizedPanel maximizes the panel, or brings it back to the size it had; a hidden panel is shown maximized (VS Code's workbench.action.toggleMaximizedPanel).
func (*Layout) TogglePanel ¶
func (l *Layout) TogglePanel()
TogglePanel shows the panel when it is hidden and hides it when it is shown.
func (*Layout) ToggleSideBar ¶
func (l *Layout) ToggleSideBar()
ToggleSideBar shows the side bar when it is hidden and hides it when it is shown.
func (*Layout) UpdateZen ¶
UpdateZen makes the activity bar and the status bar follow zenMode.hideActivityBar and zenMode.hideStatusBar while zen mode is on: a part that is to be hidden is hidden, and one that zen mode hid and is not to be any more comes back (a part the user changed is left as it is).
type LayoutState ¶
type LayoutState struct {
// SideBarVisible says whether the primary side bar is shown.
SideBarVisible bool `json:"sideBarVisible"`
// SideBarWidth is the width of the side bar when it is shown, and what it comes back to.
SideBarWidth float64 `json:"sideBarWidth"`
// SideBarPosition is the side of the window of the side bar and the activity bar.
SideBarPosition SideBarPosition `json:"sideBarPosition"`
// ActivityBarVisible says whether the activity bar is shown (workbench.activityBar.location is
// not hidden).
ActivityBarVisible bool `json:"activityBarVisible"`
// StatusBarVisible says whether the status bar is shown (workbench.statusBar.visible).
StatusBarVisible bool `json:"statusBarVisible"`
// PanelVisible says whether the panel is shown.
PanelVisible bool `json:"panelVisible"`
// PanelPosition is where the panel is.
PanelPosition PanelPosition `json:"panelPosition"`
// PanelHeight is the height of the panel when it is above or below the editors, and PanelWidth
// its width when it is at a side. Both are the sizes the panel has when it is not maximized,
// which it comes back to: the last non-maximized size.
PanelHeight float64 `json:"panelHeight"`
PanelWidth float64 `json:"panelWidth"`
// PanelMaximized says that the panel takes the place of the editor area while it is shown. It
// is kept while the panel is hidden, and workbench.panel.opensMaximized says whether showing the
// panel again brings it back.
PanelMaximized bool `json:"panelMaximized"`
// CenteredLayout says that the user (or zen mode) asked for the editor area to be centered between two margins
// (step 8.5). It is the request: whether the margins show also depends on the groups (see CenteredLayoutActive of
// the shell). A state written before step 8.5 has none.
CenteredLayout bool `json:"centeredLayout,omitempty"`
// Zen is zen mode: whether it is on, and what it did, to be undone when it ends (a state without it is not in zen
// mode).
Zen ZenState `json:"zen,omitzero"`
}
LayoutState is the part of the layout that is kept between runs: which parts are shown, how large the side bar and the panel are, where they are, and whether the panel is maximized (persisted in step 7.5). The zero value is not a layout; DefaultLayoutState is.
func DefaultLayoutState ¶
func DefaultLayoutState() LayoutState
DefaultLayoutState is the layout of a window that has nothing saved: the side bar, the activity bar and the status bar shown on the left and at the bottom, the panel at the bottom and hidden (as in VS Code), and the default sizes.
Ported from VS Code: src/vs/workbench/browser/layout.ts (LayoutStateKeys)
func LayoutStateFromSettings ¶
func LayoutStateFromSettings(s *settings.Store) LayoutState
LayoutStateFromSettings is DefaultLayoutState with what the settings say: the position of the side bar, whether the activity bar and the status bar are shown, and where the panel is.
type ManageButton ¶
type ManageButton struct {
widgets.StatefulWidget
// contains filtered or unexported fields
}
ManageButton is the gear at the bottom of the activity bar: it opens the Manage menu beside the activity bar, with the items that items gives at that moment, and onRun is told which one the user ran.
Ported from VS Code: src/vs/workbench/browser/parts/globalCompositeBar.ts
func NewManageButton ¶
func NewManageButton(items func() []kit.MenuItem, onRun func(kit.MenuItem), ctl *ManageController) *ManageButton
NewManageButton makes the Manage button; ctl, which may be nil, lets code outside open its menu.
func (*ManageButton) CreateState ¶
func (b *ManageButton) CreateState() widgets.State
CreateState implements widgets.StatefulWidget.
type ManageController ¶
type ManageController struct {
// contains filtered or unexported fields
}
ManageController opens the Manage menu from outside, as a click on the gear does.
func NewManageController ¶
func NewManageController() *ManageController
NewManageController makes a controller; give it to the Manage option of the workbench.
func (*ManageController) Open ¶
func (c *ManageController) Open()
Open opens the Manage menu, when the gear is on screen and the menu is not open.
type MenuSource ¶
type MenuSource struct {
// contains filtered or unexported fields
}
MenuSource turns the menu registry into the items of the menu widgets: the menu bar, the context menus and the Manage menu (SPEC §10.1). The labels have the mnemonics of the menu bar, and each item shows the key that runs its command (VS Code's label style on Linux, "Ctrl+N"), a check mark when it is toggled and a dimmed look when the precondition of its command does not hold. Running an item runs its command through the registry.
Ported from VS Code: src/vs/workbench/browser/parts/titlebar/menubarControl.ts and src/vs/platform/actions/browser/menuEntryActionViewItem.ts
func NewMenuSource ¶
func NewMenuSource(o MenuSourceOptions) *MenuSource
NewMenuSource makes the source of the menus.
func (*MenuSource) BarIndex ¶
func (m *MenuSource) BarIndex(menu string) int
BarIndex is the position of a menu in the menu bar, or -1 when the bar has no menu with the id (an id of a menu that is not a submenu of the main menu, or a menu with nothing in it).
func (*MenuSource) BarMenus ¶
func (m *MenuSource) BarMenus() []kit.MenuBarMenu
BarMenus are the menus of the menu bar: the submenus of MenubarMainMenu that have items. Each menu is built again, in the context of that moment, when the user opens it.
func (*MenuSource) Items ¶
func (m *MenuSource) Items(menu string, ctx contextkey.Context) []kit.MenuItem
Items are the items of a menu in a context, for a Menu or a ContextMenu.
func (*MenuSource) ItemsWithout ¶ added in v1.0.0
func (m *MenuSource) ItemsWithout(menu string, ctx contextkey.Context, drop func(command.MenuEntry) bool) []kit.MenuItem
ItemsWithout is Items with the entries of the top level that drop says yes to left out (the context menu of a row of the Source Control view leaves out the group of its inline buttons); the separators that are left at an end or in a row go too.
func (*MenuSource) ManageItems ¶
func (m *MenuSource) ManageItems() []kit.MenuItem
ManageItems are the items of the Manage menu, the gear of the activity bar. A menu with nothing in it has one dimmed item, as an empty submenu does.
func (*MenuSource) Run ¶
func (m *MenuSource) Run(item kit.MenuItem)
Run runs the command of an item that the user ran: through the registry, with the arguments of the item. A failure goes to OnError.
type MenuSourceOptions ¶
type MenuSourceOptions struct {
// Menus holds the items of the menus.
Menus *command.MenuRegistry
// Commands runs the commands of the items.
Commands *command.Registry
// Keybindings gives the keys shown at the right edge of an item; without it the items show none.
Keybindings *keybinding.Resolver
// Context gives the context keys the menu bar and the Manage menu are evaluated in, each time one
// opens; a menu that is not in the window's focus has the keys of the window. An empty context
// when nil.
Context func() contextkey.Context
// Schedule runs a function once the menu is closed and the focus is back where it was; the
// commands of the editor are bound while the editor has the focus, so a command run at once, while
// the menu still has it, would find none. Without it the command runs at once.
Schedule func(func())
// Ctx is the context of the commands that are run; context.Background() when nil.
Ctx context.Context
// OnError is told when a command run by a menu fails.
OnError func(commandID string, err error)
}
MenuSourceOptions say what a MenuSource is made of. Menus and Commands are required.
type NewMenuController ¶ added in v1.0.0
type NewMenuController struct {
// contains filtered or unexported fields
}
NewMenuController opens the menu of the "+" button of the strip that is on screen, as a click on the button does.
func NewNewMenuController ¶ added in v1.0.0
func NewNewMenuController() *NewMenuController
NewNewMenuController makes a controller that is not attached to a strip yet.
func (*NewMenuController) Open ¶ added in v1.0.0
func (c *NewMenuController) Open() bool
Open opens the menu; it reports false when no strip is on screen.
type NotificationsHost ¶
type NotificationsHost struct {
widgets.StatefulWidget
// contains filtered or unexported fields
}
NotificationsHost puts the toasts and the notification center of a Presenter over its child, which the workbench places once at its root (as kit.DialogHost does with dialogs, but below them). The toasts stack at the bottom right above the status bar, the newest on top, at most notify.MaxToasts of them, 450 px wide at most; the center is a panel at the same place with a header and the list of all the notifications. The host binds the presenter to the UI thread, follows it, and takes over the notifications.* commands.
Ported from VS Code: src/vs/workbench/browser/parts/notifications/notificationsToasts.ts, notificationsCenter.ts, notificationsList.ts and notificationsCommands.ts
func NewNotificationsHost ¶
func NewNotificationsHost(child widgets.Widget, opts NotificationsOptions) *NotificationsHost
NewNotificationsHost makes the host of the notifications of a presenter over a child.
func (*NotificationsHost) CreateState ¶
func (h *NotificationsHost) CreateState() widgets.State
CreateState implements widgets.StatefulWidget.
type NotificationsOptions ¶
type NotificationsOptions struct {
// Presenter is what the host shows: the toasts and the center of its service. Required.
Presenter *notify.Presenter
// Commands is the registry whose notifications.* commands the host takes over while it is on
// screen (command.DefaultRegistry has them) and that runs the command of a button. Without it no
// command is bound and a button runs only its Run.
Commands *command.Registry
// Keys is the scope of the context keys of the window, where the host sets notificationCenterVisible,
// notificationToastsVisible and notificationFocus.
Keys *contextkey.Scope
// Context is the context of the commands the buttons run; context.Background() when nil.
Context context.Context
// BottomInset is the height of what is below the toasts, the status bar.
BottomInset float64
// TopInset is the height of what is above them, the menu bar, which the center keeps clear.
TopInset float64
}
NotificationsOptions are the options of NotificationsHost.
type Options ¶
type Options struct {
// Layout is the model of the layout, which the commands change and the widget shows.
Layout *Layout
// Commands is the registry whose layout commands the workbench takes over while it is on screen
// (command.DefaultRegistry has them). Without it no command is bound.
Commands *command.Registry
// Keys is the root scope of the context keys of the window, where the workbench sets sideBarVisible,
// sideBarFocus, panelVisible, panelFocus, panelPosition, panelAlignment, panelMaximized,
// mainEditorAreaVisible, editorAreaFocus and statusBarFocused. Each part also has a scope of its
// own below it, for the views in it.
Keys *contextkey.Scope
// Scopes registers the focus node of each part with its scope, so that the key dispatcher of the
// window resolves keys in the scope of the part that has the focus.
Scopes *kit.FocusScopes
// Settings gives window.menuBarVisibility, and is where the commands that VS Code keeps in a setting
// (the status bar, the activity bar, the menu bar) write it; the layout follows the settings
// workbench.sideBar.location, workbench.activityBar.location, workbench.statusBar.visible and
// workbench.panel.opensMaximized. Without it the commands change the layout directly and the menu
// is the compact one.
Settings *settings.Store
// Dialogs is the queue of the dialogs of the window; the workbench shows them over everything, once.
Dialogs *kit.DialogController
// Editor is what the editor area shows.
Editor widgets.Widget
// Menus are the menus of the menu bar, and OnRunMenu is told which item the user ran.
Menus []kit.MenuBarMenu
OnRunMenu func(item kit.MenuItem)
// TitleBar, when set, puts the workspace tabs in the title bar row (SPEC §10.14), next to the menu.
TitleBar *TitleBarOptions
// MenuBar, when set, is the controller of the menu bar, with which the caller opens a menu or
// reads the state of the bar; the workbench makes its own without it.
MenuBar *kit.MenuBarController
// Views, when set, fills the activity bar with an icon for each view container of the side bar,
// titles the side bar with the container that is active and shows the views of that container
// in it (SPEC §10.4), unless the slots below say otherwise.
Views *Views
// ViewContext is the context the `when` of the views is evaluated in; every view shows when nil.
ViewContext contextkey.Context
// ViewBody builds the body of a view; a view it gives nothing for has an empty body.
ViewBody func(bc widgets.BuildContext, viewID string) widgets.Widget
// ViewName, ViewActions, ViewBodyHeight and OnViewFocus are the slots of SideBarViewsOpts of the same
// names: the title of a view when it is not the registry's, the buttons in its header, a body of a
// fixed height, and the focus entering or leaving a view.
ViewName func(viewID string) string
// ViewDescription is SideBarViewsOpts.Description.
ViewDescription func(viewID string) string
ViewActions func(bc widgets.BuildContext, viewID string) widgets.Widget
ViewBodyHeight func(viewID string) (float64, bool)
OnViewFocus func(viewID string, has bool)
// ManageItems gives the items of the Manage menu when the user opens it, from the gear at the
// bottom of the activity bar (it has none without this); OnRunMenu is told which one ran.
ManageItems func() []kit.MenuItem
// Manage, when set, opens the Manage menu from outside.
Manage *ManageController
// ActivityTop and ActivityBottom are the icons at the top of the activity bar (the view containers)
// and at the bottom (the Manage entry); they replace what Views and ManageItems make.
ActivityTop, ActivityBottom widgets.Widget
// SideBarTitle is the title of the active view container, and SideBar its body; they replace what
// Views makes.
SideBarTitle string
SideBar widgets.Widget
// PanelTabs are the views of the panel and ActivePanel the id of the one that shows; Panel is the
// body, and OnSelectPanel is told which tab the user clicked.
PanelTabs []PanelTab
ActivePanel string
Panel widgets.Widget
OnSelectPanel func(id string)
// PanelActions are the actions of the active view of the panel (the filter of the Problems, the
// channel of the Output), shown in the title strip before the buttons that maximize and hide the
// panel. They keep their room: the strip asks how wide they are before it fits the tabs (see fitPanelTabs).
PanelActions kit.TitleActions
// FocusPanelView gives the keyboard focus to the content of a view container of the panel, once the
// commands that open a view with the focus have shown it (the tree of the Problems, the editor of
// the Output). Without it the focus goes to the panel itself.
FocusPanelView func(container string)
// QuickInput, when set, shows the quick input (the command palette and the pickers) over the workbench,
// under the menu bar, above the notifications and below the dialogs (SPEC §10.6). The window keeps the
// controller; the workbench takes over workbench.action.closeQuickOpen while it is on screen.
QuickInput *quickinput.Controller
// Notifications, when set, shows the toasts and the notification center of the presenter over the
// workbench, below the dialogs, and binds the notifications.* commands (SPEC §10.7).
Notifications *notify.Presenter
// StatusBar, when set, fills the status bar with the items of its registry (SPEC §10.1): the left ones
// from the left end, the right ones to the right end. A click on an item runs its command with the
// registry of Commands.
StatusBar *StatusBarOptions
// Banners, when set, shows the banners of the window tab in a column across the top of the workbench, under the title bar
// (SPEC §10.15 "As built (step 15.2)").
Banners *Banners
// StatusLeft and StatusRight are more widgets at the two ends of the status bar, outside the registry.
// NoFolder gives the bar the colors of a window with no folder.
StatusLeft, StatusRight []widgets.Widget
NoFolder bool
// Debugging gives the bar the colors of a debug session (statusBar.debuggingBackground, the foreground and the border), which win over NoFolder's.
Debugging bool
// SideBarActions are the buttons in the title of the side bar, after its text: the start button and the configuration of Run and Debug.
SideBarActions func(bc widgets.BuildContext) widgets.Widget
// FullScreen says that the window is in full screen mode, where the window has no title bar and the menu of the
// visibility classic and compact is hidden until the Alt key shows it, in a row of its own (SPEC §10.9). While
// zen mode is on (Layout) the menu is hidden.
FullScreen bool
// Context is the context of the commands the workbench runs; context.Background() when nil.
Context context.Context
// EditorOnly shows the editor area alone below the title bar: no activity bar, side bar, panel or status bar, whatever
// the layout says, and the layout does not follow the settings. It is the body of the window tab of an extension (SPEC
// §10.14); the title bar, the quick input, the notifications and the dialogs are there as always.
EditorOnly bool
}
Options configure a Workbench. Layout is required; everything else may be left out.
type PanelOpensMaximized ¶
type PanelOpensMaximized string
PanelOpensMaximized is the value of workbench.panel.opensMaximized.
const ( // OpensMaximizedPreserve opens the panel in the state it was in when it was hidden (the default). OpensMaximizedPreserve PanelOpensMaximized = "preserve" // OpensMaximizedAlways maximizes the panel whenever it opens. OpensMaximizedAlways PanelOpensMaximized = "always" // OpensMaximizedNever opens the panel as it is not maximized. OpensMaximizedNever PanelOpensMaximized = "never" )
The values of workbench.panel.opensMaximized.
type PanelPosition ¶
type PanelPosition string
PanelPosition is where the panel is, from the editor area; the values are those of workbench.panel.defaultLocation and of the context key panelPosition.
const ( PanelBottom PanelPosition = "bottom" PanelTop PanelPosition = "top" PanelLeft PanelPosition = "left" PanelRight PanelPosition = "right" )
The positions of the panel.
func (PanelPosition) Horizontal ¶
func (p PanelPosition) Horizontal() bool
Horizontal says whether the panel is above or below the editors (VS Code's isHorizontal): its size is then a height, and it is a width when the panel is at a side.
func (PanelPosition) Valid ¶
func (p PanelPosition) Valid() bool
Valid says whether p is one of the positions.
type PanelTab ¶
type PanelTab struct {
ID string
Title string
// Badge, when it is above 0, is the count shown after the title (the Problems of the panel), and
// BadgeTooltip its hover text.
Badge int
BadgeTooltip string
}
PanelTab is a view of the panel: its id and the title it has in the title strip of the panel.
type Part ¶
type Part int
Part names a part of the workbench (SPEC §10.1).
const ( // PartMenuBar is the menu in the title bar row, or in the row of its own that full screen mode has (step 9b.2). PartMenuBar Part = iota // PartActivityBar is the activity bar, on the side of the side bar. PartActivityBar // PartSideBar is the primary side bar. PartSideBar // PartEditor is the editor area. PartEditor // PartPanel is the panel. PartPanel // PartStatusBar is the status bar at the bottom. PartStatusBar )
The parts of the workbench.
type ProblemCounts ¶
type ProblemCounts struct {
Errors, Warnings, Infos int
}
ProblemCounts are the numbers the Problems item shows.
type SideBarPosition ¶
type SideBarPosition string
SideBarPosition is the side of the window the side bar (and the activity bar) are on; the values are those of workbench.sideBar.location.
const ( SideBarLeft SideBarPosition = "left" SideBarRight SideBarPosition = "right" )
The positions of the side bar.
type SideBarViews ¶
type SideBarViews struct {
widgets.StatefulWidget
// contains filtered or unexported fields
}
SideBarViews is the body of the side bar: the views of the container the side bar shows, each a header with a chevron and the title of the view in capitals (a click, Enter or Space on it folds the body away or brings it back) over the body of the view. The bodies of the views that are open share the height that is left (SPEC §10.4).
Ported from VS Code: src/vs/base/browser/ui/splitview/paneview.ts (PaneView, Pane) and src/vs/workbench/browser/parts/views/viewPane.ts
func NewSideBarViews ¶
func NewSideBarViews(views *Views, opts ...SideBarViewsOpts) *SideBarViews
NewSideBarViews makes the views of the active container of views.
func (*SideBarViews) CreateState ¶
func (w *SideBarViews) CreateState() widgets.State
CreateState implements widgets.StatefulWidget.
type SideBarViewsOpts ¶
type SideBarViewsOpts struct {
// Context is the context the `when` of the views is evaluated in; every view shows when nil.
Context contextkey.Context
// Body builds the body of a view; a view it gives nothing for (or no Body at all) has an empty
// body, which is what the views are until the steps that build them.
Body func(bc widgets.BuildContext, viewID string) widgets.Widget
// Name gives the title of a view when it is not the name the registry has (the Explorer shows the
// name of the folder); empty keeps the name.
Name func(viewID string) string
// Description gives the text that follows the title of a view in a lighter style (the name of the file a Timeline shows, with
// "(pinned)"); empty has none.
Description func(viewID string) string
// Actions builds the buttons at the right end of the header of a view (the title actions); nil or a
// nil widget has none. They are shown while the pointer is over the view or the focus is in it, as
// VS Code shows them.
Actions func(bc widgets.BuildContext, viewID string) widgets.Widget
// BodyHeight gives a view a body of a fixed height (Open Editors); false shares the room that is left
// with the other views.
BodyHeight func(viewID string) (height float64, ok bool)
// OnFocusChange is told when the focus enters or leaves a view (the header or the body).
OnFocusChange func(viewID string, has bool)
}
SideBarViewsOpts are the options of NewSideBarViews.
type StatusAccessor ¶
type StatusAccessor struct {
// contains filtered or unexported fields
}
StatusAccessor changes or removes an item that was added to a StatusBar.
func (*StatusAccessor) Dispose ¶
func (a *StatusAccessor) Dispose()
Dispose removes the item from the bar. A second call does nothing.
func (*StatusAccessor) SetVisible ¶
func (a *StatusAccessor) SetVisible(visible bool)
SetVisible shows or hides the item without removing it.
func (*StatusAccessor) Update ¶
func (a *StatusAccessor) Update(entry StatusEntry)
Update changes what the item shows and does. Nothing is told when it is the same entry. It does nothing for an item that was disposed.
type StatusAlignment ¶
type StatusAlignment int
StatusAlignment is the side of the status bar an item is on.
const ( // StatusLeft puts the item at the left end of the bar. StatusLeft StatusAlignment = iota // StatusRight puts the item at the right end of the bar. StatusRight )
The sides of the status bar.
type StatusBar ¶
type StatusBar struct {
// contains filtered or unexported fields
}
StatusBar is the registry of the items of the status bar (SPEC §10.1): the pieces of the window and the steps to come add their items to it and update them, and the status bar widget shows them. It is safe for concurrent use; its listeners are called on the goroutine that changed it, with no lock held.
Ported from VS Code: src/vs/workbench/browser/parts/statusbar/statusbarModel.ts (StatusbarViewModel) and statusbarPart.ts (addEntry)
func (*StatusBar) Add ¶
func (b *StatusBar) Add(id string, alignment StatusAlignment, priority float64, entry StatusEntry) *StatusAccessor
Add puts an item in the bar and returns the accessor to update or remove it. Items of the same side with the same priority stay in the order they were added in.
func (*StatusBar) Get ¶
func (b *StatusBar) Get(id string) (StatusItem, bool)
Get finds an item by its id (the first, when several have it).
func (*StatusBar) Inherit ¶ added in v1.0.0
Inherit makes the bar show, besides its own items, the items of parent whose id keep accepts, as the parent has them: the status items the extensions of a hosted workspace added to its window are in the bar of the view of a client too. The parent's items come after this bar's among those of equal priority, and a change of the parent's items is a change of this bar. Call it once, before the bar is used.
func (*StatusBar) Items ¶
func (b *StatusBar) Items(alignment StatusAlignment) []StatusItem
Items are the visible items of a side in the order the bar shows them, from the left: the higher priorities first, and the earlier added first among equal ones. On the right side the item with the lowest priority is the one at the right end, so the notifications bell (negative infinity) ends the bar.
type StatusBarOptions ¶
type StatusBarOptions struct {
// Bar holds the items. Required.
Bar *StatusBar
// Keybinding gives the label of the key of a command (such as "Ctrl+G"), which is written after the
// tooltip of an item that runs it; empty or nil for none.
Keybinding func(commandID string) string
// OnError is told when the command of an item fails.
OnError func(commandID string, err error)
}
StatusBarOptions say how the status bar shows the items of a StatusBar.
type StatusEntry ¶
type StatusEntry struct {
// Name is the name of the item for the user (the list of items one can hide), such as "Editor Selection".
Name string
// Text is the text of the item. A codicon is written $(name), such as $(error); $(name~spin) is one that
// spins (drawn still), and \$(name) is the text itself. An item with no text is not shown.
Text string
// AriaLabel is what a screen reader says; the text when empty.
AriaLabel string
// Tooltip is the text of the hover over the item. The key of the command follows it, between brackets.
Tooltip string
// Command is the id of the command a click runs, with Args as its argument; an item without one is not
// clickable.
Command string
Args any
// Kind is the look of the item.
Kind StatusKind
// Color, when it is "#rrggbb" or "#rgb", is the background of the item (an extension's own color); the text is white or black,
// whichever reads better on it.
Color string
// ShowProgress puts a loading icon before the text.
ShowProgress bool
}
StatusEntry is what an item of the status bar shows and does (VS Code's IStatusbarEntry).
type StatusItem ¶
type StatusItem struct {
// ID identifies the item.
ID string
Entry StatusEntry
Alignment StatusAlignment
// Priority orders the items of a side: the higher the priority, the closer to the left end of the bar,
// on both sides.
Priority float64
// Visible is false for an item that is hidden; the bar leaves it out.
Visible bool
}
StatusItem is an item of the bar as the widget shows it.
type StatusKind ¶
type StatusKind int
StatusKind is the look of an item: the colors it has in place of the bar's.
const ( // StatusStandard is an item in the colors of the bar. StatusStandard StatusKind = iota // StatusWarning is an item on statusBarItem.warningBackground. StatusWarning // StatusError is an item on statusBarItem.errorBackground. StatusError // StatusProminent is an item on statusBarItem.prominentBackground. StatusProminent // StatusRemote is an item on statusBarItem.remoteBackground, VS Code's remote indicator (step 17e.4: the Sharing item while the // workspace is hosted). StatusRemote )
The kinds of item (VS Code's StatusbarEntryKind, with the remote kind and without the offline one).
type StatusTextRun ¶
type StatusTextRun struct {
// Icon is the name of the codicon ("error"), or empty for a run of text.
Icon string
// Spin is true for $(name~spin).
Spin bool
// Text is the text of a run that is not an icon.
Text string
}
StatusTextRun is a piece of the text of an item: a codicon or text.
func ParseStatusText ¶
func ParseStatusText(text string) []StatusTextRun
ParseStatusText splits the text of an item into text and icons. An escaped icon, \$(name), is text.
Ported from VS Code: src/vs/base/browser/ui/iconLabel/iconLabels.ts (renderLabelWithIcons) and src/vs/base/common/iconLabels.ts
type TabLabel ¶
type TabLabel struct {
// Name is the base name of the folder (NoFolderTabName for a workspace without one).
Name string
// Description is the shortest part of the parent path that tells the tab from the others of the same name,
// "work" for /home/me/work/api next to /home/me/home/api; empty when the name is unique.
Description string
}
TabLabel is what a workspace tab shows: the name, and, when another tab has the same name, the part of the path that tells them apart.
func LabelWorkspaceTabs ¶
LabelWorkspaceTabs gives the label of each tab for the folders of the tabs, in the order of the strip ("" for a workspace without a folder). Tabs of the same name get the shortest suffix of their parent folders that no other tab of that name has (VS Code's label disambiguation of the editor tabs: "work" and "home", or "a/x/src" and "b/x/src" when the nearer folders are the same). Two tabs that cannot be told apart (two tabs without a folder) keep the same label.
type TitleBarOptions ¶
type TitleBarOptions struct {
// Tabs are the workspace tabs in order, and Active the index of the one that is shown.
Tabs []WorkspaceTab
Active int
// OnActivate is called with the index of a tab that is clicked: for the active tab at the press, for the others when
// the button is released (a press that becomes a drag does not activate the tab, so the strip that is shown stays the
// strip the drag goes on in); OnClose with the index of a tab whose close button is pressed or that is pressed with
// the middle button.
OnActivate func(index int)
OnClose func(index int)
// OnMove is called when a tab is dropped at another place of the strip, with the index of the tab and the place it
// goes to (the index it has afterwards). A tab is dragged by the primary button once the pointer has moved 4 px, a
// line shows where it would go, Escape cancels, and the strip scrolls when the pointer rests at its ends. Without it
// the tabs cannot be dragged.
OnMove func(index, to int)
// ContextItems gives the items of the context menu of the tab at an index when it is pressed with the secondary
// button, and NewItems those of the menu of the "+" button. OnRunItem is called with the item the user runs in
// either menu (the workbench's OnRunMenu when nil).
ContextItems func(index int) []kit.MenuItem
NewItems func() []kit.MenuItem
OnRunItem func(item kit.MenuItem)
// NewMenu, when set, opens the menu of the "+" button from outside (the dev command of step 11.7, a test).
NewMenu *NewMenuController
}
TitleBarOptions are the workspace tabs of the title bar row and what the user does to them. A Workbench without them shows the menu and the buttons of the window only.
type TitleInput ¶
type TitleInput struct {
// Template is the value of window.title and Separator that of window.titleSeparator.
Template, Separator string
// AppName is `${appName}`: "Emetos".
AppName string
// ProfileName is `${profileName}`: the name of the profile, empty for the default one.
ProfileName string
// Home is the home folder of the user, which paths in it are written relative to as "~/...".
Home string
// Folder is the folder open in the window, or "".
Folder string
// ActiveFile is the path of the file of the active editor, or "" when there is none or it is not a
// file.
ActiveFile string
// ActiveName is the name of the active editor when it is not a file ("Untitled-1"); the name of the
// file is used when ActiveFile is set.
ActiveName string
// LanguageID is the language of the active editor.
LanguageID string
// Dirty says that the active editor has unsaved changes.
Dirty bool
// FocusedView is the name of the view that has the focus.
FocusedView string
}
TitleInput is what the title of the window is made of (SPEC §10.1): the template and the facts the variables of the template stand for. The variables that need a remote, a workspace file, a repository or a screen reader (remoteName, activeRepositoryName, activeEditorState...) are empty, as are the ones whose facts are not given.
func (TitleInput) Title ¶
func (in TitleInput) Title() string
Title expands the template with the facts: VS Code's `getWindowTitle`. A variable the template names that is not known is left out, and so is `${separator}` where it does not have text on both sides. A title that comes out empty is the name of the application.
Ported from VS Code: src/vs/workbench/browser/parts/titlebar/windowTitle.ts (getWindowTitle, getFullWindowTitle)
type Views ¶
type Views struct {
// contains filtered or unexported fields
}
Views is the state of the views of a window (SPEC §10.4): which view container the side bar shows and which views are collapsed. It is a model, with no widget in it, used on the UI thread only: the activity bar and the side bar follow it with OnChange.
Ported from VS Code: src/vs/workbench/browser/parts/paneCompositePart.ts and src/vs/workbench/browser/parts/views/viewPaneContainer.ts
func NewViews ¶
func NewViews(registry *command.ViewRegistry, layout *Layout) *Views
NewViews makes the views of a window over a registry. The side bar shows the first container of the activity bar. layout is the layout of the window, whose side bar the activity bar shows and hides; it may be nil.
func (*Views) Active ¶
Active is the id of the view container the side bar shows, or "" when there is none.
func (*Views) ActiveContainer ¶
func (v *Views) ActiveContainer() (command.ViewContainer, bool)
ActiveContainer is the container the side bar shows.
func (*Views) ActivePanel ¶
ActivePanel is the id of the view container the panel shows, or "" when the panel has none.
func (*Views) Badge ¶ added in v1.0.0
func (v *Views) Badge(container string) (ActivityBadge, bool)
Badge is the badge of the icon of a view container; false when there is none.
func (*Views) Changed ¶ added in v1.0.0
func (v *Views) Changed()
Changed tells the listeners of OnChange that something the views show changed without the registry changing: a badge, a context key that a `when` reads, the title actions of a view.
func (*Views) ClosePanel ¶ added in v1.0.0
ClosePanel hides the panel when it shows the tab of the container; it does nothing otherwise. It reports whether the panel was hidden.
func (*Views) IsCollapsed ¶
IsCollapsed tells whether a view shows only its header.
func (*Views) IsHidden ¶
IsHidden tells whether a view is not shown in its container: it starts hidden when its View says HideByDefault (Open Editors) and shows when SetHidden says so.
func (*Views) OnChange ¶
func (v *Views) OnChange(fn func()) (unsubscribe func())
OnChange calls fn when the active container or a view's state changes, and returns the function that stops it.
func (*Views) Open ¶
Open shows a view container in the side bar and shows the side bar, as the command of a container does. An id that is not a container of the side bar does nothing.
func (*Views) OpenPanel ¶
OpenPanel shows a view container in the panel and shows the panel, as the command of a view of the panel does. An id that is not a container of the panel does nothing.
func (*Views) Registry ¶
func (v *Views) Registry() *command.ViewRegistry
Registry is the registry the views come from.
func (*Views) SetBadge ¶ added in v1.0.0
func (v *Views) SetBadge(container string, b ActivityBadge)
SetBadge sets the badge of the icon of a view container; a count of 0 takes it away.
func (*Views) SetCollapsed ¶
SetCollapsed folds a view away or unfolds it.
func (*Views) SetHidden ¶
SetHidden hides a view or shows it again, and unfolds a view that is shown.
func (*Views) Toggle ¶
Toggle is a click on an icon of the activity bar: the container of the icon opens, and the one that is open closes the side bar.
func (*Views) TogglePanel ¶ added in v1.0.0
TogglePanel is the command of a view of the panel: the panel is hidden when it shows the tab of the container, and shows the tab otherwise. It reports whether the tab is shown afterwards.
type Workbench ¶
type Workbench struct {
widgets.StatefulWidget
// contains filtered or unexported fields
}
Workbench is the layout of the window (SPEC §10.1): the title bar row (the menu and the workspace tabs) over a row of the activity bar, the primary side bar and the center, over the status bar; the center is the editor area and the panel, which lies below, above, left or right of the editors. Each part can be hidden, the side bar and the panel are resized by their sashes, and the editor area takes what the window gains or loses. The dialogs of the window show over all of it.
Ported from VS Code: src/vs/workbench/browser/layout.ts and src/vs/workbench/browser/parts/
func (*Workbench) CreateState ¶
CreateState implements widgets.StatefulWidget.
type WorkspaceTab ¶
type WorkspaceTab struct {
// ID identifies the tab between builds (the stable id of the window tab).
ID string
// Name and Description are the label (LabelWorkspaceTabs gives them).
Name, Description string
// Tooltip is the text of the hover: the path of the folder, and the profile on a second line when it is not the
// default.
Tooltip string
// Dirty shows the dot of unsaved changes in place of the close button.
Dirty bool
// Folder says that the tab has a folder (the icon root-folder); a tab without one has the icon window.
Folder bool
// IconCode, when it is not 0, is the code point of the Codicon of the tab (the tab of an extension has the icon of its
// kind); it wins over Folder.
IconCode int
}
WorkspaceTab is the look of one workspace tab of the title bar.
type ZenState ¶
type ZenState struct {
// Active says that zen mode is on.
Active bool `json:"active,omitempty"`
// HidSideBar, HidPanel, HidActivityBar and HidStatusBar say that the part was shown when zen mode began and zen mode
// hid it; only those come back when it ends.
HidSideBar bool `json:"hidSideBar,omitempty"`
HidPanel bool `json:"hidPanel,omitempty"`
HidActivityBar bool `json:"hidActivityBar,omitempty"`
HidStatusBar bool `json:"hidStatusBar,omitempty"`
// ChangedSideBar, ChangedPanel, ChangedActivityBar and ChangedStatusBar say that the user showed or hid the part
// while zen mode was on: it stays as the user left it when zen mode ends.
ChangedSideBar bool `json:"changedSideBar,omitempty"`
ChangedPanel bool `json:"changedPanel,omitempty"`
ChangedActivityBar bool `json:"changedActivityBar,omitempty"`
ChangedStatusBar bool `json:"changedStatusBar,omitempty"`
// FullScreen, Centered and DoNotDisturb say that zen mode turned full screen, the centered layout and do not
// disturb on (they were off), so that ending it turns them off again (VS Code's transitionedToFullScreen,
// transitionedToCenteredEditorLayout and handleNotificationsDoNotDisturbMode).
FullScreen bool `json:"fullScreen,omitempty"`
Centered bool `json:"centered,omitempty"`
DoNotDisturb bool `json:"doNotDisturb,omitempty"`
}
ZenState is what zen mode keeps of the layout it found, as VS Code's zenModeExitInfo does (SPEC §10.9). It is saved with the layout, so that a window that closes in zen mode starts in it again (zenMode.restore) or leaves it with the parts it had.
Ported from VS Code: src/vs/workbench/browser/layout.ts (zenModeExitInfo, toggleZenMode)