Documentation
¶
Overview ¶
Package command holds the command registry (SPEC §11.2).
Index ¶
- Constants
- func MnemonicMenuLabel(title string) string
- func RefusedClasses() []string
- func RefusedExactIDs() []string
- func RefusedPrefixes() []string
- type Context
- type Handler
- type MenuEntry
- type MenuItem
- type MenuProvider
- type MenuRegistry
- func (r *MenuRegistry) Add(items ...MenuItem) error
- func (r *MenuRegistry) AddRemovable(items ...MenuItem) (remove func(), err error)
- func (r *MenuRegistry) All() []MenuItem
- func (r *MenuRegistry) Fork(commands *Registry) *MenuRegistry
- func (r *MenuRegistry) Inherit(parent *MenuRegistry)
- func (r *MenuRegistry) Items(menu string, ctx contextkey.Context) []MenuEntry
- func (r *MenuRegistry) ItemsOf(menu string) []MenuItem
- func (r *MenuRegistry) MustAdd(items ...MenuItem)
- func (r *MenuRegistry) SetProvider(menu string, p MenuProvider)
- type Meta
- type Refusal
- type Registry
- func (r *Registry) All() []Meta
- func (r *Registry) Enabled(id string, keys contextkey.Context) bool
- func (r *Registry) Fork() *Registry
- func (r *Registry) HasHandler(id string) bool
- func (r *Registry) Inherit(parent *Registry, origin extension.Origin)
- func (r *Registry) Lookup(id string) (Meta, bool)
- func (r *Registry) MustRegister(metas ...Meta)
- func (r *Registry) Register(m Meta) error
- func (r *Registry) Run(ctx Context, id string, args any) error
- func (r *Registry) SetHandler(id string, h Handler) (remove func(), err error)
- func (r *Registry) Unregister(id string) bool
- type Source
- type View
- type ViewContainer
- type ViewLocation
- type ViewRegistry
- func (r *ViewRegistry) Container(id string) (ViewContainer, bool)
- func (r *ViewRegistry) Containers(loc ViewLocation) []ViewContainer
- func (r *ViewRegistry) Fork() *ViewRegistry
- func (r *ViewRegistry) Inherit(parent *ViewRegistry)
- func (r *ViewRegistry) MustRegisterContainer(c ViewContainer)
- func (r *ViewRegistry) MustRegisterViews(views ...View)
- func (r *ViewRegistry) OnChange(fn func()) (unsubscribe func())
- func (r *ViewRegistry) RegisterContainer(c ViewContainer) error
- func (r *ViewRegistry) RegisterViews(views ...View) error
- func (r *ViewRegistry) UnregisterContainer(id string)
- func (r *ViewRegistry) UnregisterView(id string)
- func (r *ViewRegistry) View(id string) (View, bool)
- func (r *ViewRegistry) Views(container string, ctx contextkey.Context) []View
Constants ¶
const ( // ViewContainerDebug is the Run and Debug container (VS Code's VIEWLET_ID). ViewContainerDebug = "workbench.view.debug" // ViewDebugWelcome is the welcome view of the container, shown while there is no configuration (debugUx is simple). ViewDebugWelcome = "workbench.debug.welcome" // ViewDebugVariables, ViewDebugWatch, ViewDebugCallStack, ViewDebugBreakpoints and ViewDebugLoadedScripts are the five views. ViewDebugVariables = "workbench.debug.variablesView" ViewDebugWatch = "workbench.debug.watchExpressionsView" ViewDebugCallStack = "workbench.debug.callStackView" ViewDebugBreakpoints = "workbench.debug.breakPointsView" ViewDebugLoadedScripts = "workbench.debug.loadedScriptsView" )
The ids of the view container and the views of Run and Debug (common/debug.ts).
const ( // MenubarDebugMenu is the Run menu of the menu bar. MenubarDebugMenu = "MenubarDebugMenu" // DebugToolBar is the debug toolbar. DebugToolBar = "DebugToolBar" // DebugToolBarStop is the menu behind the Stop button of the toolbar. DebugToolBarStop = "DebugToolBarStop" // DebugCallStackContext is the context menu and the inline buttons of the Call Stack. DebugCallStackContext = "DebugCallStackContext" // DebugVariablesContext is the context menu of the Variables view. DebugVariablesContext = "DebugVariablesContext" // DebugWatchContext is the context menu and the inline buttons of the Watch view. DebugWatchContext = "DebugWatchContext" // DebugBreakpointsContext is the context menu of the Breakpoints view. DebugBreakpointsContext = "DebugBreakpointsContext" // DebugLoadedScriptsContext is the context menu of the Loaded Scripts view. DebugLoadedScriptsContext = "DebugLoadedScriptsContext" // DebugViewTitle is the title bar of the views of Run and Debug. DebugViewTitle = "DebugViewTitle" // DebugContainerTitle is the title bar of the Run and Debug container: the start button, the gear, and, while the toolbar is // docked, the toolbar's buttons. DebugContainerTitle = "DebugContainerTitle" )
The ids of the debug menus. DebugToolBar is the buttons of the debug toolbar in each of its places, DebugToolBarStop the other ways to end a session (the dropdown of Stop), the Debug...Context menus the context menus and inline buttons of the views, and DebugViewTitle the title bar of each view (its rows test `view == '<id>'`).
const ( DebugStartCommand = "workbench.action.debug.start" DebugRunCommand = "workbench.action.debug.run" DebugStopCommand = "workbench.action.debug.stop" DebugDisconnectCommand = "workbench.action.debug.disconnect" DebugDisconnectSuspend = "workbench.action.debug.disconnectAndSuspend" DebugRestartCommand = "workbench.action.debug.restart" DebugContinueCommand = "workbench.action.debug.continue" DebugPauseCommand = "workbench.action.debug.pause" DebugStepOverCommand = "workbench.action.debug.stepOver" DebugStepIntoCommand = "workbench.action.debug.stepInto" DebugStepOutCommand = "workbench.action.debug.stepOut" DebugStepIntoTarget = "workbench.action.debug.stepIntoTarget" DebugStepBackCommand = "workbench.action.debug.stepBack" DebugReverseContinue = "workbench.action.debug.reverseContinue" DebugTerminateThread = "workbench.action.debug.terminateThread" DebugRestartFrame = "workbench.action.debug.restartFrame" DebugFocusSession = "workbench.action.debug.focusProcess" DebugSelectAndStart = "workbench.action.debug.selectandstart" DebugConfigure = "workbench.action.debug.configure" DebugAddConfiguration = "debug.addConfiguration" DebugCallStackTop = "workbench.action.debug.callStackTop" DebugCallStackBottom = "workbench.action.debug.callStackBottom" DebugCallStackUp = "workbench.action.debug.callStackUp" DebugCallStackDown = "workbench.action.debug.callStackDown" DebugShowLoadedScripts = "workbench.action.debug.showLoadedScripts" DebugSelectSession = "workbench.action.debug.selectDebugSession" DebugCopyStackTrace = "debug.copyStackTrace" DebugCopyValue = "workbench.debug.viewlet.action.copyValue" DebugCopyEvaluatePath = "debug.copyEvaluatePath" DebugAddToWatch = "debug.addToWatchExpressions" DebugSetVariable = "debug.setVariable" DebugSetExpression = "debug.setWatchExpression" DebugRenameWatch = "debug.renameWatchExpression" DebugRemoveWatch = "debug.removeWatchExpression" DebugAddWatch = "workbench.debug.viewlet.action.addWatchExpression" DebugRemoveAllWatch = "workbench.debug.viewlet.action.removeAllWatchExpressions" DebugCollapseAll = "workbench.debug.viewlet.action.collapseAll" DebugRemoveAllBreakpoints = "workbench.debug.viewlet.action.removeAllBreakpoints" DebugEnableAllBreakpoints = "workbench.debug.viewlet.action.enableAllBreakpoints" DebugDisableAllBreakpoint = "workbench.debug.viewlet.action.disableAllBreakpoints" DebugToggleActivated = "workbench.debug.viewlet.action.toggleBreakpointsActivatedAction" DebugAddFunctionBreakpoit = "workbench.debug.viewlet.action.addFunctionBreakpointAction" DebugToggleBreakpointItem = "debug.toggleBreakpoint" DebugRemoveBreakpoint = "debug.removeBreakpoint" DebugToggleExceptions = "debug.toggleExceptionBreakpoints" DebugToggleReplIgnore = "debug.toggleReplIgnoreFocus" // DebugEditBreakpoint edits the function name or the condition of the breakpoint row it is run for. DebugEditBreakpoint = "debug.editBreakpoint" )
The ids of the commands of Run and Debug.
const ( // ViewContainerRepl is the Debug Console tab of the panel (VS Code's DEBUG_PANEL_ID) and ViewRepl its view (REPL_VIEW_ID). ViewContainerRepl = "workbench.panel.repl" ViewRepl = "workbench.panel.repl.view" )
The ids of the container and the view of the Debug Console.
const ( // DebugToggleRepl shows or hides the Debug Console (Ctrl+Shift+Y) and DebugFocusRepl shows it and gives it the keyboard. DebugToggleRepl = "workbench.debug.action.toggleRepl" DebugFocusRepl = "workbench.debug.action.focusRepl" // DebugClearRepl is Clear Console. DebugClearRepl = "workbench.debug.panel.action.clearReplAction" // DebugReplAcceptInput evaluates what is in the input, DebugReplFocusFilter moves to the filter box. DebugReplAcceptInput = "repl.action.acceptInput" DebugReplFocusFilter = "repl.action.filter" // DebugReplCopyAll and DebugReplCopyAllItem copy the lines of the console that show; DebugReplCopy copies the line under the // pointer, DebugReplPaste pastes into the input, DebugReplCollapseAll closes the groups and objects. DebugReplCopyAll = "repl.action.copyAll" DebugReplCopyAllItem = "workbench.debug.action.copyAll" DebugReplCopy = "debug.replCopy" DebugReplPaste = "debug.replPaste" DebugReplCollapseAll = "debug.collapseRepl" DebugSelectRepl = "workbench.action.debug.selectRepl" DebugSelectionToRepl = "editor.debug.action.selectionToRepl" )
The ids of the commands of the Debug Console.
const ( // DebugToggleBreakpoint is F9: a breakpoint on the lines of the cursors, or none when there is one. DebugToggleBreakpoint = "editor.debug.action.toggleBreakpoint" // DebugToggleInlineBreakpoint is Shift+F9: a breakpoint at the column of the cursor. DebugToggleInlineBreakpoint = "editor.debug.action.toggleInlineBreakpoint" // DebugConditionalBreakpoint, DebugLogPoint, DebugTriggerPoint and DebugEditBreakpointAction open the breakpoint widget at the cursor. DebugConditionalBreakpoint = "editor.debug.action.conditionalBreakpoint" DebugLogPoint = "editor.debug.action.addLogPoint" DebugTriggerPoint = "editor.debug.action.triggerByBreakpoint" DebugEditBreakpointAction = "editor.debug.action.editBreakpoint" // DebugRunToCursor and DebugJumpToCursor are Run to Cursor and Jump to Cursor. DebugRunToCursor = "editor.debug.action.runToCursor" DebugJumpToCursor = "debug.jumpToCursor" // DebugSelectionToWatch is Add to Watch for the selection or the expression at the cursor. DebugSelectionToWatch = "editor.debug.action.selectionToWatch" // DebugShowHover shows the debug hover at the cursor. DebugShowHover = "editor.debug.action.showDebugHover" // DebugGoToNextBreakpoint and DebugGoToPreviousBreakpoint move to the next and the previous enabled breakpoint. DebugGoToNextBreakpoint = "editor.debug.action.goToNextBreakpoint" DebugGoToPreviousBreakpoint = "editor.debug.action.goToPreviousBreakpoint" // DebugCloseExceptionWidget closes the exception widget (Escape). DebugCloseExceptionWidget = "editor.debug.action.closeExceptionWidget" // DebugAcceptBreakpointWidget and DebugCloseBreakpointWidget accept (Enter) and close (Escape) the breakpoint widget. DebugAcceptBreakpointWidget = "breakpointWidget.action.acceptInput" DebugCloseBreakpointWidget = "closeBreakpointWidget" )
The ids of the commands of the editor.
const ( // MenubarMainMenu holds the menus of the menu bar as submenu items, in the order of the bar. MenubarMainMenu = "MenubarMainMenu" // MenubarFileMenu, MenubarEditMenu, MenubarSelectionMenu, MenubarViewMenu, MenubarGoMenu, // MenubarTerminalMenu and MenubarHelpMenu are the menus of the menu bar. MenubarFileMenu = "MenubarFileMenu" MenubarEditMenu = "MenubarEditMenu" MenubarSelectionMenu = "MenubarSelectionMenu" MenubarViewMenu = "MenubarViewMenu" MenubarGoMenu = "MenubarGoMenu" MenubarTerminalMenu = "MenubarTerminalMenu" MenubarHelpMenu = "MenubarHelpMenu" // MenubarPreferencesMenu is the Preferences submenu of the File menu. MenubarPreferencesMenu = "MenubarPreferencesMenu" // ThemesSubMenu is the Themes submenu of the Preferences menu and of the Manage menu. ThemesSubMenu = "ThemesSubMenu" // ProfilesSubMenu is the Profiles submenu of the Preferences menu and of the Manage menu (step 8.6b). ProfilesSubMenu = "ProfilesSubMenu" // MenubarAppearanceMenu is the Appearance submenu of the View menu. MenubarAppearanceMenu = "MenubarAppearanceMenu" // MenubarRecentMenu is the Open Recent submenu of the File menu; its items are dynamic. MenubarRecentMenu = "MenubarRecentMenu" // MenubarLayoutMenu is the Editor Layout submenu of the View menu. MenubarLayoutMenu = "MenubarLayoutMenu" // MenubarSwitchEditorMenu is the Switch Editor submenu of the Go menu. MenubarSwitchEditorMenu = "MenubarSwitchEditorMenu" // MenubarSwitchGroupMenu is the Switch Group submenu of the Go menu. MenubarSwitchGroupMenu = "MenubarSwitchGroupMenu" // PanelPositionMenu is the Panel Position submenu of the Appearance menu. PanelPositionMenu = "PanelPositionMenu" // EditorContext is the context menu of the editor. EditorContext = "EditorContext" // EditorContextPeek is the Peek submenu of the context menu of the editor. EditorContextPeek = "EditorContextPeek" // EditorTitleContext is the context menu of a tab of the editor. EditorTitleContext = "EditorTitleContext" // EditorTabsNew is the menu of the "+" button after the last tab of an editor group (step 29.1, SPEC §10.3): one row for // each kind of editor that can be made. Emetos's own; VS Code has no such menu. EditorTabsNew = "EditorTabsNew" EditorSplitMoveSubmenu = "EditorSplitMoveSubmenu" // WorkspaceTabContext is the context menu of a workspace tab in the title bar (step 9b.2, SPEC §10.14). WorkspaceTabContext = "WorkspaceTabContext" // MenubarWorkspaceTabsMenu is the Workspace Tabs submenu of the View menu (step 9b.5, SPEC §10.14). MenubarWorkspaceTabsMenu = "MenubarWorkspaceTabsMenu" // WorkspaceTabNew is the menu of the "+" button after the workspace tabs: one row for each kind of window tab that // can be made (step 9b.2 has Workspace...; step 11.7 adds the extension tabs). WorkspaceTabNew = "WorkspaceTabNew" // ExplorerContext is the context menu of the Explorer. ExplorerContext = "ExplorerContext" // CommandPalette is the menu of the command palette: a command is listed there unless an item // of this menu hides it with a When that does not hold. CommandPalette = "CommandPalette" // GlobalActivity is the Manage menu: the gear at the bottom of the activity bar. GlobalActivity = "GlobalActivity" // SCMViewSort is the menu "View & Sort" of the Source Control view: the view mode and the sort key (VS Code's SCMViewSort). SCMViewSort = "SCMViewSort" // SCMRepositories is the menu "Repositories" of the Source Control view: the order and the selection mode of the repositories, // and one row for each repository that shows or hides it (VS Code's SCMRepositories). SCMRepositories = "SCMRepositories" // SCMTitle is the title bar of the Source Control view and of each repository header (scm/title) (step 24.2, SPEC §10.30). SCMTitle = "SCMTitle" // SCMSourceControlInline is the actions inline in the header of a repository (scm/repository). SCMSourceControlInline = "SCMSourceControlInline" // SCMSourceControl is the context menu of a repository (scm/sourceControl). SCMSourceControl = "SCMSourceControl" // SCMResourceGroupContext is the actions and the context menu of a group of resources (scm/resourceGroup/context). SCMResourceGroupContext = "SCMResourceGroupContext" // SCMResourceContext is the actions and the context menu of a resource (scm/resourceState/context). SCMResourceContext = "SCMResourceContext" // SCMResourceFolderContext is the actions and the context menu of a folder of the tree view (scm/resourceFolder/context). SCMResourceFolderContext = "SCMResourceFolderContext" // SCMChangeContext is the title bar of the peek of a change (scm/change/title). SCMChangeContext = "SCMChangeContext" // SCMHistoryTitle is the title bar of the Graph view (scm/history/title). SCMHistoryTitle = "SCMHistoryTitle" // SCMHistoryItemContext is the context menu of a commit of the Graph (scm/historyItem/context). SCMHistoryItemContext = "SCMHistoryItemContext" // SCMHistoryItemRefContext is the context menu of a branch or tag badge of the Graph (scm/historyItemRef/context). SCMHistoryItemRefContext = "SCMHistoryItemRefContext" // TimelineItemContext is the context menu of an item of the Timeline view (timeline/item/context). TimelineItemContext = "TimelineItemContext" // EditorContent is the prominent buttons over the content of an editor (editor/content). EditorContent = "EditorContent" // EditorTitle is the actions in the title bar of an editor (editor/title). EditorTitle = "EditorTitle" // MultiDiffEditorFileToolbar is the actions in the header of a file of the multi-file diff editor (multiDiffEditor/resource/title). MultiDiffEditorFileToolbar = "MultiDiffEditorFileToolbar" // DiffEditorHunkToolbar is the toolbar in the gutter of a hunk of the diff editor (diffEditor/gutter/hunk). DiffEditorHunkToolbar = "DiffEditorHunkToolbar" // DiffEditorSelectionToolbar is the toolbar in the gutter of a selection of the diff editor (diffEditor/gutter/selection). DiffEditorSelectionToolbar = "DiffEditorSelectionToolbar" )
The ids of the menus (VS Code's MenuId). A menu is a list of items that other code adds to by its id, so the id of a menu is a plain string.
Ported from VS Code: src/vs/platform/actions/common/actions.ts (MenuId)
const ( // ViewContainerTesting is the Testing container (VS Code's Testing.ViewletId; the Test Explorer is its only view for now). ViewContainerTesting = "workbench.view.extension.test" // ViewTestExplorer is the Test Explorer view (VS Code's Testing.ExplorerViewId). ViewTestExplorer = "workbench.view.testing" // ViewContainerTestResults is the panel tab of Test Results and ViewTestResults its view (VS Code's Testing.ResultsPanelId and ResultsViewId). ViewContainerTestResults = "workbench.panel.testResults" ViewTestResults = "workbench.panel.testResults.view" // ViewTestCoverage is the Test Coverage view of the Testing container, shown while a coverage report is open (VS Code's // Testing.CoverageViewId). ViewTestCoverage = "workbench.view.testCoverage" )
The ids of the view container and the view of Testing.
const ( // TestingViewTitle is the title bar of the Test Explorer: the buttons of group navigation and, behind "...", the other groups. TestingViewTitle = "TestingViewTitle" // TestingItem is the inline buttons (group inline) and the context menu of a test of the Test Explorer. TestingItem = "TestingItem" // TestingCoverageTitle is the title bar of the Test Coverage view (VS Code's ViewTitle of the view). TestingCoverageTitle = "TestingCoverageTitle" )
The ids of the menus of Testing. TestingViewTitle is the title bar of the Test Explorer (VS Code's ViewTitle of the view) and TestingItem the buttons and the context menu of a test (VS Code's MenuId.TestItem).
const ( TestingRunAll = "testing.runAll" TestingDebugAll = "testing.debugAll" TestingCoverageAll = "testing.coverageAll" TestingRunSelected = "testing.runSelected" TestingDebugSelected = "testing.debugSelected" TestingCoverageSelected = "testing.coverageSelected" TestingRun = "testing.run" TestingDebug = "testing.debug" TestingCoverage = "testing.coverage" TestingRunAtCursor = "testing.runAtCursor" TestingDebugAtCursor = "testing.debugAtCursor" TestingCoverageAtCursor = "testing.coverageAtCursor" TestingRunCurrentFile = "testing.runCurrentFile" TestingDebugCurrentFile = "testing.debugCurrentFile" TestingCoverageCurrentFile = "testing.coverageCurrentFile" TestingReRunLastRun = "testing.reRunLastRun" TestingDebugLastRun = "testing.debugLastRun" TestingCoverageLastRun = "testing.coverageLastRun" TestingReRunFailTests = "testing.reRunFailTests" TestingDebugFailTests = "testing.debugFailTests" TestingReRunFailedLastRun = "testing.reRunFailedFromLastRun" TestingDebugFailedLastRun = "testing.debugFailedFromLastRun" TestingShowMostRecentOutput = "testing.showMostRecentOutput" TestingCancelRun = "testing.cancelRun" TestingRefreshTests = "testing.refreshTests" TestingCancelRefresh = "testing.cancelTestRefresh" TestingClearResults = "testing.clearTestResults" TestingCollapseAll = "testing.collapseAll" TestingViewAsList = "testing.viewAsList" TestingViewAsTree = "testing.viewAsTree" TestingSortByStatus = "testing.sortByStatus" TestingSortByLocation = "testing.sortByLocation" TestingSortByDuration = "testing.sortByDuration" TestingGoToTest = "testing.editFocusedTest" TestingHideTest = "testing.hideTest" TestingUnhideTest = "testing.unhideTest" TestingUnhideAll = "testing.unhideAllTests" TestingToggleContinuous = "testing.toggleContinuousRunForTest" TestingStartContinuous = "testing.startContinuousRun" TestingStopContinuous = "testing.stopContinuousRun" TestingSelectDefaultProfiles = "testing.selectDefaultTestProfiles" TestingConfigureProfile = "testing.configureProfile" // The commands of the editor and the peek (step 26.3). TestingOpenOutputPeek = "testing.openOutputPeek" TestingGoToNextMessage = "testing.goToNextMessage" TestingGoToPrevMessage = "testing.goToPreviousMessage" TestingClosePeek = "editor.closeTestPeek" TestingPeekError = "testing.peekTestError" TestingRevealTest = "testing.revealTest" // The commands of coverage (step 26.4). TestingToggleInlineCoverage = "testing.toggleInlineCoverage" TestingToggleCoverageToolbar = "testing.coverageToggleToolbar" TestingToggleCoverageInExplorer = "testing.toggleCoverageInExplorer" TestingCoverageNextMissed = "testing.coverage.goToNextMissedLine" TestingCoveragePreviousMissed = "testing.coverage.goToPreviousMissedLine" TestingCoverageClose = "testing.coverage.close" TestingCoverageChangeSorting = "testing.coverageViewChangeSorting" TestingCoverageCollapseAll = "testing.coverageViewCollapseAll" TestingOpenCoverage = "testing.openCoverage" // TestingFocusCoverage shows the Test Coverage view and gives its tree the keyboard. TestingFocusCoverage = ViewTestCoverage + ".focus" // TestingFocusExplorer shows the Test Explorer and gives its tree the keyboard (VS Code's focus command of a view). TestingFocusExplorer = ViewTestExplorer + ".focus" // TestingFocusResults shows the Test Results panel and gives it the keyboard. TestingFocusResults = ViewTestResults + ".focus" // TestingFilter focuses the filter box of the Test Explorer (VS Code's TestCommandId.FilterAction). TestingFilter = "workbench.actions.treeView.testExplorer.filter" )
The ids of the commands of Testing (VS Code's TestCommandId).
const ( // ViewContainerExplorer is the Explorer, the first container of the activity bar. ViewContainerExplorer = "workbench.view.explorer" // ViewExplorerFolders is the view of the folder in the Explorer. ViewExplorerFolders = "workbench.explorer.fileView" // ViewExplorerEmpty is the view of the Explorer in a window that has no folder. ViewExplorerEmpty = "workbench.explorer.emptyView" // ViewOpenEditors is the Open Editors view of the Explorer. ViewOpenEditors = "workbench.explorer.openEditorsView" // ViewContainerSCM is the Source Control container (step 24.3, SPEC §10.30). ViewContainerSCM = "workbench.view.scm" // ViewSCMRepositories is the Repositories view of Source Control and ViewSCM its Changes view. ViewSCMRepositories = "workbench.scm.repositories" // ViewSCM is the Changes view of Source Control (VS Code's VIEW_PANE_ID). ViewSCM = "workbench.scm" // ViewSCMHistory is the Graph view of Source Control (VS Code's HISTORY_VIEW_PANE_ID), shown while a source control has a history // provider (step 24.20). ViewSCMHistory = "workbench.scm.history" // ViewContainerMarkers is the Problems tab of the panel. ViewContainerMarkers = "workbench.panel.markers" // ViewMarkers is the view of the Problems tab. ViewMarkers = "workbench.panel.markers.view" // ViewContainerOutput is the Output tab of the panel. ViewContainerOutput = "workbench.panel.output" // ViewOutput is the view of the Output tab. ViewOutput = "workbench.panel.output" )
The ids of the view containers and views of the window.
const DebugConsoleContext = "DebugConsoleContext"
DebugConsoleContext is the context menu of the Debug Console.
const MenubarNewBreakpointMenu = "MenubarNewBreakpointMenu"
MenubarNewBreakpointMenu is the submenu "New Breakpoint" of the Run menu.
const ViewOutline = "outline"
ViewOutline is the Outline view of the Explorer (step 12.7).
const ViewTimeline = "timeline"
ViewTimeline is the Timeline view of the Explorer.
Variables ¶
This section is empty.
Functions ¶
func MnemonicMenuLabel ¶
MnemonicMenuLabel turns a title written the way VS Code writes mnemonics ("&&File": the F is the mnemonic, a single "&" is an ampersand) into a label of the menu widgets, where a single ampersand marks the mnemonic and "&&" is an ampersand: "&&File" gives "&File" and "Q&A" gives "Q&&A".
Ported from VS Code: src/vs/base/common/labels.ts (mnemonicMenuLabel, the version for Windows and Linux)
func RefusedClasses ¶ added in v1.0.0
func RefusedClasses() []string
RefusedClasses lists the classes of ClientRefusal, in the order of the rules, each once (a class may have several rules).
func RefusedExactIDs ¶ added in v1.0.0
func RefusedExactIDs() []string
RefusedExactIDs lists the commands that ClientRefusal refuses by their whole id, and RefusedPrefixes the prefixes it refuses; the tests check that they name commands that exist.
func RefusedPrefixes ¶ added in v1.0.0
func RefusedPrefixes() []string
RefusedPrefixes lists the prefixes of the ids that ClientRefusal refuses.
Types ¶
type Context ¶
type Context struct {
// Ctx is cancelled when the work of the command is no longer wanted.
Ctx context.Context
// Keys are the context keys at the time of the request; may be nil.
Keys contextkey.Context
// Source tells what asked for the command.
Source Source
// Origin is the screen the command was asked on: the window of the host (the zero value) or the view of a client of a hosted
// workspace. A registry that forwards a command to its parent sets it (Registry.Inherit), and the extension host keeps it for the
// questions the command's handler asks (SPEC §10.18 "As built (step 24.25)").
Origin extension.Origin
// Result, when the caller set it, receives the value the command gives back (VS Code's commands return one): the interactive variables
// of a launch configuration, ${command:pickProcess}, read it (step 25.4, decision 1187). A handler that has a value calls Result once; most
// commands give none, and the caller then sees no value.
Result func(value any)
}
Context is what a command handler receives: the Go context for cancellation, the context keys of the part of the window that was focused when the command was asked for, and where the request came from.
type Handler ¶
Handler runs a command. args is a JSON-compatible value (nil, bool, float64, string, a slice or a map) or nil when the caller passed none.
type MenuEntry ¶
type MenuEntry struct {
// Command is the command to run, or empty for a separator and a submenu.
Command string
// Args are the arguments of the command.
Args any
// Icon is the name of the Codicon of the command (Meta.Icon), for a toolbar that draws icons.
Icon string
// Group is the group of the item in its menu (MenuItem.Group): a toolbar shows the items of one group as buttons.
Group string
// Title is the text of the entry; MnemonicTitle is the text with "&&" marking the mnemonic, as
// the menu bar wants it (see MnemonicMenuLabel).
Title, MnemonicTitle string
// Checked tells that the entry shows a check mark.
Checked bool
// Disabled tells that the precondition of the command does not hold.
Disabled bool
// Separator makes this entry a line between two groups.
Separator bool
// Submenu is the id of the menu a submenu entry shows; Items are its entries.
Items []MenuEntry
}
MenuEntry is an item of a menu as the context shows it: the items that apply, in order, with a separator entry between two groups.
type MenuItem ¶
type MenuItem struct {
// Menu is the id of the menu the item is in.
Menu string
// Command is the id of the command the item runs. An item whose command is not registered is not
// shown.
Command string
Submenu string
// Title is the text of the item; the title of the command when empty (a submenu needs one).
Title string
// MnemonicTitle is the text of the item in the menu bar, with the mnemonic marked by "&&" as VS
// Code writes it ("&&Undo", "Cu&&t"); Title when empty. Context menus have no mnemonics and show
// Title.
MnemonicTitle string
// ToggledTitle replaces Title in a context menu while the item is toggled, and
// ToggledMnemonicTitle (ToggledTitle when empty) replaces MnemonicTitle in the menu bar whether
// or not it is (VS Code's `toggled.title` and `toggled.mnemonicTitle`: "Primary Side Bar").
ToggledTitle, ToggledMnemonicTitle string
// Group is the group the item belongs to; the groups of a menu are separated by a line and
// ordered by name ("navigation" first, the items without a group last). VS Code names them
// "1_do", "2_ccp"...
Group string
// Order orders the items of a group, and is 0 when not set.
Order float64
// When is the condition under which the item is in the menu; nil is always.
When contextkey.Expr
// Precondition, when set, is the condition under which the item is enabled in place of the
// precondition of the command. An item that is not enabled stays in the menu, dimmed.
Precondition contextkey.Expr
// Toggled is the condition under which the item shows a check mark.
Toggled contextkey.Expr
// Args are the arguments the command is run with (an item of a dynamic menu).
Args any
// Extension marks an item that an extension's manifest or API added: the registry of the view of a client of a hosted workspace
// shows these items of its parent (MenuRegistry.Inherit).
Extension bool
// contains filtered or unexported fields
}
MenuItem is a row of a menu: a command, or a submenu that another menu is shown as. Exactly one of Command and Submenu is set.
Ported from VS Code: src/vs/platform/actions/common/actions.ts (IMenuItem, ISubmenuItem)
type MenuProvider ¶
type MenuProvider func(ctx contextkey.Context) []MenuItem
MenuProvider gives the items of a menu that change with the state of the program (the recently opened files): it is asked each time the menu is built. The items have to be of this menu.
type MenuRegistry ¶
type MenuRegistry struct {
// contains filtered or unexported fields
}
MenuRegistry holds the items of the menus (SPEC §11.2). It is safe for concurrent use. Make one with NewMenuRegistry; there is no global instance.
Ported from VS Code: src/vs/platform/actions/common/actions.ts (MenuRegistry) and src/vs/platform/actions/common/menuService.ts
func DefaultMenus ¶
func DefaultMenus(commands *Registry) *MenuRegistry
DefaultMenus makes a registry of menus over a registry of commands, with the items of the menus of the window (SPEC §10.4, §11.2). Each step that adds a command VS Code puts in a menu adds its row here, in the group and the order VS Code uses; a row for a command that does not exist yet is not added (the menus skip an item whose command is not registered, but the tests check the table).
The menu bar shows a menu only when it has an item, so File, Terminal and Help are not in the bar until the commands of their rows exist.
func NewMenuRegistry ¶
func NewMenuRegistry(commands *Registry) *MenuRegistry
NewMenuRegistry makes an empty registry of menus over a registry of commands, which gives the titles and the preconditions of the items.
func (*MenuRegistry) Add ¶
func (r *MenuRegistry) Add(items ...MenuItem) error
Add adds items to their menus. An item needs a menu, and a command or a submenu but not both.
func (*MenuRegistry) AddRemovable ¶ added in v1.0.0
func (r *MenuRegistry) AddRemovable(items ...MenuItem) (remove func(), err error)
AddRemovable is Add that gives back the function which takes the items out of their menus again (an extension's menu items go with the extension, SPEC §10.15). The function may be called more than once.
func (*MenuRegistry) All ¶
func (r *MenuRegistry) All() []MenuItem
All lists the items added to menus, by menu and then in the order they were added.
func (*MenuRegistry) Fork ¶ added in v1.0.0
func (r *MenuRegistry) Fork(commands *Registry) *MenuRegistry
Fork makes a registry of menus over another registry of commands (the fork of one window, SPEC §5.1) with the items and the providers this one has now: adding or removing an item in the fork does not touch this registry, nor the other way round.
func (*MenuRegistry) Inherit ¶ added in v1.0.0
func (r *MenuRegistry) Inherit(parent *MenuRegistry)
Inherit makes the menus show, besides their own items, the items that extensions added to parent (MenuItem.Extension) as they are at the moment a menu is built. The view of a client of a hosted workspace has the menu items of the workspace's extensions this way (SPEC §10.18 "As built (step 24.25)"); an item of a command the view's registry refuses is left out by the registry of commands. Call it once, before the registry is used.
func (*MenuRegistry) Items ¶
func (r *MenuRegistry) Items(menu string, ctx contextkey.Context) []MenuEntry
Items gives the entries of a menu in a context: the items whose When holds, in the order of VS Code (groups by name with "navigation" first and the items without a group last, then by order, then by title), with a separator entry between two groups. A group with nothing in it is left out, and so is a submenu with nothing in it, an item whose command is not registered and an item with no title. An item whose command is not enabled in the context stays, Disabled.
func (*MenuRegistry) ItemsOf ¶ added in v1.0.0
func (r *MenuRegistry) ItemsOf(menu string) []MenuItem
ItemsOf are the items that were added to a menu, as they were added, in no order and whatever their conditions (the Graph reads the group and the place of an action of the menu of the references to put its submenu there).
func (*MenuRegistry) MustAdd ¶
func (r *MenuRegistry) MustAdd(items ...MenuItem)
MustAdd is Add for the table of built-in items; it panics on an invalid item.
func (*MenuRegistry) SetProvider ¶
func (r *MenuRegistry) SetProvider(menu string, p MenuProvider)
SetProvider adds a provider of dynamic items to a menu; its items are sorted with the others.
type Meta ¶
type Meta struct {
// ID is the command id. It is VS Code's id where the command exists in VS Code.
ID string
// Title is the name shown in the command palette and the keybindings UI. It is empty for
// a command VS Code does not list (the cursor commands), which the palette skips.
Title string
// Category groups commands in the palette, such as "View"; may be empty.
Category string
// Precondition is the when-clause under which the command is enabled; nil means always.
Precondition contextkey.Expr
// Description says what the command does, for the keybindings UI; may be empty.
Description string
// Icon is the name of the Codicon the command shows as where a menu draws an icon in place of the title (the inline
// actions and the title actions of a view: VS Code's command icon); empty for none.
Icon string
}
Meta describes a command. A command is registered with its Meta first; the package that implements it attaches the handler later with SetHandler (SPEC §11.2).
Ported from VS Code: src/vs/platform/commands/common/commands.ts
type Refusal ¶ added in v1.0.0
type Refusal struct {
// Class is one of the extension.Refused constants.
Class string
// Reason says in words why the command is refused.
Reason string
}
Refusal says that a command may not be run by a client of a workspace (the extension that drives a workspace for a remote user, SPEC §10.19 "Confinement"), and why.
func ClientRefusal ¶ added in v1.0.0
ClientRefusal tells whether a client may not run the command, and why. The id is the command's, case as it is.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the commands of a window. It is safe for concurrent use. Make one with NewRegistry; there is no global instance.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry makes a registry with the metadata of the commands Emetos has. Each step that adds a command adds it here (or to a function it calls) with VS Code's id and title; a command VS Code does not list in the palette (the cursor commands) has no title. The handlers are attached later by the packages that implement the commands.
func (*Registry) Enabled ¶
func (r *Registry) Enabled(id string, keys contextkey.Context) bool
Enabled tells whether the precondition of a command holds in keys. It is false for an unknown command. Menus and the palette use it; Run does not check it, as in VS Code where the keybinding and the menu check before they ask for the command.
func (*Registry) Fork ¶
Fork makes a registry with the same commands and the handlers they have now: the stack of each command is copied, so that setting or removing a handler in the fork does not touch this registry, nor the other way round. The windows of the process each have a fork (SPEC §5.1): the commands are the process's, the handlers that the shell of a window sets are the window's.
func (*Registry) HasHandler ¶
HasHandler tells whether a command is registered and has a handler.
func (*Registry) Inherit ¶ added in v1.0.0
Inherit makes the commands of parent that this registry does not have its own, as forwards: Lookup, Enabled, HasHandler, All and Run see them, and Run runs the parent's handler with origin in the context. It is how the view of a client of a hosted workspace has the commands of the extensions that the scope of the workspace registered in the registry of the window (SPEC §10.18 "As built (step 24.25)", D50). A command that ClientRefusal refuses is not inherited (Run fails with CommandRefused). Call it once, before the registry is used.
func (*Registry) MustRegister ¶
MustRegister is Register for the table of built-in commands; it panics on an invalid or duplicate command.
func (*Registry) Register ¶
Register adds the metadata of a command. The id must not be empty, start with "-" or "^" (keybindings read those as a removal and as bubbling), or contain white space, and must not be registered yet.
func (*Registry) Run ¶
Run runs a command by id with optional arguments. It fails when the id is unknown or no handler is attached; the error of the handler is returned as it is.
func (*Registry) SetHandler ¶
SetHandler attaches a handler to a registered command. Setting a handler on a command that has one stacks it: the last one set runs, and when its remover is called the one before it runs again (an editor widget takes over a command while it has focus). The remover may be called more than once.
func (*Registry) Unregister ¶ added in v1.0.0
Unregister removes a command and its handlers, and reports whether it was registered. It is how an extension's commands go when the extension is deactivated (SPEC §10.15); the commands of the editor are never removed.
type Source ¶
type Source int
Source tells what asked for a command to run.
const ( // SourceAPI is code calling the registry directly. SourceAPI Source = iota // SourceKeybinding is a key press resolved by the keybinding dispatcher. SourceKeybinding // SourceMenu is a menu entry. SourceMenu // SourcePalette is the command palette. SourcePalette // SourceStatusBar is a click on an item of the status bar. SourceStatusBar )
The things that run commands.
type View ¶
type View struct {
// ID identifies the view ("workbench.explorer.fileView").
ID string
// Name is the title of the view, shown in its header.
Name string
// Container is the id of the container the view is in.
Container string
// When is the condition under which the view is shown; nil is always.
When contextkey.Expr
// Order orders the views of a container, the lowest first; views of an equal order keep the
// order they were registered in.
Order int
// Collapsed tells that the view starts with its body folded away.
Collapsed bool
// HideByDefault tells that the view is not shown until the user (or a command) shows it, such as
// Open Editors in the Explorer.
HideByDefault bool
// Weight is the share of the room that is left that the view gets next to the other open views (VS Code's `weight`, which
// sizes the views of Run and Debug 40, 10, 30 and 20); 0 is 1, an equal share.
Weight int
}
View is a section of a view container: a header with a title that collapses the body below it.
Ported from VS Code: src/vs/workbench/common/views.ts (IViewDescriptor, IViewsRegistry)
type ViewContainer ¶
type ViewContainer struct {
// ID identifies the container ("workbench.view.explorer").
ID string
// Title is the name of the container: the title of the side bar, and the tooltip of its icon.
Title string
// Icon is the code point of the Codicon of the container.
Icon int
// Order orders the containers in the activity bar, the lowest first; containers of an equal
// order keep the order they were registered in.
Order int
// Location is where the container is shown; the side bar when empty.
Location ViewLocation
// HideIfEmpty hides the container (its tab) while none of its views is shown, as VS Code's `hideIfEmpty` does.
HideIfEmpty bool
}
ViewContainer holds views and is shown as a whole: one icon of the activity bar and the title of the side bar, or a tab of the panel.
Ported from VS Code: src/vs/workbench/common/views.ts (ViewContainer, IViewContainersRegistry)
type ViewLocation ¶
type ViewLocation string
ViewLocation is the part of the workbench a view container is shown in.
const ( // ViewLocationSideBar is the primary side bar, switched by the activity bar. ViewLocationSideBar ViewLocation = "sidebar" // ViewLocationPanel is the panel. ViewLocationPanel ViewLocation = "panel" )
The locations of view containers.
type ViewRegistry ¶
type ViewRegistry struct {
// contains filtered or unexported fields
}
ViewRegistry holds the view containers and the views in them (SPEC §10.4). It is safe for concurrent use. Make one with NewViewRegistry; there is no global instance.
Ported from VS Code: src/vs/workbench/common/views.ts (ViewContainersRegistry, ViewsRegistry)
func DefaultViews ¶
func DefaultViews() *ViewRegistry
DefaultViews makes a registry with the view containers and the views of the window (SPEC §10.4). The steps that build the views of a container (the Explorer in 6.14, Search, Source Control, Run and Debug) register their containers and views here, with the id, title and icon VS Code gives them; until then a view is a header with an empty body.
The panel has the containers of the Problems, the Output and the Debug Console (the step for the Terminal adds its own), each with the one view that VS Code registers in it.
Ported from VS Code: src/vs/workbench/contrib/files/browser/explorerViewlet.ts, src/vs/workbench/contrib/scm/browser/scm.contribution.ts, src/vs/workbench/contrib/markers/browser/markers.contribution.ts and src/vs/workbench/contrib/output/browser/output.contribution.ts
func NewViewRegistry ¶
func NewViewRegistry() *ViewRegistry
NewViewRegistry makes an empty registry.
func (*ViewRegistry) Container ¶
func (r *ViewRegistry) Container(id string) (ViewContainer, bool)
Container returns a container by id.
func (*ViewRegistry) Containers ¶
func (r *ViewRegistry) Containers(loc ViewLocation) []ViewContainer
Containers lists the containers of a location in the order of the activity bar.
func (*ViewRegistry) Fork ¶ added in v1.0.0
func (r *ViewRegistry) Fork() *ViewRegistry
Fork makes a registry with the containers and the views of r. The two are independent from then on: what is added to or removed from one is not in the other. A window forks the registry of the process, so the views its extensions add are its own (SPEC §10.15).
func (*ViewRegistry) Inherit ¶ added in v1.0.0
func (r *ViewRegistry) Inherit(parent *ViewRegistry)
Inherit makes the registry list, besides its own, the containers and the views that parent has and it has not: the ones the extensions of a hosted workspace registered. A change of parent's is a change of this registry (OnChange). Call it once, before the registry is used.
func (*ViewRegistry) MustRegisterContainer ¶
func (r *ViewRegistry) MustRegisterContainer(c ViewContainer)
MustRegisterContainer is RegisterContainer for the table of built-in containers; it panics on a failure.
func (*ViewRegistry) MustRegisterViews ¶
func (r *ViewRegistry) MustRegisterViews(views ...View)
MustRegisterViews is RegisterViews for the table of built-in views; it panics on a failure.
func (*ViewRegistry) OnChange ¶ added in v1.0.0
func (r *ViewRegistry) OnChange(fn func()) (unsubscribe func())
OnChange calls fn after a container or a view was added or removed, on the goroutine that changed the registry and with no lock held, and returns the function that stops it.
func (*ViewRegistry) RegisterContainer ¶
func (r *ViewRegistry) RegisterContainer(c ViewContainer) error
RegisterContainer adds a view container. It needs an id and a title, and its id must be new.
func (*ViewRegistry) RegisterViews ¶
func (r *ViewRegistry) RegisterViews(views ...View) error
RegisterViews adds views to their containers, which have to be registered. A view needs an id and a name, and its id must be new.
func (*ViewRegistry) UnregisterContainer ¶ added in v1.0.0
func (r *ViewRegistry) UnregisterContainer(id string)
UnregisterContainer removes a container and its views. An id that is not a container does nothing.
func (*ViewRegistry) UnregisterView ¶ added in v1.0.0
func (r *ViewRegistry) UnregisterView(id string)
UnregisterView removes a view. An id that is not a view does nothing.
func (*ViewRegistry) View ¶
func (r *ViewRegistry) View(id string) (View, bool)
View returns a view by id.
func (*ViewRegistry) Views ¶
func (r *ViewRegistry) Views(container string, ctx contextkey.Context) []View
Views lists the views of a container whose When holds in the context (all of them for a nil context), in order.