diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index d9aa965ba41427dd32dbd50b30dba035a7a6256b..c11a0b3e666d4b21353e01ab4d2f3374165ba8f8 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts @@ -12,7 +12,7 @@ import {Builder, Dimension} from 'vs/base/browser/builder'; import {TPromise} from 'vs/base/common/winjs.base'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; import {RawContextKey, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; -import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; +import {TerminalConfigHelper, ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; export const TERMINAL_PANEL_ID = 'workbench.panel.terminal'; @@ -100,6 +100,7 @@ export interface ITerminalService { onInstanceTitleChanged: Event; activeTerminalInstanceIndex: number; + configHelper: TerminalConfigHelper; terminalInstances: ITerminalInstance[]; createInstance(name?: string): ITerminalInstance; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index 6e1bfc9e5d865e7f89dcd7a39160bd42a5f15c89..c1c43b7ab42b32c9e8ff3c29d10c04337217c941 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -10,6 +10,7 @@ import nls = require('vs/nls'); import {Action, IAction} from 'vs/base/common/actions'; import {Builder, Dimension} from 'vs/base/browser/builder'; 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'; @@ -20,7 +21,7 @@ import {KillTerminalAction, CreateNewTerminalAction, SwitchTerminalInstanceActio import {Panel} from 'vs/workbench/browser/panel'; import {Separator} from 'vs/base/browser/ui/actionbar/actionbar'; import {StandardMouseEvent} from 'vs/base/browser/mouseEvent'; -import {TerminalConfigHelper, ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; +import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; import {TPromise} from 'vs/base/common/winjs.base'; import {getBaseThemeId} from 'vs/platform/theme/common/themes'; @@ -38,7 +39,7 @@ export class TerminalPanel extends Panel implements ITerminalPanel { private font: ITerminalFont; constructor( - private configHelper: TerminalConfigHelper, + @IConfigurationService private configurationService: IConfigurationService, @IContextMenuService private contextMenuService: IContextMenuService, @IInstantiationService private instantiationService: IInstantiationService, @IKeybindingService private keybindingService: IKeybindingService, @@ -65,6 +66,12 @@ export class TerminalPanel extends Panel implements ITerminalPanel { this.attachEventListeners(); this.terminalService.setContainers(this.getContainer(), this.terminalContainer); + + this.toDispose.push(this.themeService.onDidColorThemeChange(this.updateTheme.bind(this))); + this.toDispose.push(this.configurationService.onDidUpdateConfiguration(this.updateConfig.bind(this))); + this.updateTheme(); + this.updateConfig(); + return TPromise.as(void 0); } @@ -188,7 +195,7 @@ export class TerminalPanel extends Panel implements ITerminalPanel { } this.currentBaseThemeId = baseThemeId; - let theme = this.configHelper.getTheme(baseThemeId); + let theme = this.terminalService.configHelper.getTheme(baseThemeId); let css = ''; theme.forEach((color: string, index: number) => { @@ -222,8 +229,8 @@ export class TerminalPanel extends Panel implements ITerminalPanel { if (this.terminalService.terminalInstances.length === 0) { return; } - let newFont = this.configHelper.getFont(); - DOM.toggleClass(this.parentDomElement, 'enable-ligatures', this.configHelper.getFontLigaturesEnabled()); + let newFont = this.terminalService.configHelper.getFont(); + DOM.toggleClass(this.parentDomElement, 'enable-ligatures', this.terminalService.configHelper.getFontLigaturesEnabled()); if (!this.font || this.fontsDiffer(this.font, newFont)) { this.fontStyleElement.innerHTML = '.monaco-workbench .panel.integrated-terminal .xterm {' + `font-family: ${newFont.fontFamily};` + @@ -246,13 +253,13 @@ export class TerminalPanel extends Panel implements ITerminalPanel { private updateCursorBlink(): void { this.terminalService.terminalInstances.forEach((instance) => { - instance.setCursorBlink(this.configHelper.getCursorBlink()); + instance.setCursorBlink(this.terminalService.configHelper.getCursorBlink()); }); } private updateCommandsToSkipShell(): void { this.terminalService.terminalInstances.forEach((instance) => { - instance.setCommandsToSkipShell(this.configHelper.getCommandsToSkipShell()); + instance.setCommandsToSkipShell(this.terminalService.configHelper.getCommandsToSkipShell()); }); } } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts index 2d90f713be244e2e5fc99298403f42ffc9b4cfa6..838368f12686c0d0cfeb3a276df8dae05af6556a 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts @@ -20,8 +20,10 @@ export class TerminalService implements ITerminalService { public _serviceBrand: any; private _activeTerminalInstanceIndex: number = 0; + private _configHelper: TerminalConfigHelper; private _terminalInstances: ITerminalInstance[] = []; public get activeTerminalInstanceIndex(): number { return this._activeTerminalInstanceIndex; } + public get configHelper(): TerminalConfigHelper { return this._configHelper; } public get terminalInstances(): ITerminalInstance[] { return this._terminalInstances; } private _onActiveInstanceChanged: Emitter; @@ -32,7 +34,6 @@ export class TerminalService implements ITerminalService { public get onInstanceTitleChanged(): Event { return this._onInstanceTitleChanged.event; } private terminalContainer: HTMLElement; - private configHelper: TerminalConfigHelper; private terminalFocusContextKey: IContextKey; constructor( @@ -46,15 +47,17 @@ export class TerminalService implements ITerminalService { this._onInstancesChanged = new Emitter(); this._onInstanceTitleChanged = new Emitter(); this.terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this.contextKeyService); - this.configHelper = this.instantiationService.createInstance(TerminalConfigHelper, platform.platform); + this._configHelper = this.instantiationService.createInstance(TerminalConfigHelper, platform.platform); } public createInstance(): ITerminalInstance { - console.log('creating instance'); - console.log('config helper', this.configHelper); let terminalInstance = this.instantiationService.createInstance(TerminalInstance, - this.terminalFocusContextKey, this.onTerminalInstanceDispose.bind(this), this.configHelper, this.terminalContainer); + this.terminalFocusContextKey, this.onTerminalInstanceDispose.bind(this), this._configHelper, this.terminalContainer); this.terminalInstances.push(terminalInstance); + if (this.terminalInstances.length === 1) { + // It's the first instance so it should be focused + this.setActiveInstanceByIndex(0); + } this._onInstancesChanged.fire(); return terminalInstance; } @@ -116,7 +119,7 @@ export class TerminalService implements ITerminalService { this._terminalInstances.forEach(terminalInstance => { terminalInstance.attachToElement(this.terminalContainer); }); - this.configHelper.panelContainer = panelContainer; + this._configHelper.panelContainer = panelContainer; } public showPanel(focus?: boolean): TPromise {