From d6fe5c73849a1bf530fdea476984ebd6368c3e66 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 31 Jul 2022 11:21:27 -0700 Subject: [PATCH] Update size when letter spacing changes --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 1 - .../typings/xterm-addon-webgl.d.ts | 15 ++++++++++----- demo/client.ts | 13 ++++--------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index c4d40f0d..beed0304 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -25,7 +25,6 @@ import { ICharacterJoinerService, ICoreBrowserService } from 'browser/services/S import { CharData, ICellData } from 'common/Types'; import { AttributeData } from 'common/buffer/AttributeData'; import { ICoreService, IDecorationService } from 'common/services/Services'; -import { color, rgba as rgbaNs } from 'common/Color'; export class WebglRenderer extends Disposable implements IRenderer { private _renderLayers: IRenderLayer[]; diff --git a/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts b/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts index ee390d8a..74aed0cc 100644 --- a/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts +++ b/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts @@ -12,6 +12,16 @@ declare module 'xterm-addon-webgl' { export class WebglAddon implements ITerminalAddon { public textureAtlas?: HTMLCanvasElement; + /** + * An event that is fired when the renderer loses its canvas context. + */ + public get onContextLoss(): IEvent; + + /** + * An event that is fired when the texture atlas of the renderer changes. + */ + public get onChangeTextureAtlas(): IEvent; + constructor(preserveDrawingBuffer?: boolean); /** @@ -29,10 +39,5 @@ declare module 'xterm-addon-webgl' { * Clears the terminal's texture atlas and triggers a redraw. */ public clearTextureAtlas(): void; - - /** - * Fired when the WebglRenderer loses context - */ - public get onContextLoss(): IEvent; } } diff --git a/demo/client.ts b/demo/client.ts index 1c414702..98c60f70 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -400,20 +400,18 @@ function initOptions(term: TerminalType): void { const input = document.getElementById(`opt-${o}`); addDomListener(input, 'change', () => { console.log('change', o, input.value); - if (o === 'cols' || o === 'rows') { - updateTerminalSize(); - } else if (o === 'lineHeight') { + if (o === 'lineHeight') { term.options.lineHeight = parseFloat(input.value); - updateTerminalSize(); } else if (o === 'scrollSensitivity') { term.options.scrollSensitivity = parseFloat(input.value); - updateTerminalSize(); } else if (o === 'scrollback') { term.options.scrollback = parseInt(input.value); setTimeout(() => updateTerminalSize(), 5); } else { term.options[o] = parseInt(input.value); } + if (['cols', 'rows', 'letterSpacing', 'lineHeight'].includes(o)) { + updateTerminalSize(); }); }); Object.keys(stringOptions).forEach(o => { @@ -505,10 +503,7 @@ function initAddons(term: TerminalType): void { addon.instance = new addon.ctor(); term.loadAddon(addon.instance); if (name === 'webgl') { - setTimeout(() => { - document.body.appendChild((addon.instance as WebglAddon).textureAtlas); - (addon.instance as WebglAddon).onChangeTextureAtlas(e => document.body.appendChild(e)); - }, 0); + (addon.instance as WebglAddon).onChangeTextureAtlas(e => document.body.appendChild(e)); } else if (name === 'unicode11') { term.unicode.activeVersion = '11'; } else if (name === 'search') {