From 1092b876c2a68b7a672c430841a586f2df383bd2 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 11 Jan 2022 13:51:06 +0200 Subject: [PATCH] fix padding, allow to select own theme for terminal Signed-off-by: Roman --- src/common/user-store/preferences-helpers.ts | 24 ++++++------- src/common/user-store/user-store.ts | 6 ++-- .../components/+preferences/application.tsx | 34 +++++++++++-------- .../components/dock/terminal-window.scss | 10 +++++- src/renderer/theme.store.ts | 4 +-- 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/common/user-store/preferences-helpers.ts b/src/common/user-store/preferences-helpers.ts index e26692c905..e20e259556 100644 --- a/src/common/user-store/preferences-helpers.ts +++ b/src/common/user-store/preferences-helpers.ts @@ -83,6 +83,15 @@ const colorTheme: PreferenceDescription = { }, }; +const terminalTheme: PreferenceDescription = { + fromStore(val) { + return val || ""; + }, + toStore(val) { + return val || undefined; + }, +}; + const localeTimezone: PreferenceDescription = { fromStore(val) { return val || moment.tz.guess(true) || "UTC"; @@ -233,19 +242,6 @@ const terminalCopyOnSelect: PreferenceDescription = { }, }; -const terminalUseDarkTheme: PreferenceDescription = { - fromStore(val) { - return val ?? false; - }, - toStore(val) { - if (!val) { - return undefined; - } - - return val; - }, -}; - const hiddenTableColumns: PreferenceDescription<[string, string[]][], Map>> = { fromStore(val) { return new Map( @@ -364,6 +360,7 @@ export const DESCRIPTORS = { httpsProxy, shell, colorTheme, + terminalTheme, localeTimezone, allowUntrustedCAs, allowTelemetry, @@ -377,7 +374,6 @@ export const DESCRIPTORS = { syncKubeconfigEntries, editorConfiguration, terminalCopyOnSelect, - terminalUseDarkTheme, updateChannel, extensionRegistryUrl, }; diff --git a/src/common/user-store/user-store.ts b/src/common/user-store/user-store.ts index 202924eb4d..952ca32ecc 100644 --- a/src/common/user-store/user-store.ts +++ b/src/common/user-store/user-store.ts @@ -67,6 +67,7 @@ export class UserStore extends BaseStore /* implements UserStore @observable allowErrorReporting: boolean; @observable allowUntrustedCAs: boolean; @observable colorTheme: string; + @observable terminalTheme: string; @observable localeTimezone: string; @observable downloadMirror: string; @observable httpsProxy?: string; @@ -74,7 +75,6 @@ export class UserStore extends BaseStore /* implements UserStore @observable downloadBinariesPath?: string; @observable kubectlBinariesPath?: string; @observable terminalCopyOnSelect: boolean; - @observable terminalUseDarkTheme: boolean; @observable updateChannel?: string; @observable extensionRegistryUrl: ExtensionRegistry; @@ -189,6 +189,7 @@ export class UserStore extends BaseStore /* implements UserStore this.httpsProxy = DESCRIPTORS.httpsProxy.fromStore(preferences?.httpsProxy); this.shell = DESCRIPTORS.shell.fromStore(preferences?.shell); this.colorTheme = DESCRIPTORS.colorTheme.fromStore(preferences?.colorTheme); + this.terminalTheme = DESCRIPTORS.terminalTheme.fromStore(preferences?.terminalTheme); this.localeTimezone = DESCRIPTORS.localeTimezone.fromStore(preferences?.localeTimezone); this.allowUntrustedCAs = DESCRIPTORS.allowUntrustedCAs.fromStore(preferences?.allowUntrustedCAs); this.allowTelemetry = DESCRIPTORS.allowTelemetry.fromStore(preferences?.allowTelemetry); @@ -202,7 +203,6 @@ export class UserStore extends BaseStore /* implements UserStore this.syncKubeconfigEntries.replace(DESCRIPTORS.syncKubeconfigEntries.fromStore(preferences?.syncKubeconfigEntries)); this.editorConfiguration = DESCRIPTORS.editorConfiguration.fromStore(preferences?.editorConfiguration); this.terminalCopyOnSelect = DESCRIPTORS.terminalCopyOnSelect.fromStore(preferences?.terminalCopyOnSelect); - this.terminalUseDarkTheme = DESCRIPTORS.terminalUseDarkTheme.fromStore(preferences?.terminalUseDarkTheme); this.updateChannel = DESCRIPTORS.updateChannel.fromStore(preferences?.updateChannel); this.extensionRegistryUrl = DESCRIPTORS.extensionRegistryUrl.fromStore(preferences?.extensionRegistryUrl); } @@ -214,6 +214,7 @@ export class UserStore extends BaseStore /* implements UserStore httpsProxy: DESCRIPTORS.httpsProxy.toStore(this.httpsProxy), shell: DESCRIPTORS.shell.toStore(this.shell), colorTheme: DESCRIPTORS.colorTheme.toStore(this.colorTheme), + terminalTheme: DESCRIPTORS.terminalTheme.toStore(this.terminalTheme), localeTimezone: DESCRIPTORS.localeTimezone.toStore(this.localeTimezone), allowUntrustedCAs: DESCRIPTORS.allowUntrustedCAs.toStore(this.allowUntrustedCAs), allowTelemetry: DESCRIPTORS.allowTelemetry.toStore(this.allowTelemetry), @@ -227,7 +228,6 @@ export class UserStore extends BaseStore /* implements UserStore syncKubeconfigEntries: DESCRIPTORS.syncKubeconfigEntries.toStore(this.syncKubeconfigEntries), editorConfiguration: DESCRIPTORS.editorConfiguration.toStore(this.editorConfiguration), terminalCopyOnSelect: DESCRIPTORS.terminalCopyOnSelect.toStore(this.terminalCopyOnSelect), - terminalUseDarkTheme: DESCRIPTORS.terminalUseDarkTheme.toStore(this.terminalUseDarkTheme), updateChannel: DESCRIPTORS.updateChannel.toStore(this.updateChannel), extensionRegistryUrl: DESCRIPTORS.extensionRegistryUrl.toStore(this.extensionRegistryUrl), }, diff --git a/src/renderer/components/+preferences/application.tsx b/src/renderer/components/+preferences/application.tsx index 4422eb3313..f5213592ae 100644 --- a/src/renderer/components/+preferences/application.tsx +++ b/src/renderer/components/+preferences/application.tsx @@ -57,24 +57,38 @@ export const Application = observer(() => { const [customUrl, setCustomUrl] = React.useState(userStore.extensionRegistryUrl.customUrl || ""); const [shell, setShell] = React.useState(userStore.shell || ""); const extensionSettings = AppPreferenceRegistry.getInstance().getItems().filter((preference) => preference.showInPreferencesTab === "application"); + const themeStore = ThemeStore.getInstance(); return (

Application

- + userStore.terminalTheme = value} + /> +
- + {
-
- - userStore.terminalUseDarkTheme = !userStore.terminalUseDarkTheme} - > - Always use dark terminal theme colors - -
- -
+
diff --git a/src/renderer/components/dock/terminal-window.scss b/src/renderer/components/dock/terminal-window.scss index fa0d897b0d..2b424aa990 100644 --- a/src/renderer/components/dock/terminal-window.scss +++ b/src/renderer/components/dock/terminal-window.scss @@ -27,7 +27,15 @@ flex: 1; overflow: hidden; - > .xterm { + .xterm { padding: var(--spacing); + + &, &-viewport { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + } } } \ No newline at end of file diff --git a/src/renderer/theme.store.ts b/src/renderer/theme.store.ts index ff670ce85a..c166643249 100644 --- a/src/renderer/theme.store.ts +++ b/src/renderer/theme.store.ts @@ -60,8 +60,8 @@ export class ThemeStore extends Singleton { } @computed get terminalColors(): Record { - const useDarkThemeColors = UserStore.getInstance().terminalUseDarkTheme; - const theme = useDarkThemeColors ? this.themes.get("lens-dark") : this.activeTheme; + const { terminalTheme } = UserStore.getInstance(); + const theme = this.themes.get(terminalTheme) ?? this.activeTheme; const xtermColors: Record = {}; // see also "terminal.ts" // Replacing keys stored in styles to format accepted by terminal