diff --git a/src/Buffer.ts b/src/Buffer.ts index 5eaf880b..6d218645 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -114,11 +114,14 @@ export class Buffer implements IBuffer { /** * Fills the buffer's viewport with blank lines. */ - public fillViewportRows(): void { + public fillViewportRows(fillAttr?: number): void { if (this.lines.length === 0) { + if (fillAttr === undefined) { + fillAttr = DEFAULT_ATTR; + } let i = this._terminal.rows; while (i--) { - this.lines.push(this.getBlankLine(DEFAULT_ATTR)); + this.lines.push(this.getBlankLine(fillAttr)); } } } diff --git a/src/BufferSet.ts b/src/BufferSet.ts index b213db0a..f84757d1 100644 --- a/src/BufferSet.ts +++ b/src/BufferSet.ts @@ -77,13 +77,13 @@ export class BufferSet extends EventEmitter implements IBufferSet { /** * Sets the alt Buffer of the BufferSet as its currently active Buffer */ - public activateAltBuffer(): void { + public activateAltBuffer(fillAttr?: number): void { if (this._activeBuffer === this._alt) { return; } // 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._alt.fillViewportRows(fillAttr); this._alt.x = this._normal.x; this._alt.y = this._normal.y; this._activeBuffer = this._alt; diff --git a/src/InputHandler.test.ts b/src/InputHandler.test.ts index 5fa3b47a..b2fea06a 100644 --- a/src/InputHandler.test.ts +++ b/src/InputHandler.test.ts @@ -561,5 +561,10 @@ describe('InputHandler', () => { // Text color of 'TEST' should be red expect((term.buffer.lines.get(1).get(0)[CHAR_DATA_ATTR_INDEX] >> 9) & 0x1ff).to.equal(1); }); + it('should handle DECSET/DECRST 1049 - clears alt buffer with erase attributes', () => { + handler.parse('\x1b[42m\x1b[?1049h'); + // Buffer should be filled with green background + expect(term.buffer.lines.get(20).get(10)[CHAR_DATA_ATTR_INDEX] & 0x1ff).to.equal(2); + }); }); }); diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 47e1875b..ab75366a 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -1339,7 +1339,7 @@ export class InputHandler extends Disposable implements IInputHandler { // FALL-THROUGH case 47: // alt screen buffer case 1047: // alt screen buffer - this._terminal.buffers.activateAltBuffer(); + this._terminal.buffers.activateAltBuffer(this._terminal.eraseAttr()); this._terminal.refresh(0, this._terminal.rows - 1); if (this._terminal.viewport) { this._terminal.viewport.syncScrollArea(); diff --git a/src/Types.ts b/src/Types.ts index 6a6b8369..0f60e6f7 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -306,7 +306,7 @@ export interface IBufferSet extends IEventEmitter { active: IBuffer; activateNormalBuffer(): void; - activateAltBuffer(): void; + activateAltBuffer(fillAttr?: number): void; } export interface ISelectionManager {