From 9346eba2f2916d4bad8e221dca7b85508915e160 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 25 Apr 2020 16:18:43 -0700 Subject: [PATCH] Remove Terminal.showCursor dep from input handler --- src/InputHandler.ts | 4 ++-- src/Terminal.test.ts | 2 -- src/Terminal.ts | 8 ++++---- src/TestUtils.test.ts | 6 ------ src/Types.d.ts | 4 ---- src/browser/services/RenderService.ts | 6 ++++-- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 7732d4cf7..c3f3446ea 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -1794,9 +1794,9 @@ export class InputHandler extends Disposable implements IInputHandler { case 47: // alt screen buffer case 1047: // alt screen buffer this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()); + this._coreService.isCursorInitialized = true; this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1); this._terminal.viewport?.syncScrollArea(); - this._terminal.showCursor(); break; case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste) this._coreService.decPrivateModes.bracketedPasteMode = true; @@ -2012,9 +2012,9 @@ export class InputHandler extends Disposable implements IInputHandler { if (params.params[i] === 1049) { this.restoreCursor(); } + this._coreService.isCursorInitialized = true; this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1); this._terminal.viewport?.syncScrollArea(); - this._terminal.showCursor(); break; case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste) this._coreService.decPrivateModes.bracketedPasteMode = false; diff --git a/src/Terminal.test.ts b/src/Terminal.test.ts index d70ccb45a..40e1b1415 100644 --- a/src/Terminal.test.ts +++ b/src/Terminal.test.ts @@ -140,7 +140,6 @@ describe('Terminal', () => { }; beforeEach(() => { - term.showCursor = () => { }; term.clearSelection = () => { }; }); @@ -531,7 +530,6 @@ describe('Terminal', () => { let evKeyPress: any; beforeEach(() => { - term.showCursor = () => { }; term.clearSelection = () => { }; // term.compositionHelper = { // isComposing: false, diff --git a/src/Terminal.ts b/src/Terminal.ts index c88a07150..dff303bb0 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -278,7 +278,7 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT } this.updateCursorStyle(ev); this.element.classList.add('focus'); - this.showCursor(); + this._showCursor(); this._onFocus.fire(); } @@ -830,7 +830,7 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT /** * Display the cursor element */ - public showCursor(): void { + private _showCursor(): void { if (!this._coreService.isCursorInitialized) { this._coreService.isCursorInitialized = true; this.refresh(this.buffer.y, this.buffer.y); @@ -1165,7 +1165,7 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT } this._onKey.fire({ key: result.key, domEvent: event }); - this.showCursor(); + this._showCursor(); this._coreService.triggerDataEvent(result.key, true); // Cancel events when not in screen reader mode so events don't get bubbled up and handled by @@ -1242,7 +1242,7 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT key = String.fromCharCode(key); this._onKey.fire({ key, domEvent: ev }); - this.showCursor(); + this._showCursor(); this._coreService.triggerDataEvent(key, true); return true; diff --git a/src/TestUtils.test.ts b/src/TestUtils.test.ts index c15ce5607..1cdc4c493 100644 --- a/src/TestUtils.test.ts +++ b/src/TestUtils.test.ts @@ -190,9 +190,6 @@ export class MockTerminal implements ITerminal { public reset(): void { throw new Error('Method not implemented.'); } - public showCursor(): void { - throw new Error('Method not implemented.'); - } public refresh(start: number, end: number): void { throw new Error('Method not implemented.'); } @@ -215,9 +212,6 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal { public resize(x: number, y: number): void { throw new Error('Method not implemented.'); } - public showCursor(): void { - throw new Error('Method not implemented.'); - } public handler(data: string): void { throw new Error('Method not implemented.'); } diff --git a/src/Types.d.ts b/src/Types.d.ts index 15eda648d..2b26c0701 100644 --- a/src/Types.d.ts +++ b/src/Types.d.ts @@ -21,8 +21,6 @@ export type LineData = CharData[]; * InputHandler cleanly from the ITerminal interface. */ export interface IInputHandlingTerminal { - buffers: IBufferSet; - buffer: IBuffer; viewport: IViewport; onA11yCharEmitter: IEventEmitter; @@ -31,7 +29,6 @@ export interface IInputHandlingTerminal { scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void; is(term: string): boolean; resize(x: number, y: number): void; - showCursor(): void; handleTitle(title: string): void; } @@ -143,7 +140,6 @@ export interface ITerminal extends IPublicTerminal, IElementAccessor, IBufferAcc scrollLines(disp: number, suppressScrollEvent?: boolean): void; cancel(ev: Event, force?: boolean): boolean | void; - showCursor(): void; } // Portions of the public API that are required by the internal Terminal diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index 61ba35ab0..d9aaf60ab 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -10,7 +10,7 @@ import { Disposable } from 'common/Lifecycle'; import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; import { addDisposableDomListener } from 'browser/Lifecycle'; import { IColorSet } from 'browser/Types'; -import { IOptionsService } from 'common/services/Services'; +import { IOptionsService, IBufferService, ICoreService } from 'common/services/Services'; import { ICharSizeService, IRenderService } from 'browser/services/Services'; export class RenderService extends Disposable implements IRenderService { @@ -39,7 +39,9 @@ export class RenderService extends Disposable implements IRenderService { private _rowCount: number, screenElement: HTMLElement, @IOptionsService optionsService: IOptionsService, - @ICharSizeService charSizeService: ICharSizeService + @ICharSizeService charSizeService: ICharSizeService, + @IBufferService private readonly _bufferService: IBufferService, + @ICoreService private readonly _coreService: ICoreService ) { super(); this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end));