From 22e8a2f8e7a8f6886effe22a6fa8705c1b29f6e4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 15 Oct 2022 18:07:05 -0700 Subject: [PATCH] Remove old dimension properties --- addons/xterm-addon-canvas/src/CanvasRenderer.ts | 16 ++-------------- addons/xterm-addon-fit/src/FitAddon.ts | 8 +++++--- addons/xterm-addon-fit/src/tsconfig.json | 12 +++++++++++- addons/xterm-addon-webgl/src/WebglRenderer.ts | 12 ------------ demo/client.ts | 4 ++-- src/browser/AccessibilityManager.ts | 4 ++-- src/browser/Terminal.ts | 16 ++++++++-------- src/browser/Viewport.ts | 4 ++-- .../decorations/BufferDecorationRenderer.ts | 14 +++++++------- src/browser/input/CompositionHelper.ts | 6 +++--- src/browser/input/Mouse.ts | 10 +++++----- src/browser/renderer/dom/DomRenderer.ts | 12 ------------ src/browser/renderer/shared/RendererUtils.ts | 14 +------------- src/browser/renderer/shared/Types.d.ts | 13 ------------- src/browser/services/MouseService.ts | 12 ++++++------ src/browser/services/RenderService.ts | 2 +- src/browser/services/SelectionService.test.ts | 4 ++-- src/browser/services/SelectionService.ts | 2 +- test/api/InputHandler.api.ts | 8 ++++---- test/api/MouseTracking.api.ts | 2 +- test/api/Terminal.api.ts | 2 +- 21 files changed, 64 insertions(+), 113 deletions(-) diff --git a/addons/xterm-addon-canvas/src/CanvasRenderer.ts b/addons/xterm-addon-canvas/src/CanvasRenderer.ts index f8ab3eef..d4563c5c 100644 --- a/addons/xterm-addon-canvas/src/CanvasRenderer.ts +++ b/addons/xterm-addon-canvas/src/CanvasRenderer.ts @@ -87,8 +87,8 @@ export class CanvasRenderer extends Disposable implements IRenderer { } // Resize the screen - this._screenElement.style.width = `${this.dimensions.canvasWidth}px`; - this._screenElement.style.height = `${this.dimensions.canvasHeight}px`; + this._screenElement.style.width = `${this.dimensions.css.canvas.width}px`; + this._screenElement.style.height = `${this.dimensions.css.canvas.height}px`; } public handleCharSizeChanged(): void { @@ -151,29 +151,17 @@ export class CanvasRenderer extends Disposable implements IRenderer { // See the WebGL renderer for an explanation of this section. const dpr = this._coreBrowserService.dpr; - this.dimensions.scaledCharWidth = Math.floor(this._charSizeService.width * dpr); this.dimensions.device.char.width = Math.floor(this._charSizeService.width * dpr); - this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * dpr); this.dimensions.device.char.height = Math.ceil(this._charSizeService.height * dpr); - this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.rawOptions.lineHeight); this.dimensions.device.cell.height = Math.floor(this.dimensions.device.char.height * this._optionsService.rawOptions.lineHeight); - this.dimensions.scaledCharTop = this._optionsService.rawOptions.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2); this.dimensions.device.char.top = this._optionsService.rawOptions.lineHeight === 1 ? 0 : Math.round((this.dimensions.device.cell.height - this.dimensions.device.char.height) / 2); - this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.rawOptions.letterSpacing); this.dimensions.device.cell.width = this.dimensions.device.char.width + Math.round(this._optionsService.rawOptions.letterSpacing); - this.dimensions.scaledCharLeft = Math.floor(this._optionsService.rawOptions.letterSpacing / 2); this.dimensions.device.char.left = Math.floor(this._optionsService.rawOptions.letterSpacing / 2); - this.dimensions.scaledCanvasHeight = this._bufferService.rows * this.dimensions.scaledCellHeight; this.dimensions.device.canvas.height = this._bufferService.rows * this.dimensions.device.cell.height; - this.dimensions.scaledCanvasWidth = this._bufferService.cols * this.dimensions.scaledCellWidth; this.dimensions.device.canvas.width = this._bufferService.cols * this.dimensions.device.cell.width; - this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / dpr); this.dimensions.css.canvas.height = Math.round(this.dimensions.device.canvas.height / dpr); - this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / dpr); this.dimensions.css.canvas.width = Math.round(this.dimensions.device.canvas.width / dpr); - this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows; this.dimensions.css.cell.height = this.dimensions.css.canvas.height / this._bufferService.rows; - this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols; this.dimensions.css.cell.width = this.dimensions.css.canvas.width / this._bufferService.cols; } diff --git a/addons/xterm-addon-fit/src/FitAddon.ts b/addons/xterm-addon-fit/src/FitAddon.ts index 7b9c228f..6b3df6f0 100644 --- a/addons/xterm-addon-fit/src/FitAddon.ts +++ b/addons/xterm-addon-fit/src/FitAddon.ts @@ -4,6 +4,7 @@ */ import { Terminal, ITerminalAddon } from 'xterm'; +import { IRenderDimensions } from 'browser/renderer/shared/Types'; interface ITerminalDimensions { /** @@ -58,8 +59,9 @@ export class FitAddon implements ITerminalAddon { // TODO: Remove reliance on private API const core = (this._terminal as any)._core; + const dims: IRenderDimensions = core._renderService.dimensions; - if (core._renderService.dimensions.actualCellWidth === 0 || core._renderService.dimensions.actualCellHeight === 0) { + if (dims.css.cell.width === 0 || dims.css.cell.height === 0) { return undefined; } @@ -81,8 +83,8 @@ export class FitAddon implements ITerminalAddon { const availableHeight = parentElementHeight - elementPaddingVer; const availableWidth = parentElementWidth - elementPaddingHor - scrollbarWidth; const geometry = { - cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / core._renderService.dimensions.actualCellWidth)), - rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / core._renderService.dimensions.actualCellHeight)) + cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / dims.css.cell.width)), + rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / dims.css.cell.height)) }; return geometry; } diff --git a/addons/xterm-addon-fit/src/tsconfig.json b/addons/xterm-addon-fit/src/tsconfig.json index f3e409d1..3bfbea67 100644 --- a/addons/xterm-addon-fit/src/tsconfig.json +++ b/addons/xterm-addon-fit/src/tsconfig.json @@ -13,10 +13,20 @@ "strict": true, "types": [ "../../../node_modules/@types/mocha" - ] + ], + "paths": { + "browser/*": [ + "../../../src/browser/*" + ] + } }, "include": [ "./**/*", "../../../typings/xterm.d.ts" + ], + "references": [ + { + "path": "../../../src/browser" + } ] } diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 70795dda..7fa3c0aa 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -449,39 +449,31 @@ export class WebglRenderer extends Disposable implements IRenderer { // Calculate the device character width. Width is floored as it must be drawn to an integer grid // in order for the char atlas glyphs to not be blurry. - this.dimensions.scaledCharWidth = Math.floor((this._core as any)._charSizeService.width * this._devicePixelRatio); this.dimensions.device.char.width = Math.floor((this._core as any)._charSizeService.width * this._devicePixelRatio); // Calculate the device character height. Height is ceiled in case devicePixelRatio is a // floating point number in order to ensure there is enough space to draw the character to the // cell. - this.dimensions.scaledCharHeight = Math.ceil((this._core as any)._charSizeService.height * this._devicePixelRatio); this.dimensions.device.char.height = Math.ceil((this._core as any)._charSizeService.height * this._devicePixelRatio); // Calculate the device cell height, if lineHeight is _not_ 1, the resulting value will be // floored since lineHeight can never be lower then 1, this guarentees the device cell height // will always be larger than device char height. - this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight); this.dimensions.device.cell.height = Math.floor(this.dimensions.device.char.height * this._terminal.options.lineHeight); // Calculate the y offset within a cell that glyph should draw at in order for it to be centered // correctly within the cell. - this.dimensions.scaledCharTop = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2); this.dimensions.device.char.top = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.device.cell.height - this.dimensions.device.char.height) / 2); // Calculate the device cell width, taking the letterSpacing into account. - this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing); this.dimensions.device.cell.width = this.dimensions.device.char.width + Math.round(this._terminal.options.letterSpacing); // Calculate the x offset with a cell that text should draw from in order for it to be centered // correctly within the cell. - this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing / 2); this.dimensions.device.char.left = Math.floor(this._terminal.options.letterSpacing / 2); // Recalculate the canvas dimensions, the device dimensions define the actual number of pixel in // the canvas - this.dimensions.scaledCanvasHeight = this._terminal.rows * this.dimensions.scaledCellHeight; - this.dimensions.scaledCanvasWidth = this._terminal.cols * this.dimensions.scaledCellWidth; this.dimensions.device.canvas.height = this._terminal.rows * this.dimensions.device.cell.height; this.dimensions.device.canvas.width = this._terminal.cols * this.dimensions.device.cell.width; @@ -490,8 +482,6 @@ export class WebglRenderer extends Disposable implements IRenderer { // `window.devicePixelRatio` ends up being something like `1.100000023841858` for example, when // it's actually 1.1. Ceiling may causes blurriness as the backing canvas image is 1 pixel too // large for the canvas element size. - this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / this._devicePixelRatio); - this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / this._devicePixelRatio); this.dimensions.css.canvas.height = Math.round(this.dimensions.device.canvas.height / this._devicePixelRatio); this.dimensions.css.canvas.width = Math.round(this.dimensions.device.canvas.width / this._devicePixelRatio); @@ -499,8 +489,6 @@ export class WebglRenderer extends Disposable implements IRenderer { // device pixel canvas value above. CharMeasure.width/height by itself is insufficient when the // page is not at 100% zoom level as CharMeasure is measured in CSS pixels, but the actual char // size on the canvas can differ. - this.dimensions.actualCellHeight = this.dimensions.scaledCellHeight / this._devicePixelRatio; - this.dimensions.actualCellWidth = this.dimensions.scaledCellWidth / this._devicePixelRatio; this.dimensions.css.cell.height = this.dimensions.device.cell.height / this._devicePixelRatio; this.dimensions.css.cell.width = this.dimensions.device.cell.width / this._devicePixelRatio; } diff --git a/demo/client.ts b/demo/client.ts index 44a96eb3..921ee155 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -618,8 +618,8 @@ function addDomListener(element: HTMLElement, type: string, handler: (...args: a function updateTerminalSize(): void { const cols = parseInt((document.getElementById(`opt-cols`) as HTMLInputElement).value, 10); const rows = parseInt((document.getElementById(`opt-rows`) as HTMLInputElement).value, 10); - const width = (cols * term._core._renderService.dimensions.actualCellWidth + term._core.viewport.scrollBarWidth).toString() + 'px'; - const height = (rows * term._core._renderService.dimensions.actualCellHeight).toString() + 'px'; + const width = (cols * term._core._renderService.dimensions.css.cell.width + term._core.viewport.scrollBarWidth).toString() + 'px'; + const height = (rows * term._core._renderService.dimensions.css.cell.height).toString() + 'px'; terminalContainer.style.width = width; terminalContainer.style.height = height; addons.fit.instance.fit(); diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index d0c9f601..3998e779 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -274,7 +274,7 @@ export class AccessibilityManager extends Disposable { } private _refreshRowsDimensions(): void { - if (!this._renderService.dimensions.actualCellHeight) { + if (!this._renderService.dimensions.css.cell.height) { return; } if (this._rowElements.length !== this._terminal.rows) { @@ -286,7 +286,7 @@ export class AccessibilityManager extends Disposable { } private _refreshRowDimensions(element: HTMLElement): void { - element.style.height = `${this._renderService.dimensions.actualCellHeight}px`; + element.style.height = `${this._renderService.dimensions.css.cell.height}px`; } private _announceCharacters(): void { diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index b5262b1e..3c88b948 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -321,11 +321,11 @@ export class Terminal extends CoreTerminal implements ITerminal { return; } const cursorX = Math.min(this.buffer.x, this.cols - 1); - const cellHeight = this._renderService.dimensions.actualCellHeight; + const cellHeight = this._renderService.dimensions.css.cell.height; const width = bufferLine.getWidth(cursorX); - const cellWidth = this._renderService.dimensions.actualCellWidth * width; - const cursorTop = this.buffer.y * this._renderService.dimensions.actualCellHeight; - const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; + const cellWidth = this._renderService.dimensions.css.cell.width * width; + const cursorTop = this.buffer.y * this._renderService.dimensions.css.cell.height; + const cursorLeft = cursorX * this._renderService.dimensions.css.cell.width; // Sync the textarea to the exact position of the composition view so the IME knows where the // text is. @@ -1273,13 +1273,13 @@ export class Terminal extends CoreTerminal implements ITerminal { switch (type) { case WindowsOptionsReportType.GET_WIN_SIZE_PIXELS: - const canvasWidth = this._renderService.dimensions.canvasWidth.toFixed(0); - const canvasHeight = this._renderService.dimensions.canvasHeight.toFixed(0); + const canvasWidth = this._renderService.dimensions.css.canvas.width.toFixed(0); + const canvasHeight = this._renderService.dimensions.css.canvas.height.toFixed(0); this.coreService.triggerDataEvent(`${C0.ESC}[4;${canvasHeight};${canvasWidth}t`); break; case WindowsOptionsReportType.GET_CELL_SIZE_PIXELS: - const cellWidth = this._renderService.dimensions.actualCellWidth.toFixed(0); - const cellHeight = this._renderService.dimensions.actualCellHeight.toFixed(0); + const cellWidth = this._renderService.dimensions.css.cell.width.toFixed(0); + const cellHeight = this._renderService.dimensions.css.cell.height.toFixed(0); this.coreService.triggerDataEvent(`${C0.ESC}[6;${cellHeight};${cellWidth}t`); break; } diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 0ba7c459..8e01f23c 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -107,7 +107,7 @@ export class Viewport extends Disposable implements IViewport { this._currentRowHeight = this._renderService.dimensions.device.cell.height / this._coreBrowserService.dpr; this._currentDeviceCellHeight = this._renderService.dimensions.device.cell.height; this._lastRecordedViewportHeight = this._viewportElement.offsetHeight; - const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.canvasHeight); + const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.css.canvas.height); if (this._lastRecordedBufferHeight !== newBufferHeight) { this._lastRecordedBufferHeight = newBufferHeight; this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px'; @@ -138,7 +138,7 @@ export class Viewport extends Disposable implements IViewport { } // If viewport height changed - if (this._lastRecordedViewportHeight !== this._renderService.dimensions.canvasHeight) { + if (this._lastRecordedViewportHeight !== this._renderService.dimensions.css.canvas.height) { this._refresh(immediate); return; } diff --git a/src/browser/decorations/BufferDecorationRenderer.ts b/src/browser/decorations/BufferDecorationRenderer.ts index 5836e266..72ed6428 100644 --- a/src/browser/decorations/BufferDecorationRenderer.ts +++ b/src/browser/decorations/BufferDecorationRenderer.ts @@ -72,10 +72,10 @@ export class BufferDecorationRenderer extends Disposable { private _createElement(decoration: IInternalDecoration): HTMLElement { const element = document.createElement('div'); element.classList.add('xterm-decoration'); - element.style.width = `${Math.round((decoration.options.width || 1) * this._renderService.dimensions.actualCellWidth)}px`; - element.style.height = `${(decoration.options.height || 1) * this._renderService.dimensions.actualCellHeight}px`; - element.style.top = `${(decoration.marker.line - this._bufferService.buffers.active.ydisp) * this._renderService.dimensions.actualCellHeight}px`; - element.style.lineHeight = `${this._renderService.dimensions.actualCellHeight}px`; + element.style.width = `${Math.round((decoration.options.width || 1) * this._renderService.dimensions.css.cell.width)}px`; + element.style.height = `${(decoration.options.height || 1) * this._renderService.dimensions.css.cell.height}px`; + element.style.top = `${(decoration.marker.line - this._bufferService.buffers.active.ydisp) * this._renderService.dimensions.css.cell.height}px`; + element.style.lineHeight = `${this._renderService.dimensions.css.cell.height}px`; const x = decoration.options.x ?? 0; if (x && x > this._bufferService.cols) { @@ -104,7 +104,7 @@ export class BufferDecorationRenderer extends Disposable { this._decorationElements.set(decoration, element); this._container.appendChild(element); } - element.style.top = `${line * this._renderService.dimensions.actualCellHeight}px`; + element.style.top = `${line * this._renderService.dimensions.css.cell.height}px`; element.style.display = this._altBufferIsActive ? 'none' : 'block'; decoration.onRenderEmitter.fire(element); } @@ -116,9 +116,9 @@ export class BufferDecorationRenderer extends Disposable { } const x = decoration.options.x ?? 0; if ((decoration.options.anchor || 'left') === 'right') { - element.style.right = x ? `${x * this._renderService.dimensions.actualCellWidth}px` : ''; + element.style.right = x ? `${x * this._renderService.dimensions.css.cell.width}px` : ''; } else { - element.style.left = x ? `${x * this._renderService.dimensions.actualCellWidth}px` : ''; + element.style.left = x ? `${x * this._renderService.dimensions.css.cell.width}px` : ''; } } diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index ba7d4b6a..7542969a 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -218,9 +218,9 @@ export class CompositionHelper { if (this._bufferService.buffer.isCursorInViewport) { const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); - const cellHeight = this._renderService.dimensions.actualCellHeight; - const cursorTop = this._bufferService.buffer.y * this._renderService.dimensions.actualCellHeight; - const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; + const cellHeight = this._renderService.dimensions.css.cell.height; + const cursorTop = this._bufferService.buffer.y * this._renderService.dimensions.css.cell.height; + const cursorLeft = cursorX * this._renderService.dimensions.css.cell.width; this._compositionView.style.left = cursorLeft + 'px'; this._compositionView.style.top = cursorTop + 'px'; diff --git a/src/browser/input/Mouse.ts b/src/browser/input/Mouse.ts index 309d9265..c40a7cc7 100644 --- a/src/browser/input/Mouse.ts +++ b/src/browser/input/Mouse.ts @@ -24,13 +24,13 @@ export function getCoordsRelativeToElement(window: Pick, event: Pick, element: HTMLElement, colCount: number, rowCount: number, hasValidCharSize: boolean, actualCellWidth: number, actualCellHeight: number, isSelection?: boolean): [number, number] | undefined { +export function getCoords(window: Pick, event: Pick, element: HTMLElement, colCount: number, rowCount: number, hasValidCharSize: boolean, cssCellWidth: number, cssCellHeight: number, isSelection?: boolean): [number, number] | undefined { // Coordinates cannot be measured if there are no valid if (!hasValidCharSize) { return undefined; @@ -41,8 +41,8 @@ export function getCoords(window: Pick, event: Pick< return undefined; } - coords[0] = Math.ceil((coords[0] + (isSelection ? actualCellWidth / 2 : 0)) / actualCellWidth); - coords[1] = Math.ceil(coords[1] / actualCellHeight); + coords[0] = Math.ceil((coords[0] + (isSelection ? cssCellWidth / 2 : 0)) / cssCellWidth); + coords[1] = Math.ceil(coords[1] / cssCellHeight); // Ensure coordinates are within the terminal viewport. Note that selections // need an addition point of precision to cover the end point (as characters diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index 51e9dc3e..399682ac 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -92,29 +92,17 @@ export class DomRenderer extends Disposable implements IRenderer { private _updateDimensions(): void { const dpr = this._coreBrowserService.dpr; - this.dimensions.scaledCharWidth = this._charSizeService.width * dpr; this.dimensions.device.char.width = this._charSizeService.width * dpr; - this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * dpr); this.dimensions.device.char.height = Math.ceil(this._charSizeService.height * dpr); - this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.rawOptions.letterSpacing); this.dimensions.device.cell.width = this.dimensions.device.char.width + Math.round(this._optionsService.rawOptions.letterSpacing); - this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.rawOptions.lineHeight); this.dimensions.device.cell.height = Math.floor(this.dimensions.device.char.height * this._optionsService.rawOptions.lineHeight); - this.dimensions.scaledCharLeft = 0; this.dimensions.device.char.left = 0; - this.dimensions.scaledCharTop = 0; this.dimensions.device.char.top = 0; - this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._bufferService.cols; this.dimensions.device.canvas.width = this.dimensions.device.cell.width * this._bufferService.cols; - this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._bufferService.rows; this.dimensions.device.canvas.height = this.dimensions.device.cell.height * this._bufferService.rows; - this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / dpr); this.dimensions.css.canvas.width = Math.round(this.dimensions.device.canvas.width / dpr); - this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / dpr); this.dimensions.css.canvas.height = Math.round(this.dimensions.device.canvas.height / dpr); - this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols; this.dimensions.css.cell.width = this.dimensions.css.canvas.width / this._bufferService.cols; - this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows; this.dimensions.css.cell.height = this.dimensions.css.canvas.height / this._bufferService.rows; for (const element of this._rowElements) { diff --git a/src/browser/renderer/shared/RendererUtils.ts b/src/browser/renderer/shared/RendererUtils.ts index 37743277..052f2894 100644 --- a/src/browser/renderer/shared/RendererUtils.ts +++ b/src/browser/renderer/shared/RendererUtils.ts @@ -46,19 +46,7 @@ export function createRenderDimensions(): IRenderDimensions { left: 0, top: 0 } - }, - scaledCharWidth: 0, - scaledCharHeight: 0, - scaledCellWidth: 0, - scaledCellHeight: 0, - scaledCharLeft: 0, - scaledCharTop: 0, - scaledCanvasWidth: 0, - scaledCanvasHeight: 0, - canvasWidth: 0, - canvasHeight: 0, - actualCellWidth: 0, - actualCellHeight: 0 + } }; } diff --git a/src/browser/renderer/shared/Types.d.ts b/src/browser/renderer/shared/Types.d.ts index 1185e4aa..433d48a2 100644 --- a/src/browser/renderer/shared/Types.d.ts +++ b/src/browser/renderer/shared/Types.d.ts @@ -53,19 +53,6 @@ export interface IRenderDimensions { cell: IDimensions; char: IDimensions & IOffset; }; - - /** @deprecated */ scaledCharWidth: number; - /** @deprecated */ scaledCharHeight: number; - /** @deprecated */ scaledCellWidth: number; - /** @deprecated */ scaledCellHeight: number; - /** @deprecated */ scaledCharLeft: number; - /** @deprecated */ scaledCharTop: number; - /** @deprecated */ scaledCanvasWidth: number; - /** @deprecated */ scaledCanvasHeight: number; - /** @deprecated */ canvasWidth: number; - /** @deprecated */ canvasHeight: number; - /** @deprecated */ actualCellWidth: number; - /** @deprecated */ actualCellHeight: number; } export interface IRequestRedrawEvent { diff --git a/src/browser/services/MouseService.ts b/src/browser/services/MouseService.ts index 2f5550c9..38561dfd 100644 --- a/src/browser/services/MouseService.ts +++ b/src/browser/services/MouseService.ts @@ -23,8 +23,8 @@ export class MouseService implements IMouseService { colCount, rowCount, this._charSizeService.hasValidSize, - this._renderService.dimensions.actualCellWidth, - this._renderService.dimensions.actualCellHeight, + this._renderService.dimensions.css.cell.width, + this._renderService.dimensions.css.cell.height, isSelection ); } @@ -37,14 +37,14 @@ export class MouseService implements IMouseService { if (!this._charSizeService.hasValidSize || coords[0] < 0 || coords[1] < 0 - || coords[0] >= this._renderService.dimensions.canvasWidth - || coords[1] >= this._renderService.dimensions.canvasHeight) { + || coords[0] >= this._renderService.dimensions.css.canvas.width + || coords[1] >= this._renderService.dimensions.css.canvas.height) { return undefined; } return { - col: Math.floor(coords[0] / this._renderService.dimensions.actualCellWidth), - row: Math.floor(coords[1] / this._renderService.dimensions.actualCellHeight), + col: Math.floor(coords[0] / this._renderService.dimensions.css.cell.width), + row: Math.floor(coords[1] / this._renderService.dimensions.css.cell.height), x: Math.floor(coords[0]), y: Math.floor(coords[1]) }; diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index 190967db..75ca2867 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -186,7 +186,7 @@ export class RenderService extends Disposable implements IRenderService { return; } // Don't fire the event if the dimensions haven't changed - if (this._renderer.dimensions.canvasWidth === this._canvasWidth && this._renderer.dimensions.canvasHeight === this._canvasHeight) { + if (this._renderer.dimensions.css.canvas.width === this._canvasWidth && this._renderer.dimensions.css.canvas.height === this._canvasHeight) { return; } this._onDimensionsChange.fire(this._renderer.dimensions); diff --git a/src/browser/services/SelectionService.test.ts b/src/browser/services/SelectionService.test.ts index f8a15e51..67158def 100644 --- a/src/browser/services/SelectionService.test.ts +++ b/src/browser/services/SelectionService.test.ts @@ -49,8 +49,8 @@ describe('SelectionService', () => { bufferService = new MockBufferService(20, 20, optionsService); buffer = bufferService.buffer; const renderService = new MockRenderService(); - renderService.dimensions.canvasHeight = 10 * 20; - renderService.dimensions.canvasWidth = 10 * 20; + renderService.dimensions.css.canvas.height = 10 * 20; + renderService.dimensions.css.canvas.width = 10 * 20; selectionService = new TestSelectionService(bufferService, optionsService, renderService); }); diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 763f938b..486c1941 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -408,7 +408,7 @@ export class SelectionService extends Disposable implements ISelectionService { */ private _getMouseEventScrollAmount(event: MouseEvent): number { let offset = getCoordsRelativeToElement(this._coreBrowserService.window, event, this._screenElement)[1]; - const terminalHeight = this._renderService.dimensions.canvasHeight; + const terminalHeight = this._renderService.dimensions.css.canvas.height; if (offset >= 0 && offset <= terminalHeight) { return 0; } diff --git a/test/api/InputHandler.api.ts b/test/api/InputHandler.api.ts index 8192bfed..d83fcb1f 100644 --- a/test/api/InputHandler.api.ts +++ b/test/api/InputHandler.api.ts @@ -601,9 +601,9 @@ async function getCursor(): Promise<{ col: number, row: number }> { async function getDimensions(): Promise { const dim: IRenderDimensions = await page.evaluate(`term._core._renderService.dimensions`); return { - cellWidth: dim.actualCellWidth.toFixed(0), - cellHeight: dim.actualCellHeight.toFixed(0), - width: dim.canvasWidth.toFixed(0), - height: dim.canvasHeight.toFixed(0) + cellWidth: dim.css.cell.width.toFixed(0), + cellHeight: dim.css.cell.height.toFixed(0), + width: dim.css.canvas.width.toFixed(0), + height: dim.css.canvas.height.toFixed(0) }; } diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 1b00fee5..8a64a59a 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -48,7 +48,7 @@ async function cellPos(col: number, row: number): Promise { (function() { const rect = window.term.element.getBoundingClientRect(); const dim = term._core._renderService.dimensions; - return {left: rect.left, top: rect.top, bottom: rect.bottom, right: rect.right, width: dim.actualCellWidth, height: dim.actualCellHeight}; + return {left: rect.left, top: rect.top, bottom: rect.bottom, right: rect.right, width: dim.css.cell.width, height: dim.css.cell.height}; })(); `); return [col * coords.width + coords.left + 2, row * coords.height + coords.top + 2]; diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 8564cbfa..f1edf65c 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -721,7 +721,7 @@ describe('API Integration Tests', function(): void { await page.evaluate(`window.term = new Terminal()`); await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); await page.evaluate(`document.querySelector('#terminal-container').style.display=''`); - await pollFor(page, `window.term._core._renderService.dimensions.actualCellWidth > 0`, true); + await pollFor(page, `window.term._core._renderService.dimensions.css.cell.width > 0`, true); }); describe('registerDecoration', () => {