Remove old code

This commit is contained in:
Daniel Imms
2016-09-10 20:39:28 -07:00
parent 8bfe9123a8
commit e95af24f5a
4 changed files with 0 additions and 1001 deletions

View File

@@ -53,45 +53,6 @@ export interface ITerminalConfiguration {
};
}
// export interface ITerminalProcess {
// title: string;
// process: cp.ChildProcess;
// }
// export interface ITerminalService {
// _serviceBrand: any;
// onActiveInstanceChanged: Event<string>;
// onInstancesChanged: Event<string>;
// onInstanceTitleChanged: Event<string>;
// close(): TPromise<any>;
// copySelection(): TPromise<any>;
// createNew(name?: string): TPromise<number>;
// focusNext(): TPromise<any>;
// focusPrevious(): TPromise<any>;
// hide(): TPromise<any>;
// hideTerminalInstance(terminalId: number): TPromise<any>;
// paste(): TPromise<any>;
// runSelectedText(): TPromise<any>;
// scrollDown(): TPromise<any>;
// scrollUp(): TPromise<any>;
// show(focus: boolean): TPromise<ITerminalPanel>;
// setActiveTerminal(index: number): TPromise<any>;
// setActiveTerminalById(terminalId: number): void;
// toggle(): TPromise<any>;
// getActiveTerminalIndex(): number;
// getTerminalInstanceTitles(): string[];
// initConfigHelper(panelContainer: Builder): void;
// killTerminalProcess(terminalProcess: ITerminalProcess): void;
// }
// export interface ITerminalPanel {
// closeTerminalById(terminalId: number): TPromise<void>;
// focus(): void;
// sendTextToActiveTerminal(text: string, addNewLine: boolean): void;
// }
export interface ITerminalService {
_serviceBrand: any;

View File

@@ -324,229 +324,3 @@ export class TerminalInstance implements ITerminalInstance {
}
}
}
// import DOM = require('vs/base/browser/dom');
// import URI from 'vs/base/common/uri';
// import cp = require('child_process');
// import lifecycle = require('vs/base/common/lifecycle');
// import nls = require('vs/nls');
// import os = require('os');
// import path = require('path');
// import platform = require('vs/base/common/platform');
// import xterm = require('xterm');
// import {Dimension} from 'vs/base/browser/builder';
// import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
// import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
// import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
// import {IContextKey} from 'vs/platform/contextkey/common/contextkey';
// import {IMessageService, Severity} from 'vs/platform/message/common/message';
// import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
// import {ITerminalInstance, ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal';
// import {IStringDictionary} from 'vs/base/common/collections';
// import {IShell, TerminalConfigHelper} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
// import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
// import {Keybinding} from 'vs/base/common/keyCodes';
// import {StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent';
// import {TabFocus} from 'vs/editor/common/config/commonEditorConfig';
// export class TerminalInstance {
// public id: number;
// private static eolRegex = /\r?\n/g;
// private isExiting: boolean = false;
// private skipTerminalKeybindings: Keybinding[] = [];
// private toDispose: lifecycle.IDisposable[];
// private xterm;
// private terminalDomElement: HTMLDivElement;
// private wrapperElement: HTMLDivElement;
// private font: ITerminalFont;
// public constructor(
// private terminalProcess: ITerminalProcess,
// private parentDomElement: HTMLElement,
// private contextMenuService: IContextMenuService,
// private contextService: IWorkspaceContextService,
// private instantiationService: IInstantiationService,
// private keybindingService: IKeybindingService,
// private terminalService: ITerminalService,
// private messageService: IMessageService,
// private terminalFocusContextKey: IContextKey<boolean>,
// private onExitCallback: (TerminalInstance) => void
// ) {
// this.toDispose = [];
// this.wrapperElement = document.createElement('div');
// DOM.addClass(this.wrapperElement, 'terminal-wrapper');
// this.terminalDomElement = document.createElement('div');
// this.xterm = xterm();
// this.id = this.terminalProcess.process.pid;
// this.terminalProcess.process.on('message', (message) => {
// if (message.type === 'data') {
// this.xterm.write(message.content);
// }
// });
// this.xterm.on('data', (data) => {
// this.terminalProcess.process.send({
// event: 'input',
// data: this.sanitizeInput(data)
// });
// return false;
// });
// this.xterm.attachCustomKeydownHandler((event: KeyboardEvent) => {
// // Allow the toggle tab mode keybinding to pass through the terminal so that focus can
// // be escaped
// let standardKeyboardEvent = new StandardKeyboardEvent(event);
// if (this.skipTerminalKeybindings.some((k) => standardKeyboardEvent.equals(k.value))) {
// event.preventDefault();
// return false;
// }
// // If tab focus mode is on, tab is not passed to the terminal
// if (TabFocus.getTabFocusMode() && event.keyCode === 9) {
// return false;
// }
// });
// this.terminalProcess.process.on('exit', (exitCode) => {
// // Prevent dispose functions being triggered multiple times
// if (!this.isExiting) {
// this.isExiting = true;
// this.dispose();
// if (exitCode) {
// this.messageService.show(Severity.Error, nls.localize('terminal.integrated.exitedWithCode', 'The terminal process terminated with exit code: {0}', exitCode));
// }
// this.onExitCallback(this);
// }
// });
// this.xterm.open(this.terminalDomElement);
// let xtermHelper: HTMLElement = this.xterm.element.querySelector('.xterm-helpers');
// let focusTrap: HTMLElement = document.createElement('div');
// focusTrap.setAttribute('tabindex', '0');
// DOM.addClass(focusTrap, 'focus-trap');
// focusTrap.addEventListener('focus', function (event: FocusEvent) {
// let currentElement = focusTrap;
// while (!DOM.hasClass(currentElement, 'part')) {
// currentElement = currentElement.parentElement;
// }
// let hidePanelElement = <HTMLElement>currentElement.querySelector('.hide-panel-action');
// hidePanelElement.focus();
// });
// xtermHelper.insertBefore(focusTrap, this.xterm.textarea);
// this.toDispose.push(DOM.addDisposableListener(this.xterm.textarea, 'focus', (event: KeyboardEvent) => {
// this.terminalFocusContextKey.set(true);
// }));
// this.toDispose.push(DOM.addDisposableListener(this.xterm.textarea, 'blur', (event: KeyboardEvent) => {
// this.terminalFocusContextKey.reset();
// }));
// this.toDispose.push(DOM.addDisposableListener(this.xterm.element, 'focus', (event: KeyboardEvent) => {
// this.terminalFocusContextKey.set(true);
// }));
// this.toDispose.push(DOM.addDisposableListener(this.xterm.element, 'blur', (event: KeyboardEvent) => {
// this.terminalFocusContextKey.reset();
// }));
// this.wrapperElement.appendChild(this.terminalDomElement);
// this.parentDomElement.appendChild(this.wrapperElement);
// }
// private sanitizeInput(data: any) {
// return typeof data === 'string' ? data.replace(TerminalInstance.eolRegex, os.EOL) : data;
// }
// public layout(dimension: Dimension): void {
// if (!this.font || !this.font.charWidth || !this.font.charHeight) {
// return;
// }
// if (!dimension.height) { // Minimized
// return;
// }
// let leftPadding = parseInt(getComputedStyle(document.querySelector('.terminal-outer-container')).paddingLeft.split('px')[0], 10);
// let innerWidth = dimension.width - leftPadding;
// let cols = Math.floor(innerWidth / this.font.charWidth);
// let rows = Math.floor(dimension.height / this.font.charHeight);
// if (this.xterm) {
// this.xterm.resize(cols, rows);
// this.xterm.element.style.width = innerWidth + 'px';
// }
// if (this.terminalProcess.process.connected) {
// this.terminalProcess.process.send({
// event: 'resize',
// cols: cols,
// rows: rows
// });
// }
// }
// public toggleVisibility(visible: boolean) {
// DOM.toggleClass(this.wrapperElement, 'active', visible);
// }
// public setFont(font: ITerminalFont): void {
// this.font = font;
// }
// public setCursorBlink(blink: boolean): void {
// if (this.xterm && this.xterm.cursorBlink !== blink) {
// this.xterm.cursorBlink = blink;
// this.xterm.refresh(0, this.xterm.rows - 1);
// }
// }
// public setCommandsToSkipShell(commands: string[]): void {
// this.skipTerminalKeybindings = commands.map((c) => {
// return this.keybindingService.lookupKeybindings(c);
// }).reduce((prev, curr) => {
// return prev.concat(curr);
// });
// }
// public sendText(text: string, addNewLine: boolean): void {;
// if (addNewLine && text.substr(text.length - os.EOL.length) !== os.EOL) {
// text += os.EOL;
// }
// this.terminalProcess.process.send({
// event: 'input',
// data: text
// });
// }
// public focus(force?: boolean): void {
// if (!this.xterm) {
// return;
// }
// let text = window.getSelection().toString();
// if (!text || force) {
// this.xterm.focus();
// }
// }
// public scrollDown(): void {
// this.xterm.scrollDisp(1);
// }
// public scrollUp(): void {
// this.xterm.scrollDisp(-1);
// }
// public dispose(): void {
// if (this.wrapperElement) {
// this.parentDomElement.removeChild(this.wrapperElement);
// this.wrapperElement = null;
// }
// if (this.xterm) {
// this.xterm.destroy();
// this.xterm = null;
// }
// if (this.terminalProcess) {
// this.terminalService.killTerminalProcess(this.terminalProcess);
// this.terminalProcess = null;
// }
// this.toDispose = lifecycle.dispose(this.toDispose);
// }
// }

View File

@@ -269,375 +269,3 @@ export class TerminalPanel extends Panel {
});
}
}
// import DOM = require('vs/base/browser/dom');
// import lifecycle = require('vs/base/common/lifecycle');
// import nls = require('vs/nls');
// import platform = require('vs/base/common/platform');
// import {Action, IAction} from 'vs/base/common/actions';
// import {Builder, Dimension} from 'vs/base/browser/builder';
// import {getBaseThemeId} from 'vs/platform/theme/common/themes';
// import {IActionItem} from 'vs/base/browser/ui/actionbar/actionbar';
// import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
// import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
// import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
// import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
// import {IContextKey} from 'vs/platform/contextkey/common/contextkey';
// import {IMessageService} from 'vs/platform/message/common/message';
// import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
// import {ITerminalFont, TerminalConfigHelper} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
// import {ITerminalPanel, ITerminalService, TERMINAL_PANEL_ID} from 'vs/workbench/parts/terminal/electron-browser/terminal';
// import {IThemeService} from 'vs/workbench/services/themes/common/themeService';
// import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
// import {KillTerminalAction, CreateNewTerminalAction, SwitchTerminalInstanceAction, SwitchTerminalInstanceActionItem, CopyTerminalSelectionAction, TerminalPasteAction} from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
// import {Panel} from 'vs/workbench/browser/panel';
// import {Separator} from 'vs/base/browser/ui/actionbar/actionbar';
// import {StandardMouseEvent} from 'vs/base/browser/mouseEvent';
// import {TerminalInstance} from 'vs/workbench/parts/terminal/electron-browser/terminalInstance';
// import {TPromise} from 'vs/base/common/winjs.base';
// export class TerminalPanel extends Panel implements ITerminalPanel {
// private toDispose: lifecycle.IDisposable[] = [];
// private terminalInstances: TerminalInstance[] = [];
// private actions: IAction[];
// private contextMenuActions: IAction[];
// private parentDomElement: HTMLElement;
// private terminalContainer: HTMLElement;
// private currentBaseThemeId: string;
// private themeStyleElement: HTMLElement;
// private fontStyleElement: HTMLElement;
// private font: ITerminalFont;
// private configurationHelper: TerminalConfigHelper;
// constructor(
// @ITelemetryService telemetryService: ITelemetryService,
// @IConfigurationService private configurationService: IConfigurationService,
// @IContextMenuService private contextMenuService: IContextMenuService,
// @IInstantiationService private instantiationService: IInstantiationService,
// @IKeybindingService private keybindingService: IKeybindingService,
// @IWorkspaceContextService private contextService: IWorkspaceContextService,
// @ITerminalService private terminalService: ITerminalService,
// @IThemeService private themeService: IThemeService,
// @IMessageService private messageService: IMessageService
// ) {
// super(TERMINAL_PANEL_ID, telemetryService);
// }
// public layout(dimension?: Dimension): void {
// if (!dimension) {
// return;
// }
// this.terminalInstances.forEach((t) => {
// t.layout(dimension);
// });
// }
// public getActions(): IAction[] {
// if (!this.actions) {
// this.actions = [
// this.instantiationService.createInstance(SwitchTerminalInstanceAction, SwitchTerminalInstanceAction.ID, SwitchTerminalInstanceAction.LABEL),
// this.instantiationService.createInstance(CreateNewTerminalAction, CreateNewTerminalAction.ID, CreateNewTerminalAction.PANEL_LABEL),
// this.instantiationService.createInstance(KillTerminalAction, KillTerminalAction.ID, KillTerminalAction.PANEL_LABEL)
// ];
// this.actions.forEach(a => {
// this.toDispose.push(a);
// });
// }
// return this.actions;
// }
// private getContextMenuActions(): IAction[] {
// if (!this.contextMenuActions) {
// this.contextMenuActions = [
// this.instantiationService.createInstance(CreateNewTerminalAction, CreateNewTerminalAction.ID, nls.localize('createNewTerminal', "New Terminal")),
// new Separator(),
// this.instantiationService.createInstance(CopyTerminalSelectionAction, CopyTerminalSelectionAction.ID, nls.localize('copy', "Copy")),
// this.instantiationService.createInstance(TerminalPasteAction, TerminalPasteAction.ID, nls.localize('paste', "Paste"))
// ];
// this.contextMenuActions.forEach(a => {
// this.toDispose.push(a);
// });
// }
// return this.contextMenuActions;
// }
// public getActionItem(action: Action): IActionItem {
// if (action.id === SwitchTerminalInstanceAction.ID) {
// return this.instantiationService.createInstance(SwitchTerminalInstanceActionItem, action);
// }
// return super.getActionItem(action);
// }
// public create(parent: Builder): TPromise<any> {
// super.create(parent);
// this.parentDomElement = parent.getHTMLElement();
// this.terminalService.initConfigHelper(parent);
// DOM.addClass(this.parentDomElement, 'integrated-terminal');
// this.themeStyleElement = document.createElement('style');
// this.fontStyleElement = document.createElement('style');
// this.terminalContainer = document.createElement('div');
// DOM.addClass(this.terminalContainer, 'terminal-outer-container');
// this.parentDomElement.appendChild(this.themeStyleElement);
// this.parentDomElement.appendChild(this.fontStyleElement);
// this.parentDomElement.appendChild(this.terminalContainer);
// this.attachEventListeners();
// this.configurationHelper = new TerminalConfigHelper(platform.platform, this.configurationService, parent);
// return TPromise.as(void 0);
// }
// private attachEventListeners(): void {
// this.toDispose.push(DOM.addDisposableListener(this.parentDomElement, 'mousedown', (event: MouseEvent) => {
// if (this.terminalInstances.length === 0) {
// return;
// }
// if (event.which === 2 && platform.isLinux) {
// // Drop selection and focus terminal on Linux to enable middle button paste when click
// // occurs on the selection itself.
// this.terminalInstances[this.terminalService.getActiveTerminalIndex()].focus(true);
// } else if (event.which === 3) {
// // Trigger the context menu on right click
// let anchor: HTMLElement | { x: number, y: number } = this.parentDomElement;
// if (event instanceof MouseEvent) {
// const standardEvent = new StandardMouseEvent(event);
// anchor = { x: standardEvent.posx, y: standardEvent.posy };
// }
// this.contextMenuService.showContextMenu({
// getAnchor: () => anchor,
// getActions: () => TPromise.as(this.getContextMenuActions()),
// getActionsContext: () => this.parentDomElement,
// getKeyBinding: (action) => {
// const opts = this.keybindingService.lookupKeybindings(action.id);
// if (opts.length > 0) {
// return opts[0]; // only take the first one
// }
// return null;
// }
// });
// }
// }));
// this.toDispose.push(DOM.addDisposableListener(this.parentDomElement, 'mouseup', (event) => {
// if (this.terminalInstances.length === 0) {
// return;
// }
// if (event.which !== 3) {
// this.terminalInstances[this.terminalService.getActiveTerminalIndex()].focus();
// }
// }));
// this.toDispose.push(DOM.addDisposableListener(this.parentDomElement, 'keyup', (event: KeyboardEvent) => {
// if (event.keyCode === 27) {
// // Keep terminal open on escape
// event.stopPropagation();
// }
// }));
// }
// public createNewTerminalInstance(process: ITerminalProcess, focusContextKey: IContextKey<boolean>): TPromise<number> {
// return this.createTerminal(process, focusContextKey).then((terminalInstance) => {
// this.updateConfig();
// this.focus();
// return TPromise.as(terminalInstance.id);
// });
// }
// public closeActiveTerminal(): TPromise<void> {
// return this.closeTerminal(this.terminalService.getActiveTerminalIndex());
// }
// public closeTerminal(index: number): TPromise<void> {
// this.onTerminalInstanceExit(this.terminalInstances[index]);
// return TPromise.as(void 0);
// }
// public closeTerminalById(terminalId: number): TPromise<void> {
// return this.closeTerminal(this.getTerminalIndexFromId(terminalId));
// }
// public setVisible(visible: boolean): TPromise<void> {
// if (visible) {
// if (this.terminalInstances.length > 0) {
// this.updateConfig();
// this.updateTheme();
// } else {
// return super.setVisible(visible).then(() => {
// this.terminalService.createNew();
// });
// }
// }
// return super.setVisible(visible);
// }
// public sendTextToActiveTerminal(text: string, addNewLine: boolean): void {
// let terminalInstance = this.terminalInstances[this.terminalService.getActiveTerminalIndex()];
// terminalInstance.sendText(text, addNewLine);
// }
// private createTerminal(terminalProcess: ITerminalProcess, terminalFocusContextKey: IContextKey<boolean>): TPromise<TerminalInstance> {
// return new TPromise<TerminalInstance>(resolve => {
// var terminalInstance = new TerminalInstance(
// terminalProcess,
// this.terminalContainer,
// this.contextMenuService,
// this.contextService,
// this.instantiationService,
// this.keybindingService,
// this.terminalService,
// this.messageService,
// terminalFocusContextKey,
// this.onTerminalInstanceExit.bind(this));
// this.terminalInstances.push(terminalInstance);
// this.setActiveTerminal(this.terminalInstances.length - 1);
// this.toDispose.push(this.themeService.onDidColorThemeChange(this.updateTheme.bind(this)));
// this.toDispose.push(this.configurationService.onDidUpdateConfiguration(this.updateConfig.bind(this)));
// this.updateTheme();
// this.updateConfig();
// resolve(terminalInstance);
// });
// }
// public setActiveTerminal(newActiveIndex: number): void {
// this.terminalInstances.forEach((terminalInstance, i) => {
// terminalInstance.toggleVisibility(i === newActiveIndex);
// });
// }
// private getTerminalIndexFromId(terminalId: number): number {
// let terminalIndex = -1;
// this.terminalInstances.forEach((terminalInstance, i) => {
// if (terminalInstance.id === terminalId) {
// terminalIndex = i;
// }
// });
// if (terminalIndex === -1) {
// throw new Error(`Terminal with ID ${terminalId} does not exist (has it already been disposed?)`);
// }
// return terminalIndex;
// }
// private onTerminalInstanceExit(terminalInstance: TerminalInstance): void {
// let index = this.terminalInstances.indexOf(terminalInstance);
// if (index !== -1) {
// this.terminalInstances[index].dispose();
// this.terminalInstances.splice(index, 1);
// }
// if (this.terminalInstances.length > 0) {
// this.setActiveTerminal(this.terminalService.getActiveTerminalIndex());
// }
// if (this.terminalInstances.length === 0) {
// this.terminalService.hide();
// } else {
// this.terminalService.show(true);
// }
// }
// private updateTheme(themeId?: string): void {
// if (!themeId) {
// themeId = this.themeService.getColorTheme();
// }
// let baseThemeId = getBaseThemeId(themeId);
// if (baseThemeId === this.currentBaseThemeId) {
// return;
// }
// this.currentBaseThemeId = baseThemeId;
// let theme = this.configurationHelper.getTheme(baseThemeId);
// let css = '';
// theme.forEach((color: string, index: number) => {
// let rgba = this.convertHexCssColorToRgba(color, 0.996);
// css += `.monaco-workbench .panel.integrated-terminal .xterm .xterm-color-${index} { color: ${color}; }` +
// `.monaco-workbench .panel.integrated-terminal .xterm .xterm-color-${index}::selection { background-color: ${rgba}; }` +
// `.monaco-workbench .panel.integrated-terminal .xterm .xterm-bg-color-${index} { background-color: ${color}; }` +
// `.monaco-workbench .panel.integrated-terminal .xterm .xterm-bg-color-${index}::selection { color: ${color}; }`;
// });
// this.themeStyleElement.innerHTML = css;
// }
// public scrollDown(): void {
// this.terminalInstances[this.terminalService.getActiveTerminalIndex()].scrollDown();
// }
// public scrollUp(): void {
// this.terminalInstances[this.terminalService.getActiveTerminalIndex()].scrollUp();
// }
// /**
// * Converts a CSS hex color (#rrggbb) to a CSS rgba color (rgba(r, g, b, a)).
// */
// private convertHexCssColorToRgba(hex: string, alpha: number): string {
// let r = parseInt(hex.substr(1, 2), 16);
// let g = parseInt(hex.substr(3, 2), 16);
// let b = parseInt(hex.substr(5, 2), 16);
// return `rgba(${r}, ${g}, ${b}, ${alpha})`;
// }
// private updateConfig(): void {
// this.updateFont();
// this.updateCursorBlink();
// this.updateCommandsToSkipShell();
// }
// private updateFont(): void {
// if (this.terminalInstances.length === 0) {
// return;
// }
// let newFont = this.configurationHelper.getFont();
// DOM.toggleClass(this.parentDomElement, 'enable-ligatures', this.configurationHelper.getFontLigaturesEnabled());
// if (!this.font || this.fontsDiffer(this.font, newFont)) {
// this.fontStyleElement.innerHTML = '.monaco-workbench .panel.integrated-terminal .xterm {' +
// `font-family: ${newFont.fontFamily};` +
// `font-size: ${newFont.fontSize};` +
// `line-height: ${newFont.lineHeight};` +
// '}';
// this.font = newFont;
// }
// this.terminalInstances[this.terminalService.getActiveTerminalIndex()].setFont(newFont);
// this.layout(new Dimension(this.parentDomElement.offsetWidth, this.parentDomElement.offsetHeight));
// }
// private fontsDiffer(a: ITerminalFont, b: ITerminalFont): boolean {
// return a.charHeight !== b.charHeight ||
// a.charWidth !== b.charWidth ||
// a.fontFamily !== b.fontFamily ||
// a.fontSize !== b.fontSize ||
// a.lineHeight !== b.lineHeight;
// }
// private updateCursorBlink(): void {
// this.terminalInstances.forEach((instance) => {
// instance.setCursorBlink(this.configurationHelper.getCursorBlink());
// });
// }
// private updateCommandsToSkipShell(): void {
// this.terminalInstances.forEach((instance) => {
// instance.setCommandsToSkipShell(this.configurationHelper.getCommandsToSkipShell());
// });
// }
// public focus(): void {
// let activeIndex = this.terminalService.getActiveTerminalIndex();
// if (activeIndex !== -1 && this.terminalInstances.length > 0) {
// this.terminalInstances[activeIndex].focus(true);
// }
// }
// public dispose(): void {
// this.toDispose = lifecycle.dispose(this.toDispose);
// while (this.terminalInstances.length > 0) {
// this.terminalInstances.pop().dispose();
// }
// super.dispose();
// }
// }

View File

@@ -188,367 +188,3 @@ export class TerminalService implements ITerminalService {
return terminalIndex;
}
}
// import URI from 'vs/base/common/uri';
// import Event, {Emitter} from 'vs/base/common/event';
// import cp = require('child_process');
// import nls = require('vs/nls');
// import os = require('os');
// import path = require('path');
// import platform = require('vs/base/common/platform');
// import {Builder} from 'vs/base/browser/builder';
// import {EndOfLinePreference} from 'vs/editor/common/editorCommon';
// import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
// import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
// import {IContextKey, IContextKeyService} from 'vs/platform/contextkey/common/contextkey';
// import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
// import {IMessageService, Severity} from 'vs/platform/message/common/message';
// import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
// import {IPartService} from 'vs/workbench/services/part/common/partService';
// import {IStringDictionary} from 'vs/base/common/collections';
// import {ITerminalInstance, ITerminalPanel, ITerminalService, KEYBINDING_CONTEXT_TERMINAL_FOCUS, TERMINAL_PANEL_ID} from 'vs/workbench/parts/terminal/electron-browser/terminal';
// import {TerminalInstance} from 'vs/workbench/parts/terminal/electron-browser/terminalInstance';
// import {IWorkspaceContextService, IWorkspace} from 'vs/platform/workspace/common/workspace';
// import {TPromise} from 'vs/base/common/winjs.base';
// import {TerminalConfigHelper, IShell} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
// import {TerminalPanel} from 'vs/workbench/parts/terminal/electron-browser/terminalPanel';
// export class TerminalService implements ITerminalService {
// public _serviceBrand: any;
// private activeTerminalIndex: number = 0;
// private terminalProcesses: ITerminalProcess[] = [];
// private nextTerminalName: string;
// protected _terminalFocusContextKey: IContextKey<boolean>;
// private configHelper: TerminalConfigHelper;
// private _onActiveInstanceChanged: Emitter<string>;
// private _onInstancesChanged: Emitter<string>;
// private _onInstanceTitleChanged: Emitter<string>;
// constructor(
// @ICodeEditorService private codeEditorService: ICodeEditorService,
// @IConfigurationService private configurationService: IConfigurationService,
// @IContextKeyService private contextKeyService: IContextKeyService,
// @IMessageService private messageService: IMessageService,
// @IPanelService private panelService: IPanelService,
// @IPartService private partService: IPartService,
// @IWorkspaceContextService private contextService: IWorkspaceContextService
// ) {
// this._onActiveInstanceChanged = new Emitter<string>();
// this._onInstancesChanged = new Emitter<string>();
// this._onInstanceTitleChanged = new Emitter<string>();
// this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this.contextKeyService);
// }
// public get onActiveInstanceChanged(): Event<string> {
// return this._onActiveInstanceChanged.event;
// }
// public get onInstancesChanged(): Event<string> {
// return this._onInstancesChanged.event;
// }
// public get onInstanceTitleChanged(): Event<string> {
// return this._onInstanceTitleChanged.event;
// }
// public setActiveTerminal(index: number): TPromise<any> {
// return this.show(false).then((terminalPanel) => {
// this.activeTerminalIndex = index;
// terminalPanel.setActiveTerminal(this.activeTerminalIndex);
// this._onActiveInstanceChanged.fire();
// });
// }
// public setActiveTerminalById(terminalId: number): void {
// this.setActiveTerminal(this.getTerminalIndexFromId(terminalId));
// }
// private getTerminalIndexFromId(terminalId: number): number {
// let terminalIndex = -1;
// this.terminalProcesses.forEach((terminalProcess, i) => {
// if (terminalProcess.process.pid === terminalId) {
// terminalIndex = i;
// }
// });
// if (terminalIndex === -1) {
// throw new Error(`Terminal with ID ${terminalId} does not exist (has it already been disposed?)`);
// }
// return terminalIndex;
// }
// public focusNext(): TPromise<any> {
// return this.focus().then((terminalPanel) => {
// if (this.terminalProcesses.length <= 1) {
// return;
// }
// this.activeTerminalIndex++;
// if (this.activeTerminalIndex >= this.terminalProcesses.length) {
// this.activeTerminalIndex = 0;
// }
// terminalPanel.setActiveTerminal(this.activeTerminalIndex);
// terminalPanel.focus();
// this._onActiveInstanceChanged.fire();
// });
// }
// public focusPrevious(): TPromise<any> {
// return this.focus().then((terminalPanel) => {
// if (this.terminalProcesses.length <= 1) {
// return;
// }
// this.activeTerminalIndex--;
// if (this.activeTerminalIndex < 0) {
// this.activeTerminalIndex = this.terminalProcesses.length - 1;
// }
// terminalPanel.setActiveTerminal(this.activeTerminalIndex);
// terminalPanel.focus();
// this._onActiveInstanceChanged.fire();
// });
// }
// public runSelectedText(): TPromise<any> {
// return this.focus().then((terminalPanel) => {
// let editor = this.codeEditorService.getFocusedCodeEditor();
// let selection = editor.getSelection();
// let text: string;
// if (selection.isEmpty()) {
// text = editor.getValue();
// } else {
// let endOfLinePreference = os.EOL === '\n' ? EndOfLinePreference.LF : EndOfLinePreference.CRLF;
// text = editor.getModel().getValueInRange(selection, endOfLinePreference);
// }
// terminalPanel.sendTextToActiveTerminal(text, true);
// });
// }
// public show(focus: boolean): TPromise<TerminalPanel> {
// return new TPromise<TerminalPanel>((complete) => {
// let panel = this.panelService.getActivePanel();
// if (!panel || panel.getId() !== TERMINAL_PANEL_ID) {
// return this.panelService.openPanel(TERMINAL_PANEL_ID, focus).then(() => {
// panel = this.panelService.getActivePanel();
// complete(<TerminalPanel>panel);
// });
// } else {
// if (focus) {
// panel.focus();
// }
// complete(<TerminalPanel>panel);
// }
// });
// }
// public focus(): TPromise<TerminalPanel> {
// return this.show(true);
// }
// public hide(): TPromise<any> {
// const panel = this.panelService.getActivePanel();
// if (panel && panel.getId() === TERMINAL_PANEL_ID) {
// this.partService.setPanelHidden(true);
// }
// return TPromise.as(void 0);
// }
// public hideTerminalInstance(terminalId: number): TPromise<any> {
// const panel = this.panelService.getActivePanel();
// if (panel && panel.getId() === TERMINAL_PANEL_ID) {
// if (this.terminalProcesses[this.getActiveTerminalIndex()].process.pid === terminalId) {
// this.partService.setPanelHidden(true);
// }
// }
// return TPromise.as(void 0);
// }
// public toggle(): TPromise<any> {
// const panel = this.panelService.getActivePanel();
// if (panel && panel.getId() === TERMINAL_PANEL_ID) {
// this.partService.setPanelHidden(true);
// return TPromise.as(null);
// }
// return this.focus();
// }
// public createNew(name?: string): TPromise<number> {
// let processCount = this.terminalProcesses.length;
// // When there are 0 processes it means that the panel is not yet created, so the name needs
// // to be stored for when createNew is called from TerminalPanel.create. This has to work
// // like this as TerminalPanel.setVisible must create a terminal if there is none due to how
// // the TerminalPanel is restored on launch if it was open previously.
// if (processCount === 0 && !name) {
// name = this.nextTerminalName;
// this.nextTerminalName = undefined;
// } else {
// this.nextTerminalName = name;
// }
// return this.focus().then((terminalPanel) => {
// // If the terminal panel has not been initialized yet skip this, the terminal will be
// // created via a call from TerminalPanel.setVisible
// if (terminalPanel === null) {
// return;
// }
// // Only create a new process if none have been created since toggling the terminal
// // panel. This happens when createNew is called when the panel is either empty or no yet
// // created.
// if (processCount !== this.terminalProcesses.length) {
// return TPromise.as(this.terminalProcesses[this.terminalProcesses.length - 1].process.pid);
// }
// this.initConfigHelper(terminalPanel.getContainer());
// return terminalPanel.createNewTerminalInstance(this.createTerminalProcess(name), this._terminalFocusContextKey).then((terminalId) => {
// this._onInstancesChanged.fire();
// return TPromise.as(terminalId);
// });
// });
// }
// public close(): TPromise<any> {
// return this.focus().then((terminalPanel) => {
// return terminalPanel.closeActiveTerminal();
// });
// }
// public closeById(terminalId: number): TPromise<any> {
// return this.show(false).then((terminalPanel) => {
// return terminalPanel.closeTerminalById(terminalId);
// });
// }
// public copySelection(): TPromise<any> {
// if (document.activeElement.classList.contains('xterm')) {
// document.execCommand('copy');
// } else {
// this.messageService.show(Severity.Warning, nls.localize('terminal.integrated.copySelection.noSelection', 'Cannot copy terminal selection when terminal does not have focus'));
// }
// return TPromise.as(void 0);
// }
// public paste(): TPromise<any> {
// return this.focus().then(() => {
// document.execCommand('paste');
// });
// }
// public scrollDown(): TPromise<any> {
// return this.focus().then((terminalPanel) => {
// terminalPanel.scrollDown();
// });
// }
// public scrollUp(): TPromise<any> {
// return this.focus().then((terminalPanel) => {
// terminalPanel.scrollUp();
// });
// }
// public getActiveTerminalIndex(): number {
// return this.activeTerminalIndex;
// }
// public getTerminalInstanceTitles(): string[] {
// return this.terminalProcesses.map((process, index) => `${index + 1}: ${process.title}`);
// }
// public initConfigHelper(panelElement: Builder): void {
// if (!this.configHelper) {
// this.configHelper = new TerminalConfigHelper(platform.platform, this.configurationService, panelElement);
// }
// }
// public killTerminalProcess(terminalProcess: ITerminalProcess): void {
// if (terminalProcess.process.connected) {
// terminalProcess.process.disconnect();
// terminalProcess.process.kill();
// }
// let index = this.terminalProcesses.indexOf(terminalProcess);
// if (index >= 0) {
// let wasActiveTerminal = (index === this.getActiveTerminalIndex());
// // Push active index back if the closed process was before the active process
// if (this.getActiveTerminalIndex() >= index) {
// this.activeTerminalIndex = Math.max(0, this.activeTerminalIndex - 1);
// }
// this.terminalProcesses.splice(index, 1);
// this._onInstancesChanged.fire();
// if (wasActiveTerminal) {
// this._onActiveInstanceChanged.fire();
// }
// }
// }
// private createTerminalProcess(name?: string): ITerminalProcess {
// let locale = this.configHelper.isSetLocaleVariables() ? platform.locale : undefined;
// let env = TerminalService.createTerminalEnv(process.env, this.configHelper.getShell(), this.contextService.getWorkspace(), locale);
// let terminalProcess = {
// title: name ? name : '',
// process: cp.fork('./terminalProcess', [], {
// env: env,
// cwd: URI.parse(path.dirname(require.toUrl('./terminalProcess'))).fsPath
// })
// };
// this.terminalProcesses.push(terminalProcess);
// this._onInstancesChanged.fire();
// this.activeTerminalIndex = this.terminalProcesses.length - 1;
// this._onActiveInstanceChanged.fire();
// if (!name) {
// // Only listen for process title changes when a name is not provided
// terminalProcess.process.on('message', (message) => {
// if (message.type === 'title') {
// terminalProcess.title = message.content ? message.content : '';
// this._onInstanceTitleChanged.fire();
// }
// });
// }
// return terminalProcess;
// }
// public static createTerminalEnv(parentEnv: IStringDictionary<string>, shell: IShell, workspace: IWorkspace, locale?: string): IStringDictionary<string> {
// let env = this.cloneEnv(parentEnv);
// env['PTYPID'] = process.pid.toString();
// env['PTYSHELL'] = shell.executable;
// shell.args.forEach((arg, i) => {
// env[`PTYSHELLARG${i}`] = arg;
// });
// env['PTYCWD'] = this.sanitizeCwd(workspace ? workspace.resource.fsPath : os.homedir());
// if (locale) {
// env['LANG'] = this.getLangEnvVariable(locale);
// }
// return env;
// }
// private static sanitizeCwd(cwd: string) {
// // Make the drive letter uppercase on Windows (see #9448)
// if (platform.platform === platform.Platform.Windows && cwd && cwd[1] === ':') {
// return cwd[0].toUpperCase() + cwd.substr(1);
// }
// return cwd;
// }
// private static cloneEnv(env: IStringDictionary<string>): IStringDictionary<string> {
// let newEnv: IStringDictionary<string> = Object.create(null);
// Object.keys(env).forEach((key) => {
// newEnv[key] = env[key];
// });
// return newEnv;
// }
// private static getLangEnvVariable(locale: string) {
// const parts = locale.split('-');
// const n = parts.length;
// if (n > 1) {
// parts[n - 1] = parts[n - 1].toUpperCase();
// }
// return parts.join('_') + '.UTF-8';
// }
// }
// export interface ITerminalProcessConfiguration {
// name: string;
// shell: IShell;
// }