From 78f8f4005e6c754e7abae65a601e8d236313d4e5 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 16 Jan 2019 17:13:34 +0000 Subject: [PATCH] fixed #610 --- terminus-core/src/theme.ts | 6 +++--- .../src/components/baseTerminalTab.component.ts | 4 ++-- terminus-terminal/src/frontends/frontend.ts | 6 +++++- terminus-terminal/src/frontends/htermFrontend.ts | 7 ++++--- terminus-terminal/src/frontends/xtermFrontend.ts | 6 ++++-- .../src/services/terminalFrontend.service.ts | 9 ++++++--- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/terminus-core/src/theme.ts b/terminus-core/src/theme.ts index 327051d6..52145010 100644 --- a/terminus-core/src/theme.ts +++ b/terminus-core/src/theme.ts @@ -5,19 +5,19 @@ import { Theme } from './api' export class StandardTheme extends Theme { name = 'Standard' css = require('./theme.scss') - terminalBackground = '#1D272D' + terminalBackground = '#222a33' } @Injectable() export class StandardCompactTheme extends Theme { name = 'Compact' css = require('./theme.compact.scss') - terminalBackground = '#1D272D' + terminalBackground = '#222a33' } @Injectable() export class PaperTheme extends Theme { name = 'Paper' css = require('./theme.paper.scss') - terminalBackground = '#1D272D' + terminalBackground = '#f7f1e0' } diff --git a/terminus-terminal/src/components/baseTerminalTab.component.ts b/terminus-terminal/src/components/baseTerminalTab.component.ts index 62dcce2d..98e9cdbd 100644 --- a/terminus-terminal/src/components/baseTerminalTab.component.ts +++ b/terminus-terminal/src/components/baseTerminalTab.component.ts @@ -144,7 +144,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit this.session.releaseInitialDataBuffer() }) - this.frontend.configure(this.config.store) + this.frontend.configure() this.frontend.attach(this.content.nativeElement) this.attachTermContainerHandlers() @@ -294,7 +294,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit } configure (): void { - this.frontend.configure(this.config.store) + this.frontend.configure() if (this.config.store.terminal.background === 'colorScheme') { if (this.config.store.terminal.colorScheme.background) { diff --git a/terminus-terminal/src/frontends/frontend.ts b/terminus-terminal/src/frontends/frontend.ts index 4e0550c5..fae63875 100644 --- a/terminus-terminal/src/frontends/frontend.ts +++ b/terminus-terminal/src/frontends/frontend.ts @@ -1,7 +1,11 @@ import { Observable, Subject, AsyncSubject, ReplaySubject, BehaviorSubject } from 'rxjs' import { ResizeEvent } from '../api' +import { ConfigService, ThemesService } from 'terminus-core' export abstract class Frontend { + configService: ConfigService + themesService: ThemesService + enableResizing = true protected ready = new AsyncSubject() protected title = new ReplaySubject(1) @@ -54,6 +58,6 @@ export abstract class Frontend { abstract visualBell (): void abstract scrollToBottom (): void - abstract configure (configStore: any): void + abstract configure (): void abstract setZoom (zoom: number): void } diff --git a/terminus-terminal/src/frontends/htermFrontend.ts b/terminus-terminal/src/frontends/htermFrontend.ts index a6ae60bc..f7503cc3 100644 --- a/terminus-terminal/src/frontends/htermFrontend.ts +++ b/terminus-terminal/src/frontends/htermFrontend.ts @@ -51,7 +51,9 @@ export class HTermFrontend extends Frontend { this.term.onVTKeystroke('\f') } - configure (config: any): void { + configure (): void { + let config = this.configService.store + this.configuredFontSize = config.terminal.fontSize this.configuredLinePadding = config.terminal.linePadding this.setFontSize() @@ -85,8 +87,7 @@ export class HTermFrontend extends Frontend { preferenceManager.set('background-color', config.terminal.colorScheme.background) } } else { - // hterm can't parse "transparent" - preferenceManager.set('background-color', 'transparent') + preferenceManager.set('background-color', config.appearance.vibrancy ? 'transparent' : this.themesService.findCurrentTheme().terminalBackground) } this.configuredBackgroundColor = preferenceManager.get('background-color') diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index b8faa1d8..96f7d256 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -110,7 +110,9 @@ export class XTermFrontend extends Frontend { this.xtermCore._scrollToBottom() } - configure (config: any): void { + configure (): void { + let config = this.configService.store + setTimeout(() => { if (this.xterm.cols && this.xterm.rows) { this.resizeHandler() @@ -131,7 +133,7 @@ export class XTermFrontend extends Frontend { let theme: ITheme = { foreground: config.terminal.colorScheme.foreground, - background: (config.terminal.background === 'colorScheme') ? config.terminal.colorScheme.background : 'transparent', + background: (config.terminal.background === 'colorScheme') ? config.terminal.colorScheme.background : (config.appearance.vibrancy ? 'transparent' : this.themesService.findCurrentTheme().terminalBackground), cursor: config.terminal.colorScheme.cursor, } diff --git a/terminus-terminal/src/services/terminalFrontend.service.ts b/terminus-terminal/src/services/terminalFrontend.service.ts index b02b778e..4189a15e 100644 --- a/terminus-terminal/src/services/terminalFrontend.service.ts +++ b/terminus-terminal/src/services/terminalFrontend.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core' -import { ConfigService } from 'terminus-core' +import { ConfigService, ThemesService } from 'terminus-core' import { Frontend } from '../frontends/frontend' import { HTermFrontend } from '../frontends/htermFrontend' import { XTermFrontend } from '../frontends/xtermFrontend' @@ -9,13 +9,16 @@ import { BaseSession } from '../services/sessions.service' export class TerminalFrontendService { private containers = new WeakMap() - constructor (private config: ConfigService) { } + constructor (private config: ConfigService, private themes: ThemesService) { } getFrontend (session?: BaseSession): Frontend { if (!session) { - return (this.config.store.terminal.frontend === 'xterm') + let frontend: Frontend = (this.config.store.terminal.frontend === 'xterm') ? new XTermFrontend() : new HTermFrontend() + frontend.configService = this.config + frontend.themesService = this.themes + return frontend } if (!this.containers.has(session)) { this.containers.set(