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
+11 -11
View File
@@ -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: ITerminal, alpha: boolean): void {
protected _setTransparency(terminal: ITerminal, 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: ITerminal, cell: CellData, x: number, y: number): void {
protected _fillCharTrueColor(terminal: ITerminal, 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: ITerminal, cell: ICellData, x: number, y: number): void {
protected _drawChars(terminal: ITerminal, 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
+6 -6
View File
@@ -180,7 +180,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,
@@ -194,30 +194,30 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _renderBarCursor(terminal: ITerminal, 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: ITerminal, 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: ITerminal, 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: ITerminal, 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();
}
}
+7 -7
View File
@@ -31,12 +31,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;
}
}
@@ -53,14 +53,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;
}
+6 -6
View File
@@ -41,7 +41,7 @@ export class SelectionRenderLayer extends BaseRenderLayer {
public reset(terminal: ITerminal): void {
if (this._state.start && this._state.end) {
this._clearState();
this.clearAll();
this._clearAll();
}
}
@@ -52,7 +52,7 @@ export class SelectionRenderLayer extends BaseRenderLayer {
}
// Remove all selections
this.clearAll();
this._clearAll();
// Selection does not exist
if (!start || !end) {
@@ -77,22 +77,22 @@ export class SelectionRenderLayer extends BaseRenderLayer {
const startCol = start[0];
const width = end[0] - startCol;
const height = viewportCappedEndRow - viewportCappedStartRow + 1;
this.fillCells(startCol, viewportCappedStartRow, width, height);
this._fillCells(startCol, viewportCappedStartRow, width, height);
} else {
// Draw first row
const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
const startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;
this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);
this._fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);
// Draw middle rows
const middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);
this.fillCells(0, viewportCappedStartRow + 1, terminal.cols, middleRowsCount);
this._fillCells(0, viewportCappedStartRow + 1, terminal.cols, middleRowsCount);
// Draw final row
if (viewportCappedStartRow !== viewportCappedEndRow) {
// Only draw viewportEndRow if it's not the same as viewportStartRow
const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : terminal.cols;
this.fillCells(0, viewportCappedEndRow, endCol, 1);
this._fillCells(0, viewportCappedEndRow, endCol, 1);
}
}
+8 -8
View File
@@ -52,7 +52,7 @@ export class TextRenderLayer extends BaseRenderLayer {
public reset(terminal: ITerminal): void {
this._state.clear();
this.clearAll();
this._clearAll();
}
private _forEachCell(
@@ -179,13 +179,13 @@ export class TextRenderLayer extends BaseRenderLayer {
} if (y !== startY) {
// our row changed, draw the previous row
ctx.fillStyle = prevFillStyle;
this.fillCells(startX, startY, cols - startX, 1);
this._fillCells(startX, startY, cols - startX, 1);
startX = x;
startY = y;
} else if (prevFillStyle !== nextFillStyle) {
// our color changed, draw the previous characters in this row
ctx.fillStyle = prevFillStyle;
this.fillCells(startX, startY, x - startX, 1);
this._fillCells(startX, startY, x - startX, 1);
startX = x;
startY = y;
}
@@ -196,7 +196,7 @@ export class TextRenderLayer extends BaseRenderLayer {
// flush the last color we encountered
if (prevFillStyle !== null) {
ctx.fillStyle = prevFillStyle;
this.fillCells(startX, startY, cols - startX, 1);
this._fillCells(startX, startY, cols - startX, 1);
}
ctx.restore();
@@ -207,7 +207,7 @@ export class TextRenderLayer extends BaseRenderLayer {
if (cell.isInvisible()) {
return;
}
this.drawChars(terminal, cell, x, y);
this._drawChars(terminal, cell, x, y);
if (cell.isUnderline()) {
this._ctx.save();
@@ -233,7 +233,7 @@ export class TextRenderLayer extends BaseRenderLayer {
}
}
this.fillBottomLineAtCells(x, y, cell.getWidth());
this._fillBottomLineAtCells(x, y, cell.getWidth());
this._ctx.restore();
}
});
@@ -249,13 +249,13 @@ export class TextRenderLayer extends BaseRenderLayer {
this._charAtlas.beginFrame();
}
this.clearCells(0, firstRow, terminal.cols, lastRow - firstRow + 1);
this._clearCells(0, firstRow, terminal.cols, lastRow - firstRow + 1);
this._drawBackground(terminal, firstRow, lastRow);
this._drawForeground(terminal, firstRow, lastRow);
}
public onOptionsChanged(terminal: ITerminal): void {
this.setTransparency(terminal, terminal.options.allowTransparency);
this._setTransparency(terminal, terminal.options.allowTransparency);
}
/**