1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

terminal custom fonts -- fine-tuning

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2022-05-20 16:20:25 +03:00
parent 7fcb860e98
commit 58281ea49c
2 changed files with 15 additions and 21 deletions

View File

@ -12,6 +12,7 @@
@import "./fonts"; @import "./fonts";
:root { :root {
--flex-gap: #{$padding};
--unit: 8px; --unit: 8px;
--padding: var(--unit); --padding: var(--unit);
--margin: var(--unit); --margin: var(--unit);
@ -64,16 +65,12 @@
color: var(--textColorAccent); color: var(--textColorAccent);
} }
html {
font-size: 62.5%; // 1 rem == 10px
color: var(--textColorPrimary);
background-color: var(--mainBackground);
--flex-gap: #{$padding};
}
html, body { html, body {
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
color: var(--textColorPrimary);
background-color: var(--mainBackground);
font: var(--font-size) var(--font-main);
} }
#terminal-init { #terminal-init {
@ -94,10 +91,6 @@ html, body {
} }
} }
body {
font: $font-size $font-main;
}
fieldset { fieldset {
border: 0; border: 0;
padding: 0; padding: 0;

View File

@ -72,6 +72,10 @@ export class Terminal {
return this.dependencies.terminalConfig.get().fontSize; return this.dependencies.terminalConfig.get().fontSize;
} }
get theme(): Record<string/*paramName*/, string/*color*/> {
return this.dependencies.themeStore.xtermColors;
}
constructor(protected readonly dependencies: TerminalDependencies, { constructor(protected readonly dependencies: TerminalDependencies, {
tabId, tabId,
api, api,
@ -105,9 +109,7 @@ export class Terminal {
window.addEventListener("resize", this.onResize); window.addEventListener("resize", this.onResize);
this.disposer.push( this.disposer.push(
reaction(() => this.dependencies.themeStore.xtermColors, colors => { reaction(() => this.theme, colors => this.xterm.setOption("theme", colors), {
this.xterm?.setOption("theme", colors);
}, {
fireImmediately: true, fireImmediately: true,
}), }),
reaction(() => this.fontSize, this.setFontSize, { fireImmediately: true }), reaction(() => this.fontSize, this.setFontSize, { fireImmediately: true }),
@ -126,15 +128,14 @@ export class Terminal {
} }
fit = () => { fit = () => {
// Since this function is debounced we need to read this value as late as possible
if (!this.xterm) {
return;
}
try { try {
this.fitAddon.fit(); const { cols, rows } = this.fitAddon.proposeDimensions();
const { cols, rows } = this.xterm;
// attempt to resize/fit terminal when it's not visible in DOM will crash with exception
// see: https://github.com/xtermjs/xterm.js/issues/3118
if (isNaN(cols) || isNaN(rows)) return;
this.fitAddon.fit();
this.api.sendTerminalSize(cols, rows); this.api.sendTerminalSize(cols, rows);
} catch (error) { } catch (error) {
// see https://github.com/lensapp/lens/issues/1891 // see https://github.com/lensapp/lens/issues/1891