From 7b0d0e810c7ff509406afbf532063eb6b35b9261 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 16 Aug 2017 08:45:30 -0700 Subject: [PATCH] _isAltBuffer -> _hasScrollback --- src/Buffer.test.ts | 8 ++++---- src/Buffer.ts | 11 +++++------ src/BufferSet.ts | 7 +++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Buffer.test.ts b/src/Buffer.test.ts index 9a3d91681..6baa230dd 100644 --- a/src/Buffer.test.ts +++ b/src/Buffer.test.ts @@ -20,7 +20,7 @@ describe('Buffer', () => { terminal.cols = INIT_COLS; terminal.rows = INIT_ROWS; terminal.options.scrollback = 1000; - buffer = new Buffer(terminal, false); + buffer = new Buffer(terminal, true); }); describe('constructor', () => { @@ -92,7 +92,7 @@ describe('Buffer', () => { describe('no scrollback', () => { it('should trim from the top of the buffer when the cursor reaches the bottom', () => { terminal.options.scrollback = 0; - buffer = new Buffer(terminal, false); + buffer = new Buffer(terminal, true); assert.equal(buffer.lines.maxLength, INIT_ROWS); buffer.y = INIT_ROWS - 1; buffer.fillViewportRows(); @@ -172,11 +172,11 @@ describe('Buffer', () => { }); }); - describe('alt buffer', () => { + describe('buffer marked to have no scrollback', () => { it('should always have a scrollback of 0', () => { assert.equal(terminal.options.scrollback, 1000); // Test size on initialization - buffer = new Buffer(terminal, true); + buffer = new Buffer(terminal, false); buffer.fillViewportRows(); assert.equal(buffer.lines.maxLength, INIT_ROWS); // Test size on buffer increase diff --git a/src/Buffer.ts b/src/Buffer.ts index bf2ceb713..fd6f8aefa 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -32,11 +32,12 @@ export class Buffer implements IBuffer { /** * Create a new Buffer. * @param _terminal The terminal the Buffer will belong to. - * @param _isAltBuffer Whether the buffer is the alt buffer. + * @param _hasScrollback Whether the buffer should respecr the scrollback of + * the terminal.. */ constructor( private _terminal: ITerminal, - private _isAltBuffer: boolean + private _hasScrollback: boolean ) { this.clear(); } @@ -47,13 +48,11 @@ export class Buffer implements IBuffer { /** * Gets the correct buffer length based on the rows provided, the terminal's - * scrollback and whether this is an alt buffer. + * scrollback and whether this buffer is flagged to have scrollback or not. * @param rows The terminal rows to use in the calculation. */ private _getCorrectBufferLength(rows: number): number { - // The alt buffer should never have scrollback. - // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer - if (this._isAltBuffer) { + if (!this._hasScrollback) { return rows; } return rows + this._terminal.options.scrollback; diff --git a/src/BufferSet.ts b/src/BufferSet.ts index 851fc47df..d37a650f9 100644 --- a/src/BufferSet.ts +++ b/src/BufferSet.ts @@ -21,9 +21,12 @@ export class BufferSet extends EventEmitter implements IBufferSet { */ constructor(private _terminal: ITerminal) { super(); - this._normal = new Buffer(this._terminal, false); + this._normal = new Buffer(this._terminal, true); this._normal.fillViewportRows(); - this._alt = new Buffer(this._terminal, true); + + // The alt buffer should never have scrollback. + // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer + this._alt = new Buffer(this._terminal, false); this._activeBuffer = this._normal; }