1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-25 19:42:42 +03:00
This commit is contained in:
Eugene Pankov 2019-01-16 17:13:34 +00:00
parent 38cfb3f036
commit 78f8f4005e
6 changed files with 24 additions and 14 deletions

View File

@ -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'
}

View File

@ -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) {

View File

@ -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<void>()
protected title = new ReplaySubject<string>(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
}

View File

@ -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')

View File

@ -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,
}

View File

@ -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<BaseSession, Frontend>()
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(