Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tabby-terminal/src/frontends/xtermFrontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SerializeAddon } from '@xterm/addon-serialize'
import { ImageAddon } from '@xterm/addon-image'
import { CanvasAddon } from '@xterm/addon-canvas'
import { BaseTerminalProfile, TerminalColorScheme } from '../api/interfaces'
import { getTerminalBackgroundColor } from '../helpers'
import { getXtermBackgroundColor } from '../helpers'
import './xterm.css'

const COLOR_NAMES = [
Expand Down Expand Up @@ -394,7 +394,7 @@ export class XTermFrontend extends Frontend {
foreground: scheme.foreground,
selectionBackground: scheme.selection ?? '#88888888',
selectionForeground: scheme.selectionForeground ?? undefined,
background: getTerminalBackgroundColor(this.configService, this.themes, scheme) ?? '#00000000',
background: getXtermBackgroundColor(this.configService, this.themes, scheme),
cursor: scheme.cursor,
cursorAccent: scheme.cursorAccent,
overviewRulerBorder: scheme.background,
Expand Down
26 changes: 24 additions & 2 deletions tabby-terminal/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { TerminalColorScheme } from './api/interfaces'
import { ConfigService, ThemesService } from 'tabby-core'

function getActiveTerminalTheme (
themes: ThemesService,
): { appTheme: ReturnType<ThemesService['findCurrentTheme']>, appColorScheme: TerminalColorScheme } {
const appTheme = themes.findCurrentTheme()
const appColorScheme = themes._getActiveColorScheme() as TerminalColorScheme

return { appTheme, appColorScheme }
}

export function getTerminalBackgroundColor (
config: ConfigService,
themes: ThemesService,
scheme: TerminalColorScheme | null,
): string|null {
const appTheme = themes.findCurrentTheme()
const appColorScheme = themes._getActiveColorScheme() as TerminalColorScheme
const { appTheme, appColorScheme } = getActiveTerminalTheme(themes)

// Use non transparent background when:
// - legacy theme and user choses colorScheme based BG
Expand All @@ -19,3 +27,17 @@ export function getTerminalBackgroundColor (

return shouldUseCSBackground && scheme ? scheme.background : null
}

export function getXtermBackgroundColor (
config: ConfigService,
themes: ThemesService,
scheme: TerminalColorScheme | null,
): string {
const configuredBackground = getTerminalBackgroundColor(config, themes, scheme)
if (configuredBackground) {
return configuredBackground
}

const { appTheme, appColorScheme } = getActiveTerminalTheme(themes)
return appTheme.followsColorScheme ? appColorScheme.background : appTheme.terminalBackground
}
Loading