Many terminal API changes

This commit is contained in:
Daniel Imms
2016-08-19 12:09:18 -07:00
parent 2fb2d9a5dd
commit 65888050c3
8 changed files with 53 additions and 20 deletions

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import {TPromise} from 'vs/base/common/winjs.base';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import vscode = require('vscode');
import {MainContext, MainThreadTerminalServiceShape} from './extHost.protocol';
@@ -19,28 +18,49 @@ export class ExtHostTerminal implements vscode.Terminal {
constructor(proxy: MainThreadTerminalServiceShape, id: number, name?: string) {
this.name = name;
this._id = id;
this._proxy = proxy;
this._proxy.$createTerminal(name).then((terminalId) => {
this._id = terminalId;
});
}
public sendText(text: string, addNewLine: boolean = true): void {
this.checkId();
this.checkDisposed();
this._proxy.$sendText(this._id, text, addNewLine);
}
public show(preserveFocus: boolean): void {
this.checkId();
this.checkDisposed();
this._proxy.$show(this._id, preserveFocus);
}
public hide(): void {
this.checkId();
this.checkDisposed();
this._proxy.$hide(this._id);
}
public dispose(): void {
this.checkId();
if (!this._disposed) {
this._disposed = true;
this._proxy.$dispose(this._id);
}
}
private checkId() {
if (!this._id) {
throw new Error('Terminal has not been initialized yet');
}
}
private checkDisposed() {
if (this._disposed) {
throw new Error('Terminal has already been disposed');
}
}
}
export class ExtHostTerminalService {
@@ -51,9 +71,7 @@ export class ExtHostTerminalService {
this._proxy = threadService.get(MainContext.MainThreadTerminalService);
}
public createTerminal(name?: string): TPromise<vscode.Terminal> {
return this._proxy.$createTerminal(name).then((terminalId) => {
return new ExtHostTerminal(this._proxy, terminalId, name);
});
public createTerminal(name?: string): vscode.Terminal {
return new ExtHostTerminal(this._proxy, -1, name);
}
}