terminal.contribution.ts 36.1 KB
Newer Older
D
Daniel Imms 已提交
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

D
Daniel Imms 已提交
6
import 'vs/css!./media/scrollbar';
D
Daniel Imms 已提交
7
import 'vs/css!./media/terminal';
D
Daniel Imms 已提交
8
import 'vs/css!./media/xterm';
9
import 'vs/css!./media/widgets';
D
Daniel Imms 已提交
10 11
import * as debugActions from 'vs/workbench/parts/debug/browser/debugActions';
import * as nls from 'vs/nls';
12
import * as panel from 'vs/workbench/browser/panel';
13
import * as platform from 'vs/base/common/platform';
14
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
15
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';
16
import { getTerminalDefaultShellUnixLike, getTerminalDefaultShellWindows } from 'vs/workbench/parts/terminal/node/terminal';
B
Benjamin Pasero 已提交
17
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
18 19
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
20
import { KillTerminalAction, ClearSelectionTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, CreateNewInActiveWorkspaceTerminalAction, FocusActiveTerminalAction, FocusNextTerminalAction, FocusPreviousTerminalAction, SelectDefaultShellWindowsTerminalAction, RunSelectedTextInTerminalAction, RunActiveFileInTerminalAction, ScrollDownTerminalAction, ScrollDownPageTerminalAction, ScrollToBottomTerminalAction, ScrollUpTerminalAction, ScrollUpPageTerminalAction, ScrollToTopTerminalAction, TerminalPasteAction, ToggleTerminalAction, ClearTerminalAction, AllowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand, RenameTerminalAction, SelectAllTerminalAction, FocusTerminalFindWidgetAction, HideTerminalFindWidgetAction, DeleteWordLeftTerminalAction, DeleteWordRightTerminalAction, QuickOpenActionTermContributor, QuickOpenTermAction, TERMINAL_PICKER_PREFIX, MoveToLineStartTerminalAction, MoveToLineEndTerminalAction, SplitTerminalAction, SplitInActiveWorkspaceTerminalAction, FocusPreviousPaneTerminalAction, FocusNextPaneTerminalAction, ResizePaneLeftTerminalAction, ResizePaneRightTerminalAction, ResizePaneUpTerminalAction, ResizePaneDownTerminalAction, ScrollToPreviousCommandAction, ScrollToNextCommandAction, SelectToPreviousCommandAction, SelectToNextCommandAction, SelectToPreviousLineAction, SelectToNextLineAction, ToggleEscapeSequenceLoggingAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
21
import { Registry } from 'vs/platform/registry/common/platform';
22 23 24
import { ShowAllCommandsAction } from 'vs/workbench/parts/quickopen/browser/commandsHandler';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { TerminalService } from 'vs/workbench/parts/terminal/electron-browser/terminalService';
25
import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode';
26
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
27
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
B
Benjamin Pasero 已提交
28
import { OpenNextRecentlyUsedEditorInGroupAction, OpenPreviousRecentlyUsedEditorInGroupAction, FocusActiveGroupAction, FocusFirstGroupAction, FocusLastGroupAction, OpenFirstEditorInGroup, OpenLastEditorInGroup } from 'vs/workbench/browser/parts/editor/editorActions';
29
import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
D
Daniel Imms 已提交
30
import { registerColors } from 'vs/workbench/parts/terminal/common/terminalColorRegistry';
31
import { NavigateUpAction, NavigateDownAction, NavigateLeftAction, NavigateRightAction } from 'vs/workbench/electron-browser/actions';
32
import { QUICKOPEN_ACTION_ID, getQuickNavigateHandler, QUICKOPEN_FOCUS_SECONDARY_ACTION_ID } from 'vs/workbench/browser/parts/quickopen/quickopen';
T
t-amqi 已提交
33
import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
34
import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions';
35
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
36
import { TogglePanelAction } from 'vs/workbench/browser/parts/panel/panelActions';
37 38
import { TerminalPanel } from 'vs/workbench/parts/terminal/electron-browser/terminalPanel';
import { TerminalPickerHandler } from 'vs/workbench/parts/terminal/browser/terminalQuickOpen';
39
import { setupTerminalCommands, TERMINAL_COMMAND_ID } from 'vs/workbench/parts/terminal/common/terminalCommands';
40
import { setupTerminalMenu } from 'vs/workbench/parts/terminal/common/terminalMenu';
T
t-amqi 已提交
41

42
const quickOpenRegistry = (Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen));
T
t-amqi 已提交
43

44 45
const inTerminalsPicker = 'inTerminalPicker';

T
t-amqi 已提交
46 47
quickOpenRegistry.registerQuickOpenHandler(
	new QuickOpenHandlerDescriptor(
48 49
		TerminalPickerHandler,
		TerminalPickerHandler.ID,
T
t-amqi 已提交
50
		TERMINAL_PICKER_PREFIX,
51
		inTerminalsPicker,
T
t-amqi 已提交
52
		nls.localize('quickOpen.terminal', "Show All Opened Terminals")
T
t-amqi 已提交
53 54
	)
);
D
Daniel Imms 已提交
55

56 57
const quickOpenNavigateNextInTerminalPickerId = 'workbench.action.quickOpenNavigateNextInTerminalPicker';
CommandsRegistry.registerCommand(
J
Johannes Rieken 已提交
58
	{ id: quickOpenNavigateNextInTerminalPickerId, handler: getQuickNavigateHandler(quickOpenNavigateNextInTerminalPickerId, true) });
59 60 61

const quickOpenNavigatePreviousInTerminalPickerId = 'workbench.action.quickOpenNavigatePreviousInTerminalPicker';
CommandsRegistry.registerCommand(
J
Johannes Rieken 已提交
62
	{ id: quickOpenNavigatePreviousInTerminalPickerId, handler: getQuickNavigateHandler(quickOpenNavigatePreviousInTerminalPickerId, false) });
63 64


65
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
B
Benjamin Pasero 已提交
66
registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenTermAction, QuickOpenTermAction.ID, QuickOpenTermAction.LABEL), 'Terminal: Switch Active Terminal', nls.localize('terminal', "Terminal"));
67 68 69
const actionBarRegistry = Registry.as<IActionBarRegistry>(ActionBarExtensions.Actionbar);
actionBarRegistry.registerActionBarContributor(Scope.VIEWER, QuickOpenActionTermContributor);

D
Daniel Imms 已提交
70
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
71
configurationRegistry.registerConfiguration({
72 73 74 75 76
	id: 'terminal',
	order: 100,
	title: nls.localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"),
	type: 'object',
	properties: {
77
		'terminal.integrated.shell.linux': {
D
Daniel Imms 已提交
78
			description: nls.localize('terminal.integrated.shell.linux', "The path of the shell that the terminal uses on Linux. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
79 80
			type: 'string',
			default: getTerminalDefaultShellUnixLike()
81
		},
D
Daniel Imms 已提交
82
		'terminal.integrated.shellArgs.linux': {
D
Daniel Imms 已提交
83
			description: nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
84 85 86
			type: 'array',
			items: {
				type: 'string'
D
Daniel Imms 已提交
87
			},
88
			default: []
D
Daniel Imms 已提交
89
		},
90
		'terminal.integrated.shell.osx': {
D
Daniel Imms 已提交
91
			description: nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on macOS. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
92 93
			type: 'string',
			default: getTerminalDefaultShellUnixLike()
94
		},
D
Daniel Imms 已提交
95
		'terminal.integrated.shellArgs.osx': {
D
Daniel Imms 已提交
96
			description: nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the macOS terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
97 98 99
			type: 'array',
			items: {
				type: 'string'
D
Daniel Imms 已提交
100
			},
101 102 103
			// Unlike on Linux, ~/.profile is not sourced when logging into a macOS session. This
			// is the reason terminals on macOS typically run login shells by default which set up
			// the environment. See http://unix.stackexchange.com/a/119675/115410
104
			default: ['-l']
D
Daniel Imms 已提交
105
		},
106
		'terminal.integrated.shell.windows': {
D
Daniel Imms 已提交
107
			description: nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
108 109
			type: 'string',
			default: getTerminalDefaultShellWindows()
110
		},
111
		'terminal.integrated.shellArgs.windows': {
D
Daniel Imms 已提交
112
			description: nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
113 114 115
			type: 'array',
			items: {
				type: 'string'
116
			},
117
			default: []
118
		},
D
Daniel Imms 已提交
119
		'terminal.integrated.macOptionIsMeta': {
D
Daniel Imms 已提交
120
			description: nls.localize('terminal.integrated.macOptionIsMeta', "Controls whether to treat the option key as the meta key in the terminal on macOS."),
121 122
			type: 'boolean',
			default: false
D
Daniel Imms 已提交
123
		},
124
		'terminal.integrated.macOptionClickForcesSelection': {
D
Daniel Imms 已提交
125
			description: nls.localize('terminal.integrated.macOptionClickForcesSelection', "Controls whether to force selection when using Option+click on macOS. This will force a regular (line) selection and disallow the use of column selection mode. This enables copying and pasting using the regular terminal selection, for example, when mouse mode is enabled in tmux."),
126 127
			type: 'boolean',
			default: false
128
		},
129
		'terminal.integrated.copyOnSelection': {
D
Daniel Imms 已提交
130
			description: nls.localize('terminal.integrated.copyOnSelection', "Controls whether text selected in the terminal will be copied to the clipboard."),
131 132
			type: 'boolean',
			default: false
133
		},
134
		'terminal.integrated.drawBoldTextInBrightColors': {
D
Daniel Imms 已提交
135
			description: nls.localize('terminal.integrated.drawBoldTextInBrightColors', "Controls whether bold text in the terminal will always use the \"bright\" ANSI color variant."),
136 137
			type: 'boolean',
			default: true
138
		},
139
		'terminal.integrated.fontFamily': {
140
			description: nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to `#editor.fontFamily#`'s value."),
141
			type: 'string'
142
		},
143 144 145 146 147 148
		// TODO: Support font ligatures
		// 'terminal.integrated.fontLigatures': {
		// 	'description': nls.localize('terminal.integrated.fontLigatures', "Controls whether font ligatures are enabled in the terminal."),
		// 	'type': 'boolean',
		// 	'default': false
		// },
149
		'terminal.integrated.fontSize': {
150 151 152
			description: nls.localize('terminal.integrated.fontSize', "Controls the font size in pixels of the terminal."),
			type: 'number',
			default: EDITOR_FONT_DEFAULTS.fontSize
153
		},
154
		'terminal.integrated.letterSpacing': {
155 156 157
			description: nls.localize('terminal.integrated.letterSpacing', "Controls the letter spacing of the terminal, this is an integer value which represents the amount of additional pixels to add between characters."),
			type: 'number',
			default: DEFAULT_LETTER_SPACING
158
		},
159
		'terminal.integrated.lineHeight': {
160 161 162
			description: nls.localize('terminal.integrated.lineHeight', "Controls the line height of the terminal, this number is multiplied by the terminal font size to get the actual line-height in pixels."),
			type: 'number',
			default: DEFAULT_LINE_HEIGHT
163
		},
164
		'terminal.integrated.fontWeight': {
165 166 167 168
			type: 'string',
			enum: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
			description: nls.localize('terminal.integrated.fontWeight', "The font weight to use within the terminal for non-bold text."),
			default: 'normal'
169 170
		},
		'terminal.integrated.fontWeightBold': {
171 172 173 174
			type: 'string',
			enum: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
			description: nls.localize('terminal.integrated.fontWeightBold', "The font weight to use within the terminal for bold text."),
			default: 'bold'
175
		},
176
		'terminal.integrated.cursorBlinking': {
177 178 179
			description: nls.localize('terminal.integrated.cursorBlinking', "Controls whether the terminal cursor blinks."),
			type: 'boolean',
			default: false
180
		},
181
		'terminal.integrated.cursorStyle': {
182 183 184
			description: nls.localize('terminal.integrated.cursorStyle', "Controls the style of terminal cursor."),
			enum: [TerminalCursorStyle.BLOCK, TerminalCursorStyle.LINE, TerminalCursorStyle.UNDERLINE],
			default: TerminalCursorStyle.BLOCK
185
		},
D
Daniel Imms 已提交
186
		'terminal.integrated.scrollback': {
187 188 189
			description: nls.localize('terminal.integrated.scrollback', "Controls the maximum amount of lines the terminal keeps in its buffer."),
			type: 'number',
			default: 1000
D
Daniel Imms 已提交
190
		},
191
		'terminal.integrated.setLocaleVariables': {
192 193 194
			description: nls.localize('terminal.integrated.setLocaleVariables', "Controls whether locale variables are set at startup of the terminal, this defaults to `true` on macOS, `false` on other platforms."),
			type: 'boolean',
			default: platform.isMacintosh
195
		},
D
Daniel Imms 已提交
196
		'terminal.integrated.rendererType': {
197 198 199 200 201 202 203
			type: 'string',
			enum: ['auto', 'canvas', 'dom'],
			enumDescriptions: [
				nls.localize('terminal.integrated.rendererType.auto', "Let VS Code guess which renderer to use."),
				nls.localize('terminal.integrated.rendererType.canvas', "Use the standard GPU/canvas-based renderer"),
				nls.localize('terminal.integrated.rendererType.dom', "Use the fallback DOM-based renderer.")
			],
D
Daniel Imms 已提交
204
			default: 'auto',
205
			description: nls.localize('terminal.integrated.rendererType', "Controls how the terminal is rendered.")
D
Daniel Imms 已提交
206
		},
207
		'terminal.integrated.rightClickBehavior': {
208 209 210 211 212 213 214
			type: 'string',
			enum: ['default', 'copyPaste', 'selectWord'],
			enumDescriptions: [
				nls.localize('terminal.integrated.rightClickBehavior.default', "Show the context menu."),
				nls.localize('terminal.integrated.rightClickBehavior.copyPaste', "Copy when there is a selection, otherwise paste."),
				nls.localize('terminal.integrated.rightClickBehavior.selectWord', "Select the word under the cursor and show the context menu.")
			],
215
			default: platform.isMacintosh ? 'selectWord' : platform.isWindows ? 'copyPaste' : 'default',
216
			description: nls.localize('terminal.integrated.rightClickBehavior', "Controls how terminal reacts to right click.")
217
		},
D
Daniel Imms 已提交
218
		'terminal.integrated.cwd': {
219 220 221
			description: nls.localize('terminal.integrated.cwd', "An explicit start path where the terminal will be launched, this is used as the current working directory (cwd) for the shell process. This may be particularly useful in workspace settings if the root directory is not a convenient cwd."),
			type: 'string',
			default: undefined
222
		},
D
Daniel Imms 已提交
223
		'terminal.integrated.confirmOnExit': {
D
Daniel Imms 已提交
224
			description: nls.localize('terminal.integrated.confirmOnExit', "Controls whether to confirm on exit if there are active terminal sessions."),
225 226
			type: 'boolean',
			default: false
D
Daniel Imms 已提交
227
		},
D
Daniel Imms 已提交
228
		'terminal.integrated.enableBell': {
D
Daniel Imms 已提交
229
			description: nls.localize('terminal.integrated.enableBell', "Controls whether the terminal bell is enabled."),
230 231
			type: 'boolean',
			default: false
D
Daniel Imms 已提交
232
		},
233
		'terminal.integrated.commandsToSkipShell': {
234 235 236 237
			description: nls.localize('terminal.integrated.commandsToSkipShell', "A set of command IDs whose keybindings will not be sent to the shell and instead always be handled by Code. This allows the use of keybindings that would normally be consumed by the shell to act the same as when the terminal is not focused, for example ctrl+p to launch Quick Open."),
			type: 'array',
			items: {
				type: 'string'
238
			},
239
			default: [
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
				TERMINAL_COMMAND_ID.CLEAR_SELECTION,
				TERMINAL_COMMAND_ID.CLEAR,
				TERMINAL_COMMAND_ID.COPY_SELECTION,
				TERMINAL_COMMAND_ID.DELETE_WORD_LEFT,
				TERMINAL_COMMAND_ID.DELETE_WORD_RIGHT,
				TERMINAL_COMMAND_ID.FIND_WIDGET_FOCUS,
				TERMINAL_COMMAND_ID.FIND_WIDGET_HIDE,
				TERMINAL_COMMAND_ID.FOCUS_NEXT_PANE,
				TERMINAL_COMMAND_ID.FOCUS_NEXT,
				TERMINAL_COMMAND_ID.FOCUS_PREVIOUS_PANE,
				TERMINAL_COMMAND_ID.FOCUS_PREVIOUS,
				TERMINAL_COMMAND_ID.FOCUS,
				TERMINAL_COMMAND_ID.KILL,
				TERMINAL_COMMAND_ID.MOVE_TO_LINE_END,
				TERMINAL_COMMAND_ID.MOVE_TO_LINE_START,
				TERMINAL_COMMAND_ID.NEW_IN_ACTIVE_WORKSPACE,
				TERMINAL_COMMAND_ID.NEW,
				TERMINAL_COMMAND_ID.PASTE,
				TERMINAL_COMMAND_ID.RESIZE_PANE_DOWN,
				TERMINAL_COMMAND_ID.RESIZE_PANE_LEFT,
				TERMINAL_COMMAND_ID.RESIZE_PANE_RIGHT,
				TERMINAL_COMMAND_ID.RESIZE_PANE_UP,
				TERMINAL_COMMAND_ID.RUN_ACTIVE_FILE,
				TERMINAL_COMMAND_ID.RUN_SELECTED_TEXT,
				TERMINAL_COMMAND_ID.SCROLL_DOWN_LINE,
				TERMINAL_COMMAND_ID.SCROLL_DOWN_PAGE,
				TERMINAL_COMMAND_ID.SCROLL_TO_BOTTOM,
				TERMINAL_COMMAND_ID.SCROLL_TO_NEXT_COMMAND,
				TERMINAL_COMMAND_ID.SCROLL_TO_PREVIOUS_COMMAND,
				TERMINAL_COMMAND_ID.SCROLL_TO_TOP,
				TERMINAL_COMMAND_ID.SCROLL_UP_LINE,
				TERMINAL_COMMAND_ID.SCROLL_UP_PAGE,
				TERMINAL_COMMAND_ID.SELECT_ALL,
				TERMINAL_COMMAND_ID.SELECT_TO_NEXT_COMMAND,
				TERMINAL_COMMAND_ID.SELECT_TO_NEXT_LINE,
				TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_COMMAND,
				TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_LINE,
				TERMINAL_COMMAND_ID.SPLIT_IN_ACTIVE_WORKSPACE,
				TERMINAL_COMMAND_ID.SPLIT,
				TERMINAL_COMMAND_ID.TOGGLE,
280
				ToggleTabFocusModeAction.ID,
281
				QUICKOPEN_ACTION_ID,
282
				QUICKOPEN_FOCUS_SECONDARY_ACTION_ID,
283
				ShowAllCommandsAction.ID,
284 285 286 287 288 289 290
				'workbench.action.tasks.build',
				'workbench.action.tasks.restartTask',
				'workbench.action.tasks.runTask',
				'workbench.action.tasks.showLog',
				'workbench.action.tasks.showTasks',
				'workbench.action.tasks.terminate',
				'workbench.action.tasks.test',
291 292 293 294 295 296 297 298 299
				'workbench.action.terminal.focusAtIndex1',
				'workbench.action.terminal.focusAtIndex2',
				'workbench.action.terminal.focusAtIndex3',
				'workbench.action.terminal.focusAtIndex4',
				'workbench.action.terminal.focusAtIndex5',
				'workbench.action.terminal.focusAtIndex6',
				'workbench.action.terminal.focusAtIndex7',
				'workbench.action.terminal.focusAtIndex8',
				'workbench.action.terminal.focusAtIndex9',
B
Benjamin Pasero 已提交
300 301 302 303 304 305 306
				'workbench.action.focusSecondEditorGroup',
				'workbench.action.focusThirdEditorGroup',
				'workbench.action.focusFourthEditorGroup',
				'workbench.action.focusFifthEditorGroup',
				'workbench.action.focusSixthEditorGroup',
				'workbench.action.focusSeventhEditorGroup',
				'workbench.action.focusEighthEditorGroup',
307 308 309 310
				debugActions.StartAction.ID,
				debugActions.StopAction.ID,
				debugActions.RunAction.ID,
				debugActions.RestartAction.ID,
311
				debugActions.ContinueAction.ID,
312
				debugActions.PauseAction.ID,
313 314 315
				debugActions.StepIntoAction.ID,
				debugActions.StepOutAction.ID,
				debugActions.StepOverAction.ID,
316
				OpenNextRecentlyUsedEditorInGroupAction.ID,
317
				OpenPreviousRecentlyUsedEditorInGroupAction.ID,
B
Benjamin Pasero 已提交
318
				FocusActiveGroupAction.ID,
319
				FocusFirstGroupAction.ID,
B
Benjamin Pasero 已提交
320 321 322
				FocusLastGroupAction.ID,
				OpenFirstEditorInGroup.ID,
				OpenLastEditorInGroup.ID,
323 324 325
				NavigateUpAction.ID,
				NavigateDownAction.ID,
				NavigateRightAction.ID,
326
				NavigateLeftAction.ID,
327
				TogglePanelAction.ID,
328
				'workbench.action.quickOpenView'
329
			].sort()
330
		},
331
		'terminal.integrated.env.osx': {
332 333 334 335
			description: nls.localize('terminal.integrated.env.osx', "Object with environment variables that will be added to the VS Code process to be used by the terminal on macOS. Set to `null` to delete the environment variable."),
			type: 'object',
			additionalProperties: {
				type: ['string', 'null']
336
			},
337
			default: {}
338
		},
339
		'terminal.integrated.env.linux': {
340 341 342 343
			description: nls.localize('terminal.integrated.env.linux', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Linux. Set to `null` to delete the environment variable."),
			type: 'object',
			additionalProperties: {
				type: ['string', 'null']
344
			},
345
			default: {}
346
		},
347
		'terminal.integrated.env.windows': {
348 349 350 351
			description: nls.localize('terminal.integrated.env.windows', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Windows. Set to `null` to delete the environment variable."),
			type: 'object',
			additionalProperties: {
				type: ['string', 'null']
352
			},
353
			default: {}
B
bpceee 已提交
354 355
		},
		'terminal.integrated.showExitAlert': {
D
Daniel Imms 已提交
356
			description: nls.localize('terminal.integrated.showExitAlert', "Controls whether to show the alert \"The terminal process terminated with exit code\" when exit code is non-zero."),
357 358
			type: 'boolean',
			default: true
B
bpceee 已提交
359
		},
360
		'terminal.integrated.experimentalRestore': {
D
Daniel Imms 已提交
361
			description: nls.localize('terminal.integrated.experimentalRestore', "Controls whether to restore terminal sessions for the workspace automatically when launching VS Code. This is an experimental setting; it may be buggy and could change or be removed in the future."),
362 363
			type: 'boolean',
			default: false
364
		},
365
		// TODO: Default to dynamic and remove setting in 1.27
366
		'terminal.integrated.experimentalTextureCachingStrategy': {
367 368 369 370
			description: nls.localize('terminal.integrated.experimentalTextureCachingStrategy', "Controls how the terminal stores glyph textures. `static` is the default and uses a fixed texture to draw the characters from. `dynamic` will draw the characters to the texture as they are needed, this should boost overall performance at the cost of slightly increased draw time the first time a character is drawn. `dynamic` will eventually become the default and this setting will be removed. Changes to this setting will only apply to new terminals."),
			type: 'string',
			enum: ['static', 'dynamic'],
			default: 'dynamic'
371
		},
372 373
	}
});
D
Daniel Imms 已提交
374

375
registerSingleton(ITerminalService, TerminalService);
D
Daniel Imms 已提交
376

377
(<panel.PanelRegistry>Registry.as(panel.Extensions.Panels)).registerPanel(new panel.PanelDescriptor(
378
	TerminalPanel,
379 380
	TERMINAL_PANEL_ID,
	nls.localize('terminal', "Terminal"),
I
isidor 已提交
381
	'terminal',
B
Benjamin Pasero 已提交
382
	40,
383
	TERMINAL_COMMAND_ID.TOGGLE
384
));
D
Daniel Imms 已提交
385

386 387
// On mac cmd+` is reserved to cycle between windows, that's why the keybindings use WinCtrl
const category = nls.localize('terminalCategory', "Terminal");
D
Daniel Imms 已提交
388
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
389 390 391 392 393 394 395 396 397
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(KillTerminalAction, KillTerminalAction.ID, KillTerminalAction.LABEL), 'Terminal: Kill the Active Terminal Instance', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CopyTerminalSelectionAction, CopyTerminalSelectionAction.ID, CopyTerminalSelectionAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C }
}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, KEYBINDING_CONTEXT_TERMINAL_FOCUS)), 'Terminal: Copy Selection', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CreateNewTerminalAction, CreateNewTerminalAction.ID, CreateNewTerminalAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKTICK,
	mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.US_BACKTICK }
}), 'Terminal: Create New Integrated Terminal', category);
398
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ClearSelectionTerminalAction, ClearSelectionTerminalAction.ID, ClearSelectionTerminalAction.LABEL, {
399 400
	primary: KeyCode.Escape,
	linux: { primary: KeyCode.Escape }
401
}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE)), 'Terminal: Escape selection', category);
402
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CreateNewInActiveWorkspaceTerminalAction, CreateNewInActiveWorkspaceTerminalAction.ID, CreateNewInActiveWorkspaceTerminalAction.LABEL), 'Terminal: Create New Integrated Terminal (In Active Workspace)', category);
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusActiveTerminalAction, FocusActiveTerminalAction.ID, FocusActiveTerminalAction.LABEL), 'Terminal: Focus Terminal', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusNextTerminalAction, FocusNextTerminalAction.ID, FocusNextTerminalAction.LABEL), 'Terminal: Focus Next Terminal', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusPreviousTerminalAction, FocusPreviousTerminalAction.ID, FocusPreviousTerminalAction.LABEL), 'Terminal: Focus Previous Terminal', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(TerminalPasteAction, TerminalPasteAction.ID, TerminalPasteAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_V },
	// Don't apply to Mac since cmd+v works
	mac: { primary: null }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Paste into Active Terminal', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectAllTerminalAction, SelectAllTerminalAction.ID, SelectAllTerminalAction.LABEL, {
	// Don't use ctrl+a by default as that would override the common go to start
	// of prompt shell binding
	primary: null,
	// Technically this doesn't need to be here as it will fall back to this
	// behavior anyway when handed to xterm.js, having this handled by VS Code
	// makes it easier for users to see how it works though.
	mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_A }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select All', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(RunSelectedTextInTerminalAction, RunSelectedTextInTerminalAction.ID, RunSelectedTextInTerminalAction.LABEL), 'Terminal: Run Selected Text In Active Terminal', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(RunActiveFileInTerminalAction, RunActiveFileInTerminalAction.ID, RunActiveFileInTerminalAction.LABEL), 'Terminal: Run Active File In Active Terminal', category);
423
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleTerminalAction, ToggleTerminalAction.ID, ToggleTerminalAction.LABEL, {
424 425 426 427
	primary: KeyMod.CtrlCmd | KeyCode.US_BACKTICK,
	mac: { primary: KeyMod.WinCtrl | KeyCode.US_BACKTICK }
}), 'View: Toggle Integrated Terminal', nls.localize('viewCategory', "View"));
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollDownTerminalAction, ScrollDownTerminalAction.ID, ScrollDownTerminalAction.LABEL, {
428
	primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown,
429 430 431 432 433 434 435 436 437 438 439
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Down (Line)', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollDownPageTerminalAction, ScrollDownPageTerminalAction.ID, ScrollDownPageTerminalAction.LABEL, {
	primary: KeyMod.Shift | KeyCode.PageDown,
	mac: { primary: KeyCode.PageDown }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Down (Page)', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollToBottomTerminalAction, ScrollToBottomTerminalAction.ID, ScrollToBottomTerminalAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.End,
	linux: { primary: KeyMod.Shift | KeyCode.End }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll to Bottom', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollUpTerminalAction, ScrollUpTerminalAction.ID, ScrollUpTerminalAction.LABEL, {
440
	primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp,
441 442 443 444 445 446 447 448 449 450 451 452 453
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow },
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Up (Line)', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollUpPageTerminalAction, ScrollUpPageTerminalAction.ID, ScrollUpPageTerminalAction.LABEL, {
	primary: KeyMod.Shift | KeyCode.PageUp,
	mac: { primary: KeyCode.PageUp }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Up (Page)', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollToTopTerminalAction, ScrollToTopTerminalAction.ID, ScrollToTopTerminalAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.Home,
	linux: { primary: KeyMod.Shift | KeyCode.Home }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll to Top', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ClearTerminalAction, ClearTerminalAction.ID, ClearTerminalAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.KEY_K,
	linux: { primary: null }
454
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KeybindingWeight.WorkbenchContrib + 1), 'Terminal: Clear', category);
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
if (platform.isWindows) {
	actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectDefaultShellWindowsTerminalAction, SelectDefaultShellWindowsTerminalAction.ID, SelectDefaultShellWindowsTerminalAction.LABEL), 'Terminal: Select Default Shell', category);
}
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(AllowWorkspaceShellTerminalCommand, AllowWorkspaceShellTerminalCommand.ID, AllowWorkspaceShellTerminalCommand.LABEL), 'Terminal: Allow Workspace Shell Configuration', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(DisallowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand.ID, DisallowWorkspaceShellTerminalCommand.LABEL), 'Terminal: Disallow Workspace Shell Configuration', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(RenameTerminalAction, RenameTerminalAction.ID, RenameTerminalAction.LABEL), 'Terminal: Rename', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusTerminalFindWidgetAction, FocusTerminalFindWidgetAction.ID, FocusTerminalFindWidgetAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.KEY_F
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Focus Find Widget', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(HideTerminalFindWidgetAction, HideTerminalFindWidgetAction.ID, HideTerminalFindWidgetAction.LABEL, {
	primary: KeyCode.Escape,
	secondary: [KeyMod.Shift | KeyCode.Escape]
}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE)), 'Terminal: Hide Find Widget', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(DeleteWordLeftTerminalAction, DeleteWordLeftTerminalAction.ID, DeleteWordLeftTerminalAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.Backspace,
	mac: { primary: KeyMod.Alt | KeyCode.Backspace }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Delete Word Left', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(DeleteWordRightTerminalAction, DeleteWordRightTerminalAction.ID, DeleteWordRightTerminalAction.LABEL, {
	primary: KeyMod.CtrlCmd | KeyCode.Delete,
	mac: { primary: KeyMod.Alt | KeyCode.Delete }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Delete Word Right', category);
476 477 478 479 480 481 482 483
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(MoveToLineStartTerminalAction, MoveToLineStartTerminalAction.ID, MoveToLineStartTerminalAction.LABEL, {
	primary: null,
	mac: { primary: KeyMod.CtrlCmd | KeyCode.LeftArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Move To Line Start', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(MoveToLineEndTerminalAction, MoveToLineEndTerminalAction.ID, MoveToLineEndTerminalAction.LABEL, {
	primary: null,
	mac: { primary: KeyMod.CtrlCmd | KeyCode.RightArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Move To Line End', category);
D
Daniel Imms 已提交
484
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SplitTerminalAction, SplitTerminalAction.ID, SplitTerminalAction.LABEL, {
D
Daniel Imms 已提交
485 486
	primary: KeyMod.CtrlCmd | KeyCode.US_BACKSLASH,
	secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_5],
D
Daniel Imms 已提交
487
	mac: {
D
Daniel Imms 已提交
488
		primary: KeyMod.CtrlCmd | KeyCode.US_BACKSLASH,
489
		secondary: [KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_5]
D
Daniel Imms 已提交
490
	}
D
Daniel Imms 已提交
491
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Split', category);
492
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SplitInActiveWorkspaceTerminalAction, SplitInActiveWorkspaceTerminalAction.ID, SplitInActiveWorkspaceTerminalAction.LABEL), 'Terminal: Split Terminal (In Active Workspace)', category);
493
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusPreviousPaneTerminalAction, FocusPreviousPaneTerminalAction.ID, FocusPreviousPaneTerminalAction.LABEL, {
494
	primary: KeyMod.Alt | KeyCode.LeftArrow,
495 496 497 498 499
	secondary: [KeyMod.Alt | KeyCode.UpArrow],
	mac: {
		primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.LeftArrow,
		secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.UpArrow]
	}
500 501
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Focus Previous Pane', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusNextPaneTerminalAction, FocusNextPaneTerminalAction.ID, FocusNextPaneTerminalAction.LABEL, {
502
	primary: KeyMod.Alt | KeyCode.RightArrow,
503 504 505 506 507
	secondary: [KeyMod.Alt | KeyCode.DownArrow],
	mac: {
		primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.RightArrow,
		secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.DownArrow]
	}
508
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Focus Next Pane', category);
D
Daniel Imms 已提交
509
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ResizePaneLeftTerminalAction, ResizePaneLeftTerminalAction.ID, ResizePaneLeftTerminalAction.LABEL, {
510 511
	primary: null,
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow },
D
Daniel Imms 已提交
512 513 514
	mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.LeftArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Left', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ResizePaneRightTerminalAction, ResizePaneRightTerminalAction.ID, ResizePaneRightTerminalAction.LABEL, {
515 516
	primary: null,
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow },
D
Daniel Imms 已提交
517 518 519
	mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.RightArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Right', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ResizePaneUpTerminalAction, ResizePaneUpTerminalAction.ID, ResizePaneUpTerminalAction.LABEL, {
520 521
	primary: null,
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow },
D
Daniel Imms 已提交
522 523 524
	mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.UpArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Up', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ResizePaneDownTerminalAction, ResizePaneDownTerminalAction.ID, ResizePaneDownTerminalAction.LABEL, {
525 526
	primary: null,
	linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow },
D
Daniel Imms 已提交
527 528
	mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.DownArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Down', category);
529
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollToPreviousCommandAction, ScrollToPreviousCommandAction.ID, ScrollToPreviousCommandAction.LABEL, {
D
Daniel Imms 已提交
530 531
	primary: null,
	mac: { primary: KeyMod.CtrlCmd | KeyCode.UpArrow }
532 533
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll To Previous Command', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollToNextCommandAction, ScrollToNextCommandAction.ID, ScrollToNextCommandAction.LABEL, {
D
Daniel Imms 已提交
534 535
	primary: null,
	mac: { primary: KeyMod.CtrlCmd | KeyCode.DownArrow }
536
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll To Next Command', category);
D
Daniel Imms 已提交
537 538 539 540 541 542 543 544
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToPreviousCommandAction, SelectToPreviousCommandAction.ID, SelectToPreviousCommandAction.LABEL, {
	primary: null,
	mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select To Previous Command', category);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToNextCommandAction, SelectToNextCommandAction.ID, SelectToNextCommandAction.LABEL, {
	primary: null,
	mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow }
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select To Next Command', category);
545 546
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);
547
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleEscapeSequenceLoggingAction, ToggleEscapeSequenceLoggingAction.ID, ToggleEscapeSequenceLoggingAction.LABEL), 'Terminal: Toggle Escape Sequence Logging', category);
548

549 550
setupTerminalCommands();
setupTerminalMenu();
551

552
registerColors();