diff --git a/.all-contributorsrc b/.all-contributorsrc index e6040402..021fcdad 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1310,6 +1310,15 @@ "contributions": [ "code" ] + }, + { + "login": "fireblue", + "name": "fireblue", + "avatar_url": "https://avatars.githubusercontent.com/u/1034929?v=4", + "profile": "https://github.com/fireblue", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.de-DE.md b/README.de-DE.md index 13175c0b..cb222f0a 100644 --- a/README.de-DE.md +++ b/README.de-DE.md @@ -340,6 +340,7 @@ Dank geht an diese wunderbaren Menschen ([emoji key](https://allcontributors.org
extends Bas configure (): void { this.frontend?.configure(this.profile) - if (!this.themes.findCurrentTheme().followsColorScheme && this.config.store.terminal.background === 'colorScheme') { - const scheme = this.profile.terminalColorScheme ?? this.config.store.terminal.colorScheme - if (scheme.background) { - this.backgroundColor = scheme.background - } - } else { - this.backgroundColor = null - } + this.backgroundColor = getTerminalBackgroundColor(this.config, this.themes, this.profile.terminalColorScheme) } zoomIn (): void { diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts index 26961e77..534e3bb7 100644 --- a/tabby-terminal/src/frontends/xtermFrontend.ts +++ b/tabby-terminal/src/frontends/xtermFrontend.ts @@ -1,3 +1,4 @@ +import deepEqual from 'deep-equal' import { BehaviorSubject, filter, firstValueFrom, takeUntil } from 'rxjs' import { Injector } from '@angular/core' import { ConfigService, getCSSFontFamily, getWindows10Build, HostAppService, HotkeysService, Platform, PlatformService, ThemesService } from 'tabby-core' @@ -11,9 +12,9 @@ import { Unicode11Addon } from '@xterm/addon-unicode11' import { SerializeAddon } from '@xterm/addon-serialize' import { ImageAddon } from '@xterm/addon-image' import { CanvasAddon } from '@xterm/addon-canvas' -import './xterm.css' -import deepEqual from 'deep-equal' import { BaseTerminalProfile, TerminalColorScheme } from '../api/interfaces' +import { getTerminalBackgroundColor } from '../helpers' +import './xterm.css' const COLOR_NAMES = [ 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', @@ -361,21 +362,21 @@ export class XTermFrontend extends Frontend { } private configureColors (scheme: TerminalColorScheme|undefined): void { - const config = this.configService.store + const appColorScheme = this.themes._getActiveColorScheme() as TerminalColorScheme - scheme = scheme ?? this.themes._getActiveColorScheme() + scheme = scheme ?? appColorScheme const theme: ITheme = { - foreground: scheme!.foreground, - selectionBackground: scheme!.selection ?? '#88888888', - selectionForeground: scheme!.selectionForeground ?? undefined, - background: !this.themes.findCurrentTheme().followsColorScheme && config.terminal.background === 'colorScheme' ? scheme!.background : '#00000000', - cursor: scheme!.cursor, - cursorAccent: scheme!.cursorAccent, + foreground: scheme.foreground, + selectionBackground: scheme.selection ?? '#88888888', + selectionForeground: scheme.selectionForeground ?? undefined, + background: getTerminalBackgroundColor(this.configService, this.themes, scheme) ?? '#00000000', + cursor: scheme.cursor, + cursorAccent: scheme.cursorAccent, } for (let i = 0; i < COLOR_NAMES.length; i++) { - theme[COLOR_NAMES[i]] = scheme!.colors[i] + theme[COLOR_NAMES[i]] = scheme.colors[i] } if (!deepEqual(this.configuredTheme, theme)) { diff --git a/tabby-terminal/src/helpers.ts b/tabby-terminal/src/helpers.ts new file mode 100644 index 00000000..fcee6a7c --- /dev/null +++ b/tabby-terminal/src/helpers.ts @@ -0,0 +1,21 @@ +import { TerminalColorScheme } from './api/interfaces' +import { ConfigService, ThemesService } from 'tabby-core' + +export function getTerminalBackgroundColor ( + config: ConfigService, + themes: ThemesService, + scheme?: TerminalColorScheme, +): string|null { + const appTheme = themes.findCurrentTheme() + const appColorScheme = themes._getActiveColorScheme() as TerminalColorScheme + + // Use non transparent background when: + // - legacy theme and user choses colorScheme based BG + // - or new theme but profile-specific scheme is used + const shouldUseCSBackground = + !appTheme.followsColorScheme && config.store.terminal.background === 'colorScheme' + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + || appTheme.followsColorScheme && scheme?.name !== appColorScheme.name + + return shouldUseCSBackground && scheme ? scheme.background : null +} diff --git a/yarn.lock b/yarn.lock index eaaf5a7b..9e3ec19f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5603,10 +5603,10 @@ lzma-native@^8.0.5, lzma-native@^8.0.6: node-gyp-build "^4.2.1" readable-stream "^3.6.0" -macos-release@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-3.1.0.tgz#6165bb0736ae567ed6649e36ce6a24d87cbb7aca" - integrity sha512-/M/R0gCDgM+Cv1IuBG1XGdfTFnMEG6PZeT+KGWHO/OG+imqmaD9CH5vHBTycEM3+Kc4uG2Il+tFAuUWLqQOeUA== +macos-release@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-3.3.0.tgz#92cb67bc66d67c3fde4a9e14f5f909afa418b072" + integrity sha512-tPJQ1HeyiU2vRruNGhZ+VleWuMQRro8iFtJxYgnS4NQe+EukKF6aGiIT+7flZhISAt2iaXBCfFGvAyif7/f8nQ== magic-string@^0.27.0: version "0.27.0"