Resolve TODOs

This commit is contained in:
Daniel Imms 2016-09-11 12:17:56 -07:00
parent b0b5475286
commit a38afe6709
2 changed files with 9 additions and 7 deletions

View file

@ -42,9 +42,8 @@ export class TerminalInstance implements ITerminalInstance {
private skipTerminalKeybindings: Keybinding[] = [];
private process: cp.ChildProcess;
private xterm: any;
// TODO: Improve HTML element names?
private wrapperElement: HTMLDivElement;
private terminalDomElement: HTMLDivElement;
private xtermElement: HTMLDivElement;
public constructor(
private terminalFocusContextKey: IContextKey<boolean>,
@ -67,6 +66,10 @@ export class TerminalInstance implements ITerminalInstance {
}
}
public addDisposable(disposable: lifecycle.IDisposable): void {
this.toDispose.push(disposable);
}
public attachToElement(container: HTMLElement): void {
if (this.wrapperElement) {
throw new Error('The terminal instance has already been attached to a container');
@ -74,10 +77,10 @@ export class TerminalInstance implements ITerminalInstance {
this.wrapperElement = document.createElement('div');
DOM.addClass(this.wrapperElement, 'terminal-wrapper');
this.terminalDomElement = document.createElement('div');
this.xtermElement = document.createElement('div');
this.xterm = xterm();
this.xterm.open(this.terminalDomElement);
this.xterm.open(this.xtermElement);
this.process.on('message', (message) => {
if (message.type === 'data') {
@ -133,7 +136,7 @@ export class TerminalInstance implements ITerminalInstance {
this.terminalFocusContextKey.reset();
}));
this.wrapperElement.appendChild(this.terminalDomElement);
this.wrapperElement.appendChild(this.xtermElement);
this.container.appendChild(this.wrapperElement);
this.layout(new Dimension(this.container.offsetWidth, this.container.offsetHeight));

View file

@ -52,8 +52,7 @@ export class TerminalService implements ITerminalService {
public createInstance(name?: string, shellPath?: string): ITerminalInstance {
let terminalInstance = <TerminalInstance>this.instantiationService.createInstance(TerminalInstance,
this.terminalFocusContextKey, this.onTerminalInstanceDispose.bind(this), this._configHelper, this.terminalContainer, name, shellPath);
// TODO: Dispose this event handler when the terminalInstance is disposed
terminalInstance.onTitleChanged(this._onInstanceTitleChanged.fire, this._onInstanceTitleChanged);
terminalInstance.addDisposable(terminalInstance.onTitleChanged(this._onInstanceTitleChanged.fire, this._onInstanceTitleChanged));
this.terminalInstances.push(terminalInstance);
if (this.terminalInstances.length === 1) {
// It's the first instance so it should be made active automatically