From dada7fe728798503707ebaca295cf025fd0415e6 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 18 Dec 2019 11:20:36 +1100 Subject: [PATCH] Move origin mode into core service --- src/InputHandler.ts | 9 ++++----- src/Types.d.ts | 1 - src/common/TestUtils.test.ts | 1 + src/common/Types.d.ts | 1 + src/common/services/CoreService.ts | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 750d03e9..681fc7a4 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -626,7 +626,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ private _restrictCursor(): void { this._bufferService.buffer.x = Math.min(this._bufferService.cols - 1, Math.max(0, this._bufferService.buffer.x)); - this._bufferService.buffer.y = this._terminal.originMode + this._bufferService.buffer.y = this._coreService.decPrivateModes.origin ? Math.min(this._bufferService.buffer.scrollBottom, Math.max(this._bufferService.buffer.scrollTop, this._bufferService.buffer.y)) : Math.min(this._bufferService.rows - 1, Math.max(0, this._bufferService.buffer.y)); this._dirtyRowService.markDirty(this._bufferService.buffer.y); @@ -637,7 +637,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ private _setCursor(x: number, y: number): void { this._dirtyRowService.markDirty(this._bufferService.buffer.y); - if (this._terminal.originMode) { + if (this._coreService.decPrivateModes.origin) { this._bufferService.buffer.x = x; this._bufferService.buffer.y = this._bufferService.buffer.scrollTop + y; } else { @@ -1410,7 +1410,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._terminal.reset(); break; case 6: - this._terminal.originMode = true; + this._coreService.decPrivateModes.origin = true; this._setCursor(0, 0); break; case 7: @@ -1593,7 +1593,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._terminal.reset(); break; case 6: - this._terminal.originMode = false; + this._coreService.decPrivateModes.origin = false; this._setCursor(0, 0); break; case 7: @@ -1964,7 +1964,6 @@ export class InputHandler extends Disposable implements IInputHandler { public softReset(params: IParams): void { this._coreService.isCursorHidden = false; this._terminal.insertMode = false; - this._terminal.originMode = false; this._terminal.applicationKeypad = false; // ? if (this._terminal.viewport) { this._terminal.viewport.syncScrollArea(); diff --git a/src/Types.d.ts b/src/Types.d.ts index 98982133..095fdf35 100644 --- a/src/Types.d.ts +++ b/src/Types.d.ts @@ -26,7 +26,6 @@ export interface IInputHandlingTerminal { cols: number; rows: number; applicationKeypad: boolean; - originMode: boolean; insertMode: boolean; bracketedPasteMode: boolean; curAttrData: IAttributeData; diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index 65a68cbd..e556b371 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -59,6 +59,7 @@ export class MockCoreService implements ICoreService { isFocused: boolean = false; decPrivateModes: IDecPrivateModes = { applicationCursorKeys: false, + origin: false, wraparound: true }; onData: IEvent = new EventEmitter().event; diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 67434425..a3887e04 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -152,6 +152,7 @@ export interface IMarker extends IDisposable { export interface IDecPrivateModes { applicationCursorKeys: boolean; + origin: boolean; wraparound: boolean; // defaults: xterm - true, vt100 - false } diff --git a/src/common/services/CoreService.ts b/src/common/services/CoreService.ts index f5f1c438..4a94b0bb 100644 --- a/src/common/services/CoreService.ts +++ b/src/common/services/CoreService.ts @@ -10,6 +10,7 @@ import { clone } from 'common/Clone'; const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({ applicationCursorKeys: false, + origin: false, wraparound: true // defaults: xterm - true, vt100 - false });