mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move to settings object
Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box>
This commit is contained in:
parent
0cfb8f0c75
commit
5375c79611
@ -10,7 +10,7 @@ import { getAppVersion, ObservableToggleSet } from "../utils";
|
|||||||
import type { editor } from "monaco-editor";
|
import type { editor } from "monaco-editor";
|
||||||
import merge from "lodash/merge";
|
import merge from "lodash/merge";
|
||||||
import { SemVer } from "semver";
|
import { SemVer } from "semver";
|
||||||
import { defaultTheme, defaultEditorFontFamily, defaultFontSize } from "../vars";
|
import { defaultTheme, defaultEditorFontFamily, defaultFontSize, defaultTerminalFontFamily } from "../vars";
|
||||||
|
|
||||||
export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
||||||
filePath: string;
|
filePath: string;
|
||||||
@ -18,6 +18,15 @@ export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
|||||||
|
|
||||||
export interface KubeconfigSyncValue {
|
export interface KubeconfigSyncValue {
|
||||||
}
|
}
|
||||||
|
export interface TerminalConfig {
|
||||||
|
fontSize: number;
|
||||||
|
fontFamily: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultTerminalConfig: TerminalConfig = {
|
||||||
|
fontSize: defaultFontSize,
|
||||||
|
fontFamily: defaultTerminalFontFamily,
|
||||||
|
};
|
||||||
|
|
||||||
export type EditorConfiguration = Pick<editor.IStandaloneEditorConstructionOptions,
|
export type EditorConfiguration = Pick<editor.IStandaloneEditorConstructionOptions,
|
||||||
"minimap" | "tabSize" | "lineNumbers" | "fontSize" | "fontFamily">;
|
"minimap" | "tabSize" | "lineNumbers" | "fontSize" | "fontFamily">;
|
||||||
@ -188,32 +197,6 @@ const downloadBinariesPath: PreferenceDescription<string | undefined> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const terminalFontSize: PreferenceDescription<number | undefined> = {
|
|
||||||
fromStore(val) {
|
|
||||||
return val;
|
|
||||||
},
|
|
||||||
toStore(val) {
|
|
||||||
if (!val) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return val;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const terminalFontFamily: PreferenceDescription<string | undefined> = {
|
|
||||||
fromStore(val) {
|
|
||||||
return val;
|
|
||||||
},
|
|
||||||
toStore(val) {
|
|
||||||
if (!val) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return val;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const kubectlBinariesPath: PreferenceDescription<string | undefined> = {
|
const kubectlBinariesPath: PreferenceDescription<string | undefined> = {
|
||||||
fromStore(val) {
|
fromStore(val) {
|
||||||
return val;
|
return val;
|
||||||
@ -300,6 +283,15 @@ const editorConfiguration: PreferenceDescription<EditorConfiguration, EditorConf
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const terminalConfig: PreferenceDescription<TerminalConfig, TerminalConfig> = {
|
||||||
|
fromStore(val) {
|
||||||
|
return merge(defaultTerminalConfig, val);
|
||||||
|
},
|
||||||
|
toStore(val) {
|
||||||
|
return val;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const updateChannels = new Map([
|
const updateChannels = new Map([
|
||||||
["latest", {
|
["latest", {
|
||||||
label: "Stable",
|
label: "Stable",
|
||||||
@ -385,8 +377,7 @@ export const DESCRIPTORS = {
|
|||||||
syncKubeconfigEntries,
|
syncKubeconfigEntries,
|
||||||
editorConfiguration,
|
editorConfiguration,
|
||||||
terminalCopyOnSelect,
|
terminalCopyOnSelect,
|
||||||
terminalFontSize,
|
terminalConfig,
|
||||||
terminalFontFamily,
|
|
||||||
updateChannel,
|
updateChannel,
|
||||||
extensionRegistryUrl,
|
extensionRegistryUrl,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { getAppVersion } from "../utils/app-version";
|
|||||||
import { kubeConfigDefaultPath } from "../kube-helpers";
|
import { kubeConfigDefaultPath } from "../kube-helpers";
|
||||||
import { appEventBus } from "../app-event-bus/event-bus";
|
import { appEventBus } from "../app-event-bus/event-bus";
|
||||||
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
||||||
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
|
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel, TerminalConfig } from "./preferences-helpers";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../main/logger";
|
||||||
|
|
||||||
export interface UserStoreModel {
|
export interface UserStoreModel {
|
||||||
@ -57,6 +57,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
|||||||
@observable downloadBinariesPath?: string;
|
@observable downloadBinariesPath?: string;
|
||||||
@observable kubectlBinariesPath?: string;
|
@observable kubectlBinariesPath?: string;
|
||||||
@observable terminalCopyOnSelect: boolean;
|
@observable terminalCopyOnSelect: boolean;
|
||||||
|
@observable terminalConfig: TerminalConfig;
|
||||||
@observable terminalFontSize?: number;
|
@observable terminalFontSize?: number;
|
||||||
@observable terminalFontFamily?: string;
|
@observable terminalFontFamily?: string;
|
||||||
@observable updateChannel?: string;
|
@observable updateChannel?: string;
|
||||||
@ -187,8 +188,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
|||||||
this.syncKubeconfigEntries.replace(DESCRIPTORS.syncKubeconfigEntries.fromStore(preferences?.syncKubeconfigEntries));
|
this.syncKubeconfigEntries.replace(DESCRIPTORS.syncKubeconfigEntries.fromStore(preferences?.syncKubeconfigEntries));
|
||||||
this.editorConfiguration = DESCRIPTORS.editorConfiguration.fromStore(preferences?.editorConfiguration);
|
this.editorConfiguration = DESCRIPTORS.editorConfiguration.fromStore(preferences?.editorConfiguration);
|
||||||
this.terminalCopyOnSelect = DESCRIPTORS.terminalCopyOnSelect.fromStore(preferences?.terminalCopyOnSelect);
|
this.terminalCopyOnSelect = DESCRIPTORS.terminalCopyOnSelect.fromStore(preferences?.terminalCopyOnSelect);
|
||||||
this.terminalFontSize = DESCRIPTORS.terminalFontSize.fromStore(preferences?.terminalFontSize);
|
this.terminalConfig = DESCRIPTORS.terminalConfig.fromStore(preferences?.terminalConfig);
|
||||||
this.terminalFontFamily = DESCRIPTORS.terminalFontFamily.fromStore(preferences?.terminalFontFamily);
|
|
||||||
this.updateChannel = DESCRIPTORS.updateChannel.fromStore(preferences?.updateChannel);
|
this.updateChannel = DESCRIPTORS.updateChannel.fromStore(preferences?.updateChannel);
|
||||||
this.extensionRegistryUrl = DESCRIPTORS.extensionRegistryUrl.fromStore(preferences?.extensionRegistryUrl);
|
this.extensionRegistryUrl = DESCRIPTORS.extensionRegistryUrl.fromStore(preferences?.extensionRegistryUrl);
|
||||||
}
|
}
|
||||||
@ -214,8 +214,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
|||||||
syncKubeconfigEntries: DESCRIPTORS.syncKubeconfigEntries.toStore(this.syncKubeconfigEntries),
|
syncKubeconfigEntries: DESCRIPTORS.syncKubeconfigEntries.toStore(this.syncKubeconfigEntries),
|
||||||
editorConfiguration: DESCRIPTORS.editorConfiguration.toStore(this.editorConfiguration),
|
editorConfiguration: DESCRIPTORS.editorConfiguration.toStore(this.editorConfiguration),
|
||||||
terminalCopyOnSelect: DESCRIPTORS.terminalCopyOnSelect.toStore(this.terminalCopyOnSelect),
|
terminalCopyOnSelect: DESCRIPTORS.terminalCopyOnSelect.toStore(this.terminalCopyOnSelect),
|
||||||
terminalFontFamily: DESCRIPTORS.terminalFontFamily.toStore(this.terminalFontFamily),
|
terminalConfig: DESCRIPTORS.terminalConfig.toStore(this.terminalConfig),
|
||||||
terminalFontSize: DESCRIPTORS.terminalFontSize.toStore(this.terminalFontSize),
|
|
||||||
updateChannel: DESCRIPTORS.updateChannel.toStore(this.updateChannel),
|
updateChannel: DESCRIPTORS.updateChannel.toStore(this.updateChannel),
|
||||||
extensionRegistryUrl: DESCRIPTORS.extensionRegistryUrl.toStore(this.extensionRegistryUrl),
|
extensionRegistryUrl: DESCRIPTORS.extensionRegistryUrl.toStore(this.extensionRegistryUrl),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -30,8 +30,8 @@ export const Terminal = observer(() => {
|
|||||||
const userStore = UserStore.getInstance();
|
const userStore = UserStore.getInstance();
|
||||||
const [terminalSettings, setTerminalSettings] = React.useState({
|
const [terminalSettings, setTerminalSettings] = React.useState({
|
||||||
shell: userStore.shell || "",
|
shell: userStore.shell || "",
|
||||||
terminalFontSize: userStore.terminalFontSize,
|
terminalFontSize: userStore.terminalConfig.fontSize,
|
||||||
terminalFontFamily: userStore.terminalFontFamily,
|
terminalFontFamily: userStore.terminalConfig.fontFamily,
|
||||||
});
|
});
|
||||||
const defaultShell = process.env.SHELL
|
const defaultShell = process.env.SHELL
|
||||||
|| process.env.PTYSHELL
|
|| process.env.PTYSHELL
|
||||||
@ -77,7 +77,7 @@ export const Terminal = observer(() => {
|
|||||||
...terminalSettings,
|
...terminalSettings,
|
||||||
terminalFontSize: Number(value),
|
terminalFontSize: Number(value),
|
||||||
})}
|
})}
|
||||||
onBlur={() => userStore.terminalFontSize = terminalSettings.terminalFontSize}
|
onBlur={() => userStore.terminalConfig.fontSize = terminalSettings.terminalFontSize}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
@ -90,7 +90,7 @@ export const Terminal = observer(() => {
|
|||||||
...terminalSettings,
|
...terminalSettings,
|
||||||
terminalFontFamily: value.toString(),
|
terminalFontFamily: value.toString(),
|
||||||
})}
|
})}
|
||||||
onBlur={() => userStore.terminalFontFamily = terminalSettings.terminalFontFamily}
|
onBlur={() => userStore.terminalConfig.fontFamily = terminalSettings.terminalFontFamily}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</div>);
|
</div>);
|
||||||
|
|||||||
@ -11,24 +11,28 @@ import type { DockStore, TabId } from "../dock-store/dock.store";
|
|||||||
import { TerminalApi, TerminalChannels } from "../../../api/terminal-api";
|
import { TerminalApi, TerminalChannels } from "../../../api/terminal-api";
|
||||||
import { ThemeStore } from "../../../theme.store";
|
import { ThemeStore } from "../../../theme.store";
|
||||||
import { disposer } from "../../../utils";
|
import { disposer } from "../../../utils";
|
||||||
import { isMac, defaultTerminalFontFamily, defaultFontSize} from "../../../../common/vars";
|
import { isMac, defaultTerminalFontFamily } from "../../../../common/vars";
|
||||||
import { once } from "lodash";
|
import { once } from "lodash";
|
||||||
import { UserStore } from "../../../../common/user-store";
|
import { UserStore } from "../../../../common/user-store";
|
||||||
import { clipboard } from "electron";
|
import { clipboard } from "electron";
|
||||||
import logger from "../../../../common/logger";
|
import logger from "../../../../common/logger";
|
||||||
|
import type { TerminalConfig } from "../../../common/user-store/preferences-helpers";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
dockStore: DockStore
|
dockStore: DockStore
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Terminal {
|
export class Terminal {
|
||||||
|
|
||||||
|
private terminalConfig: TerminalConfig = UserStore.getInstance().terminalConfig;
|
||||||
|
|
||||||
public static get spawningPool() {
|
public static get spawningPool() {
|
||||||
return document.getElementById("terminal-init");
|
return document.getElementById("terminal-init");
|
||||||
}
|
}
|
||||||
|
|
||||||
static async preloadFonts() {
|
static async preloadFonts() {
|
||||||
const fontPath = require("../../fonts/roboto-mono-nerd.ttf").default; // eslint-disable-line @typescript-eslint/no-var-requires
|
const fontPath = require("../fonts/roboto-mono-nerd.ttf").default; // eslint-disable-line @typescript-eslint/no-var-requires
|
||||||
const fontFace = new FontFace(defaultFontFamily, `url(${fontPath})`);
|
const fontFace = new FontFace(defaultTerminalFontFamily, `url(${fontPath})`);
|
||||||
|
|
||||||
await fontFace.load();
|
await fontFace.load();
|
||||||
document.fonts.add(fontFace);
|
document.fonts.add(fontFace);
|
||||||
@ -37,8 +41,8 @@ export class Terminal {
|
|||||||
private xterm: XTerm | null = new XTerm({
|
private xterm: XTerm | null = new XTerm({
|
||||||
cursorBlink: true,
|
cursorBlink: true,
|
||||||
cursorStyle: "bar",
|
cursorStyle: "bar",
|
||||||
fontSize: UserStore.getInstance().terminalFontSize || defaultFontSize,
|
fontSize: this.terminalConfig.fontSize,
|
||||||
fontFamily: UserStore.getInstance().terminalFontFamily || defaultTerminalFontFamily,
|
fontFamily: this.terminalConfig.fontFamily,
|
||||||
});
|
});
|
||||||
private readonly fitAddon = new FitAddon();
|
private readonly fitAddon = new FitAddon();
|
||||||
private scrollPos = 0;
|
private scrollPos = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user