Remove terminal.reset usage from input handler

This commit is contained in:
Daniel Imms
2019-12-18 11:55:25 +11:00
parent 7a1bef7daf
commit 33db0203dd
5 changed files with 11 additions and 12 deletions
+4 -4
View File
@@ -36,26 +36,26 @@ function getLines(term: TestTerminal, limit: number = term.rows): string[] {
describe('InputHandler', () => { describe('InputHandler', () => {
describe('save and restore cursor', () => { describe('save and restore cursor', () => {
const terminal = new MockInputHandlingTerminal(); const terminal = new MockInputHandlingTerminal();
terminal.curAttrData.fg = 3;
const bufferService = new MockBufferService(80, 30); const bufferService = new MockBufferService(80, 30);
bufferService.buffer.x = 1; bufferService.buffer.x = 1;
bufferService.buffer.y = 2; bufferService.buffer.y = 2;
bufferService.buffer.ybase = 0; bufferService.buffer.ybase = 0;
const inputHandler = new InputHandler(terminal, bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService()); 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 // Save cursor position
inputHandler.saveCursor(); inputHandler.saveCursor();
assert.equal(bufferService.buffer.x, 1); assert.equal(bufferService.buffer.x, 1);
assert.equal(bufferService.buffer.y, 2); assert.equal(bufferService.buffer.y, 2);
assert.equal(terminal.curAttrData.fg, 3); assert.equal((inputHandler as any)._curAttrData.fg, 3);
// Change cursor position // Change cursor position
bufferService.buffer.x = 10; bufferService.buffer.x = 10;
bufferService.buffer.y = 20; bufferService.buffer.y = 20;
terminal.curAttrData.fg = 30; (inputHandler as any)._curAttrData.fg = 30;
// Restore cursor position // Restore cursor position
inputHandler.restoreCursor(); inputHandler.restoreCursor();
assert.equal(bufferService.buffer.x, 1); assert.equal(bufferService.buffer.x, 1);
assert.equal(bufferService.buffer.y, 2); assert.equal(bufferService.buffer.y, 2);
assert.equal(terminal.curAttrData.fg, 3); assert.equal((inputHandler as any)._curAttrData.fg, 3);
}); });
describe('setCursorStyle', () => { describe('setCursorStyle', () => {
it('should call Terminal.setOption with correct params', () => { it('should call Terminal.setOption with correct params', () => {
+5 -3
View File
@@ -133,6 +133,8 @@ export class InputHandler extends Disposable implements IInputHandler {
private _onRequestRefreshRows = new EventEmitter<number, number>(); private _onRequestRefreshRows = new EventEmitter<number, number>();
public get onRequestRefreshRows(): IEvent<number, number> { return this._onRequestRefreshRows.event; } public get onRequestRefreshRows(): IEvent<number, number> { return this._onRequestRefreshRows.event; }
private _onRequestReset = new EventEmitter<void>();
public get onRequestReset(): IEvent<void> { return this._onRequestReset.event; }
private _onCursorMove = new EventEmitter<void>(); private _onCursorMove = new EventEmitter<void>();
public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; } public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }
private _onLineFeed = new EventEmitter<void>(); private _onLineFeed = new EventEmitter<void>();
@@ -1410,7 +1412,7 @@ export class InputHandler extends Disposable implements IInputHandler {
// TODO: move DECCOLM into compat addon // TODO: move DECCOLM into compat addon
this._terminal.savedCols = this._bufferService.cols; this._terminal.savedCols = this._bufferService.cols;
this._terminal.resize(132, this._bufferService.rows); this._terminal.resize(132, this._bufferService.rows);
this._terminal.reset(); this._onRequestReset.fire();
break; break;
case 6: case 6:
this._coreService.decPrivateModes.origin = true; 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); this._terminal.resize(this._terminal.savedCols, this._bufferService.rows);
} }
delete this._terminal.savedCols; delete this._terminal.savedCols;
this._terminal.reset(); this._onRequestReset.fire();
break; break;
case 6: case 6:
this._coreService.decPrivateModes.origin = false; this._coreService.decPrivateModes.origin = false;
@@ -2193,7 +2195,7 @@ export class InputHandler extends Disposable implements IInputHandler {
*/ */
public reset(): void { public reset(): void {
this._parser.reset(); this._parser.reset();
this._terminal.reset(); // TODO: save to move from terminal? this._onRequestReset.fire();
} }
/** /**
+1 -1
View File
@@ -53,7 +53,6 @@ import { CharSizeService } from 'browser/services/CharSizeService';
import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService'; import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
import { Disposable } from 'common/Lifecycle'; import { Disposable } from 'common/Lifecycle';
import { IBufferSet, IBuffer } from 'common/buffer/Types'; import { IBufferSet, IBuffer } from 'common/buffer/Types';
import { Attributes } from 'common/buffer/Constants';
import { MouseService } from 'browser/services/MouseService'; import { MouseService } from 'browser/services/MouseService';
import { IParams, IFunctionIdentifier } from 'common/parser/Types'; import { IParams, IFunctionIdentifier } from 'common/parser/Types';
import { CoreService } from 'common/services/CoreService'; 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 // 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 = 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.onRequestRefreshRows((start, end) => this.refresh(start, end));
this._inputHandler.onRequestReset(() => this.reset());
this._inputHandler.onCursorMove(() => this._onCursorMove.fire()); this._inputHandler.onCursorMove(() => this._onCursorMove.fire());
this._inputHandler.onLineFeed(() => this._onLineFeed.fire()); this._inputHandler.onLineFeed(() => this._onLineFeed.fire());
this.register(this._inputHandler); this.register(this._inputHandler);
+1 -3
View File
@@ -204,7 +204,6 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal {
rows: number; rows: number;
insertMode: boolean; insertMode: boolean;
bracketedPasteMode: boolean; bracketedPasteMode: boolean;
curAttrData = new AttributeData();
savedCols: number; savedCols: number;
x10Mouse: boolean; x10Mouse: boolean;
vt200Mouse: boolean; vt200Mouse: boolean;
@@ -226,11 +225,10 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal {
bell(): void { bell(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
updateRange(y: number): void { updateRange(y: number): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
scroll(isWrapped?: boolean): void { scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
nextStop(x?: number): number { nextStop(x?: number): number {
-1
View File
@@ -43,7 +43,6 @@ export interface IInputHandlingTerminal {
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void; scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
is(term: string): boolean; is(term: string): boolean;
resize(x: number, y: number): void; resize(x: number, y: number): void;
reset(): void;
showCursor(): void; showCursor(): void;
handleTitle(title: string): void; handleTitle(title: string): void;
} }