mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Font settings for editor and ternimal (#4694)
* Add font settings for editor. Add terminal tab Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Move shell settings to terminal tab Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Add termilan font settings to store Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Fix store crash Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Cleanup Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Remove unsued font-list Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Cleanup. Move default font size to a const Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Remove package.lock Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * PR fixes and cleanup Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Move to settings object Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Test Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Add reaction to update terminals. Cleanup Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Add config field to terminal Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Merge with master and resolve conflicts Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Fix merge issues Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> * Fix lint and resolve conflicts Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box> Co-authored-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box>
This commit is contained in:
1 parent
6cba82c491
commit
b7d29f8c49
9 files changed
+165
-55
No files matched your search
@@ -11,24 +11,28 @@ import type { DockStore, TabId } from "../dock-store/dock.store";
|
||||
import { TerminalApi, TerminalChannels } from "../../../api/terminal-api";
|
||||
import { ThemeStore } from "../../../theme.store";
|
||||
import { disposer } from "../../../utils";
|
||||
import { isMac } from "../../../../common/vars";
|
||||
import { isMac, defaultTerminalFontFamily } from "../../../../common/vars";
|
||||
import { once } from "lodash";
|
||||
import { UserStore } from "../../../../common/user-store";
|
||||
import { clipboard } from "electron";
|
||||
import logger from "../../../../common/logger";
|
||||
import type { TerminalConfig } from "../../../../common/user-store/preferences-helpers";
|
||||
|
||||
interface Dependencies {
|
||||
dockStore: DockStore
|
||||
}
|
||||
|
||||
export class Terminal {
|
||||
|
||||
private terminalConfig: TerminalConfig = UserStore.getInstance().terminalConfig;
|
||||
|
||||
public static get spawningPool() {
|
||||
return document.getElementById("terminal-init");
|
||||
}
|
||||
|
||||
static async preloadFonts() {
|
||||
const fontPath = require("../../fonts/roboto-mono-nerd.ttf").default; // eslint-disable-line @typescript-eslint/no-var-requires
|
||||
const fontFace = new FontFace("RobotoMono", `url(${fontPath})`);
|
||||
const fontFace = new FontFace(defaultTerminalFontFamily, `url(${fontPath})`);
|
||||
|
||||
await fontFace.load();
|
||||
document.fonts.add(fontFace);
|
||||
@@ -37,8 +41,8 @@ export class Terminal {
|
||||
private xterm: XTerm | null = new XTerm({
|
||||
cursorBlink: true,
|
||||
cursorStyle: "bar",
|
||||
fontSize: 13,
|
||||
fontFamily: "RobotoMono",
|
||||
fontSize: this.terminalConfig.fontSize,
|
||||
fontFamily: this.terminalConfig.fontFamily,
|
||||
});
|
||||
private readonly fitAddon = new FitAddon();
|
||||
private scrollPos = 0;
|
||||
@@ -97,6 +101,12 @@ export class Terminal {
|
||||
}, {
|
||||
fireImmediately: true,
|
||||
}),
|
||||
reaction(() => UserStore.getInstance().terminalConfig.fontSize, this.setFontSize, {
|
||||
fireImmediately: true,
|
||||
}),
|
||||
reaction(() => UserStore.getInstance().terminalConfig.fontFamily, this.setFontFamily, {
|
||||
fireImmediately: true,
|
||||
}),
|
||||
dependencies.dockStore.onResize(this.onResize),
|
||||
() => onDataHandler.dispose(),
|
||||
() => this.fitAddon.dispose(),
|
||||
@@ -192,6 +202,14 @@ export class Terminal {
|
||||
}
|
||||
};
|
||||
|
||||
setFontSize = (size: number) => {
|
||||
this.xterm.options.fontSize = size;
|
||||
};
|
||||
|
||||
setFontFamily = (family: string) => {
|
||||
this.xterm.options.fontFamily = family;
|
||||
};
|
||||
|
||||
keyHandler = (evt: KeyboardEvent): boolean => {
|
||||
const { code, ctrlKey, metaKey } = evt;
|
||||
|
||||
|
||||
Reference in new issue
Block a user