Enforce underscore prefix for protected members

This commit is contained in:
Daniel Imms
2019-06-27 18:36:44 -07:00
parent 73521390d2
commit 10fedf4ccf
12 changed files with 75 additions and 77 deletions
@@ -66,7 +66,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._ctx = this._canvas.getContext('2d', {alpha: this._alpha});
// Draw the background if this is an opaque layer
if (!this._alpha) {
this.clearAll();
this._clearAll();
}
}
@@ -81,7 +81,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._refreshCharAtlas(terminal, colorSet);
}
protected setTransparency(terminal: Terminal, alpha: boolean): void {
protected _setTransparency(terminal: Terminal, alpha: boolean): void {
// Do nothing when alpha doesn't change
if (alpha === this._alpha) {
return;
@@ -127,7 +127,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
// Draw the background if this is an opaque layer
if (!this._alpha) {
this.clearAll();
this._clearAll();
}
this._refreshCharAtlas(terminal, this._colors);
@@ -142,7 +142,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to fill.
* @param height The number of rows to fill.
*/
protected fillCells(x: number, y: number, width: number, height: number): void {
protected _fillCells(x: number, y: number, width: number, height: number): void {
this._ctx.fillRect(
x * this._scaledCellWidth,
y * this._scaledCellHeight,
@@ -156,7 +156,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill.
* @param y The row to fill.
*/
protected fillBottomLineAtCells(x: number, y: number, width: number = 1): void {
protected _fillBottomLineAtCells(x: number, y: number, width: number = 1): void {
this._ctx.fillRect(
x * this._scaledCellWidth,
(y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */,
@@ -170,7 +170,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill.
* @param y The row to fill.
*/
protected fillLeftLineAtCell(x: number, y: number): void {
protected _fillLeftLineAtCell(x: number, y: number): void {
this._ctx.fillRect(
x * this._scaledCellWidth,
y * this._scaledCellHeight,
@@ -184,7 +184,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill.
* @param y The row to fill.
*/
protected strokeRectAtCell(x: number, y: number, width: number, height: number): void {
protected _strokeRectAtCell(x: number, y: number, width: number, height: number): void {
this._ctx.lineWidth = window.devicePixelRatio;
this._ctx.strokeRect(
x * this._scaledCellWidth + window.devicePixelRatio / 2,
@@ -196,7 +196,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
/**
* Clears the entire canvas.
*/
protected clearAll(): void {
protected _clearAll(): void {
if (this._alpha) {
this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
} else {
@@ -212,7 +212,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to clear.
* @param height The number of rows to clear.
*/
protected clearCells(x: number, y: number, width: number, height: number): void {
protected _clearCells(x: number, y: number, width: number, height: number): void {
if (this._alpha) {
this._ctx.clearRect(
x * this._scaledCellWidth,
@@ -239,7 +239,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param y The row to draw at.
* @param color The color of the character.
*/
protected fillCharTrueColor(terminal: Terminal, cell: CellData, x: number, y: number): void {
protected _fillCharTrueColor(terminal: Terminal, cell: CellData, x: number, y: number): void {
this._ctx.font = this._getFont(terminal, false, false);
this._ctx.textBaseline = 'middle';
this._clipRow(terminal, y);
@@ -263,7 +263,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* This is used to validate whether a cached image can be used.
* @param bold Whether the text is bold.
*/
protected drawChars(terminal: Terminal, cell: ICellData, x: number, y: number): void {
protected _drawChars(terminal: Terminal, cell: ICellData, x: number, y: number): void {
// skip cache right away if we draw in RGB
// Note: to avoid bad runtime JoinedCellData will be skipped
@@ -182,7 +182,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _clearCursor(): void {
if (this._state) {
this.clearCells(this._state.x, this._state.y, this._state.width, 1);
this._clearCells(this._state.x, this._state.y, this._state.width, 1);
this._state = {
x: null,
y: null,
@@ -196,30 +196,30 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _renderBarCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css;
this.fillLeftLineAtCell(x, y);
this._fillLeftLineAtCell(x, y);
this._ctx.restore();
}
private _renderBlockCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css;
this.fillCells(x, y, cell.getWidth(), 1);
this._fillCells(x, y, cell.getWidth(), 1);
this._ctx.fillStyle = this._colors.cursorAccent.css;
this.fillCharTrueColor(terminal, cell, x, y);
this._fillCharTrueColor(terminal, cell, x, y);
this._ctx.restore();
}
private _renderUnderlineCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css;
this.fillBottomLineAtCells(x, y);
this._fillBottomLineAtCells(x, y);
this._ctx.restore();
}
private _renderBlurCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.strokeStyle = this._colors.cursor.css;
this.strokeRectAtCell(x, y, cell.getWidth(), 1);
this._strokeRectAtCell(x, y, cell.getWidth(), 1);
this._ctx.restore();
}
}
@@ -32,12 +32,12 @@ export class LinkRenderLayer extends BaseRenderLayer {
private _clearCurrentLink(): void {
if (this._state) {
this.clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
this._clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
const middleRowCount = this._state.y2 - this._state.y1 - 1;
if (middleRowCount > 0) {
this.clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
this._clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
}
this.clearCells(0, this._state.y2, this._state.x2, 1);
this._clearCells(0, this._state.y2, this._state.x2, 1);
this._state = null;
}
}
@@ -54,14 +54,14 @@ export class LinkRenderLayer extends BaseRenderLayer {
if (e.y1 === e.y2) {
// Single line link
this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
} else {
// Multi-line link
this.fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
this._fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
for (let y = e.y1 + 1; y < e.y2; y++) {
this.fillBottomLineAtCells(0, y, e.cols);
this._fillBottomLineAtCells(0, y, e.cols);
}
this.fillBottomLineAtCells(0, e.y2, e.x2);
this._fillBottomLineAtCells(0, e.y2, e.x2);
}
this._state = e;
}