mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Menu migration (#122599)
This commit is contained in:
parent
c554dccf10
commit
5bf5c77800
|
@ -157,11 +157,11 @@ export class MenuId {
|
|||
static readonly TimelineTitleContext = new MenuId('TimelineTitleContext');
|
||||
static readonly AccountsContext = new MenuId('AccountsContext');
|
||||
static readonly PanelTitle = new MenuId('PanelTitle');
|
||||
static readonly TerminalContainerContext = new MenuId('TerminalContainerContext');
|
||||
static readonly TerminalToolbarContext = new MenuId('TerminalToolbarContext');
|
||||
static readonly TerminalTabsWidgetContext = new MenuId('TerminalTabsWidgetContext');
|
||||
static readonly TerminalTabsWidgetEmptyContext = new MenuId('TerminalTabsWidgetEmptyContext');
|
||||
static readonly TerminalSingleTabContext = new MenuId('TerminalSingleTabContext');
|
||||
static readonly TerminalInstanceContext = new MenuId('TerminalInstanceContext');
|
||||
static readonly TerminalNewDropdownContext = new MenuId('TerminalNewDropdownContext');
|
||||
static readonly TerminalTabContext = new MenuId('TerminalTabContext');
|
||||
static readonly TerminalTabEmptyAreaContext = new MenuId('TerminalTabEmptyAreaContext');
|
||||
static readonly TerminalInlineTabContext = new MenuId('TerminalInlineTabContext');
|
||||
|
||||
readonly id: number;
|
||||
readonly _debugName: string;
|
||||
|
|
|
@ -37,6 +37,7 @@ import { IQuickAccessRegistry, Extensions as QuickAccessExtensions } from 'vs/pl
|
|||
import { TasksQuickAccessProvider } from 'vs/workbench/contrib/tasks/browser/tasksQuickAccess';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry';
|
||||
import { TerminalMenuBarGroup } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
|
||||
|
||||
const SHOW_TASKS_COMMANDS_CONTEXT = ContextKeyExpr.or(ShellExecutionSupportedContext, ProcessExecutionSupportedContext);
|
||||
|
||||
|
@ -163,7 +164,7 @@ export class TaskStatusBarContributions extends Disposable implements IWorkbench
|
|||
workbenchRegistry.registerWorkbenchContribution(TaskStatusBarContributions, LifecyclePhase.Restored);
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: '2_run',
|
||||
group: TerminalMenuBarGroup.Run,
|
||||
command: {
|
||||
id: 'workbench.action.tasks.runTask',
|
||||
title: nls.localize({ key: 'miRunTask', comment: ['&& denotes a mnemonic'] }, "&&Run Task...")
|
||||
|
@ -173,7 +174,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
|||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: '2_run',
|
||||
group: TerminalMenuBarGroup.Run,
|
||||
command: {
|
||||
id: 'workbench.action.tasks.build',
|
||||
title: nls.localize({ key: 'miBuildTask', comment: ['&& denotes a mnemonic'] }, "Run &&Build Task...")
|
||||
|
@ -184,7 +185,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
|||
|
||||
// Manage Tasks
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: '3_manage',
|
||||
group: TerminalMenuBarGroup.Manage,
|
||||
command: {
|
||||
precondition: TASK_RUNNING_STATE,
|
||||
id: 'workbench.action.tasks.showTasks',
|
||||
|
@ -195,7 +196,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
|||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: '3_manage',
|
||||
group: TerminalMenuBarGroup.Manage,
|
||||
command: {
|
||||
precondition: TASK_RUNNING_STATE,
|
||||
id: 'workbench.action.tasks.restartTask',
|
||||
|
@ -206,7 +207,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
|||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: '3_manage',
|
||||
group: TerminalMenuBarGroup.Manage,
|
||||
command: {
|
||||
precondition: TASK_RUNNING_STATE,
|
||||
id: 'workbench.action.tasks.terminate',
|
||||
|
@ -218,7 +219,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
|||
|
||||
// Configure Tasks
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: '4_configure',
|
||||
group: TerminalMenuBarGroup.Configure,
|
||||
command: {
|
||||
id: 'workbench.action.tasks.configureTaskRunner',
|
||||
title: nls.localize({ key: 'miConfigureTask', comment: ['&& denotes a mnemonic'] }, "&&Configure Tasks...")
|
||||
|
@ -228,7 +229,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
|||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: '4_configure',
|
||||
group: TerminalMenuBarGroup.Configure,
|
||||
command: {
|
||||
id: 'workbench.action.tasks.configureDefaultBuildTask',
|
||||
title: nls.localize({ key: 'miConfigureBuildTask', comment: ['&& denotes a mnemonic'] }, "Configure De&&fault Build Task...")
|
||||
|
|
|
@ -21,7 +21,6 @@ import { TerminalViewPane } from 'vs/workbench/contrib/terminal/browser/terminal
|
|||
import { KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE_KEY, KEYBINDING_CONTEXT_TERMINAL_FOCUS, TERMINAL_VIEW_ID, TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { registerColors } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
|
||||
import { setupTerminalCommands } from 'vs/workbench/contrib/terminal/browser/terminalCommands';
|
||||
import { setupTerminalMenu } from 'vs/workbench/contrib/terminal/common/terminalMenu';
|
||||
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { TerminalService } from 'vs/workbench/contrib/terminal/browser/terminalService';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
@ -37,6 +36,7 @@ import { RemoteTerminalService } from 'vs/workbench/contrib/terminal/browser/rem
|
|||
import { isIPad } from 'vs/base/browser/browser';
|
||||
import { WindowsShellType } from 'vs/platform/terminal/common/terminal';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { setupTerminalMenus } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
|
||||
|
||||
// Register services
|
||||
registerSingleton(ITerminalService, TerminalService, true);
|
||||
|
@ -161,6 +161,7 @@ registerSendSequenceKeybinding(String.fromCharCode('E'.charCodeAt(0) - 64), {
|
|||
});
|
||||
|
||||
setupTerminalCommands();
|
||||
setupTerminalMenu();
|
||||
|
||||
setupTerminalMenus();
|
||||
|
||||
registerColors();
|
||||
|
|
|
@ -15,7 +15,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
|
|||
import { EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { localize } from 'vs/nls';
|
||||
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { Action2, ICommandActionTitle, ILocalizedString, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { Action2, ICommandActionTitle, ILocalizedString, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyAndExpr, ContextKeyEqualsExpr, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
@ -42,20 +42,6 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
|
|||
export const switchTerminalActionViewItemSeparator = '─────────';
|
||||
export const switchTerminalShowTabsTitle = localize('showTerminalTabs', "Show Tabs");
|
||||
|
||||
const enum ContextMenuGroup {
|
||||
Create = '1_create',
|
||||
Edit = '2_edit',
|
||||
Clear = '3_clear',
|
||||
Kill = '4_kill',
|
||||
Config = '5_config'
|
||||
}
|
||||
|
||||
export const enum ContextMenuTabsGroup {
|
||||
Default = '1_create_default',
|
||||
Profile = '2_create_profile',
|
||||
Configure = '3_configure'
|
||||
}
|
||||
|
||||
async function getCwdForSplit(configHelper: ITerminalConfigHelper, instance: ITerminalInstance, folders?: IWorkspaceFolder[], commandService?: ICommandService): Promise<string | URI | undefined> {
|
||||
switch (configHelper.config.splitCwd) {
|
||||
case 'workspaceRoot':
|
||||
|
@ -204,13 +190,7 @@ export function registerTerminalActions() {
|
|||
await terminalService.showPanel(true);
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalTabsWidgetEmptyContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW_WITH_PROFILE,
|
||||
title: localize('workbench.action.terminal.newWithProfile.short', "New Terminal With Profile")
|
||||
},
|
||||
group: ContextMenuGroup.Create
|
||||
});
|
||||
|
||||
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
|
@ -227,14 +207,6 @@ export function registerTerminalActions() {
|
|||
terminalService.showTabs();
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalContainerContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SHOW_TABS,
|
||||
title: localize('workbench.action.terminal.showsTabs', "Show Tabs")
|
||||
},
|
||||
when: ContextKeyExpr.not('config.terminal.integrated.tabs.enabled'),
|
||||
group: ContextMenuGroup.Config
|
||||
});
|
||||
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
|
@ -753,11 +725,7 @@ export function registerTerminalActions() {
|
|||
title: { value: localize('workbench.action.terminal.changeIcon', "Change Icon..."), original: 'Change Icon...' },
|
||||
f1: true,
|
||||
category,
|
||||
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED,
|
||||
menu: {
|
||||
id: MenuId.TerminalSingleTabContext,
|
||||
group: ContextMenuGroup.Edit
|
||||
}
|
||||
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
});
|
||||
}
|
||||
async run(accessor: ServicesAccessor) {
|
||||
|
@ -771,11 +739,7 @@ export function registerTerminalActions() {
|
|||
title: { value: localize('workbench.action.terminal.changeIcon', "Change Icon..."), original: 'Change Icon...' },
|
||||
f1: false,
|
||||
category,
|
||||
precondition: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_TABS_SINGULAR_SELECTION),
|
||||
menu: {
|
||||
id: MenuId.TerminalTabsWidgetContext,
|
||||
group: ContextMenuGroup.Edit
|
||||
}
|
||||
precondition: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_TABS_SINGULAR_SELECTION)
|
||||
});
|
||||
}
|
||||
async run(accessor: ServicesAccessor) {
|
||||
|
@ -789,11 +753,7 @@ export function registerTerminalActions() {
|
|||
title: { value: localize('workbench.action.terminal.rename', "Rename..."), original: 'Rename...' },
|
||||
f1: true,
|
||||
category,
|
||||
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED,
|
||||
menu: {
|
||||
id: MenuId.TerminalSingleTabContext,
|
||||
group: ContextMenuGroup.Edit
|
||||
}
|
||||
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
});
|
||||
}
|
||||
async run(accessor: ServicesAccessor) {
|
||||
|
@ -816,16 +776,6 @@ export function registerTerminalActions() {
|
|||
weight: KeybindingWeight.WorkbenchContrib
|
||||
},
|
||||
precondition: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_TABS_SINGULAR_SELECTION),
|
||||
menu: [
|
||||
{
|
||||
id: MenuId.TerminalTabsWidgetContext,
|
||||
group: ContextMenuGroup.Edit
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalContainerContext,
|
||||
group: ContextMenuGroup.Edit
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
async run(accessor: ServicesAccessor) {
|
||||
|
@ -1350,23 +1300,6 @@ export function registerTerminalActions() {
|
|||
when: KEYBINDING_CONTEXT_TERMINAL_FOCUS
|
||||
},
|
||||
icon: Codicon.splitHorizontal,
|
||||
menu: [
|
||||
{
|
||||
id: MenuId.ViewTitle,
|
||||
group: 'navigation',
|
||||
order: 2,
|
||||
when: ContextKeyAndExpr.create([
|
||||
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
|
||||
ContextKeyExpr.not('config.terminal.integrated.tabs.enabled')
|
||||
]),
|
||||
}, {
|
||||
id: MenuId.TerminalSingleTabContext,
|
||||
group: ContextMenuGroup.Create
|
||||
}, {
|
||||
id: MenuId.TerminalContainerContext,
|
||||
group: ContextMenuGroup.Create
|
||||
}
|
||||
],
|
||||
description: {
|
||||
description: 'workbench.action.terminal.split',
|
||||
args: [{
|
||||
|
@ -1398,10 +1331,6 @@ export function registerTerminalActions() {
|
|||
f1: false,
|
||||
category,
|
||||
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED,
|
||||
menu: {
|
||||
id: MenuId.TerminalTabsWidgetContext,
|
||||
group: ContextMenuGroup.Create
|
||||
},
|
||||
keybinding: {
|
||||
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_5,
|
||||
mac: {
|
||||
|
@ -1461,12 +1390,7 @@ export function registerTerminalActions() {
|
|||
mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_A },
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_FOCUS
|
||||
}],
|
||||
menu: {
|
||||
id: MenuId.TerminalContainerContext,
|
||||
group: ContextMenuGroup.Edit,
|
||||
order: 3
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
run(accessor: ServicesAccessor) {
|
||||
|
@ -1525,20 +1449,6 @@ export function registerTerminalActions() {
|
|||
await terminalService.showPanel(true);
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalTabsWidgetEmptyContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW,
|
||||
title: localize('workbench.action.terminal.new.short', "New Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Create
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalContainerContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW,
|
||||
title: localize('workbench.action.terminal.new.short', "New Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Create
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -1569,20 +1479,7 @@ export function registerTerminalActions() {
|
|||
});
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalContainerContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.KILL,
|
||||
title: localize('workbench.action.terminal.kill.short', "Kill Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Kill
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalSingleTabContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.KILL,
|
||||
title: localize('workbench.action.terminal.kill.short', "Kill Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Kill
|
||||
});
|
||||
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -1593,10 +1490,6 @@ export function registerTerminalActions() {
|
|||
f1: false,
|
||||
category,
|
||||
precondition: ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN),
|
||||
menu: {
|
||||
id: MenuId.TerminalTabsWidgetContext,
|
||||
group: ContextMenuGroup.Kill
|
||||
},
|
||||
keybinding: {
|
||||
primary: KeyCode.Delete,
|
||||
mac: {
|
||||
|
@ -1632,11 +1525,7 @@ export function registerTerminalActions() {
|
|||
// highest priority when chords are registered afterwards
|
||||
weight: KeybindingWeight.WorkbenchContrib + 1,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_FOCUS
|
||||
}],
|
||||
menu: {
|
||||
id: MenuId.TerminalContainerContext,
|
||||
group: ContextMenuGroup.Clear
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
run(accessor: ServicesAccessor) {
|
||||
|
@ -1660,13 +1549,7 @@ export function registerTerminalActions() {
|
|||
await accessor.get(ITerminalService).showProfileQuickPick('setDefault');
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalToolbarContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SELECT_DEFAULT_PROFILE,
|
||||
title: { value: localize('workbench.action.terminal.selectDefaultProfile', "Select Default Profile"), original: 'Select Default Profile' }
|
||||
},
|
||||
group: ContextMenuTabsGroup.Configure
|
||||
});
|
||||
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -1703,13 +1586,7 @@ export function registerTerminalActions() {
|
|||
await accessor.get(IPreferencesService).openSettings(false, '@feature:terminal');
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalToolbarContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.CONFIGURE_TERMINAL_SETTINGS,
|
||||
title: localize('workbench.action.terminal.openSettings', "Configure Terminal Settings")
|
||||
},
|
||||
group: ContextMenuTabsGroup.Configure
|
||||
});
|
||||
|
||||
// Some commands depend on platform features
|
||||
if (BrowserFeatures.clipboard.writeText) {
|
||||
registerAction2(class extends Action2 {
|
||||
|
@ -1734,14 +1611,6 @@ export function registerTerminalActions() {
|
|||
await accessor.get(ITerminalService).getActiveInstance()?.copySelection();
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalContainerContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.COPY_SELECTION,
|
||||
title: localize('workbench.action.terminal.copySelection.short', "Copy")
|
||||
},
|
||||
group: ContextMenuGroup.Edit,
|
||||
order: 1
|
||||
});
|
||||
}
|
||||
|
||||
if (BrowserFeatures.clipboard.readText) {
|
||||
|
@ -1766,14 +1635,6 @@ export function registerTerminalActions() {
|
|||
await accessor.get(ITerminalService).getActiveInstance()?.paste();
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.TerminalContainerContext, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.PASTE,
|
||||
title: localize('workbench.action.terminal.paste.short', "Paste")
|
||||
},
|
||||
group: ContextMenuGroup.Edit,
|
||||
order: 2
|
||||
});
|
||||
}
|
||||
|
||||
if (BrowserFeatures.clipboard.readText && isLinux) {
|
||||
|
@ -1852,18 +1713,6 @@ export function registerTerminalActions() {
|
|||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SWITCH_TERMINAL,
|
||||
title: switchTerminalTitle
|
||||
},
|
||||
group: 'navigation',
|
||||
order: 0,
|
||||
when: ContextKeyAndExpr.create([
|
||||
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
|
||||
ContextKeyExpr.not('config.terminal.integrated.tabs.enabled')
|
||||
]),
|
||||
});
|
||||
}
|
||||
|
||||
interface IRemoteTerminalPick extends IQuickPickItem {
|
||||
|
|
332
src/vs/workbench/contrib/terminal/browser/terminalMenus.ts
Normal file
332
src/vs/workbench/contrib/terminal/browser/terminalMenus.ts
Normal file
|
@ -0,0 +1,332 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { ContextKeyAndExpr, ContextKeyEqualsExpr, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, TERMINAL_COMMAND_ID, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
|
||||
const enum ContextMenuGroup {
|
||||
Create = '1_create',
|
||||
Edit = '2_edit',
|
||||
Clear = '3_clear',
|
||||
Kill = '4_kill',
|
||||
Config = '5_config'
|
||||
}
|
||||
|
||||
export const enum TerminalTabContextMenuGroup {
|
||||
Default = '1_create_default',
|
||||
Profile = '2_create_profile',
|
||||
Configure = '3_configure'
|
||||
}
|
||||
|
||||
export const enum TerminalMenuBarGroup {
|
||||
Create = '1_create',
|
||||
Run = '2_run',
|
||||
Manage = '3_manage',
|
||||
Configure = '4_configure'
|
||||
}
|
||||
|
||||
export function setupTerminalMenus(): void {
|
||||
MenuRegistry.appendMenuItems(
|
||||
[
|
||||
{
|
||||
id: MenuId.MenubarTerminalMenu, item: {
|
||||
group: TerminalMenuBarGroup.Create,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW,
|
||||
title: localize({ key: 'miNewTerminal', comment: ['&& denotes a mnemonic'] }, "&&New Terminal")
|
||||
},
|
||||
order: 1
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.MenubarTerminalMenu, item: {
|
||||
group: TerminalMenuBarGroup.Create,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SPLIT,
|
||||
title: localize({ key: 'miSplitTerminal', comment: ['&& denotes a mnemonic'] }, "&&Split Terminal"),
|
||||
precondition: ContextKeyExpr.has('terminalIsOpen')
|
||||
},
|
||||
order: 2,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.MenubarTerminalMenu, item: {
|
||||
group: TerminalMenuBarGroup.Run,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.RUN_ACTIVE_FILE,
|
||||
title: localize({ key: 'miRunActiveFile', comment: ['&& denotes a mnemonic'] }, "Run &&Active File")
|
||||
},
|
||||
order: 3,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.MenubarTerminalMenu, item: {
|
||||
group: TerminalMenuBarGroup.Run,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.RUN_SELECTED_TEXT,
|
||||
title: localize({ key: 'miRunSelectedText', comment: ['&& denotes a mnemonic'] }, "Run &&Selected Text")
|
||||
},
|
||||
order: 4,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
MenuRegistry.appendMenuItems(
|
||||
[
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
group: ContextMenuGroup.Create,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SPLIT,
|
||||
title: localize('workbench.action.terminal.split', "Split Terminal")
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW,
|
||||
title: localize('workbench.action.terminal.new.short', "New Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Create
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.KILL,
|
||||
title: localize('workbench.action.terminal.kill.short', "Kill Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Kill
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.COPY_SELECTION,
|
||||
title: localize('workbench.action.terminal.copySelection.short', "Copy")
|
||||
},
|
||||
group: ContextMenuGroup.Edit,
|
||||
order: 1
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.PASTE,
|
||||
title: localize('workbench.action.terminal.paste.short', "Paste")
|
||||
},
|
||||
group: ContextMenuGroup.Edit,
|
||||
order: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.CLEAR,
|
||||
title: localize('workbench.action.terminal.clear', "Clear")
|
||||
},
|
||||
group: ContextMenuGroup.Clear,
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SHOW_TABS,
|
||||
title: localize('workbench.action.terminal.showsTabs', "Show Tabs")
|
||||
},
|
||||
when: ContextKeyExpr.not('config.terminal.integrated.tabs.enabled'),
|
||||
group: ContextMenuGroup.Config
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInstanceContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SELECT_ALL,
|
||||
title: localize('workbench.action.terminal.selectAll', "Select All"),
|
||||
},
|
||||
group: ContextMenuGroup.Edit,
|
||||
order: 3
|
||||
}
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
MenuRegistry.appendMenuItems(
|
||||
[
|
||||
{
|
||||
id: MenuId.TerminalTabEmptyAreaContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW_WITH_PROFILE,
|
||||
title: localize('workbench.action.terminal.newWithProfile.short', "New Terminal With Profile")
|
||||
},
|
||||
group: ContextMenuGroup.Create
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalTabEmptyAreaContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW,
|
||||
title: localize('workbench.action.terminal.new.short', "New Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Create
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
MenuRegistry.appendMenuItems(
|
||||
[
|
||||
{
|
||||
id: MenuId.TerminalNewDropdownContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SELECT_DEFAULT_PROFILE,
|
||||
title: { value: localize('workbench.action.terminal.selectDefaultProfile', "Select Default Profile"), original: 'Select Default Profile' }
|
||||
},
|
||||
group: TerminalTabContextMenuGroup.Configure
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalNewDropdownContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.CONFIGURE_TERMINAL_SETTINGS,
|
||||
title: localize('workbench.action.terminal.openSettings', "Configure Terminal Settings")
|
||||
},
|
||||
group: TerminalTabContextMenuGroup.Configure
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
MenuRegistry.appendMenuItems(
|
||||
[
|
||||
{
|
||||
id: MenuId.ViewTitle, item: {
|
||||
group: 'navigation',
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SPLIT,
|
||||
title: localize('workbench.action.terminal.split', "Split Terminal")
|
||||
},
|
||||
order: 2,
|
||||
when: ContextKeyAndExpr.create([
|
||||
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
|
||||
ContextKeyExpr.not('config.terminal.integrated.tabs.enabled')
|
||||
])
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.ViewTitle, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SWITCH_TERMINAL,
|
||||
title: { value: localize('workbench.action.terminal.switchTerminal', "Switch Terminal"), original: 'Switch Terminal' }
|
||||
},
|
||||
group: 'navigation',
|
||||
order: 0,
|
||||
when: ContextKeyAndExpr.create([
|
||||
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
|
||||
ContextKeyExpr.not('config.terminal.integrated.tabs.enabled')
|
||||
]),
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
MenuRegistry.appendMenuItems(
|
||||
[
|
||||
{
|
||||
id: MenuId.TerminalInlineTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.CHANGE_ICON,
|
||||
title: localize('workbench.action.terminal.changeIcon', "Change Icon...")
|
||||
},
|
||||
group: ContextMenuGroup.Edit,
|
||||
order: 3
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInlineTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.RENAME,
|
||||
title: localize('workbench.action.terminal.rename', "Rename...")
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInlineTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.RENAME_INSTANCE,
|
||||
title: localize('workbench.action.terminal.renameInstance', "Rename...")
|
||||
},
|
||||
group: ContextMenuGroup.Edit
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInlineTabContext, item: {
|
||||
group: ContextMenuGroup.Create,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SPLIT,
|
||||
title: localize('workbench.action.terminal.split', "Split Terminal")
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalInlineTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.KILL,
|
||||
title: localize('workbench.action.terminal.kill.short', "Kill Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Kill
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
MenuRegistry.appendMenuItems(
|
||||
[
|
||||
{
|
||||
id: MenuId.TerminalTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.RENAME_INSTANCE,
|
||||
title: localize('workbench.action.terminal.renameInstance', "Rename...")
|
||||
},
|
||||
group: ContextMenuGroup.Edit
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.CHANGE_ICON_INSTANCE,
|
||||
title: localize('workbench.action.terminal.changeIcon', "Change Icon...")
|
||||
},
|
||||
group: ContextMenuGroup.Edit
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SPLIT_INSTANCE,
|
||||
title: localize('workbench.action.terminal.splitInstance', "Split Terminal"),
|
||||
},
|
||||
group: ContextMenuGroup.Create
|
||||
}
|
||||
},
|
||||
{
|
||||
id: MenuId.TerminalTabContext, item: {
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.KILL_INSTANCE,
|
||||
title: localize('workbench.action.terminal.killInstance', "Kill Terminal")
|
||||
},
|
||||
group: ContextMenuGroup.Kill,
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
|
@ -90,9 +90,9 @@ export class TerminalTabbedView extends Disposable {
|
|||
tabWidgetContainer.appendChild(this._terminalTabTree);
|
||||
this._tabTreeContainer.appendChild(tabWidgetContainer);
|
||||
|
||||
this._instanceMenu = this._register(menuService.createMenu(MenuId.TerminalContainerContext, contextKeyService));
|
||||
this._tabsWidgetMenu = this._register(menuService.createMenu(MenuId.TerminalTabsWidgetContext, contextKeyService));
|
||||
this._tabsWidgetEmptyMenu = this._register(menuService.createMenu(MenuId.TerminalTabsWidgetEmptyContext, contextKeyService));
|
||||
this._instanceMenu = this._register(menuService.createMenu(MenuId.TerminalInstanceContext, contextKeyService));
|
||||
this._tabsWidgetMenu = this._register(menuService.createMenu(MenuId.TerminalTabContext, contextKeyService));
|
||||
this._tabsWidgetEmptyMenu = this._register(menuService.createMenu(MenuId.TerminalTabEmptyAreaContext, contextKeyService));
|
||||
|
||||
this._register(this._tabsWidget = this._instantiationService.createInstance(TerminalTabsWidget, this._terminalTabTree));
|
||||
this._register(this._findWidget = this._instantiationService.createInstance(TerminalFindWidget, this._terminalService.getFindState()));
|
||||
|
|
|
@ -10,7 +10,7 @@ import { IContextMenuService, IContextViewService } from 'vs/platform/contextvie
|
|||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService, IColorTheme, registerThemingParticipant, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
|
||||
import { ContextMenuTabsGroup, switchTerminalActionViewItemSeparator, switchTerminalShowTabsTitle } from 'vs/workbench/contrib/terminal/browser/terminalActions';
|
||||
import { switchTerminalActionViewItemSeparator, switchTerminalShowTabsTitle } from 'vs/workbench/contrib/terminal/browser/terminalActions';
|
||||
import { TERMINAL_BACKGROUND_COLOR, TERMINAL_BORDER_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
|
||||
import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { ITerminalInstance, ITerminalService, TerminalConnectionState } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
|
@ -36,6 +36,7 @@ import { reset } from 'vs/base/browser/dom';
|
|||
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
|
||||
import { getColorForSeverity } from 'vs/workbench/contrib/terminal/browser/terminalStatusList';
|
||||
import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
import { TerminalTabContextMenuGroup } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
|
||||
|
||||
export class TerminalViewPane extends ViewPane {
|
||||
private _actions: IAction[] | undefined;
|
||||
|
@ -89,8 +90,8 @@ export class TerminalViewPane extends ViewPane {
|
|||
}
|
||||
});
|
||||
|
||||
this._dropdownMenu = this._register(this._menuService.createMenu(MenuId.TerminalToolbarContext, this._contextKeyService));
|
||||
this._singleTabMenu = this._register(this._menuService.createMenu(MenuId.TerminalSingleTabContext, this._contextKeyService));
|
||||
this._dropdownMenu = this._register(this._menuService.createMenu(MenuId.TerminalNewDropdownContext, this._contextKeyService));
|
||||
this._singleTabMenu = this._register(this._menuService.createMenu(MenuId.TerminalInlineTabContext, this._contextKeyService));
|
||||
this._register(this._terminalService.onDidChangeAvailableProfiles(profiles => this._updateTabActionBar(profiles)));
|
||||
}
|
||||
|
||||
|
@ -208,12 +209,12 @@ export class TerminalViewPane extends ViewPane {
|
|||
const submenuActions: IAction[] = [];
|
||||
|
||||
for (const p of profiles) {
|
||||
dropdownActions.push(new MenuItemAction({ id: TERMINAL_COMMAND_ID.NEW_WITH_PROFILE, title: p.profileName, category: ContextMenuTabsGroup.Profile }, undefined, { arg: p, shouldForwardArgs: true }, this._contextKeyService, this._commandService));
|
||||
submenuActions.push(new MenuItemAction({ id: TERMINAL_COMMAND_ID.SPLIT, title: p.profileName, category: ContextMenuTabsGroup.Profile }, undefined, { arg: p, shouldForwardArgs: true }, this._contextKeyService, this._commandService));
|
||||
dropdownActions.push(new MenuItemAction({ id: TERMINAL_COMMAND_ID.NEW_WITH_PROFILE, title: p.profileName, category: TerminalTabContextMenuGroup.Profile }, undefined, { arg: p, shouldForwardArgs: true }, this._contextKeyService, this._commandService));
|
||||
submenuActions.push(new MenuItemAction({ id: TERMINAL_COMMAND_ID.SPLIT, title: p.profileName, category: TerminalTabContextMenuGroup.Profile }, undefined, { arg: p, shouldForwardArgs: true }, this._contextKeyService, this._commandService));
|
||||
}
|
||||
|
||||
for (const contributed of this._terminalContributionService.terminalTypes) {
|
||||
dropdownActions.push(new MenuItemAction({ id: contributed.command, title: contributed.title, category: ContextMenuTabsGroup.Profile }, undefined, undefined, this._contextKeyService, this._commandService));
|
||||
dropdownActions.push(new MenuItemAction({ id: contributed.command, title: contributed.title, category: TerminalTabContextMenuGroup.Profile }, undefined, undefined, this._contextKeyService, this._commandService));
|
||||
}
|
||||
|
||||
if (dropdownActions.length > 0) {
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export function setupTerminalMenu() {
|
||||
|
||||
// Manage
|
||||
const createGroup = '1_create';
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: createGroup,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.NEW,
|
||||
title: nls.localize({ key: 'miNewTerminal', comment: ['&& denotes a mnemonic'] }, "&&New Terminal")
|
||||
},
|
||||
order: 1
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: createGroup,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.SPLIT,
|
||||
title: nls.localize({ key: 'miSplitTerminal', comment: ['&& denotes a mnemonic'] }, "&&Split Terminal"),
|
||||
precondition: ContextKeyExpr.has('terminalIsOpen')
|
||||
},
|
||||
order: 2,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
});
|
||||
|
||||
// Run
|
||||
const runGroup = '2_run';
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: runGroup,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.RUN_ACTIVE_FILE,
|
||||
title: nls.localize({ key: 'miRunActiveFile', comment: ['&& denotes a mnemonic'] }, "Run &&Active File")
|
||||
},
|
||||
order: 3,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, {
|
||||
group: runGroup,
|
||||
command: {
|
||||
id: TERMINAL_COMMAND_ID.RUN_SELECTED_TEXT,
|
||||
title: nls.localize({ key: 'miRunSelectedText', comment: ['&& denotes a mnemonic'] }, "Run &&Selected Text")
|
||||
},
|
||||
order: 4,
|
||||
when: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue