From 5679d5edf1021d0b2ecb8ebbb9ccc7a42d9a60c3 Mon Sep 17 00:00:00 2001 From: Austin Warren Date: Wed, 17 Jul 2019 17:16:42 -0700 Subject: [PATCH] Fix code from xterm-addon-fit so that we don't run into issues with the first recovered console.. I'm sure there's a better way. --- .../src/frontends/xtermFrontend.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index a6cb2909..ea80bd9c 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -85,8 +85,21 @@ export class XTermFrontend extends Frontend { this.resizeHandler = () => { try { - if (getComputedStyle(this.xtermCore.element).getPropertyValue('height') !== 'auto') { - this.fitAddon.fit() + if (this.xtermCore.element && getComputedStyle(this.xtermCore.element).getPropertyValue('height') !== 'auto') { + + let t = window.getComputedStyle(this.xtermCore.element.parentElement) + let r = parseInt(t.getPropertyValue("height")) + let n = Math.max(0, parseInt(t.getPropertyValue("width"))) + let o = window.getComputedStyle(this.xtermCore.element) + let i = r - (parseInt(o.getPropertyValue("padding-top")) + parseInt(o.getPropertyValue("padding-bottom"))) + let l = n - (parseInt(o.getPropertyValue("padding-right")) + parseInt(o.getPropertyValue("padding-left"))) - this.xtermCore.viewport.scrollBarWidth + let actualCellWidth = this.xtermCore._renderService.dimensions.actualCellWidth || 9; + let actualCellHeight = this.xtermCore._renderService.dimensions.actualCellHeight || 17; + let cols = Math.floor(l / actualCellWidth) + let rows = Math.floor(i / actualCellHeight); + + console.log("resizing to: ", cols, rows); + this.xterm.resize(cols, rows); } } catch (e) { // tends to throw when element wasn't shown yet