Create new event with emitter object to simplify code
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user