Rename startRow/endRow in TextRenderLayer

Renaming these to firstRow/lastRow makes the inclusivity of the range
clearer.

Addresses this comment:
https://github.com/xtermjs/xterm.js/pull/1393#discussion_r182471582
This commit is contained in:
Benjamin Woodruff
2018-04-18 20:22:55 -07:00
parent b853aa4929
commit 0fe59df2e9
+11 -11
View File
@@ -50,8 +50,8 @@ export class TextRenderLayer extends BaseRenderLayer {
private _forEachCell( private _forEachCell(
terminal: ITerminal, terminal: ITerminal,
startRow: number, firstRow: number,
endRow: number, lastRow: number,
callback: ( callback: (
code: number, code: number,
char: string, char: string,
@@ -63,7 +63,7 @@ export class TextRenderLayer extends BaseRenderLayer {
flags: number flags: number
) => void ) => void
): void { ): void {
for (let y = startRow; y <= endRow; y++) { for (let y = firstRow; y <= lastRow; y++) {
const row = y + terminal.buffer.ydisp; const row = y + terminal.buffer.ydisp;
const line = terminal.buffer.lines.get(row); const line = terminal.buffer.lines.get(row);
for (let x = 0; x < terminal.cols; x++) { for (let x = 0; x < terminal.cols; x++) {
@@ -128,8 +128,8 @@ export class TextRenderLayer extends BaseRenderLayer {
} }
} }
private _drawBackground(terminal: ITerminal, startRow: number, endRow: number): void { private _drawBackground(terminal: ITerminal, firstRow: number, lastRow: number): void {
this._forEachCell(terminal, startRow, endRow, (code, char, width, x, y, fg, bg, flags) => { this._forEachCell(terminal, firstRow, lastRow, (code, char, width, x, y, fg, bg, flags) => {
// libvte and xterm both draw the background (but not foreground) of invisible characters, // libvte and xterm both draw the background (but not foreground) of invisible characters,
// so we should too. // so we should too.
const isDefaultBackground = bg >= 256; const isDefaultBackground = bg >= 256;
@@ -142,8 +142,8 @@ export class TextRenderLayer extends BaseRenderLayer {
}); });
} }
private _drawForeground(terminal: ITerminal, startRow: number, endRow: number): void { private _drawForeground(terminal: ITerminal, firstRow: number, lastRow: number): void {
this._forEachCell(terminal, startRow, endRow, (code, char, width, x, y, fg, bg, flags) => { this._forEachCell(terminal, firstRow, lastRow, (code, char, width, x, y, fg, bg, flags) => {
if (flags & FLAGS.INVISIBLE) { if (flags & FLAGS.INVISIBLE) {
return; return;
} }
@@ -169,15 +169,15 @@ export class TextRenderLayer extends BaseRenderLayer {
}); });
} }
public onGridChanged(terminal: ITerminal, startRow: number, endRow: number): void { public onGridChanged(terminal: ITerminal, firstRow: number, lastRow: number): void {
// Resize has not been called yet // Resize has not been called yet
if (this._state.cache.length === 0) { if (this._state.cache.length === 0) {
return; return;
} }
this.clearCells(0, startRow, terminal.cols, endRow - startRow + 1); // endRow is inclusive this.clearCells(0, firstRow, terminal.cols, lastRow - firstRow + 1);
this._drawBackground(terminal, startRow, endRow); this._drawBackground(terminal, firstRow, lastRow);
this._drawForeground(terminal, startRow, endRow); this._drawForeground(terminal, firstRow, lastRow);
} }
public onOptionsChanged(terminal: ITerminal): void { public onOptionsChanged(terminal: ITerminal): void {