From 1cff37af9966715331da2498a8fbcf60d77e4d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 22 Feb 2020 20:08:34 +0100 Subject: [PATCH 1/4] fix dom renderer --- src/browser/renderer/dom/DomRenderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index c2464d0e..f8ad717b 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -352,7 +352,7 @@ export class DomRenderer extends Disposable implements IRenderer { public renderRows(start: number, end: number): void { const cursorAbsoluteY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; - const cursorX = this._bufferService.buffer.x; + const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); const cursorBlink = this._optionsService.options.cursorBlink; for (let y = start; y <= end; y++) { From 8d1b4bf78f3be09501ade0dbbb143f0406f47425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 22 Feb 2020 20:18:45 +0100 Subject: [PATCH 2/4] fix webgl renderer --- .../src/renderLayer/CursorRenderLayer.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index 1072a171..c898487e 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -128,6 +128,9 @@ export class CursorRenderLayer extends BaseRenderLayer { const cursorY = terminal.buffer.baseY + terminal.buffer.cursorY; const viewportRelativeCursorY = cursorY - terminal.buffer.viewportY; + // in case cursor.x == cols adjust visual cursor to cols - 1 + const correctedX = Math.min(terminal.buffer.cursorX, terminal.cols - 1); + // Don't draw the cursor if it's off-screen if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) { this._clearCursor(); @@ -135,7 +138,7 @@ export class CursorRenderLayer extends BaseRenderLayer { } // TODO: Need fast buffer API for loading cell - (terminal as any)._core.buffer.lines.get(cursorY).loadCell(terminal.buffer.cursorX, this._cell); + (terminal as any)._core.buffer.lines.get(cursorY).loadCell(correctedX, this._cell); if (this._cell.content === undefined) { return; } @@ -146,12 +149,12 @@ export class CursorRenderLayer extends BaseRenderLayer { this._ctx.fillStyle = this._colors.cursor.css; const cursorStyle = terminal.getOption('cursorStyle'); if (cursorStyle && cursorStyle !== 'block') { - this._cursorRenderers[cursorStyle](terminal, terminal.buffer.cursorX, viewportRelativeCursorY, this._cell); + this._cursorRenderers[cursorStyle](terminal, correctedX, viewportRelativeCursorY, this._cell); } else { - this._renderBlurCursor(terminal, terminal.buffer.cursorX, viewportRelativeCursorY, this._cell); + this._renderBlurCursor(terminal, correctedX, viewportRelativeCursorY, this._cell); } this._ctx.restore(); - this._state.x = terminal.buffer.cursorX; + this._state.x = correctedX; this._state.y = viewportRelativeCursorY; this._state.isFocused = false; this._state.style = cursorStyle; @@ -167,7 +170,7 @@ export class CursorRenderLayer extends BaseRenderLayer { if (this._state) { // The cursor is already in the correct spot, don't redraw - if (this._state.x === terminal.buffer.cursorX && + if (this._state.x === correctedX && this._state.y === viewportRelativeCursorY && this._state.isFocused === isTerminalFocused(terminal) && this._state.style === terminal.getOption('cursorStyle') && @@ -178,10 +181,10 @@ export class CursorRenderLayer extends BaseRenderLayer { } this._ctx.save(); - this._cursorRenderers[terminal.getOption('cursorStyle') || 'block'](terminal, terminal.buffer.cursorX, viewportRelativeCursorY, this._cell); + this._cursorRenderers[terminal.getOption('cursorStyle') || 'block'](terminal, correctedX, viewportRelativeCursorY, this._cell); this._ctx.restore(); - this._state.x = terminal.buffer.cursorX; + this._state.x = correctedX; this._state.y = viewportRelativeCursorY; this._state.isFocused = false; this._state.style = terminal.getOption('cursorStyle'); From db304513b19ebd7ebd08abd020999cb7cea4bafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 22 Feb 2020 20:30:36 +0100 Subject: [PATCH 3/4] unify naming, adjust addon version, fix interface description --- addons/xterm-addon-webgl/package.json | 2 +- .../src/renderLayer/CursorRenderLayer.ts | 16 ++++++++-------- src/browser/renderer/CursorRenderLayer.ts | 16 ++++++++-------- typings/xterm.d.ts | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/addons/xterm-addon-webgl/package.json b/addons/xterm-addon-webgl/package.json index 34422774..ca49e795 100644 --- a/addons/xterm-addon-webgl/package.json +++ b/addons/xterm-addon-webgl/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-webgl", - "version": "0.5.0", + "version": "0.5.1", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index c898487e..2ade8007 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -129,7 +129,7 @@ export class CursorRenderLayer extends BaseRenderLayer { const viewportRelativeCursorY = cursorY - terminal.buffer.viewportY; // in case cursor.x == cols adjust visual cursor to cols - 1 - const correctedX = Math.min(terminal.buffer.cursorX, terminal.cols - 1); + const cursorX = Math.min(terminal.buffer.cursorX, terminal.cols - 1); // Don't draw the cursor if it's off-screen if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) { @@ -138,7 +138,7 @@ export class CursorRenderLayer extends BaseRenderLayer { } // TODO: Need fast buffer API for loading cell - (terminal as any)._core.buffer.lines.get(cursorY).loadCell(correctedX, this._cell); + (terminal as any)._core.buffer.lines.get(cursorY).loadCell(cursorX, this._cell); if (this._cell.content === undefined) { return; } @@ -149,12 +149,12 @@ export class CursorRenderLayer extends BaseRenderLayer { this._ctx.fillStyle = this._colors.cursor.css; const cursorStyle = terminal.getOption('cursorStyle'); if (cursorStyle && cursorStyle !== 'block') { - this._cursorRenderers[cursorStyle](terminal, correctedX, viewportRelativeCursorY, this._cell); + this._cursorRenderers[cursorStyle](terminal, cursorX, viewportRelativeCursorY, this._cell); } else { - this._renderBlurCursor(terminal, correctedX, viewportRelativeCursorY, this._cell); + this._renderBlurCursor(terminal, cursorX, viewportRelativeCursorY, this._cell); } this._ctx.restore(); - this._state.x = correctedX; + this._state.x = cursorX; this._state.y = viewportRelativeCursorY; this._state.isFocused = false; this._state.style = cursorStyle; @@ -170,7 +170,7 @@ export class CursorRenderLayer extends BaseRenderLayer { if (this._state) { // The cursor is already in the correct spot, don't redraw - if (this._state.x === correctedX && + if (this._state.x === cursorX && this._state.y === viewportRelativeCursorY && this._state.isFocused === isTerminalFocused(terminal) && this._state.style === terminal.getOption('cursorStyle') && @@ -181,10 +181,10 @@ export class CursorRenderLayer extends BaseRenderLayer { } this._ctx.save(); - this._cursorRenderers[terminal.getOption('cursorStyle') || 'block'](terminal, correctedX, viewportRelativeCursorY, this._cell); + this._cursorRenderers[terminal.getOption('cursorStyle') || 'block'](terminal, cursorX, viewportRelativeCursorY, this._cell); this._ctx.restore(); - this._state.x = correctedX; + this._state.x = cursorX; this._state.y = viewportRelativeCursorY; this._state.isFocused = false; this._state.style = terminal.getOption('cursorStyle'); diff --git a/src/browser/renderer/CursorRenderLayer.ts b/src/browser/renderer/CursorRenderLayer.ts index 293f51e6..8b25667b 100644 --- a/src/browser/renderer/CursorRenderLayer.ts +++ b/src/browser/renderer/CursorRenderLayer.ts @@ -141,8 +141,8 @@ export class CursorRenderLayer extends BaseRenderLayer { } // in case cursor.x == cols adjust visual cursor to cols - 1 - const xCorrected = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); - this._bufferService.buffer.lines.get(cursorY)!.loadCell(xCorrected, this._cell); + const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); + this._bufferService.buffer.lines.get(cursorY)!.loadCell(cursorX, this._cell); if (this._cell.content === undefined) { return; } @@ -153,12 +153,12 @@ export class CursorRenderLayer extends BaseRenderLayer { this._ctx.fillStyle = this._colors.cursor.css; const cursorStyle = this._optionsService.options.cursorStyle; if (cursorStyle && cursorStyle !== 'block') { - this._cursorRenderers[cursorStyle](xCorrected, viewportRelativeCursorY, this._cell); + this._cursorRenderers[cursorStyle](cursorX, viewportRelativeCursorY, this._cell); } else { - this._renderBlurCursor(xCorrected, viewportRelativeCursorY, this._cell); + this._renderBlurCursor(cursorX, viewportRelativeCursorY, this._cell); } this._ctx.restore(); - this._state.x = xCorrected; + this._state.x = cursorX; this._state.y = viewportRelativeCursorY; this._state.isFocused = false; this._state.style = cursorStyle; @@ -174,7 +174,7 @@ export class CursorRenderLayer extends BaseRenderLayer { if (this._state) { // The cursor is already in the correct spot, don't redraw - if (this._state.x === xCorrected && + if (this._state.x === cursorX && this._state.y === viewportRelativeCursorY && this._state.isFocused === this._coreBrowserService.isFocused && this._state.style === this._optionsService.options.cursorStyle && @@ -185,10 +185,10 @@ export class CursorRenderLayer extends BaseRenderLayer { } this._ctx.save(); - this._cursorRenderers[this._optionsService.options.cursorStyle || 'block'](xCorrected, viewportRelativeCursorY, this._cell); + this._cursorRenderers[this._optionsService.options.cursorStyle || 'block'](cursorX, viewportRelativeCursorY, this._cell); this._ctx.restore(); - this._state.x = xCorrected; + this._state.x = cursorX; this._state.y = viewportRelativeCursorY; this._state.isFocused = false; this._state.style = this._optionsService.options.cursorStyle; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 4fb50ae3..3383a63a 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1177,7 +1177,7 @@ declare module 'xterm' { /** * The x position of the cursor. This ranges between `0` (left side) and - * `Terminal.cols - 1` (right side). + * `Terminal.cols` (behind last cell of the row). */ readonly cursorX: number; From e0ac87e7029f2500147a424faf17a865dc518b05 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 13 Mar 2020 19:17:34 -0700 Subject: [PATCH 4/4] Update xterm.d.ts --- typings/xterm.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 3383a63a..bed7e883 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1177,7 +1177,7 @@ declare module 'xterm' { /** * The x position of the cursor. This ranges between `0` (left side) and - * `Terminal.cols` (behind last cell of the row). + * `Terminal.cols` (after last cell of the row). */ readonly cursorX: number;