From f61d861883c59a6a79efd740c0a3ed0784d51ebc Mon Sep 17 00:00:00 2001 From: cpsdqs Date: Fri, 10 Nov 2017 00:09:12 +0100 Subject: [PATCH] Make cursor work in double-width lines --- js/term/screen_renderer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/term/screen_renderer.js b/js/term/screen_renderer.js index 8ee77b4..668431d 100644 --- a/js/term/screen_renderer.js +++ b/js/term/screen_renderer.js @@ -800,17 +800,22 @@ module.exports = class CanvasRenderer extends EventEmitter { let cursorX = x let cursorY = y + let cursorWidth = cellWidth // JS doesn't allow same-name assignment if (this.cursor.hanging) { // draw hanging cursor in the margin cursorX += 1 } - let screenX = cursorX * cellWidth + this.padding + // double-width lines + if (this.screenLines[cursorY]) cursorWidth *= 2 + + let screenX = cursorX * cursorWidth + this.padding let screenY = cursorY * cellHeight + this.padding + if (this.cursor.style === 'block') { // block - ctx.rect(screenX, screenY, cellWidth, cellHeight) + ctx.rect(screenX, screenY, cursorWidth, cellHeight) } else if (this.cursor.style === 'bar') { // vertical bar let barWidth = 2 @@ -818,7 +823,7 @@ module.exports = class CanvasRenderer extends EventEmitter { } else if (this.cursor.style === 'line') { // underline let lineHeight = 2 - ctx.rect(screenX, screenY + charSize.height, cellWidth, lineHeight) + ctx.rect(screenX, screenY + charSize.height, cursorWidth, lineHeight) } ctx.clip()