Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/contextmenu/browser/contextmenu.contribution.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Disposable } from '../../../../base/common/lifecycle.js';
7
import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js';
8
import { ILayoutService } from '../../../../platform/layout/browser/layoutService.js';
9
import { Registry } from '../../../../platform/registry/common/platform.js';
10
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from '../../../common/contributions.js';
11
import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js';
12
13
class ContextMenuContribution extends Disposable implements IWorkbenchContribution {
14
15
constructor(
16
@ILayoutService layoutService: ILayoutService,
17
@IContextMenuService contextMenuService: IContextMenuService
18
) {
19
super();
20
21
const update = (visible: boolean) => layoutService.activeContainer.classList.toggle('context-menu-visible', visible);
22
this._register(contextMenuService.onDidShowContextMenu(() => update(true)));
23
this._register(contextMenuService.onDidHideContextMenu(() => update(false)));
24
}
25
}
26
27
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
28
.registerWorkbenchContribution(ContextMenuContribution, LifecyclePhase.Eventually);
29
30