提交 983cf3b9 编写于 作者: D Daniel Imms

Implement terminal kill

上级 c80c9ce3
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import {ITerminalService, TERMINAL_PANEL_ID} from 'vs/workbench/parts/terminal/electron-browser/terminal';
import {ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal';
import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
import {IPartService} from 'vs/workbench/services/part/common/partService';
import {MainThreadTerminalServiceShape} from './extHost.protocol';
......@@ -33,10 +33,7 @@ export class MainThreadTerminalService extends MainThreadTerminalServiceShape {
public $hide(terminalId: number): void {
if (this.terminalService.getActiveInstance().id === terminalId) {
const panel = this.panelService.getActivePanel();
if (panel && panel.getId() === TERMINAL_PANEL_ID) {
this.partService.setPanelHidden(true);
}
this.terminalService.hidePanel();
}
}
......
......@@ -112,6 +112,7 @@ export interface ITerminalService {
setActiveInstanceToPrevious(): void;
showPanel(focus?: boolean): TPromise<void>;
hidePanel(): void;
togglePanel(): TPromise<void>;
setContainers(panelContainer: Builder, terminalContainer: HTMLElement): void;
}
......
......@@ -143,18 +143,53 @@ export class TerminalInstance implements ITerminalInstance {
this.layout(new Dimension(this.container.offsetWidth, this.container.offsetHeight));
}
public copySelection(): void {}
public dispose(): void {}
public focus(): void {}
public paste(): void {}
public sendText(text: string, addNewLine: boolean): void {}
public copySelection(): void {
// TODO: Implement
}
public dispose(): void {
if (this.wrapperElement) {
this.container.removeChild(this.wrapperElement);
this.wrapperElement = null;
}
if (this.xterm) {
this.xterm.destroy();
this.xterm = null;
}
if (this.process) {
if (this.process.connected) {
this.process.disconnect();
this.process.kill();
}
this.process = null;
}
this.toDispose = lifecycle.dispose(this.toDispose);
this.onExitCallback(this);
}
public focus(): void {
// TODO: Implement
}
public paste(): void {
// TODO: Implement
}
public sendText(text: string, addNewLine: boolean): void {
// TODO: Implement
}
public setVisible(visible: boolean): void {
DOM.toggleClass(this.wrapperElement, 'active', visible);
}
public scrollDown(): void {}
public scrollUp(): void {}
public scrollDown(): void {
// TODO: Implement
}
public scrollUp(): void {
// TODO: Implement
}
private sanitizeInput(data: any) {
return typeof data === 'string' ? data.replace(TerminalInstance.EOL_REGEX, os.EOL) : data;
......@@ -187,7 +222,6 @@ export class TerminalInstance implements ITerminalInstance {
if (exitCode) {
this.messageService.show(Severity.Error, nls.localize('terminal.integrated.exitedWithCode', 'The terminal process terminated with exit code: {0}', exitCode));
}
this.onExitCallback(this);
}
});
}
......
......@@ -68,7 +68,22 @@ export class TerminalService implements ITerminalService {
}
private onTerminalInstanceDispose(terminalInstance: TerminalInstance): void {
// TODO: Handle terminal exit here
let index = this.terminalInstances.indexOf(terminalInstance);
let wasActiveInstance = terminalInstance === this.getActiveInstance();
if (index !== -1) {
this.terminalInstances.splice(index, 1);
}
if (wasActiveInstance && this.terminalInstances.length > 0) {
let newIndex = index < this.terminalInstances.length ? index : this.terminalInstances.length - 1;
this.setActiveInstanceByIndex(newIndex);
}
if (this.terminalInstances.length === 0) {
this.hidePanel();
}
this._onInstancesChanged.fire();
if (wasActiveInstance) {
this._onActiveInstanceChanged.fire();
}
}
public getActiveInstance(): ITerminalInstance {
......@@ -143,6 +158,13 @@ export class TerminalService implements ITerminalService {
});
}
public hidePanel(): void {
const panel = this.panelService.getActivePanel();
if (panel && panel.getId() === TERMINAL_PANEL_ID) {
this.partService.setPanelHidden(true);
}
}
public togglePanel(): TPromise<any> {
const panel = this.panelService.getActivePanel();
if (panel && panel.getId() === TERMINAL_PANEL_ID) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册