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;