Merge branch 'master' into parser_colon_notation

This commit is contained in:
Daniel Imms
2019-06-29 13:54:02 -07:00
committed by GitHub
18 changed files with 103 additions and 85 deletions
+1
View File
@@ -3,6 +3,7 @@ node_modules/
.lock-wscript .lock-wscript
lib/ lib/
out/ out/
out-test/
Makefile.gyp Makefile.gyp
*.Makefile *.Makefile
*.target.gyp.mk *.target.gyp.mk
+4
View File
@@ -6,6 +6,9 @@
!*.js !*.js
!*.json !*.json
# Whitelist - css/
!css/**/*.css
# Whitelist - dist/ # Whitelist - dist/
!dist/**/*.js !dist/**/*.js
!dist/**/*.js.map !dist/**/*.js.map
@@ -33,6 +36,7 @@
!typings/*.d.ts !typings/*.d.ts
# Blacklist - (normal behavior) these will override any whitelist # Blacklist - (normal behavior) these will override any whitelist
*.d.ts.map
*.test.ts *.test.ts
*.test.d.ts *.test.d.ts
*.test.js *.test.js
@@ -66,7 +66,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._ctx = this._canvas.getContext('2d', {alpha: this._alpha}); this._ctx = this._canvas.getContext('2d', {alpha: this._alpha});
// Draw the background if this is an opaque layer // Draw the background if this is an opaque layer
if (!this._alpha) { if (!this._alpha) {
this.clearAll(); this._clearAll();
} }
} }
@@ -81,7 +81,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._refreshCharAtlas(terminal, colorSet); 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 // Do nothing when alpha doesn't change
if (alpha === this._alpha) { if (alpha === this._alpha) {
return; return;
@@ -127,7 +127,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
// Draw the background if this is an opaque layer // Draw the background if this is an opaque layer
if (!this._alpha) { if (!this._alpha) {
this.clearAll(); this._clearAll();
} }
this._refreshCharAtlas(terminal, this._colors); this._refreshCharAtlas(terminal, this._colors);
@@ -142,7 +142,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to fill. * @param width The number of columns to fill.
* @param height The number of rows 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( this._ctx.fillRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
y * this._scaledCellHeight, y * this._scaledCellHeight,
@@ -156,7 +156,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill. * @param x The column to fill.
* @param y The row 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( this._ctx.fillRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
(y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */, (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 x The column to fill.
* @param y The row 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( this._ctx.fillRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
y * this._scaledCellHeight, y * this._scaledCellHeight,
@@ -184,7 +184,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill. * @param x The column to fill.
* @param y The row 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.lineWidth = window.devicePixelRatio;
this._ctx.strokeRect( this._ctx.strokeRect(
x * this._scaledCellWidth + window.devicePixelRatio / 2, x * this._scaledCellWidth + window.devicePixelRatio / 2,
@@ -196,7 +196,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
/** /**
* Clears the entire canvas. * Clears the entire canvas.
*/ */
protected clearAll(): void { protected _clearAll(): void {
if (this._alpha) { if (this._alpha) {
this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height); this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
} else { } else {
@@ -212,7 +212,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to clear. * @param width The number of columns to clear.
* @param height The number of rows 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) { if (this._alpha) {
this._ctx.clearRect( this._ctx.clearRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
@@ -239,7 +239,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param y The row to draw at. * @param y The row to draw at.
* @param color The color of the character. * @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.font = this._getFont(terminal, false, false);
this._ctx.textBaseline = 'middle'; this._ctx.textBaseline = 'middle';
this._clipRow(terminal, y); 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. * This is used to validate whether a cached image can be used.
* @param bold Whether the text is bold. * @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 // skip cache right away if we draw in RGB
// Note: to avoid bad runtime JoinedCellData will be skipped // Note: to avoid bad runtime JoinedCellData will be skipped
@@ -182,7 +182,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _clearCursor(): void { private _clearCursor(): void {
if (this._state) { 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 = { this._state = {
x: null, x: null,
y: null, y: null,
@@ -196,30 +196,30 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _renderBarCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void { private _renderBarCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; this._ctx.fillStyle = this._colors.cursor.css;
this.fillLeftLineAtCell(x, y); this._fillLeftLineAtCell(x, y);
this._ctx.restore(); this._ctx.restore();
} }
private _renderBlockCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void { private _renderBlockCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; 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._ctx.fillStyle = this._colors.cursorAccent.css;
this.fillCharTrueColor(terminal, cell, x, y); this._fillCharTrueColor(terminal, cell, x, y);
this._ctx.restore(); this._ctx.restore();
} }
private _renderUnderlineCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void { private _renderUnderlineCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; this._ctx.fillStyle = this._colors.cursor.css;
this.fillBottomLineAtCells(x, y); this._fillBottomLineAtCells(x, y);
this._ctx.restore(); this._ctx.restore();
} }
private _renderBlurCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void { private _renderBlurCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.strokeStyle = this._colors.cursor.css; this._ctx.strokeStyle = this._colors.cursor.css;
this.strokeRectAtCell(x, y, cell.getWidth(), 1); this._strokeRectAtCell(x, y, cell.getWidth(), 1);
this._ctx.restore(); this._ctx.restore();
} }
} }
@@ -32,12 +32,12 @@ export class LinkRenderLayer extends BaseRenderLayer {
private _clearCurrentLink(): void { private _clearCurrentLink(): void {
if (this._state) { 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; const middleRowCount = this._state.y2 - this._state.y1 - 1;
if (middleRowCount > 0) { 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; this._state = null;
} }
} }
@@ -54,14 +54,14 @@ export class LinkRenderLayer extends BaseRenderLayer {
if (e.y1 === e.y2) { if (e.y1 === e.y2) {
// Single line link // Single line link
this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1); this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
} else { } else {
// Multi-line link // 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++) { 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; this._state = e;
} }
+3 -3
View File
@@ -55,7 +55,7 @@
* The z-index of the helpers must be higher than the canvases in order for * The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top. * IMEs to appear on top.
*/ */
z-index: 10; z-index: 5;
} }
.xterm .xterm-helper-textarea { .xterm .xterm-helper-textarea {
@@ -69,7 +69,7 @@
top: 0; top: 0;
width: 0; width: 0;
height: 0; height: 0;
z-index: -10; z-index: -5;
/** Prevent wrapping so the IME appears against the textarea at the correct position */ /** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
@@ -150,7 +150,7 @@
top: 0; top: 0;
bottom: 0; bottom: 0;
right: 0; right: 0;
z-index: 100; z-index: 10;
color: transparent; color: transparent;
} }
+1 -1
View File
@@ -15,7 +15,7 @@ import { CellData } from 'common/buffer/CellData';
class TestLinkifier extends Linkifier { class TestLinkifier extends Linkifier {
constructor(terminal: ITerminal) { constructor(terminal: ITerminal) {
super(terminal); super(terminal);
(<any>Linkifier).TIME_BEFORE_LINKIFY = 0; Linkifier._timeBeforeLatency = 0;
} }
public get linkMatchers(): ILinkMatcher[] { return this._linkMatchers; } public get linkMatchers(): ILinkMatcher[] { return this._linkMatchers; }
+10 -10
View File
@@ -9,6 +9,13 @@ import { MouseZone } from './MouseZoneManager';
import { getStringCellWidth } from 'common/CharWidth'; import { getStringCellWidth } from 'common/CharWidth';
import { EventEmitter, IEvent } from 'common/EventEmitter'; import { EventEmitter, IEvent } from 'common/EventEmitter';
/**
* Limit of the unwrapping line expansion (overscan) at the top and bottom
* of the actual viewport in ASCII characters.
* A limit of 2000 should match most sane urls.
*/
const OVERSCAN_CHAR_LIMIT = 2000;
/** /**
* The Linkifier applies links to rows shortly after they have been refreshed. * The Linkifier applies links to rows shortly after they have been refreshed.
*/ */
@@ -18,14 +25,7 @@ export class Linkifier implements ILinkifier {
* the costly operation of searching every row multiple times, potentially a * the costly operation of searching every row multiple times, potentially a
* huge amount of times. * huge amount of times.
*/ */
protected static readonly TIME_BEFORE_LINKIFY = 200; protected static _timeBeforeLatency = 200;
/**
* Limit of the unwrapping line expansion (overscan) at the top and bottom
* of the actual viewport in ASCII characters.
* A limit of 2000 should match most sane urls.
*/
protected static readonly OVERSCAN_CHAR_LIMIT = 2000;
protected _linkMatchers: ILinkMatcher[] = []; protected _linkMatchers: ILinkMatcher[] = [];
@@ -85,7 +85,7 @@ export class Linkifier implements ILinkifier {
if (this._rowsTimeoutId) { if (this._rowsTimeoutId) {
clearTimeout(this._rowsTimeoutId); clearTimeout(this._rowsTimeoutId);
} }
this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier.TIME_BEFORE_LINKIFY); this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency);
} }
/** /**
@@ -114,7 +114,7 @@ export class Linkifier implements ILinkifier {
// the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom. // the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom.
// This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT // This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT
// chars will not match anymore at the viewport borders. // chars will not match anymore at the viewport borders.
const overscanLineLimit = Math.ceil(Linkifier.OVERSCAN_CHAR_LIMIT / this._terminal.cols); const overscanLineLimit = Math.ceil(OVERSCAN_CHAR_LIMIT / this._terminal.cols);
const iterator = this._terminal.buffer.iterator( const iterator = this._terminal.buffer.iterator(
false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit); false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
while (iterator.hasNext()) { while (iterator.hasNext()) {
+2 -4
View File
@@ -22,9 +22,7 @@ export function applyWindowsMode(terminal: ITerminal): IDisposable {
const line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1); const line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);
const lastChar = line.get(terminal.cols - 1); const lastChar = line.get(terminal.cols - 1);
if (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE) { const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y); nextLine.isWrapped = (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE);
nextLine.isWrapped = true;
}
}); });
} }
+16
View File
@@ -44,6 +44,7 @@ export class Terminal implements ITerminalApi {
this._core.focus(); this._core.focus();
} }
public resize(columns: number, rows: number): void { public resize(columns: number, rows: number): void {
this._verifyIntegers(columns, rows);
this._core.resize(columns, rows); this._core.resize(columns, rows);
} }
public writeln(data: string): void { public writeln(data: string): void {
@@ -74,12 +75,14 @@ export class Terminal implements ITerminalApi {
this._core.deregisterCharacterJoiner(joinerId); this._core.deregisterCharacterJoiner(joinerId);
} }
public addMarker(cursorYOffset: number): IMarker { public addMarker(cursorYOffset: number): IMarker {
this._verifyIntegers(cursorYOffset);
return this._core.addMarker(cursorYOffset); return this._core.addMarker(cursorYOffset);
} }
public hasSelection(): boolean { public hasSelection(): boolean {
return this._core.hasSelection(); return this._core.hasSelection();
} }
public select(column: number, row: number, length: number): void { public select(column: number, row: number, length: number): void {
this._verifyIntegers(column, row, length);
this._core.select(column, row, length); this._core.select(column, row, length);
} }
public getSelection(): string { public getSelection(): string {
@@ -95,6 +98,7 @@ export class Terminal implements ITerminalApi {
this._core.selectAll(); this._core.selectAll();
} }
public selectLines(start: number, end: number): void { public selectLines(start: number, end: number): void {
this._verifyIntegers(start, end);
this._core.selectLines(start, end); this._core.selectLines(start, end);
} }
public dispose(): void { public dispose(): void {
@@ -102,9 +106,11 @@ export class Terminal implements ITerminalApi {
this._core.dispose(); this._core.dispose();
} }
public scrollLines(amount: number): void { public scrollLines(amount: number): void {
this._verifyIntegers(amount);
this._core.scrollLines(amount); this._core.scrollLines(amount);
} }
public scrollPages(pageCount: number): void { public scrollPages(pageCount: number): void {
this._verifyIntegers(pageCount);
this._core.scrollPages(pageCount); this._core.scrollPages(pageCount);
} }
public scrollToTop(): void { public scrollToTop(): void {
@@ -114,6 +120,7 @@ export class Terminal implements ITerminalApi {
this._core.scrollToBottom(); this._core.scrollToBottom();
} }
public scrollToLine(line: number): void { public scrollToLine(line: number): void {
this._verifyIntegers(line);
this._core.scrollToLine(line); this._core.scrollToLine(line);
} }
public clear(): void { public clear(): void {
@@ -149,6 +156,7 @@ export class Terminal implements ITerminalApi {
this._core.optionsService.setOption(key, value); this._core.optionsService.setOption(key, value);
} }
public refresh(start: number, end: number): void { public refresh(start: number, end: number): void {
this._verifyIntegers(start, end);
this._core.refresh(start, end); this._core.refresh(start, end);
} }
public reset(): void { public reset(): void {
@@ -163,6 +171,14 @@ export class Terminal implements ITerminalApi {
public static get strings(): ILocalizableStrings { public static get strings(): ILocalizableStrings {
return Strings; return Strings;
} }
private _verifyIntegers(...values: number[]): void {
values.forEach(value => {
if (value % 1 !== 0) {
throw new Error('This API does not accept floating point numbers');
}
});
}
} }
class BufferApiView implements IBufferApi { class BufferApiView implements IBufferApi {
+11 -11
View File
@@ -66,7 +66,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._ctx = this._canvas.getContext('2d', {alpha: this._alpha}); this._ctx = this._canvas.getContext('2d', {alpha: this._alpha});
// Draw the background if this is an opaque layer // Draw the background if this is an opaque layer
if (!this._alpha) { if (!this._alpha) {
this.clearAll(); this._clearAll();
} }
} }
@@ -81,7 +81,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._refreshCharAtlas(terminal, colorSet); 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 // Do nothing when alpha doesn't change
if (alpha === this._alpha) { if (alpha === this._alpha) {
return; return;
@@ -127,7 +127,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
// Draw the background if this is an opaque layer // Draw the background if this is an opaque layer
if (!this._alpha) { if (!this._alpha) {
this.clearAll(); this._clearAll();
} }
this._refreshCharAtlas(terminal, this._colors); this._refreshCharAtlas(terminal, this._colors);
@@ -142,7 +142,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to fill. * @param width The number of columns to fill.
* @param height The number of rows 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( this._ctx.fillRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
y * this._scaledCellHeight, y * this._scaledCellHeight,
@@ -156,7 +156,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill. * @param x The column to fill.
* @param y The row 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( this._ctx.fillRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
(y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */, (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 x The column to fill.
* @param y The row 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( this._ctx.fillRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
y * this._scaledCellHeight, y * this._scaledCellHeight,
@@ -184,7 +184,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill. * @param x The column to fill.
* @param y The row 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.lineWidth = window.devicePixelRatio;
this._ctx.strokeRect( this._ctx.strokeRect(
x * this._scaledCellWidth + window.devicePixelRatio / 2, x * this._scaledCellWidth + window.devicePixelRatio / 2,
@@ -196,7 +196,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
/** /**
* Clears the entire canvas. * Clears the entire canvas.
*/ */
protected clearAll(): void { protected _clearAll(): void {
if (this._alpha) { if (this._alpha) {
this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height); this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
} else { } else {
@@ -212,7 +212,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to clear. * @param width The number of columns to clear.
* @param height The number of rows 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) { if (this._alpha) {
this._ctx.clearRect( this._ctx.clearRect(
x * this._scaledCellWidth, x * this._scaledCellWidth,
@@ -239,7 +239,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param y The row to draw at. * @param y The row to draw at.
* @param color The color of the character. * @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.font = this._getFont(terminal, false, false);
this._ctx.textBaseline = 'middle'; this._ctx.textBaseline = 'middle';
this._clipRow(terminal, y); 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. * This is used to validate whether a cached image can be used.
* @param bold Whether the text is bold. * @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 // skip cache right away if we draw in RGB
// Note: to avoid bad runtime JoinedCellData will be skipped // 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 { private _clearCursor(): void {
if (this._state) { 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 = { this._state = {
x: null, x: null,
y: null, y: null,
@@ -194,30 +194,30 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _renderBarCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void { private _renderBarCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; this._ctx.fillStyle = this._colors.cursor.css;
this.fillLeftLineAtCell(x, y); this._fillLeftLineAtCell(x, y);
this._ctx.restore(); this._ctx.restore();
} }
private _renderBlockCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void { private _renderBlockCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; 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._ctx.fillStyle = this._colors.cursorAccent.css;
this.fillCharTrueColor(terminal, cell, x, y); this._fillCharTrueColor(terminal, cell, x, y);
this._ctx.restore(); this._ctx.restore();
} }
private _renderUnderlineCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void { private _renderUnderlineCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; this._ctx.fillStyle = this._colors.cursor.css;
this.fillBottomLineAtCells(x, y); this._fillBottomLineAtCells(x, y);
this._ctx.restore(); this._ctx.restore();
} }
private _renderBlurCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void { private _renderBlurCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.strokeStyle = this._colors.cursor.css; this._ctx.strokeStyle = this._colors.cursor.css;
this.strokeRectAtCell(x, y, cell.getWidth(), 1); this._strokeRectAtCell(x, y, cell.getWidth(), 1);
this._ctx.restore(); this._ctx.restore();
} }
} }
+7 -7
View File
@@ -31,12 +31,12 @@ export class LinkRenderLayer extends BaseRenderLayer {
private _clearCurrentLink(): void { private _clearCurrentLink(): void {
if (this._state) { 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; const middleRowCount = this._state.y2 - this._state.y1 - 1;
if (middleRowCount > 0) { 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; this._state = null;
} }
} }
@@ -53,14 +53,14 @@ export class LinkRenderLayer extends BaseRenderLayer {
if (e.y1 === e.y2) { if (e.y1 === e.y2) {
// Single line link // Single line link
this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1); this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
} else { } else {
// Multi-line link // 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++) { 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; this._state = e;
} }
+6 -6
View File
@@ -41,7 +41,7 @@ export class SelectionRenderLayer extends BaseRenderLayer {
public reset(terminal: ITerminal): void { public reset(terminal: ITerminal): void {
if (this._state.start && this._state.end) { if (this._state.start && this._state.end) {
this._clearState(); this._clearState();
this.clearAll(); this._clearAll();
} }
} }
@@ -52,7 +52,7 @@ export class SelectionRenderLayer extends BaseRenderLayer {
} }
// Remove all selections // Remove all selections
this.clearAll(); this._clearAll();
// Selection does not exist // Selection does not exist
if (!start || !end) { if (!start || !end) {
@@ -77,22 +77,22 @@ export class SelectionRenderLayer extends BaseRenderLayer {
const startCol = start[0]; const startCol = start[0];
const width = end[0] - startCol; const width = end[0] - startCol;
const height = viewportCappedEndRow - viewportCappedStartRow + 1; const height = viewportCappedEndRow - viewportCappedStartRow + 1;
this.fillCells(startCol, viewportCappedStartRow, width, height); this._fillCells(startCol, viewportCappedStartRow, width, height);
} else { } else {
// Draw first row // Draw first row
const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0; const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
const startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols; 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 // Draw middle rows
const middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0); 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 // Draw final row
if (viewportCappedStartRow !== viewportCappedEndRow) { if (viewportCappedStartRow !== viewportCappedEndRow) {
// Only draw viewportEndRow if it's not the same as viewportStartRow // Only draw viewportEndRow if it's not the same as viewportStartRow
const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : terminal.cols; 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 { public reset(terminal: ITerminal): void {
this._state.clear(); this._state.clear();
this.clearAll(); this._clearAll();
} }
private _forEachCell( private _forEachCell(
@@ -179,13 +179,13 @@ export class TextRenderLayer extends BaseRenderLayer {
} if (y !== startY) { } if (y !== startY) {
// our row changed, draw the previous row // our row changed, draw the previous row
ctx.fillStyle = prevFillStyle; ctx.fillStyle = prevFillStyle;
this.fillCells(startX, startY, cols - startX, 1); this._fillCells(startX, startY, cols - startX, 1);
startX = x; startX = x;
startY = y; startY = y;
} else if (prevFillStyle !== nextFillStyle) { } else if (prevFillStyle !== nextFillStyle) {
// our color changed, draw the previous characters in this row // our color changed, draw the previous characters in this row
ctx.fillStyle = prevFillStyle; ctx.fillStyle = prevFillStyle;
this.fillCells(startX, startY, x - startX, 1); this._fillCells(startX, startY, x - startX, 1);
startX = x; startX = x;
startY = y; startY = y;
} }
@@ -196,7 +196,7 @@ export class TextRenderLayer extends BaseRenderLayer {
// flush the last color we encountered // flush the last color we encountered
if (prevFillStyle !== null) { if (prevFillStyle !== null) {
ctx.fillStyle = prevFillStyle; ctx.fillStyle = prevFillStyle;
this.fillCells(startX, startY, cols - startX, 1); this._fillCells(startX, startY, cols - startX, 1);
} }
ctx.restore(); ctx.restore();
@@ -207,7 +207,7 @@ export class TextRenderLayer extends BaseRenderLayer {
if (cell.isInvisible()) { if (cell.isInvisible()) {
return; return;
} }
this.drawChars(terminal, cell, x, y); this._drawChars(terminal, cell, x, y);
if (cell.isUnderline()) { if (cell.isUnderline()) {
this._ctx.save(); 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(); this._ctx.restore();
} }
}); });
@@ -249,13 +249,13 @@ export class TextRenderLayer extends BaseRenderLayer {
this._charAtlas.beginFrame(); 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._drawBackground(terminal, firstRow, lastRow);
this._drawForeground(terminal, firstRow, lastRow); this._drawForeground(terminal, firstRow, lastRow);
} }
public onOptionsChanged(terminal: ITerminal): void { public onOptionsChanged(terminal: ITerminal): void {
this.setTransparency(terminal, terminal.options.allowTransparency); this._setTransparency(terminal, terminal.options.allowTransparency);
} }
/** /**
+2 -1
View File
@@ -2,6 +2,7 @@
"extends": "./tsconfig-base.json", "extends": "./tsconfig-base.json",
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"strict": true "strict": true,
"declarationMap": true
} }
} }
+1 -3
View File
@@ -96,9 +96,7 @@
{"type": "type", "format": "PascalCase"}, {"type": "type", "format": "PascalCase"},
{"type": "class", "format": "PascalCase"}, {"type": "class", "format": "PascalCase"},
{"type": "property", "modifiers": ["const"], "format": ["camelCase", "UPPER_CASE"]}, {"type": "property", "modifiers": ["const"], "format": ["camelCase", "UPPER_CASE"]},
{"type": "member", "modifiers": ["protected"], "format": "camelCase", "leadingUnderscore": "allow"}, {"type": "member", "modifiers": ["protected"], "format": "camelCase", "leadingUnderscore": "require"},
// TODO: Change allow to require when there aren't many PRs out
// {"type": "member", "modifiers": ["protected"], "format": "camelCase", "leadingUnderscore": "require"},
{"type": "member", "modifiers": ["private"], "format": "camelCase", "leadingUnderscore": "require"}, {"type": "member", "modifiers": ["private"], "format": "camelCase", "leadingUnderscore": "require"},
{"type": "variable", "modifiers": ["const"], "format": ["camelCase", "UPPER_CASE"]}, {"type": "variable", "modifiers": ["const"], "format": ["camelCase", "UPPER_CASE"]},
{"type": "interface", "prefix": "I"} {"type": "interface", "prefix": "I"}
+1 -1
View File
@@ -2537,7 +2537,7 @@ js-tokens@^4.0.0:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
js-yaml@3.13.1, js-yaml@^3.13.1: js-yaml@3.13.1, js-yaml@^3.13.1, js-yaml@^3.7.0:
version "3.13.1" version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==