From 0b54df14e2cda3f1c160e8031e8238fe3a81d1c7 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 20 Sep 2017 12:16:27 +0900 Subject: [PATCH 1/2] Remove unnecessary rounding --- src/renderer/BaseRenderLayer.ts | 40 +++++++++++---------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index 8f655de5..16de826e 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -88,16 +88,6 @@ export abstract class BaseRenderLayer implements IRenderLayer { public abstract reset(terminal: ITerminal): void; - /** - * Gets the left position of a cell. Since character width is stored as a - * float in order to prevent bad letter spacing, drawing shapes in the cell - * need to be rounded. - * @param x The column of the cell. - */ - private _getCellLeft(x: number): number { - return Math.round(x * this._scaledCharWidth); - } - /** * Fills 1+ cells completely. This uses the existing fillStyle on the context. * @param x The column to start at. @@ -106,12 +96,11 @@ export abstract class BaseRenderLayer implements IRenderLayer { * @param height The number of rows to fill. */ protected fillCells(x: number, y: number, width: number, height: number): void { - const cellLeft = this._getCellLeft(x); this._ctx.fillRect( - cellLeft, - y * this._scaledLineHeight, - this._getCellLeft(x + width) - cellLeft, - height * this._scaledLineHeight); + x * this._scaledCharWidth, + y * this._scaledLineHeight, + width * this._scaledCharWidth, + height * this._scaledLineHeight); } /** @@ -121,11 +110,10 @@ export abstract class BaseRenderLayer implements IRenderLayer { * @param y The row to fill. */ protected fillBottomLineAtCells(x: number, y: number, width: number = 1): void { - const cellLeft = this._getCellLeft(x); this._ctx.fillRect( - cellLeft, + x * this._scaledCharWidth, (y + 1) * this._scaledLineHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */, - this._getCellLeft(x + width) - cellLeft, + width * this._scaledCharWidth, window.devicePixelRatio); } @@ -137,7 +125,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { */ protected fillLeftLineAtCell(x: number, y: number): void { this._ctx.fillRect( - this._getCellLeft(x), + x * this._scaledCharWidth, y * this._scaledLineHeight, window.devicePixelRatio, this._scaledLineHeight); @@ -150,12 +138,11 @@ export abstract class BaseRenderLayer implements IRenderLayer { * @param y The row to fill. */ protected strokeRectAtCell(x: number, y: number, width: number, height: number): void { - const cellLeft = this._getCellLeft(x); this._ctx.lineWidth = window.devicePixelRatio; this._ctx.strokeRect( - cellLeft + window.devicePixelRatio / 2, + x * this._scaledCharWidth + window.devicePixelRatio / 2, y * this._scaledLineHeight + (window.devicePixelRatio / 2), - this._getCellLeft(x + width) - cellLeft - window.devicePixelRatio, + width * this._scaledCharWidth - window.devicePixelRatio, (height * this._scaledLineHeight) - window.devicePixelRatio); } @@ -179,19 +166,18 @@ export abstract class BaseRenderLayer implements IRenderLayer { * @param height The number of rows to clear. */ protected clearCells(x: number, y: number, width: number, height: number): void { - const cellLeft = this._getCellLeft(x); if (this._alpha) { this._ctx.clearRect( - cellLeft, + x * this._scaledCharWidth, y * this._scaledLineHeight, - this._getCellLeft(x + width) - cellLeft, + width * this._scaledCharWidth, height * this._scaledLineHeight); } else { this._ctx.fillStyle = this._colors.background; this._ctx.fillRect( - cellLeft, + x * this._scaledCharWidth, y * this._scaledLineHeight, - this._getCellLeft(x + width) - cellLeft, + width * this._scaledCharWidth, height * this._scaledLineHeight); } } From 8243eef67ca6bc81a77d76b95cc4fd78d3ba8e6d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 20 Sep 2017 12:54:20 +0900 Subject: [PATCH 2/2] Properly clear links MouzeZoneManager rows are not 0-based Fixes #990 --- src/input/MouseZoneManager.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/input/MouseZoneManager.ts b/src/input/MouseZoneManager.ts index c7feed2a..026e79c2 100644 --- a/src/input/MouseZoneManager.ts +++ b/src/input/MouseZoneManager.ts @@ -50,10 +50,16 @@ export class MouseZoneManager implements IMouseZoneManager { return; } + // Clear all if start/end weren't set + if (!end) { + start = 0; + end = this._terminal.rows - 1; + } + // Iterate through zones and clear them out if they're within the range for (let i = 0; i < this._zones.length; i++) { const zone = this._zones[i]; - if (zone.y >= start && zone.y <= end) { + if (zone.y > start && zone.y <= end + 1) { if (this._currentZone && this._currentZone === zone) { this._currentZone.leaveCallback(); this._currentZone = null;