From e46a9e12d0107085ec3f0db73aaf938a8d2389b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Tue, 6 Dec 2022 13:40:25 +0100 Subject: [PATCH] fix demo in epiphany --- .../xterm-addon-canvas/src/BaseRenderLayer.ts | 3 +++ demo/client.ts | 26 +++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/addons/xterm-addon-canvas/src/BaseRenderLayer.ts b/addons/xterm-addon-canvas/src/BaseRenderLayer.ts index d2a7a4ed..fb146884 100644 --- a/addons/xterm-addon-canvas/src/BaseRenderLayer.ts +++ b/addons/xterm-addon-canvas/src/BaseRenderLayer.ts @@ -373,6 +373,9 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer } else { glyph = this._charAtlas.getRasterizedGlyph(cell.getCode() || WHITESPACE_CELL_CODE, this._cellColorResolver.result.bg, this._cellColorResolver.result.fg, this._cellColorResolver.result.ext); } + if (!glyph.size.x || !glyph.size.y) { + return; + } this._ctx.save(); this._clipRow(y); // Draw the image, use the bitmap if it's available diff --git a/demo/client.ts b/demo/client.ts index 38c4748a..280b5e56 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -273,22 +273,22 @@ function createTerminal(): void { socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/terminals/'; addons.fit.instance!.fit(); - typedTerm.loadAddon(addons.webgl.instance); - setTimeout(() => { - if (addons.webgl.instance !== undefined) { - setTextureAtlas(addons.webgl.instance.textureAtlas); - addons.webgl.instance.onChangeTextureAtlas(e => setTextureAtlas(e)); - addons.webgl.instance.onAddTextureAtlasCanvas(e => appendTextureAtlas(e)); - addons.webgl.instance.onRemoveTextureAtlasCanvas(e => removeTextureAtlas(e)); - } - }, 0); - try { // try-catch to allow the demo to load if webgl is not supported + // try to start with webgl renderer (might throw on older safari/webkit) + try { + typedTerm.loadAddon(addons.webgl.instance); + term.open(terminalContainer); + setTextureAtlas(addons.webgl.instance.textureAtlas); + addons.webgl.instance.onChangeTextureAtlas(e => setTextureAtlas(e)); + addons.webgl.instance.onAddTextureAtlasCanvas(e => appendTextureAtlas(e)); + addons.webgl.instance.onRemoveTextureAtlasCanvas(e => removeTextureAtlas(e)); + } catch (e) { + console.log(e); + addons.webgl.instance.dispose(); + addons.webgl.instance = undefined; term.open(terminalContainer); } - catch { - addons.webgl.instance = undefined; - } + term.focus(); addDomListener(paddingElement, 'change', setPadding);