Support buffers with scrollback of 0, force alt as 0

Fixes #802
This commit is contained in:
Daniel Imms
2017-08-06 18:18:49 -07:00
parent 27f7679494
commit a57f55dcbf
5 changed files with 68 additions and 51 deletions
+2 -15
View File
@@ -21,9 +21,9 @@ export class BufferSet extends EventEmitter implements IBufferSet {
*/
constructor(private _terminal: ITerminal) {
super();
this._normal = new Buffer(this._terminal);
this._normal = new Buffer(this._terminal, false);
this._normal.fillViewportRows();
this._alt = new Buffer(this._terminal);
this._alt = new Buffer(this._terminal, true);
this._activeBuffer = this._normal;
}
@@ -71,22 +71,10 @@ export class BufferSet extends EventEmitter implements IBufferSet {
// Since the alt buffer is always cleared when the normal buffer is
// activated, we want to fill it when switching to it.
this._alt.fillViewportRows();
this._activeBuffer = this._alt;
this.emit('activate', this._alt);
}
/**
* Refreshes the max length of the buffer set, this should be called whenever
* terminal rows or scrollback changes.
* @param rows The number of terminal rows.
*/
public refreshMaxLength(rows: number): void {
this._normal.lines.maxLength = rows + this._terminal.options.scrollback;
// TODO: The alt buffer should never have scrollback, see https://github.com/sourcelair/xterm.js/issues/802
this._alt.lines.maxLength = rows + this._terminal.options.scrollback;
}
/**
* Resizes both normal and alt buffers, adjusting their data accordingly.
* @param newCols The new number of columns.
@@ -95,6 +83,5 @@ export class BufferSet extends EventEmitter implements IBufferSet {
public resize(newCols: number, newRows: number): void {
this._normal.resize(newCols, newRows);
this._alt.resize(newCols, newRows);
this.refreshMaxLength(newRows);
}
}