terminal.ts 19.4 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.
 *--------------------------------------------------------------------------------------------*/

M
Matt Bierner 已提交
6
import { Event } from 'vs/base/common/event';
D
Dirk Baeumer 已提交
7
import { IDisposable } from 'vs/base/common/lifecycle';
D
Daniel Imms 已提交
8
import { RawContextKey, ContextKeyExpr, IContextKey } from 'vs/platform/contextkey/common/contextkey';
9 10
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
D
Daniel Imms 已提交
11 12 13 14 15

export const TERMINAL_PANEL_ID = 'workbench.panel.terminal';

export const TERMINAL_SERVICE_ID = 'terminalService';

16
/**  A context key that is set when the integrated terminal has focus. */
A
Alex Dima 已提交
17
export const KEYBINDING_CONTEXT_TERMINAL_FOCUS = new RawContextKey<boolean>('terminalFocus', undefined);
18
/**  A context key that is set when the integrated terminal does not have focus. */
J
Johannes Rieken 已提交
19
export const KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_FOCUS.toNegated();
20

21 22 23 24 25
/** A keybinding context key that is set when the integrated terminal has text selected. */
export const KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED = new RawContextKey<boolean>('terminalTextSelected', undefined);
/** A keybinding context key that is set when the integrated terminal does not have text selected. */
export const KEYBINDING_CONTEXT_TERMINAL_TEXT_NOT_SELECTED: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED.toNegated();

R
rebornix 已提交
26 27 28 29
/**  A context key that is set when the find widget in integrated terminal is visible. */
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('terminalFindWidgetVisible', undefined);
/**  A context key that is set when the find widget in integrated terminal is not visible. */
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE.toNegated();
30 31 32 33
/**  A context key that is set when the find widget find input in integrated terminal is focused. */
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED = new RawContextKey<boolean>('terminalFindWidgetInputFocused', false);
/**  A context key that is set when the find widget find input in integrated terminal is not focused. */
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_NOT_FOCUSED: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED.toNegated();
R
rebornix 已提交
34

35
export const IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY = 'terminal.integrated.isWorkspaceShellAllowed';
36
export const NEVER_SUGGEST_SELECT_WINDOWS_SHELL_STORAGE_KEY = 'terminal.integrated.neverSuggestSelectWindowsShell';
D
Daniel Imms 已提交
37
export const NEVER_MEASURE_RENDER_TIME_STORAGE_KEY = 'terminal.integrated.neverMeasureRenderTime';
38

B
Benjamin Pasero 已提交
39
export const ITerminalService = createDecorator<ITerminalService>(TERMINAL_SERVICE_ID);
D
Daniel Imms 已提交
40

41 42 43 44 45 46
export const TerminalCursorStyle = {
	BLOCK: 'block',
	LINE: 'line',
	UNDERLINE: 'underline'
};

47 48
export const TERMINAL_CONFIG_SECTION = 'terminal.integrated';

49 50 51 52
export const DEFAULT_LETTER_SPACING = 0;
export const MINIMUM_LETTER_SPACING = -5;
export const DEFAULT_LINE_HEIGHT = 1.0;

53 54
export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';

55
export interface ITerminalConfiguration {
D
Daniel Imms 已提交
56 57 58 59
	shell: {
		linux: string;
		osx: string;
		windows: string;
60
	};
D
Daniel Imms 已提交
61 62 63 64 65
	shellArgs: {
		linux: string[];
		osx: string[];
		windows: string[];
	};
D
Daniel Imms 已提交
66
	macOptionIsMeta: boolean;
D
Daniel Imms 已提交
67
	rendererType: 'auto' | 'canvas' | 'dom';
68
	rightClickBehavior: 'default' | 'copyPaste' | 'selectWord';
D
Daniel Imms 已提交
69 70
	cursorBlinking: boolean;
	cursorStyle: string;
71
	drawBoldTextInBrightColors: boolean;
D
Daniel Imms 已提交
72
	fontFamily: string;
73 74
	fontWeight: FontWeight;
	fontWeightBold: FontWeight;
75
	// fontLigatures: boolean;
D
Daniel Imms 已提交
76
	fontSize: number;
77
	letterSpacing: number;
D
Daniel Imms 已提交
78 79 80 81 82 83
	lineHeight: number;
	setLocaleVariables: boolean;
	scrollback: number;
	commandsToSkipShell: string[];
	cwd: string;
	confirmOnExit: boolean;
D
Daniel Imms 已提交
84
	enableBell: boolean;
85 86 87 88 89
	env: {
		linux: { [key: string]: string };
		osx: { [key: string]: string };
		windows: { [key: string]: string };
	};
B
bpceee 已提交
90
	showExitAlert: boolean;
91
	experimentalRestore: boolean;
92
	experimentalTextureCachingStrategy: 'static' | 'dynamic';
93 94
}

95
export interface ITerminalConfigHelper {
96
	config: ITerminalConfiguration;
97
	getFont(): ITerminalFont;
98 99 100 101
	/**
	 * Merges the default shell path and args into the provided launch configuration
	 */
	mergeDefaultShellPathAndArgs(shell: IShellLaunchConfig): void;
102 103
	/** Sets whether a workspace shell configuration is allowed or not */
	setWorkspaceShellAllowed(isAllowed: boolean): void;
104 105 106 107
}

export interface ITerminalFont {
	fontFamily: string;
D
Daniel Imms 已提交
108
	fontSize: number;
109
	letterSpacing: number;
110
	lineHeight: number;
111 112
	charWidth?: number;
	charHeight?: number;
113 114
}

115
export interface IShellLaunchConfig {
116 117 118
	/**
	 * The name of the terminal, if this is not set the name of the process will be used.
	 */
119
	name?: string;
120 121 122 123

	/**
	 * The shell executable (bash, cmd, etc.).
	 */
124
	executable?: string;
125

126 127
	/**
	 * The CLI arguments to use with executable, a string[] is in argv format and will be escaped,
D
Daniel Imms 已提交
128 129
	 * a string is in "CommandLine" pre-escaped format and will be used as is. The string option is
	 * only supported on Windows and will throw an exception if used on macOS or Linux.
130 131
	 */
	args?: string[] | string;
132

133 134 135 136 137
	/**
	 * The current working directory of the terminal, this overrides the `terminal.integrated.cwd`
	 * settings key.
	 */
	cwd?: string;
138

139 140 141 142 143
	/**
	 * A custom environment for the terminal, if this is not set the environment will be inherited
	 * from the VS Code process.
	 */
	env?: { [key: string]: string };
144

145 146 147 148 149
	/**
	 * Whether to ignore a custom cwd from the `terminal.integrated.cwd` settings key (eg. if the
	 * shell is being launched by an extension).
	 */
	ignoreConfigurationCwd?: boolean;
150

151
	/** Whether to wait for a key press before closing the terminal. */
152 153
	waitOnExit?: boolean | string;

154 155 156 157 158 159 160
	/**
	 * A string including ANSI escape sequences that will be written to the terminal emulator
	 * _before_ the terminal process has launched, a trailing \n is added at the end of the string.
	 * This allows for example the terminal instance to display a styled message as the first line
	 * of the terminal. Use \x1b over \033 or \e for the escape control character.
	 */
	initialText?: string;
161 162 163 164 165 166

	/**
	 * When true the terminal will be created with no process. This is primarily used to give
	 * extensions full control over the terminal.
	 */
	isRendererOnly?: boolean;
167 168
}

D
Daniel Imms 已提交
169
export interface ITerminalService {
170
	_serviceBrand: any;
171

D
Daniel Imms 已提交
172
	activeTabIndex: number;
173
	configHelper: ITerminalConfigHelper;
D
Daniel Imms 已提交
174
	onActiveTabChanged: Event<void>;
175
	onTabDisposed: Event<ITerminalTab>;
176
	onInstanceCreated: Event<ITerminalInstance>;
177
	onInstanceDisposed: Event<ITerminalInstance>;
178
	onInstanceProcessIdReady: Event<ITerminalInstance>;
D
Daniel Imms 已提交
179
	onInstanceDimensionsChanged: Event<ITerminalInstance>;
180
	onInstanceRequestExtHostProcess: Event<ITerminalProcessExtHostRequest>;
181
	onInstancesChanged: Event<void>;
182
	onInstanceTitleChanged: Event<string>;
183
	terminalInstances: ITerminalInstance[];
D
Daniel Imms 已提交
184
	terminalTabs: ITerminalTab[];
185

186 187 188 189 190 191 192
	/**
	 * Creates a terminal.
	 * @param shell The shell launch configuration to use.
	 * @param wasNewTerminalAction Whether this was triggered by a new terminal action, if so a
	 * default shell selection dialog may display.
	 */
	createTerminal(shell?: IShellLaunchConfig, wasNewTerminalAction?: boolean): ITerminalInstance;
193 194 195 196 197 198

	/**
	 * Creates a terminal renderer.
	 * @param name The name of the terminal.
	 */
	createTerminalRenderer(name: string): ITerminalInstance;
199 200 201 202
	/**
	 * Creates a raw terminal instance, this should not be used outside of the terminal part.
	 */
	createInstance(terminalFocusContextKey: IContextKey<boolean>, configHelper: ITerminalConfigHelper, container: HTMLElement, shellLaunchConfig: IShellLaunchConfig, doCreateProcess: boolean): ITerminalInstance;
203
	getInstanceFromId(terminalId: number): ITerminalInstance;
T
t-amqi 已提交
204
	getInstanceFromIndex(terminalIndex: number): ITerminalInstance;
D
Daniel Imms 已提交
205
	getTabLabels(): string[];
206 207 208
	getActiveInstance(): ITerminalInstance;
	setActiveInstance(terminalInstance: ITerminalInstance): void;
	setActiveInstanceByIndex(terminalIndex: number): void;
209
	getActiveOrCreateInstance(wasNewTerminalAction?: boolean): ITerminalInstance;
210
	splitInstance(instance: ITerminalInstance, shell?: IShellLaunchConfig): void;
211

212
	getActiveTab(): ITerminalTab;
213 214 215 216
	setActiveTabToNext(): void;
	setActiveTabToPrevious(): void;
	setActiveTabByIndex(tabIndex: number): void;

217
	showPanel(focus?: boolean): TPromise<void>;
D
Daniel Imms 已提交
218
	hidePanel(): void;
219 220
	focusFindWidget(): TPromise<void>;
	hideFindWidget(): void;
221

222
	setContainers(panelContainer: HTMLElement, terminalContainer: HTMLElement): void;
D
Daniel Imms 已提交
223
	selectDefaultWindowsShell(): TPromise<string>;
224
	setWorkspaceShellAllowed(isAllowed: boolean): void;
225

226
	requestExtHostProcess(proxy: ITerminalProcessExtHostProxy, shellLaunchConfig: IShellLaunchConfig, cols: number, rows: number): void;
D
Daniel Imms 已提交
227
}
D
Daniel Imms 已提交
228

D
Daniel Imms 已提交
229 230 231 232 233 234 235
export const enum Direction {
	Left = 0,
	Right = 1,
	Up = 2,
	Down = 3
}

236
export interface ITerminalTab {
D
Daniel Imms 已提交
237
	activeInstance: ITerminalInstance;
238
	terminalInstances: ITerminalInstance[];
D
Daniel Imms 已提交
239
	title: string;
D
Daniel Imms 已提交
240
	onDisposed: Event<ITerminalTab>;
241
	onInstancesChanged: Event<void>;
242

243 244
	focusPreviousPane(): void;
	focusNextPane(): void;
D
Daniel Imms 已提交
245
	resizePane(direction: Direction): void;
246
	setActiveInstanceByIndex(index: number): void;
D
Daniel Imms 已提交
247
	attachToElement(element: HTMLElement): void;
D
Daniel Imms 已提交
248 249
	setVisible(visible: boolean): void;
	layout(width: number, height: number): void;
250
	addDisposable(disposable: IDisposable): void;
D
Daniel Imms 已提交
251
	split(terminalFocusContextKey: IContextKey<boolean>, configHelper: ITerminalConfigHelper, shellLaunchConfig: IShellLaunchConfig): ITerminalInstance;
252 253
}

D
Daniel Imms 已提交
254 255 256 257 258 259 260 261 262 263 264 265
export interface ITerminalDimensions {
	/**
	 * The columns of the terminal.
	 */
	readonly cols: number;

	/**
	 * The rows of the terminal.
	 */
	readonly rows: number;
}

266
export interface ITerminalInstance {
D
jsdoc  
Daniel Imms 已提交
267 268 269 270
	/**
	 * The ID of the terminal instance, this is an arbitrary number only used to identify the
	 * terminal instance.
	 */
D
Daniel Imms 已提交
271 272 273 274
	readonly id: number;

	readonly cols: number;
	readonly rows: number;
D
jsdoc  
Daniel Imms 已提交
275

276
	/**
277 278
	 * The process ID of the shell process, this is undefined when there is no process associated
	 * with this terminal.
279
	 */
280
	processId: number | undefined;
281

D
jsdoc  
Daniel Imms 已提交
282 283 284
	/**
	 * An event that fires when the terminal instance's title changes.
	 */
D
Daniel Imms 已提交
285
	onTitleChanged: Event<string>;
D
jsdoc  
Daniel Imms 已提交
286

287 288 289 290 291
	/**
	 * An event that fires when the terminal instance is disposed.
	 */
	onDisposed: Event<ITerminalInstance>;

292 293
	onFocused: Event<ITerminalInstance>;

294 295
	onProcessIdReady: Event<ITerminalInstance>;

296 297
	onRequestExtHostProcess: Event<ITerminalInstance>;

D
Daniel Imms 已提交
298 299
	onDimensionsChanged: Event<void>;

D
Daniel Imms 已提交
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
	/**
	 * Attach a listener to the raw data stream coming from the pty, including ANSI escape
	 * sequences.
	 */
	onData: Event<string>;

	/**
	 * Attach a listener to the "renderer" input event, this event fires for terminal renderers on
	 * keystrokes and when the Terminal.sendText extension API is used.
	 * @param listener The listener function.
	 */
	onRendererInput: Event<string>;

	/**
	 * Attach a listener to listen for new lines added to this terminal instance.
	 *
	 * @param listener The listener function which takes new line strings added to the terminal,
	 * excluding ANSI escape sequences. The line event will fire when an LF character is added to
	 * the terminal (ie. the line is not wrapped). Note that this means that the line data will
	 * not fire for the last line, until either the line is ended with a LF character of the process
	 * is exited. The lineData string will contain the fully wrapped line, not containing any LF/CR
	 * characters.
	 */
	onLineData: Event<string>;

	/**
	 * Attach a listener that fires when the terminal's pty process exits. The number in the event
	 * is the processes' exit code, an exit code of null means the process was killed as a result of
	 * the ITerminalInstance being disposed.
	 */
	onExit: Event<number>;

D
Daniel Imms 已提交
332 333
	processReady: TPromise<void>;

D
jsdoc  
Daniel Imms 已提交
334 335 336 337 338 339
	/**
	 * The title of the terminal. This is either title or the process currently running or an
	 * explicit name given to the terminal instance through the extension API.
	 *
	 * @readonly
	 */
340 341
	title: string;

K
Kai Wood 已提交
342 343 344 345 346 347 348
	/**
	 * The focus state of the terminal before exiting.
	 *
	 * @readonly
	 */
	hadFocusOnExit: boolean;

A
Amy Qiu 已提交
349 350 351 352 353 354
	/**
	 * False when the title is set by an API or the user. We check this to make sure we
	 * do not override the title when the process title changes in the terminal.
	 */
	isTitleSetByProcess: boolean;

355 356 357
	/**
	 * The shell launch config used to launch the shell.
	 */
D
Daniel Imms 已提交
358
	readonly shellLaunchConfig: IShellLaunchConfig;
359

360 361 362 363 364 365 366
	/**
	 * Whether to disable layout for the terminal. This is useful when the size of the terminal is
	 * being manipulating (eg. adding a split pane) and we want the terminal to ignore particular
	 * resize events.
	 */
	disableLayout: boolean;

D
Daniel Imms 已提交
367 368 369 370 371 372
	/**
	 * An object that tracks when commands are run and enables navigating and selecting between
	 * them.
	 */
	readonly commandTracker: ITerminalCommandTracker;

D
jsdoc  
Daniel Imms 已提交
373 374 375
	/**
	 * Dispose the terminal instance, removing it from the panel/service and freeing up resources.
	 */
376
	dispose(): void;
D
jsdoc  
Daniel Imms 已提交
377

378 379 380 381 382 383 384
	/**
	 * Registers a link matcher, allowing custom link patterns to be matched and handled.
	 * @param regex The regular expression the search for, specifically this searches the
	 * textContent of the rows. You will want to use \s to match a space ' ' character for example.
	 * @param handler The callback when the link is called.
	 * @param matchIndex The index of the link from the regex.match(html) call. This defaults to 0
	 * (for regular expressions without capture groups).
385 386
	 * @param validationCallback A callback which can be used to validate the link after it has been
	 * added to the DOM.
387 388
	 * @return The ID of the new matcher, this can be used to deregister.
	 */
D
Daniel Imms 已提交
389
	registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void): number;
390 391 392 393 394 395 396 397

	/**
	 * Deregisters a link matcher if it has been registered.
	 * @param matcherId The link matcher's ID (returned after register)
	 * @return Whether a link matcher was found and deregistered.
	 */
	deregisterLinkMatcher(matcherId: number): void;

398 399 400 401 402
	/**
	 * Check if anything is selected in terminal.
	 */
	hasSelection(): boolean;

D
jsdoc  
Daniel Imms 已提交
403 404 405
	/**
	 * Copies the terminal selection to the clipboard.
	 */
406
	copySelection(): void;
D
jsdoc  
Daniel Imms 已提交
407

408 409 410 411 412
	/**
	 * Current selection in the terminal.
	 */
	readonly selection: string | undefined;

413 414 415 416 417
	/**
	 * Clear current selection.
	 */
	clearSelection(): void;

418 419 420 421 422
	/**
	 * Select all text in the terminal.
	 */
	selectAll(): void;

R
rebornix 已提交
423 424 425 426 427 428 429 430 431 432
	/**
	 * Find the next instance of the term
	*/
	findNext(term: string): boolean;

	/**
	 * Find the previous instance of the term
	 */
	findPrevious(term: string): boolean;

433 434 435 436 437
	/**
	 * Notifies the terminal that the find widget's focus state has been changed.
	 */
	notifyFindWidgetFocusChanged(isFocused: boolean): void;

D
jsdoc  
Daniel Imms 已提交
438 439 440 441 442
	/**
	 * Focuses the terminal instance.
	 *
	 * @param focus Force focus even if there is a selection.
	 */
D
Daniel Imms 已提交
443
	focus(force?: boolean): void;
D
jsdoc  
Daniel Imms 已提交
444 445 446 447

	/**
	 * Focuses and pastes the contents of the clipboard into the terminal instance.
	 */
448
	paste(): void;
D
jsdoc  
Daniel Imms 已提交
449 450 451 452 453 454 455 456 457 458

	/**
	 * Send text to the terminal instance. The text is written to the stdin of the underlying pty
	 * process (shell) of the terminal instance.
	 *
	 * @param text The text to send.
	 * @param addNewLine Whether to add a new line to the text being sent, this is normally
	 * required to run a command in the terminal. The character(s) added are \n or \r\n
	 * depending on the platform. This defaults to `true`.
	 */
459
	sendText(text: string, addNewLine: boolean): void;
D
jsdoc  
Daniel Imms 已提交
460

461 462 463 464 465 466
	/**
	 * Write text directly to the terminal, skipping the process if it exists.
	 * @param text The text to write.
	 */
	write(text: string): void;

467 468 469 470
	/** Scroll the terminal buffer down 1 line. */
	scrollDownLine(): void;
	/** Scroll the terminal buffer down 1 page. */
	scrollDownPage(): void;
471 472
	/** Scroll the terminal buffer to the bottom. */
	scrollToBottom(): void;
473 474 475 476
	/** Scroll the terminal buffer up 1 line. */
	scrollUpLine(): void;
	/** Scroll the terminal buffer up 1 page. */
	scrollUpPage(): void;
477 478
	/** Scroll the terminal buffer to the top. */
	scrollToTop(): void;
D
Daniel Imms 已提交
479

D
Daniel Imms 已提交
480 481 482 483 484
	/**
	 * Clears the terminal buffer, leaving only the prompt line.
	 */
	clear(): void;

D
jsdoc  
Daniel Imms 已提交
485 486 487 488 489 490
	/**
	 * Attaches the terminal instance to an element on the DOM, before this is called the terminal
	 * instance process may run in the background but cannot be displayed on the UI.
	 *
	 * @param container The element to attach the terminal instance to.
	 */
D
Daniel Imms 已提交
491
	attachToElement(container: HTMLElement): void;
D
jsdoc  
Daniel Imms 已提交
492 493

	/**
494
	 * Updates the configuration of the terminal instance.
D
jsdoc  
Daniel Imms 已提交
495
	 */
496
	updateConfig(): void;
D
Daniel Imms 已提交
497

498 499 500 501 502 503
	/**
	 * Updates the accessibility support state of the terminal instance.
	 * @param isEnabled Whether it's enabled.
	 */
	updateAccessibilitySupport(isEnabled: boolean): void;

D
jsdoc  
Daniel Imms 已提交
504 505 506 507 508
	/**
	 * Configure the dimensions of the terminal instance.
	 *
	 * @param dimension The dimensions of the container.
	 */
509
	layout(dimension: { width: number, height: number }): void;
D
jsdoc  
Daniel Imms 已提交
510 511 512 513 514 515

	/**
	 * Sets whether the terminal instance's element is visible in the DOM.
	 *
	 * @param visible Whether the element is visible.
	 */
D
Daniel Imms 已提交
516
	setVisible(visible: boolean): void;
517

518 519 520 521 522
	/**
	 * Immediately kills the terminal's current pty process and launches a new one to replace it.
	 *
	 * @param shell The new launch configuration.
	 */
523
	reuseTerminal(shell?: IShellLaunchConfig): void;
D
Daniel Imms 已提交
524

B
Ben Stein 已提交
525 526 527
	/**
	 * Sets the title of the terminal instance.
	 */
A
Amy Qiu 已提交
528
	setTitle(title: string, eventFromProcess: boolean): void;
529

D
Daniel Imms 已提交
530 531
	setDimensions(dimensions: ITerminalDimensions): void;

532
	addDisposable(disposable: IDisposable): void;
D
Daniel Imms 已提交
533
}
D
Daniel Imms 已提交
534 535

export interface ITerminalCommandTracker {
536 537
	scrollToPreviousCommand(): void;
	scrollToNextCommand(): void;
D
Daniel Imms 已提交
538 539
	selectToPreviousCommand(): void;
	selectToNextCommand(): void;
540 541
	selectToPreviousLine(): void;
	selectToNextLine(): void;
542
}
D
Daniel Imms 已提交
543 544

export interface ITerminalProcessManager extends IDisposable {
545
	readonly processState: ProcessState;
D
Daniel Imms 已提交
546 547 548 549 550 551 552 553
	readonly ptyProcessReady: TPromise<void>;
	readonly shellProcessId: number;
	readonly initialCwd: string;

	readonly onProcessReady: Event<void>;
	readonly onProcessData: Event<string>;
	readonly onProcessTitle: Event<string>;
	readonly onProcessExit: Event<number>;
D
Daniel Imms 已提交
554

D
Daniel Imms 已提交
555
	addDisposable(disposable: IDisposable);
D
Daniel Imms 已提交
556
	createProcess(shellLaunchConfig: IShellLaunchConfig, cols: number, rows: number);
D
Daniel Imms 已提交
557
	write(data: string): void;
D
Daniel Imms 已提交
558
	setDimensions(cols: number, rows: number): void;
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
}

export enum ProcessState {
	// The process has not been initialized yet.
	UNINITIALIZED,
	// The process is currently launching, the process is marked as launching
	// for a short duration after being created and is helpful to indicate
	// whether the process died as a result of bad shell and args.
	LAUNCHING,
	// The process is running normally.
	RUNNING,
	// The process was killed during launch, likely as a result of bad shell and
	// args.
	KILLED_DURING_LAUNCH,
	// The process was killed by the user (the event originated from VS Code).
	KILLED_BY_USER,
	// The process was killed by itself, for example the shell crashed or `exit`
	// was run.
	KILLED_BY_PROCESS
}
579 580


581
export interface ITerminalProcessExtHostProxy extends IDisposable {
582 583
	readonly terminalId: number;

584 585 586
	emitData(data: string): void;
	emitTitle(title: string): void;
	emitPid(pid: number): void;
D
Daniel Imms 已提交
587
	emitExit(exitCode: number): void;
588 589 590 591

	onInput(listener: (data: string) => void): void;
	onResize(listener: (cols: number, rows: number) => void): void;
	onShutdown(listener: () => void): void;
592
}
593 594 595 596 597 598 599

export interface ITerminalProcessExtHostRequest {
	proxy: ITerminalProcessExtHostProxy;
	shellLaunchConfig: IShellLaunchConfig;
	cols: number;
	rows: number;
}