Create new event with emitter object to simplify code

This commit is contained in:
Daniel Imms
2022-10-01 08:45:40 -07:00
parent 969db2bcf9
commit ed15a8e170
33 changed files with 247 additions and 307 deletions
+5 -7
View File
@@ -7,7 +7,7 @@ import { Terminal, ITerminalAddon, IEvent } from 'xterm';
import { WebglRenderer } from './WebglRenderer';
import { ICharacterJoinerService, ICoreBrowserService, IRenderService } from 'browser/services/Services';
import { IColorSet } from 'browser/Types';
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
import { EventEmitter, forwardEvent, initEvent } from 'common/EventEmitter';
import { isSafari } from 'common/Platform';
import { ICoreService, IDecorationService } from 'common/services/Services';
@@ -15,10 +15,8 @@ export class WebglAddon implements ITerminalAddon {
private _terminal?: Terminal;
private _renderer?: WebglRenderer;
private readonly _onChangeTextureAtlas = new EventEmitter<HTMLElement>();
public readonly onChangeTextureAtlas = this._onChangeTextureAtlas.event;
private readonly _onContextLoss = new EventEmitter<void>();
public readonly onContextLoss = this._onContextLoss.event;
public readonly onChangeTextureAtlas = initEvent<HTMLElement>();
public readonly onContextLoss = initEvent<void>();
constructor(
private _preserveDrawingBuffer?: boolean
@@ -39,8 +37,8 @@ export class WebglAddon implements ITerminalAddon {
const decorationService: IDecorationService = (terminal as any)._core._decorationService;
const colors: IColorSet = (terminal as any)._core._colorManager.colors;
this._renderer = new WebglRenderer(terminal, colors, characterJoinerService, coreBrowserService, coreService, decorationService, this._preserveDrawingBuffer);
forwardEvent(this._renderer.onContextLoss, this._onContextLoss);
forwardEvent(this._renderer.onChangeTextureAtlas, this._onChangeTextureAtlas);
forwardEvent(this._renderer.onContextLoss, this.onContextLoss);
forwardEvent(this._renderer.onChangeTextureAtlas, this.onChangeTextureAtlas);
renderService.setRenderer(this._renderer);
}