mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
@@ -20,6 +20,8 @@ export class ExtHostTerminal implements vscode.Terminal {
|
||||
private _pidPromise: TPromise<number>;
|
||||
private _pidPromiseComplete: TValueCallback<number>;
|
||||
|
||||
private _onDataCallback: (data: string) => any;
|
||||
|
||||
constructor(
|
||||
proxy: MainThreadTerminalServiceShape,
|
||||
name?: string,
|
||||
@@ -67,6 +69,11 @@ export class ExtHostTerminal implements vscode.Terminal {
|
||||
this._queueApiRequest(this._proxy.$hide, []);
|
||||
}
|
||||
|
||||
public onData(callback: (data: string) => any): void {
|
||||
this._onDataCallback = callback;
|
||||
this._queueApiRequest(this._proxy.$registerOnData, []);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (!this._disposed) {
|
||||
this._disposed = true;
|
||||
@@ -79,6 +86,10 @@ export class ExtHostTerminal implements vscode.Terminal {
|
||||
this._pidPromiseComplete = null;
|
||||
}
|
||||
|
||||
public _onData(data: string): void {
|
||||
this._onDataCallback(data);
|
||||
}
|
||||
|
||||
private _queueApiRequest(callback: (...args: any[]) => void, args: any[]) {
|
||||
let request: ApiRequest = new ApiRequest(callback, args);
|
||||
if (!this._id) {
|
||||
@@ -138,6 +149,11 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
|
||||
terminal._setProcessId(processId);
|
||||
}
|
||||
|
||||
public $acceptTerminalData(id: number, data: string): void {
|
||||
let terminal = this._getTerminalById(id);
|
||||
terminal._onData(data);
|
||||
}
|
||||
|
||||
private _getTerminalById(id: number): ExtHostTerminal {
|
||||
let index = this._getTerminalIndexById(id);
|
||||
return index !== null ? this._terminals[index] : null;
|
||||
|
||||
Reference in New Issue
Block a user