Remove ITerminal dependency in RenderDebouncer
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { ITerminal } from '../Types';
|
||||
/**
|
||||
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IDisposable } from 'xterm';
|
||||
|
||||
/**
|
||||
@@ -7,10 +11,10 @@ import { IDisposable } from 'xterm';
|
||||
export class RenderDebouncer implements IDisposable {
|
||||
private _rowStart: number;
|
||||
private _rowEnd: number;
|
||||
private _rowCount: number;
|
||||
private _animationFrame: number = null;
|
||||
|
||||
constructor(
|
||||
private _terminal: ITerminal,
|
||||
private _callback: (start: number, end: number) => void
|
||||
) {
|
||||
}
|
||||
@@ -22,10 +26,11 @@ export class RenderDebouncer implements IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public refresh(rowStart: number, rowEnd: number): void {
|
||||
public refresh(rowStart: number, rowEnd: number, rowCount: number): void {
|
||||
this._rowCount = rowCount;
|
||||
// Get the min/max row start/end for the arg values
|
||||
rowStart = rowStart !== null && rowStart !== undefined ? rowStart : 0;
|
||||
rowEnd = rowEnd !== null && rowEnd !== undefined ? rowEnd : this._terminal.rows - 1;
|
||||
rowEnd = rowEnd !== null && rowEnd !== undefined ? rowEnd : this._rowCount - 1;
|
||||
// Check whether the row start/end values have already been set
|
||||
const isRowStartSet = this._rowStart !== undefined && this._rowStart !== null;
|
||||
const isRowEndSet = this._rowEnd !== undefined && this._rowEnd !== null;
|
||||
@@ -43,7 +48,7 @@ export class RenderDebouncer implements IDisposable {
|
||||
private _innerRefresh(): void {
|
||||
// Clamp values
|
||||
this._rowStart = Math.max(this._rowStart, 0);
|
||||
this._rowEnd = Math.min(this._rowEnd, this._terminal.rows - 1);
|
||||
this._rowEnd = Math.min(this._rowEnd, this._rowCount - 1);
|
||||
|
||||
// Run render callback
|
||||
this._callback(this._rowStart, this._rowEnd);
|
||||
|
||||
Reference in New Issue
Block a user