WIP refactor of integrated terminal part

This commit is contained in:
Daniel Imms
2016-09-09 19:01:16 -07:00
parent f0644a47fc
commit 9981aefa8a
10 changed files with 1390 additions and 892 deletions

View File

@@ -15,17 +15,11 @@ export class ExtHostTerminal implements vscode.Terminal {
private _id: number;
private _proxy: MainThreadTerminalServiceShape;
private _disposed: boolean;
private _queuedRequests: ApiRequest[] = [];
constructor(proxy: MainThreadTerminalServiceShape, id: number, name?: string) {
this._name = name;
this._proxy = proxy;
this._proxy.$createTerminal(name).then((terminalId) => {
this._id = terminalId;
this._queuedRequests.forEach((r) => {
r.run(this._proxy, this._id);
});
});
this._id = this._proxy.$createTerminal(name);
}
public get name(): string {
@@ -35,32 +29,17 @@ export class ExtHostTerminal implements vscode.Terminal {
public sendText(text: string, addNewLine: boolean = true): void {
this._checkDisposed();
let request: ApiRequest = new ApiRequest(this._proxy.$sendText, [text, addNewLine]);
if (!this._id) {
this._queuedRequests.push(request);
return;
}
request.run(this._proxy, this._id);
this._proxy.$sendText(this._id, text, addNewLine);
}
public show(preserveFocus: boolean): void {
this._checkDisposed();
let request: ApiRequest = new ApiRequest(this._proxy.$show, [preserveFocus]);
if (!this._id) {
this._queuedRequests.push(request);
return;
}
request.run(this._proxy, this._id);
this._proxy.$show(this._id, preserveFocus);
}
public hide(): void {
this._checkDisposed();
let request: ApiRequest = new ApiRequest(this._proxy.$hide, []);
if (!this._id) {
this._queuedRequests.push(request);
return;
}
request.run(this._proxy, this._id);
this._proxy.$hide(this._id);
}
public dispose(): void {
@@ -89,17 +68,3 @@ export class ExtHostTerminalService {
return new ExtHostTerminal(this._proxy, -1, name);
}
}
class ApiRequest {
private _callback: (...args: any[]) => void;
private _args: any[];
constructor(callback: (...args: any[]) => void, args: any[]) {
this._callback = callback;
this._args = args;
}
public run(proxy: MainThreadTerminalServiceShape, id: number) {
this._callback.apply(proxy, [id].concat(this._args));
}
}