terminal.ts 19.9 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';
8
import * as platform from 'vs/base/common/platform';
D
Daniel Imms 已提交
9
import { RawContextKey, ContextKeyExpr, IContextKey } from 'vs/platform/contextkey/common/contextkey';
10 11
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
D
Daniel Imms 已提交
12 13 14 15 16

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

export const TERMINAL_SERVICE_ID = 'terminalService';

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

22 23 24 25 26
/** 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 已提交
27 28 29 30
/**  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();
31 32 33 34
/**  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 已提交
35

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

40 41 42 43 44
// The creation of extension host terminals is delayed by this value (milliseconds). The purpose of
// this delay is to allow the terminal instance to initialize correctly and have its ID set before
// trying to create the corressponding object on the ext host.
export const EXT_HOST_CREATION_DELAY = 100;

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

47 48 49 50 51 52
export const TerminalCursorStyle = {
	BLOCK: 'block',
	LINE: 'line',
	UNDERLINE: 'underline'
};

53 54
export const TERMINAL_CONFIG_SECTION = 'terminal.integrated';

55 56 57 58
export const DEFAULT_LETTER_SPACING = 0;
export const MINIMUM_LETTER_SPACING = -5;
export const DEFAULT_LINE_HEIGHT = 1.0;

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

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

101
export interface ITerminalConfigHelper {
102
	config: ITerminalConfiguration;
103
	getFont(): ITerminalFont;
104 105 106
	/**
	 * Merges the default shell path and args into the provided launch configuration
	 */
107
	mergeDefaultShellPathAndArgs(shell: IShellLaunchConfig, platformOverride?: platform.Platform): void;
108 109
	/** Sets whether a workspace shell configuration is allowed or not */
	setWorkspaceShellAllowed(isAllowed: boolean): void;
110 111 112 113
}

export interface ITerminalFont {
	fontFamily: string;
D
Daniel Imms 已提交
114
	fontSize: number;
115
	letterSpacing: number;
116
	lineHeight: number;
117 118
	charWidth?: number;
	charHeight?: number;
119 120
}

121
export interface IShellLaunchConfig {
122 123 124
	/**
	 * The name of the terminal, if this is not set the name of the process will be used.
	 */
125
	name?: string;
126 127 128 129

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

132 133
	/**
	 * The CLI arguments to use with executable, a string[] is in argv format and will be escaped,
D
Daniel Imms 已提交
134 135
	 * 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.
136 137
	 */
	args?: string[] | string;
138

139 140 141 142 143
	/**
	 * The current working directory of the terminal, this overrides the `terminal.integrated.cwd`
	 * settings key.
	 */
	cwd?: string;
144

145 146 147 148 149
	/**
	 * 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 };
150

151 152 153 154 155
	/**
	 * 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;
156

157
	/** Whether to wait for a key press before closing the terminal. */
158 159
	waitOnExit?: boolean | string;

160 161 162 163 164 165 166
	/**
	 * 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;
167 168 169 170 171 172

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

D
Daniel Imms 已提交
175
export interface ITerminalService {
176
	_serviceBrand: any;
177

D
Daniel Imms 已提交
178
	activeTabIndex: number;
179
	configHelper: ITerminalConfigHelper;
D
Daniel Imms 已提交
180
	onActiveTabChanged: Event<void>;
181
	onTabDisposed: Event<ITerminalTab>;
182
	onInstanceCreated: Event<ITerminalInstance>;
183
	onInstanceDisposed: Event<ITerminalInstance>;
184
	onInstanceProcessIdReady: Event<ITerminalInstance>;
D
Daniel Imms 已提交
185
	onInstanceDimensionsChanged: Event<ITerminalInstance>;
186
	onInstanceRequestExtHostProcess: Event<ITerminalProcessExtHostRequest>;
187
	onInstancesChanged: Event<void>;
188
	onInstanceTitleChanged: Event<string>;
189
	onActiveInstanceChanged: Event<ITerminalInstance>;
190
	terminalInstances: ITerminalInstance[];
D
Daniel Imms 已提交
191
	terminalTabs: ITerminalTab[];
192

193 194 195 196 197 198 199
	/**
	 * 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;
200 201 202 203 204 205

	/**
	 * Creates a terminal renderer.
	 * @param name The name of the terminal.
	 */
	createTerminalRenderer(name: string): ITerminalInstance;
206 207 208 209
	/**
	 * 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;
210
	getInstanceFromId(terminalId: number): ITerminalInstance;
T
t-amqi 已提交
211
	getInstanceFromIndex(terminalIndex: number): ITerminalInstance;
D
Daniel Imms 已提交
212
	getTabLabels(): string[];
213 214 215
	getActiveInstance(): ITerminalInstance;
	setActiveInstance(terminalInstance: ITerminalInstance): void;
	setActiveInstanceByIndex(terminalIndex: number): void;
216
	getActiveOrCreateInstance(wasNewTerminalAction?: boolean): ITerminalInstance;
217
	splitInstance(instance: ITerminalInstance, shell?: IShellLaunchConfig): void;
218

219
	getActiveTab(): ITerminalTab;
220 221 222 223
	setActiveTabToNext(): void;
	setActiveTabToPrevious(): void;
	setActiveTabByIndex(tabIndex: number): void;

224
	showPanel(focus?: boolean): TPromise<void>;
D
Daniel Imms 已提交
225
	hidePanel(): void;
226 227
	focusFindWidget(): TPromise<void>;
	hideFindWidget(): void;
228

229
	setContainers(panelContainer: HTMLElement, terminalContainer: HTMLElement): void;
D
Daniel Imms 已提交
230
	selectDefaultWindowsShell(): TPromise<string>;
231
	setWorkspaceShellAllowed(isAllowed: boolean): void;
232

233
	requestExtHostProcess(proxy: ITerminalProcessExtHostProxy, shellLaunchConfig: IShellLaunchConfig, cols: number, rows: number): void;
D
Daniel Imms 已提交
234
}
D
Daniel Imms 已提交
235

D
Daniel Imms 已提交
236 237 238 239 240 241 242
export const enum Direction {
	Left = 0,
	Right = 1,
	Up = 2,
	Down = 3
}

243
export interface ITerminalTab {
D
Daniel Imms 已提交
244
	activeInstance: ITerminalInstance;
245
	terminalInstances: ITerminalInstance[];
D
Daniel Imms 已提交
246
	title: string;
D
Daniel Imms 已提交
247
	onDisposed: Event<ITerminalTab>;
248
	onInstancesChanged: Event<void>;
249

250 251
	focusPreviousPane(): void;
	focusNextPane(): void;
D
Daniel Imms 已提交
252
	resizePane(direction: Direction): void;
253
	setActiveInstanceByIndex(index: number): void;
D
Daniel Imms 已提交
254
	attachToElement(element: HTMLElement): void;
D
Daniel Imms 已提交
255 256
	setVisible(visible: boolean): void;
	layout(width: number, height: number): void;
257
	addDisposable(disposable: IDisposable): void;
D
Daniel Imms 已提交
258
	split(terminalFocusContextKey: IContextKey<boolean>, configHelper: ITerminalConfigHelper, shellLaunchConfig: IShellLaunchConfig): ITerminalInstance;
259 260
}

D
Daniel Imms 已提交
261 262 263 264 265 266 267 268 269 270 271 272
export interface ITerminalDimensions {
	/**
	 * The columns of the terminal.
	 */
	readonly cols: number;

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

273
export interface ITerminalInstance {
D
jsdoc  
Daniel Imms 已提交
274 275 276 277
	/**
	 * The ID of the terminal instance, this is an arbitrary number only used to identify the
	 * terminal instance.
	 */
D
Daniel Imms 已提交
278 279 280 281
	readonly id: number;

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

283
	/**
284 285
	 * The process ID of the shell process, this is undefined when there is no process associated
	 * with this terminal.
286
	 */
287
	processId: number | undefined;
288

D
jsdoc  
Daniel Imms 已提交
289 290 291
	/**
	 * An event that fires when the terminal instance's title changes.
	 */
D
Daniel Imms 已提交
292
	onTitleChanged: Event<string>;
D
jsdoc  
Daniel Imms 已提交
293

294 295 296 297 298
	/**
	 * An event that fires when the terminal instance is disposed.
	 */
	onDisposed: Event<ITerminalInstance>;

299 300
	onFocused: Event<ITerminalInstance>;

301 302
	onProcessIdReady: Event<ITerminalInstance>;

303 304
	onRequestExtHostProcess: Event<ITerminalInstance>;

D
Daniel Imms 已提交
305 306
	onDimensionsChanged: Event<void>;

307 308
	onFocus: Event<ITerminalInstance>;

D
Daniel Imms 已提交
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
	/**
	 * 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 已提交
341 342
	processReady: TPromise<void>;

D
jsdoc  
Daniel Imms 已提交
343 344 345 346 347 348
	/**
	 * 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
	 */
349 350
	title: string;

K
Kai Wood 已提交
351 352 353 354 355 356 357
	/**
	 * The focus state of the terminal before exiting.
	 *
	 * @readonly
	 */
	hadFocusOnExit: boolean;

A
Amy Qiu 已提交
358 359 360 361 362 363
	/**
	 * 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;

364 365 366
	/**
	 * The shell launch config used to launch the shell.
	 */
D
Daniel Imms 已提交
367
	readonly shellLaunchConfig: IShellLaunchConfig;
368

369 370 371 372 373 374 375
	/**
	 * 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 已提交
376 377 378 379 380 381
	/**
	 * An object that tracks when commands are run and enables navigating and selecting between
	 * them.
	 */
	readonly commandTracker: ITerminalCommandTracker;

D
jsdoc  
Daniel Imms 已提交
382 383 384
	/**
	 * Dispose the terminal instance, removing it from the panel/service and freeing up resources.
	 */
385
	dispose(): void;
D
jsdoc  
Daniel Imms 已提交
386

387 388 389 390 391 392 393
	/**
	 * 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).
394 395
	 * @param validationCallback A callback which can be used to validate the link after it has been
	 * added to the DOM.
396 397
	 * @return The ID of the new matcher, this can be used to deregister.
	 */
D
Daniel Imms 已提交
398
	registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void): number;
399 400 401 402 403 404 405 406

	/**
	 * 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;

407 408 409 410 411
	/**
	 * Check if anything is selected in terminal.
	 */
	hasSelection(): boolean;

D
jsdoc  
Daniel Imms 已提交
412 413 414
	/**
	 * Copies the terminal selection to the clipboard.
	 */
415
	copySelection(): void;
D
jsdoc  
Daniel Imms 已提交
416

417 418 419 420 421
	/**
	 * Current selection in the terminal.
	 */
	readonly selection: string | undefined;

422 423 424 425 426
	/**
	 * Clear current selection.
	 */
	clearSelection(): void;

427 428 429 430 431
	/**
	 * Select all text in the terminal.
	 */
	selectAll(): void;

R
rebornix 已提交
432 433 434 435 436 437 438 439 440 441
	/**
	 * Find the next instance of the term
	*/
	findNext(term: string): boolean;

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

442 443 444 445 446
	/**
	 * Notifies the terminal that the find widget's focus state has been changed.
	 */
	notifyFindWidgetFocusChanged(isFocused: boolean): void;

D
jsdoc  
Daniel Imms 已提交
447 448 449 450 451
	/**
	 * Focuses the terminal instance.
	 *
	 * @param focus Force focus even if there is a selection.
	 */
D
Daniel Imms 已提交
452
	focus(force?: boolean): void;
D
jsdoc  
Daniel Imms 已提交
453 454 455 456

	/**
	 * Focuses and pastes the contents of the clipboard into the terminal instance.
	 */
457
	paste(): void;
D
jsdoc  
Daniel Imms 已提交
458 459 460 461 462 463 464 465 466 467

	/**
	 * 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`.
	 */
468
	sendText(text: string, addNewLine: boolean): void;
D
jsdoc  
Daniel Imms 已提交
469

470 471 472 473 474 475
	/**
	 * Write text directly to the terminal, skipping the process if it exists.
	 * @param text The text to write.
	 */
	write(text: string): void;

476 477 478 479
	/** Scroll the terminal buffer down 1 line. */
	scrollDownLine(): void;
	/** Scroll the terminal buffer down 1 page. */
	scrollDownPage(): void;
480 481
	/** Scroll the terminal buffer to the bottom. */
	scrollToBottom(): void;
482 483 484 485
	/** Scroll the terminal buffer up 1 line. */
	scrollUpLine(): void;
	/** Scroll the terminal buffer up 1 page. */
	scrollUpPage(): void;
486 487
	/** Scroll the terminal buffer to the top. */
	scrollToTop(): void;
D
Daniel Imms 已提交
488

D
Daniel Imms 已提交
489 490 491 492 493
	/**
	 * Clears the terminal buffer, leaving only the prompt line.
	 */
	clear(): void;

D
jsdoc  
Daniel Imms 已提交
494 495 496 497 498 499
	/**
	 * 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 已提交
500
	attachToElement(container: HTMLElement): void;
D
jsdoc  
Daniel Imms 已提交
501 502

	/**
503
	 * Updates the configuration of the terminal instance.
D
jsdoc  
Daniel Imms 已提交
504
	 */
505
	updateConfig(): void;
D
Daniel Imms 已提交
506

507 508 509 510 511 512
	/**
	 * Updates the accessibility support state of the terminal instance.
	 * @param isEnabled Whether it's enabled.
	 */
	updateAccessibilitySupport(isEnabled: boolean): void;

D
jsdoc  
Daniel Imms 已提交
513 514 515 516 517
	/**
	 * Configure the dimensions of the terminal instance.
	 *
	 * @param dimension The dimensions of the container.
	 */
518
	layout(dimension: { width: number, height: number }): void;
D
jsdoc  
Daniel Imms 已提交
519 520 521 522 523 524

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

527 528 529 530 531
	/**
	 * Immediately kills the terminal's current pty process and launches a new one to replace it.
	 *
	 * @param shell The new launch configuration.
	 */
532
	reuseTerminal(shell?: IShellLaunchConfig): void;
D
Daniel Imms 已提交
533

B
Ben Stein 已提交
534 535 536
	/**
	 * Sets the title of the terminal instance.
	 */
A
Amy Qiu 已提交
537
	setTitle(title: string, eventFromProcess: boolean): void;
538

D
Daniel Imms 已提交
539 540
	setDimensions(dimensions: ITerminalDimensions): void;

541
	addDisposable(disposable: IDisposable): void;
D
Daniel Imms 已提交
542
}
D
Daniel Imms 已提交
543 544

export interface ITerminalCommandTracker {
545 546
	scrollToPreviousCommand(): void;
	scrollToNextCommand(): void;
D
Daniel Imms 已提交
547 548
	selectToPreviousCommand(): void;
	selectToNextCommand(): void;
549 550
	selectToPreviousLine(): void;
	selectToNextLine(): void;
551
}
D
Daniel Imms 已提交
552 553

export interface ITerminalProcessManager extends IDisposable {
554
	readonly processState: ProcessState;
D
Daniel Imms 已提交
555 556 557 558 559 560 561 562
	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 已提交
563

D
Daniel Imms 已提交
564
	addDisposable(disposable: IDisposable);
D
Daniel Imms 已提交
565
	createProcess(shellLaunchConfig: IShellLaunchConfig, cols: number, rows: number);
D
Daniel Imms 已提交
566
	write(data: string): void;
D
Daniel Imms 已提交
567
	setDimensions(cols: number, rows: number): void;
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
}

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
}
588 589


590
export interface ITerminalProcessExtHostProxy extends IDisposable {
591 592
	readonly terminalId: number;

593 594 595
	emitData(data: string): void;
	emitTitle(title: string): void;
	emitPid(pid: number): void;
D
Daniel Imms 已提交
596
	emitExit(exitCode: number): void;
597 598 599 600

	onInput(listener: (data: string) => void): void;
	onResize(listener: (cols: number, rows: number) => void): void;
	onShutdown(listener: () => void): void;
601
}
602 603 604 605 606 607 608

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