提交 83270589 编写于 作者: D Daniel Imms

Get xterm.js initializing

上级 f95f8c66
......@@ -93,7 +93,7 @@ export class TerminalConfigHelper {
public constructor(
private platform: Platform,
private configurationService: IConfigurationService) {
@IConfigurationService private configurationService: IConfigurationService) {
}
public getTheme(baseThemeId: string): string[] {
......
......@@ -45,14 +45,15 @@ export class TerminalInstance implements ITerminalInstance {
private onExitCallback: (TerminalInstance) => void,
private configHelper: TerminalConfigHelper,
private container: HTMLElement,
private contextService: IWorkspaceContextService,
private messageService: IMessageService,
private terminalService: ITerminalService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IMessageService private messageService: IMessageService,
@ITerminalService private terminalService: ITerminalService
) {
this._id = TerminalInstance.ID_COUNTER++;
this.createProcess();
if (container) {
console.log('attach to element', container);
this.attachToElement(container);
}
}
......@@ -66,11 +67,36 @@ export class TerminalInstance implements ITerminalInstance {
DOM.addClass(this.wrapperElement, 'terminal-wrapper');
this.terminalDomElement = document.createElement('div');
this.xterm = xterm();
this.xterm.open(this.terminalDomElement);
this.wrapperElement = document.createElement('div');
DOM.addClass(this.wrapperElement, 'terminal-wrapper');
this.terminalDomElement = document.createElement('div');
this.process.on('message', (message) => {
if (message.type === 'data') {
this.xterm.write(message.content);
}
});
this.xterm.on('data', (data) => {
this.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;
}
});
let xtermHelper: HTMLElement = this.xterm.element.querySelector('.xterm-helpers');
let focusTrap: HTMLElement = document.createElement('div');
focusTrap.setAttribute('tabindex', '0');
......@@ -137,12 +163,6 @@ export class TerminalInstance implements ITerminalInstance {
}
});
}
this.xterm = xterm();
this.process.on('message', (message) => {
if (message.type === 'data') {
this.xterm.write(message.content);
}
});
this.process.on('exit', (exitCode) => {
// Prevent dispose functions being triggered multiple times
if (!this.isExiting) {
......@@ -154,27 +174,6 @@ export class TerminalInstance implements ITerminalInstance {
this.onExitCallback(this);
}
});
this.xterm.on('data', (data) => {
this.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;
}
});
}
public createTerminalEnv(parentEnv: IStringDictionary<string>, shell: IShell, workspace: IWorkspace, locale?: string): IStringDictionary<string> {
......
......@@ -3,15 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import DOM = require('vs/base/browser/dom');
import lifecycle = require('vs/base/common/lifecycle');
import {Action, IAction} from 'vs/base/common/actions';
import {Dimension} from 'vs/base/browser/builder';
import {Builder, Dimension} from 'vs/base/browser/builder';
import {IActionItem} from 'vs/base/browser/ui/actionbar/actionbar';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {ITerminalPanel, TERMINAL_PANEL_ID} from 'vs/workbench/parts/terminal/electron-browser/terminal';
import {ITerminalPanel, ITerminalService, TERMINAL_PANEL_ID} from 'vs/workbench/parts/terminal/electron-browser/terminal';
import {KillTerminalAction, CreateNewTerminalAction, SwitchTerminalInstanceAction, SwitchTerminalInstanceActionItem} from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
import {Panel} from 'vs/workbench/browser/panel';
import {TPromise} from 'vs/base/common/winjs.base';
export class TerminalPanel extends Panel implements ITerminalPanel {
......@@ -19,14 +21,41 @@ export class TerminalPanel extends Panel implements ITerminalPanel {
private actions: IAction[];
//private contextMenuActions: IAction[];
private parentDomElement: HTMLElement;
private terminalContainer: HTMLElement;
//private currentBaseThemeId: string;
//private themeStyleElement: HTMLElement;
//private fontStyleElement: HTMLElement;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@ITerminalService private terminalService: ITerminalService,
@IInstantiationService private instantiationService: IInstantiationService
) {
super(TERMINAL_PANEL_ID, telemetryService);
}
public create(parent: Builder): TPromise<any> {
super.create(parent);
this.parentDomElement = parent.getHTMLElement();
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);
this.terminalService.setContainers(this.getContainer(), this.terminalContainer);
return TPromise.as(void 0);
}
public layout(dimension?: Dimension): void {
if (!dimension) {
return;
......
......@@ -50,6 +50,8 @@ export class TerminalService implements ITerminalService {
}
public createInstance(): ITerminalInstance {
console.log('creating instance');
console.log('config helper', this.configHelper);
let terminalInstance = <TerminalInstance>this.instantiationService.createInstance(TerminalInstance,
this.terminalFocusContextKey, this.onTerminalInstanceDispose.bind(this), this.configHelper, this.terminalContainer);
this.terminalInstances.push(terminalInstance);
......@@ -105,6 +107,7 @@ export class TerminalService implements ITerminalService {
}
public setContainers(panelContainer: Builder, terminalContainer: HTMLElement): void {
console.log('set containers');
this.terminalContainer = terminalContainer;
this._terminalInstances.forEach(terminalInstance => {
terminalInstance.attachToElement(this.terminalContainer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册