mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Allow loading canvas before open
This commit is contained in:
@@ -14,21 +14,23 @@ export class CanvasAddon implements ITerminalAddon {
|
||||
private _renderer?: CanvasRenderer;
|
||||
|
||||
public activate(terminal: Terminal): void {
|
||||
const core = (terminal as any)._core;
|
||||
if (!terminal.element) {
|
||||
throw new Error('Cannot activate CanvasAddon before Terminal.open');
|
||||
core.onWillOpen(() => this.activate(terminal));
|
||||
return;
|
||||
}
|
||||
this._terminal = terminal;
|
||||
const bufferService: IBufferService = (terminal as any)._core._bufferService;
|
||||
const renderService: IRenderService = (terminal as any)._core._renderService;
|
||||
const characterJoinerService: ICharacterJoinerService = (terminal as any)._core._characterJoinerService;
|
||||
const charSizeService: ICharSizeService = (terminal as any)._core._charSizeService;
|
||||
const coreService: ICoreService = (terminal as any)._core.coreService;
|
||||
const coreBrowserService: ICoreBrowserService = (terminal as any)._core._coreBrowserService;
|
||||
const decorationService: IDecorationService = (terminal as any)._core._decorationService;
|
||||
const optionsService: IOptionsService = (terminal as any)._core.optionsService;
|
||||
const colors: IColorSet = (terminal as any)._core._colorManager.colors;
|
||||
const screenElement: HTMLElement = (terminal as any)._core.screenElement;
|
||||
const linkifier = (terminal as any)._core.linkifier2;
|
||||
const bufferService: IBufferService = core._bufferService;
|
||||
const renderService: IRenderService = core._renderService;
|
||||
const characterJoinerService: ICharacterJoinerService = core._characterJoinerService;
|
||||
const charSizeService: ICharSizeService = core._charSizeService;
|
||||
const coreService: ICoreService = core.coreService;
|
||||
const coreBrowserService: ICoreBrowserService = core._coreBrowserService;
|
||||
const decorationService: IDecorationService = core._decorationService;
|
||||
const optionsService: IOptionsService = core.optionsService;
|
||||
const colors: IColorSet = core._colorManager.colors;
|
||||
const screenElement: HTMLElement = core.screenElement;
|
||||
const linkifier = core.linkifier2;
|
||||
this._renderer = new CanvasRenderer(colors, screenElement, linkifier, bufferService, charSizeService, optionsService, characterJoinerService, coreService, coreBrowserService, decorationService);
|
||||
renderService.setRenderer(this._renderer);
|
||||
renderService.onResize(bufferService.cols, bufferService.rows);
|
||||
|
||||
@@ -25,20 +25,21 @@ export class WebglAddon implements ITerminalAddon {
|
||||
) {}
|
||||
|
||||
public activate(terminal: Terminal): void {
|
||||
const core = (terminal as any)._core;
|
||||
if (!terminal.element) {
|
||||
(terminal as any)._core.onWillOpen(() => this.activate(terminal));
|
||||
core.onWillOpen(() => this.activate(terminal));
|
||||
return;
|
||||
}
|
||||
if (isSafari) {
|
||||
throw new Error('Webgl is not currently supported on Safari');
|
||||
}
|
||||
this._terminal = terminal;
|
||||
const renderService: IRenderService = (terminal as any)._core._renderService;
|
||||
const characterJoinerService: ICharacterJoinerService = (terminal as any)._core._characterJoinerService;
|
||||
const coreBrowserService: ICoreBrowserService = (terminal as any)._core._coreBrowserService;
|
||||
const coreService: ICoreService = (terminal as any)._core.coreService;
|
||||
const decorationService: IDecorationService = (terminal as any)._core._decorationService;
|
||||
const colors: IColorSet = (terminal as any)._core._colorManager.colors;
|
||||
const renderService: IRenderService = core._renderService;
|
||||
const characterJoinerService: ICharacterJoinerService = core._characterJoinerService;
|
||||
const coreBrowserService: ICoreBrowserService = core._coreBrowserService;
|
||||
const coreService: ICoreService = core.coreService;
|
||||
const decorationService: IDecorationService = core._decorationService;
|
||||
const colors: IColorSet = 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);
|
||||
|
||||
Reference in New Issue
Block a user