From 0f3ed38c8b516ada26c8b4ac48d7d4724ba5820a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 18 Jul 2018 09:11:04 -0700 Subject: [PATCH] Move terminal menu to parts/terminal Part of #54510 --- .../parts/menubar/menubar.contribution.ts | 100 ------------------ .../parts/terminal/common/terminalCommands.ts | 2 +- .../parts/terminal/common/terminalMenu.ts | 96 +++++++++++++++++ .../electron-browser/terminal.contribution.ts | 6 +- 4 files changed, 101 insertions(+), 103 deletions(-) create mode 100644 src/vs/workbench/parts/terminal/common/terminalMenu.ts diff --git a/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts b/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts index dd13ba1c0c9..d74f6c44577 100644 --- a/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts +++ b/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts @@ -18,7 +18,6 @@ layoutMenuRegistration(); goMenuRegistration(); debugMenuRegistration(); tasksMenuRegistration(); -terminalMenuRegistration(); if (isMacintosh) { windowMenuRegistration(); @@ -1511,102 +1510,3 @@ function helpMenuRegistration() { order: 1 }); } - -function terminalMenuRegistration() { - - // Manage - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '1_manage', - command: { - id: 'workbench.action.terminal.new', - title: nls.localize({ key: 'miNewTerminal', comment: ['&& denotes a mnemonic'] }, "&&New Terminal") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '1_manage', - command: { - id: 'workbench.action.terminal.split', - title: nls.localize({ key: 'miSplitTerminal', comment: ['&& denotes a mnemonic'] }, "&&Split Terminal") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '1_manage', - command: { - id: 'workbench.action.terminal.kill', - title: nls.localize({ key: 'miKillTerminal', comment: ['&& denotes a mnemonic'] }, "&&Kill Terminal") - }, - order: 3 - }); - - // Run - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '2_run', - command: { - id: 'workbench.action.terminal.clear', - title: nls.localize({ key: 'miClear', comment: ['&& denotes a mnemonic'] }, "&&Clear") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '2_run', - command: { - id: 'workbench.action.terminal.runActiveFile', - title: nls.localize({ key: 'miRunActiveFile', comment: ['&& denotes a mnemonic'] }, "Run &&Active File") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '2_run', - command: { - id: 'workbench.action.terminal.runSelectedFile', - title: nls.localize({ key: 'miRunSelectedText', comment: ['&& denotes a mnemonic'] }, "Run &&Selected Text") - }, - order: 3 - }); - - // Selection - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '3_selection', - command: { - id: 'workbench.action.terminal.scrollToPreviousCommand', - title: nls.localize({ key: 'miScrollToPreviousCommand', comment: ['&& denotes a mnemonic'] }, "Scroll To Previous Command") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '3_selection', - command: { - id: 'workbench.action.terminal.scrollToNextCommand', - title: nls.localize({ key: 'miScrollToNextCommand', comment: ['&& denotes a mnemonic'] }, "Scroll To Next Command") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '3_selection', - command: { - id: 'workbench.action.terminal.selectToPreviousCommand', - title: nls.localize({ key: 'miSelectToPreviousCommand', comment: ['&& denotes a mnemonic'] }, "Select To Previous Command") - }, - order: 3 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { - group: '3_selection', - command: { - id: 'workbench.action.terminal.selectToNextCommand', - title: nls.localize({ key: 'miSelectToNextCommand', comment: ['&& denotes a mnemonic'] }, "Select To Next Command") - }, - order: 4 - }); -} \ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/common/terminalCommands.ts b/src/vs/workbench/parts/terminal/common/terminalCommands.ts index 828588d03b1..ceccf307528 100644 --- a/src/vs/workbench/parts/terminal/common/terminalCommands.ts +++ b/src/vs/workbench/parts/terminal/common/terminalCommands.ts @@ -6,7 +6,7 @@ import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal'; -export function setup(): void { +export function setupTerminalCommands(): void { registerOpenTerminalAtIndexCommands(); } diff --git a/src/vs/workbench/parts/terminal/common/terminalMenu.ts b/src/vs/workbench/parts/terminal/common/terminalMenu.ts new file mode 100644 index 00000000000..c746213d02a --- /dev/null +++ b/src/vs/workbench/parts/terminal/common/terminalMenu.ts @@ -0,0 +1,96 @@ +/*--------------------------------------------------------------------------------------------- + * 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'; + +export function setupTerminalMenu() { + // Manage + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '1_manage', + command: { + id: 'workbench.action.terminal.new', + title: nls.localize({ key: 'miNewTerminal', comment: ['&& denotes a mnemonic'] }, "&&New Terminal") + }, + order: 1 + }); + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '1_manage', + command: { + id: 'workbench.action.terminal.split', + title: nls.localize({ key: 'miSplitTerminal', comment: ['&& denotes a mnemonic'] }, "&&Split Terminal") + }, + order: 2 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '1_manage', + command: { + id: 'workbench.action.terminal.kill', + title: nls.localize({ key: 'miKillTerminal', comment: ['&& denotes a mnemonic'] }, "&&Kill Terminal") + }, + order: 3 + }); + + // Run + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '2_run', + command: { + id: 'workbench.action.terminal.clear', + title: nls.localize({ key: 'miClear', comment: ['&& denotes a mnemonic'] }, "&&Clear") + }, + order: 1 + }); + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '2_run', + command: { + id: 'workbench.action.terminal.runActiveFile', + title: nls.localize({ key: 'miRunActiveFile', comment: ['&& denotes a mnemonic'] }, "Run &&Active File") + }, + order: 2 + }); + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '2_run', + command: { + id: 'workbench.action.terminal.runSelectedFile', + title: nls.localize({ key: 'miRunSelectedText', comment: ['&& denotes a mnemonic'] }, "Run &&Selected Text") + }, + order: 3 + }); + + // Scroll/selection + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '3_selection', + command: { + id: 'workbench.action.terminal.scrollToPreviousCommand', + title: nls.localize({ key: 'miScrollToPreviousCommand', comment: ['&& denotes a mnemonic'] }, "Scroll To Previous Command") + }, + order: 1 + }); + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '3_selection', + command: { + id: 'workbench.action.terminal.scrollToNextCommand', + title: nls.localize({ key: 'miScrollToNextCommand', comment: ['&& denotes a mnemonic'] }, "Scroll To Next Command") + }, + order: 2 + }); + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '3_selection', + command: { + id: 'workbench.action.terminal.selectToPreviousCommand', + title: nls.localize({ key: 'miSelectToPreviousCommand', comment: ['&& denotes a mnemonic'] }, "Select To Previous Command") + }, + order: 3 + }); + MenuRegistry.appendMenuItem(MenuId.MenubarTerminalMenu, { + group: '3_selection', + command: { + id: 'workbench.action.terminal.selectToNextCommand', + title: nls.localize({ key: 'miSelectToNextCommand', comment: ['&& denotes a mnemonic'] }, "Select To Next Command") + }, + order: 4 + }); +} \ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index 5ba5b9659d1..2aa5e667ddc 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -11,7 +11,6 @@ import * as debugActions from 'vs/workbench/parts/debug/browser/debugActions'; import * as nls from 'vs/nls'; import * as panel from 'vs/workbench/browser/panel'; import * as platform from 'vs/base/common/platform'; -import * as terminalCommands from 'vs/workbench/parts/terminal/common/terminalCommands'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { ITerminalService, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, TERMINAL_PANEL_ID, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE, TerminalCursorStyle, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE, DEFAULT_LINE_HEIGHT, DEFAULT_LETTER_SPACING } from 'vs/workbench/parts/terminal/common/terminal'; import { getTerminalDefaultShellUnixLike, getTerminalDefaultShellWindows } from 'vs/workbench/parts/terminal/node/terminal'; @@ -37,6 +36,8 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { TogglePanelAction } from 'vs/workbench/browser/parts/panel/panelActions'; import { TerminalPanel } from 'vs/workbench/parts/terminal/electron-browser/terminalPanel'; import { TerminalPickerHandler } from 'vs/workbench/parts/terminal/browser/terminalQuickOpen'; +import { setupTerminalCommands } from 'vs/workbench/parts/terminal/common/terminalCommands'; +import { setupTerminalMenu } from 'vs/workbench/parts/terminal/common/terminalMenu'; const quickOpenRegistry = (Registry.as(QuickOpenExtensions.Quickopen)); @@ -533,6 +534,7 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToNextComm actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToPreviousLineAction, SelectToPreviousLineAction.ID, SelectToPreviousLineAction.LABEL), 'Terminal: Select To Previous Line', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToNextLineAction, SelectToNextLineAction.ID, SelectToNextLineAction.LABEL), 'Terminal: Select To Next Line', category); -terminalCommands.setup(); +setupTerminalCommands(); +setupTerminalMenu(); registerColors(); -- GitLab