diff --git a/tabby-core/src/api/index.ts b/tabby-core/src/api/index.ts index bfa42a7ee..789ac544e 100644 --- a/tabby-core/src/api/index.ts +++ b/tabby-core/src/api/index.ts @@ -6,7 +6,7 @@ export { TabRecoveryProvider, RecoveryToken } from './tabRecovery' export { ToolbarButtonProvider, ToolbarButton } from './toolbarButtonProvider' export { ConfigProvider } from './configProvider' export { HotkeyProvider, HotkeyDescription, Hotkey } from './hotkeyProvider' -export { Theme } from './theme' +export { Theme, TerminalColorScheme } from './theme' export { TabContextMenuItemProvider } from './tabContextMenuProvider' export { SelectorOption } from './selector' export { CLIHandler, CLIEvent } from './cli' diff --git a/tabby-core/src/api/theme.ts b/tabby-core/src/api/theme.ts index bae63c16f..fa6a077f3 100644 --- a/tabby-core/src/api/theme.ts +++ b/tabby-core/src/api/theme.ts @@ -15,3 +15,14 @@ export abstract class Theme { macOSWindowButtonsInsetY?: number followsColorScheme?: boolean } + +export interface TerminalColorScheme { + name: string + foreground: string + background: string + cursor: string + colors: string[] + selection?: string + selectionForeground?: string + cursorAccent?: string +} diff --git a/tabby-core/src/services/themes.service.ts b/tabby-core/src/services/themes.service.ts index d9f133e3d..17ff5a6de 100644 --- a/tabby-core/src/services/themes.service.ts +++ b/tabby-core/src/services/themes.service.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core' import { Subject, Observable } from 'rxjs' import * as Color from 'color' import { ConfigService } from '../services/config.service' -import { Theme } from '../api/theme' +import { TerminalColorScheme, Theme } from '../api/theme' import { PlatformService, PlatformTheme } from '../api/platform' import { NewTheme } from '../theme' @@ -199,7 +199,7 @@ export class ThemesService { } /// @hidden - _getActiveColorScheme (): any { + _getActiveColorScheme (): TerminalColorScheme { let theme: PlatformTheme = 'dark' if (this.getConfigStoreOrDefaults().appearance.colorSchemeMode === 'light') { theme = 'light' @@ -208,9 +208,9 @@ export class ThemesService { } if (theme === 'light') { - return this.getConfigStoreOrDefaults().terminal.lightColorScheme + return this.getConfigStoreOrDefaults().terminal.lightColorScheme as TerminalColorScheme } else { - return this.getConfigStoreOrDefaults().terminal.colorScheme + return this.getConfigStoreOrDefaults().terminal.colorScheme as TerminalColorScheme } } diff --git a/tabby-terminal/src/api/colorSchemeProvider.ts b/tabby-terminal/src/api/colorSchemeProvider.ts index d28b8fdd9..5a1e72539 100644 --- a/tabby-terminal/src/api/colorSchemeProvider.ts +++ b/tabby-terminal/src/api/colorSchemeProvider.ts @@ -1,4 +1,4 @@ -import { TerminalColorScheme } from './interfaces' +import { TerminalColorScheme } from 'tabby-core' /** * Extend to add more terminal color schemes diff --git a/tabby-terminal/src/api/interfaces.ts b/tabby-terminal/src/api/interfaces.ts index b492c70d7..bfa8c701d 100644 --- a/tabby-terminal/src/api/interfaces.ts +++ b/tabby-terminal/src/api/interfaces.ts @@ -1,21 +1,10 @@ -import { ConnectableProfile, Profile } from 'tabby-core' +import { ConnectableProfile, Profile, TerminalColorScheme } from 'tabby-core' export interface ResizeEvent { columns: number rows: number } -export interface TerminalColorScheme { - name: string - foreground: string - background: string - cursor: string - colors: string[] - selection?: string - selectionForeground?: string - cursorAccent?: string -} - export interface BaseTerminalProfile extends Profile { terminalColorScheme: TerminalColorScheme | null } diff --git a/tabby-terminal/src/colorSchemes.ts b/tabby-terminal/src/colorSchemes.ts index 32e763e87..47d7dcd2d 100644 --- a/tabby-terminal/src/colorSchemes.ts +++ b/tabby-terminal/src/colorSchemes.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' -import { TerminalColorScheme } from './api/interfaces' import { TerminalColorSchemeProvider } from './api/colorSchemeProvider' +import { TerminalColorScheme } from 'tabby-core' @Injectable({ providedIn: 'root' }) export class DefaultColorSchemes extends TerminalColorSchemeProvider { diff --git a/tabby-terminal/src/components/colorSchemePreview.component.ts b/tabby-terminal/src/components/colorSchemePreview.component.ts index a64ed5cbf..5aa186397 100644 --- a/tabby-terminal/src/components/colorSchemePreview.component.ts +++ b/tabby-terminal/src/components/colorSchemePreview.component.ts @@ -1,6 +1,5 @@ import { Component, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core' -import { BaseComponent, ConfigService, getCSSFontFamily } from 'tabby-core' -import { TerminalColorScheme } from '../api/interfaces' +import { BaseComponent, ConfigService, getCSSFontFamily, TerminalColorScheme } from 'tabby-core' /** @hidden */ @Component({ diff --git a/tabby-terminal/src/components/colorSchemeSelector.component.ts b/tabby-terminal/src/components/colorSchemeSelector.component.ts index c028368c3..ffe1d9146 100644 --- a/tabby-terminal/src/components/colorSchemeSelector.component.ts +++ b/tabby-terminal/src/components/colorSchemeSelector.component.ts @@ -2,9 +2,8 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker' import { Component, Inject, Input, ChangeDetectionStrategy, ChangeDetectorRef, HostBinding, Output, EventEmitter } from '@angular/core' -import { ConfigService } from 'tabby-core' +import { ConfigService, TerminalColorScheme } from 'tabby-core' import { TerminalColorSchemeProvider } from '../api/colorSchemeProvider' -import { TerminalColorScheme } from '../api/interfaces' _('Search color schemes') diff --git a/tabby-terminal/src/components/colorSchemeSettingsForMode.component.ts b/tabby-terminal/src/components/colorSchemeSettingsForMode.component.ts index 1adeb69c8..cb7a5bbe2 100644 --- a/tabby-terminal/src/components/colorSchemeSettingsForMode.component.ts +++ b/tabby-terminal/src/components/colorSchemeSettingsForMode.component.ts @@ -3,9 +3,8 @@ import deepEqual from 'deep-equal' import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker' import { Component, Inject, Input, ChangeDetectionStrategy, ChangeDetectorRef, HostBinding } from '@angular/core' -import { ConfigService, PlatformService, TranslateService } from 'tabby-core' +import { ConfigService, PlatformService, TerminalColorScheme, TranslateService } from 'tabby-core' import { TerminalColorSchemeProvider } from '../api/colorSchemeProvider' -import { TerminalColorScheme } from '../api/interfaces' _('Search color schemes') diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts index 1e7098d3a..d2adbcf8b 100644 --- a/tabby-terminal/src/frontends/xtermFrontend.ts +++ b/tabby-terminal/src/frontends/xtermFrontend.ts @@ -1,7 +1,7 @@ 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' +import { ConfigService, getCSSFontFamily, getWindows10Build, HostAppService, HotkeysService, Platform, PlatformService, TerminalColorScheme, ThemesService } from 'tabby-core' import { Frontend, SearchOptions, SearchState } from './frontend' import { Terminal, ITheme } from '@xterm/xterm' import { FitAddon } from '@xterm/addon-fit' @@ -12,7 +12,7 @@ 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 { BaseTerminalProfile, TerminalColorScheme } from '../api/interfaces' +import { BaseTerminalProfile } from '../api/interfaces' import { getXtermBackgroundColor } from '../helpers' import { generatePalette } from '../generatePalette' import './xterm.css' @@ -455,7 +455,7 @@ export class XTermFrontend extends Frontend { } private configureColors (scheme: TerminalColorScheme | null): void { - const appColorScheme = this.themes._getActiveColorScheme() as TerminalColorScheme + const appColorScheme = this.themes._getActiveColorScheme() scheme = scheme ?? appColorScheme diff --git a/tabby-terminal/src/helpers.ts b/tabby-terminal/src/helpers.ts index 8e1d57122..c818f381b 100644 --- a/tabby-terminal/src/helpers.ts +++ b/tabby-terminal/src/helpers.ts @@ -1,11 +1,10 @@ -import { TerminalColorScheme } from './api/interfaces' -import { ConfigService, ThemesService } from 'tabby-core' +import { ConfigService, ThemesService, Theme, TerminalColorScheme } from 'tabby-core' function getActiveTerminalTheme ( themes: ThemesService, -): { appTheme: ReturnType, appColorScheme: TerminalColorScheme } { +): { appTheme: Theme, appColorScheme: TerminalColorScheme } { const appTheme = themes.findCurrentTheme() - const appColorScheme = themes._getActiveColorScheme() as TerminalColorScheme + const appColorScheme = themes._getActiveColorScheme() return { appTheme, appColorScheme } } diff --git a/tabby-terminal/src/index.ts b/tabby-terminal/src/index.ts index a674933fc..753e882e4 100644 --- a/tabby-terminal/src/index.ts +++ b/tabby-terminal/src/index.ts @@ -105,3 +105,4 @@ export * from './api/middleware' export * from './session' export { LoginScriptsSettingsComponent, StreamProcessingSettingsComponent } export { MultifocusService } from './services/multifocus.service' +export { TerminalColorScheme } from 'tabby-core' // was previously defined in this plugin