diff --git a/src/InputHandler.test.ts b/src/InputHandler.test.ts index fa9ef67c..fa42312c 100644 --- a/src/InputHandler.test.ts +++ b/src/InputHandler.test.ts @@ -36,26 +36,26 @@ function getLines(term: TestTerminal, limit: number = term.rows): string[] { describe('InputHandler', () => { describe('save and restore cursor', () => { const terminal = new MockInputHandlingTerminal(); - terminal.curAttrData.fg = 3; const bufferService = new MockBufferService(80, 30); bufferService.buffer.x = 1; bufferService.buffer.y = 2; bufferService.buffer.ybase = 0; const inputHandler = new InputHandler(terminal, bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService()); + (inputHandler as any)._curAttrData.fg = 3; // Save cursor position inputHandler.saveCursor(); assert.equal(bufferService.buffer.x, 1); assert.equal(bufferService.buffer.y, 2); - assert.equal(terminal.curAttrData.fg, 3); + assert.equal((inputHandler as any)._curAttrData.fg, 3); // Change cursor position bufferService.buffer.x = 10; bufferService.buffer.y = 20; - terminal.curAttrData.fg = 30; + (inputHandler as any)._curAttrData.fg = 30; // Restore cursor position inputHandler.restoreCursor(); assert.equal(bufferService.buffer.x, 1); assert.equal(bufferService.buffer.y, 2); - assert.equal(terminal.curAttrData.fg, 3); + assert.equal((inputHandler as any)._curAttrData.fg, 3); }); describe('setCursorStyle', () => { it('should call Terminal.setOption with correct params', () => { diff --git a/src/InputHandler.ts b/src/InputHandler.ts index d01ebc5e..ecc09a7d 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -133,6 +133,8 @@ export class InputHandler extends Disposable implements IInputHandler { private _onRequestRefreshRows = new EventEmitter(); public get onRequestRefreshRows(): IEvent { return this._onRequestRefreshRows.event; } + private _onRequestReset = new EventEmitter(); + public get onRequestReset(): IEvent { return this._onRequestReset.event; } private _onCursorMove = new EventEmitter(); public get onCursorMove(): IEvent { return this._onCursorMove.event; } private _onLineFeed = new EventEmitter(); @@ -1410,7 +1412,7 @@ export class InputHandler extends Disposable implements IInputHandler { // TODO: move DECCOLM into compat addon this._terminal.savedCols = this._bufferService.cols; this._terminal.resize(132, this._bufferService.rows); - this._terminal.reset(); + this._onRequestReset.fire(); break; case 6: this._coreService.decPrivateModes.origin = true; @@ -1589,7 +1591,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._terminal.resize(this._terminal.savedCols, this._bufferService.rows); } delete this._terminal.savedCols; - this._terminal.reset(); + this._onRequestReset.fire(); break; case 6: this._coreService.decPrivateModes.origin = false; @@ -2193,7 +2195,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public reset(): void { this._parser.reset(); - this._terminal.reset(); // TODO: save to move from terminal? + this._onRequestReset.fire(); } /** diff --git a/src/Terminal.ts b/src/Terminal.ts index 21d8ee60..91684cfd 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -53,7 +53,6 @@ import { CharSizeService } from 'browser/services/CharSizeService'; import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService'; import { Disposable } from 'common/Lifecycle'; import { IBufferSet, IBuffer } from 'common/buffer/Types'; -import { Attributes } from 'common/buffer/Constants'; import { MouseService } from 'browser/services/MouseService'; import { IParams, IFunctionIdentifier } from 'common/parser/Types'; import { CoreService } from 'common/services/CoreService'; @@ -259,6 +258,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp // Register input handler and refire/handle events this._inputHandler = new InputHandler(this, this._bufferService, this._charsetService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService); this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end)); + this._inputHandler.onRequestReset(() => this.reset()); this._inputHandler.onCursorMove(() => this._onCursorMove.fire()); this._inputHandler.onLineFeed(() => this._onLineFeed.fire()); this.register(this._inputHandler); diff --git a/src/TestUtils.test.ts b/src/TestUtils.test.ts index 9338fbc0..d425a358 100644 --- a/src/TestUtils.test.ts +++ b/src/TestUtils.test.ts @@ -204,7 +204,6 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal { rows: number; insertMode: boolean; bracketedPasteMode: boolean; - curAttrData = new AttributeData(); savedCols: number; x10Mouse: boolean; vt200Mouse: boolean; @@ -226,11 +225,10 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal { bell(): void { throw new Error('Method not implemented.'); } - updateRange(y: number): void { throw new Error('Method not implemented.'); } - scroll(isWrapped?: boolean): void { + scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void { throw new Error('Method not implemented.'); } nextStop(x?: number): number { diff --git a/src/Types.d.ts b/src/Types.d.ts index e5021f88..bf3f3221 100644 --- a/src/Types.d.ts +++ b/src/Types.d.ts @@ -43,7 +43,6 @@ export interface IInputHandlingTerminal { scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void; is(term: string): boolean; resize(x: number, y: number): void; - reset(): void; showCursor(): void; handleTitle(title: string): void; }