From 451d9aab96df86f077ef39000490dc62ef654ce8 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 26 Apr 2020 06:21:16 -0700 Subject: [PATCH] Register forwardEvent calls --- src/Terminal.ts | 18 +++++++++--------- src/common/CoreTerminal.ts | 8 ++++---- src/common/EventEmitter.ts | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index 41bbd177..9572345e 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -175,15 +175,15 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT } else { // 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.unicodeService, this._instantiationService); - this._inputHandler.onRequestBell(() => this.bell()); - this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end)); - this._inputHandler.onRequestReset(() => this.reset()); - this._inputHandler.onScrollRequest((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined)); - forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove); - forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed); - forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange); - forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter); - forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter); + this.register(this._inputHandler.onRequestBell(() => this.bell())); + this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end))); + this.register(this._inputHandler.onRequestReset(() => this.reset())); + this.register(this._inputHandler.onScrollRequest((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined))); + this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); + this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed)); + this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); + this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); + this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter)); this.register(this._inputHandler); } diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index fd1d9309..90cc7ade 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -90,10 +90,10 @@ export abstract class CoreTerminal extends Disposable { this._instantiationService.setService(ICharsetService, this._charsetService); // Setup listeners - forwardEvent(this._bufferService.onResize, this._onResize); - forwardEvent(this._coreService.onData, this._onData); - forwardEvent(this._coreService.onBinary, this._onBinary); - this.optionsService.onOptionChange(key => this._updateOptions(key)); + this.register(forwardEvent(this._bufferService.onResize, this._onResize)); + this.register(forwardEvent(this._coreService.onData, this._onData)); + this.register(forwardEvent(this._coreService.onBinary, this._onBinary)); + this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); } public dispose(): void { diff --git a/src/common/EventEmitter.ts b/src/common/EventEmitter.ts index 847e3249..4684809f 100644 --- a/src/common/EventEmitter.ts +++ b/src/common/EventEmitter.ts @@ -64,6 +64,6 @@ export class EventEmitter implements IEventEmitter { } } -export function forwardEvent(from: IEvent, to: IEventEmitter): void { - from(e => to.fire(e)); +export function forwardEvent(from: IEvent, to: IEventEmitter): IDisposable { + return from(e => to.fire(e)); }