From bc702d28ff32ad3086b18a4db75e732ae544a55d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:39:19 -0700 Subject: [PATCH] Support webgl strikethrough, fix underline position Fixes #580 --- .../xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index fb20c1c8..db0da6d7 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -339,6 +339,7 @@ export class WebglCharAtlas implements IDisposable { const dim = !!this._workAttributeData.isDim(); const italic = !!this._workAttributeData.isItalic(); const underline = !!this._workAttributeData.isUnderline(); + const strikethrough = !!this._workAttributeData.isStrikethrough(); let fgColor = this._workAttributeData.getFgColor(); let fgColorMode = this._workAttributeData.getFgColorMode(); let bgColor = this._workAttributeData.getBgColor(); @@ -393,9 +394,19 @@ export class WebglCharAtlas implements IDisposable { this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); if (underline) { this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; - this._tmpCtx.moveTo(0, this._config.scaledCharHeight - 1); - this._tmpCtx.lineTo(this._config.scaledCharWidth, this._config.scaledCharHeight - 1); + this._tmpCtx.beginPath(); + this._tmpCtx.moveTo(padding, padding + this._config.scaledCharHeight - 0.5); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + this._config.scaledCharHeight - 0.5); this._tmpCtx.stroke(); + this._tmpCtx.closePath(); + } + if (strikethrough) { + this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; + this._tmpCtx.beginPath(); + this._tmpCtx.moveTo(padding, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + this._tmpCtx.stroke(); + this._tmpCtx.closePath(); } this._tmpCtx.restore();