Fix dependency injection for decoration service
This commit is contained in:
@@ -16,10 +16,10 @@ export class BufferDecorationRenderer extends Disposable {
|
|||||||
private _altBufferIsActive: boolean = false;
|
private _altBufferIsActive: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private readonly _screenElement: HTMLElement,
|
||||||
@IBufferService private readonly _bufferService: IBufferService,
|
@IBufferService private readonly _bufferService: IBufferService,
|
||||||
@IRenderService private readonly _renderService: IRenderService,
|
@IDecorationService private readonly _decorationService: IDecorationService,
|
||||||
private readonly _decorationService: IDecorationService,
|
@IRenderService private readonly _renderService: IRenderService
|
||||||
private readonly _screenElement: HTMLElement
|
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ export class OverviewRulerRenderer extends Disposable {
|
|||||||
private _x: number | undefined;
|
private _x: number | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private readonly _viewportElement: HTMLElement,
|
||||||
|
private readonly _screenElement: HTMLElement,
|
||||||
@IBufferService private readonly _bufferService: IBufferService,
|
@IBufferService private readonly _bufferService: IBufferService,
|
||||||
@IRenderService private readonly _renderService: IRenderService,
|
|
||||||
@IDecorationService private readonly _decorationService: IDecorationService,
|
@IDecorationService private readonly _decorationService: IDecorationService,
|
||||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||||
private readonly _viewportElement: HTMLElement,
|
@IRenderService private readonly _renderService: IRenderService
|
||||||
private readonly _screenElement: HTMLElement
|
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this._canvas = document.createElement('canvas');
|
this._canvas = document.createElement('canvas');
|
||||||
|
|||||||
@@ -587,14 +587,14 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
this.linkifier.attachToDom(this.element, this._mouseZoneManager);
|
this.linkifier.attachToDom(this.element, this._mouseZoneManager);
|
||||||
this.linkifier2.attachToDom(this.screenElement, this._mouseService, this._renderService);
|
this.linkifier2.attachToDom(this.screenElement, this._mouseService, this._renderService);
|
||||||
if (this._decorationService) {
|
if (this._decorationService) {
|
||||||
this._bufferDecorationRenderer = new BufferDecorationRenderer(this._bufferService, this._renderService, this._decorationService, this.screenElement);
|
this._bufferDecorationRenderer = this._instantiationService.createInstance(BufferDecorationRenderer, this.screenElement);
|
||||||
}
|
}
|
||||||
if (this.options.overviewRulerWidth && this._decorationService) {
|
if (this.options.overviewRulerWidth && this._decorationService) {
|
||||||
this._overviewRulerRenderer = new OverviewRulerRenderer(this._bufferService, this._renderService, this._decorationService, this._instantiationService, this._viewportElement, this.screenElement);
|
this._overviewRulerRenderer = this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement);
|
||||||
}
|
}
|
||||||
this.optionsService.onOptionChange(() => {
|
this.optionsService.onOptionChange(() => {
|
||||||
if (!this._overviewRulerRenderer && this.options.overviewRulerWidth && this._renderService && this._viewportElement && this.screenElement && this._decorationService) {
|
if (!this._overviewRulerRenderer && this.options.overviewRulerWidth && this._renderService && this._viewportElement && this.screenElement && this._decorationService) {
|
||||||
this._overviewRulerRenderer = new OverviewRulerRenderer(this._bufferService, this._renderService, this._decorationService, this._instantiationService, this._viewportElement, this.screenElement);
|
this._overviewRulerRenderer = this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement);
|
||||||
}});
|
}});
|
||||||
// This event listener must be registered aftre MouseZoneManager is created
|
// This event listener must be registered aftre MouseZoneManager is created
|
||||||
this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e)));
|
this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e)));
|
||||||
|
|||||||
@@ -3,19 +3,21 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import { EventEmitter } from 'common/EventEmitter';
|
import { EventEmitter } from 'common/EventEmitter';
|
||||||
import { Disposable } from 'common/Lifecycle';
|
import { Disposable } from 'common/Lifecycle';
|
||||||
import { IDecorationService, IInternalDecoration } from 'common/services/Services';
|
import { IDecorationService, IInternalDecoration } from 'common/services/Services';
|
||||||
import { IDecorationOptions, IDecoration, IMarker, IEvent } from 'xterm';
|
import { IDecorationOptions, IDecoration, IMarker, IEvent } from 'xterm';
|
||||||
|
|
||||||
export class DecorationService extends Disposable implements IDecorationService {
|
export class DecorationService extends Disposable implements IDecorationService {
|
||||||
|
public serviceBrand: any;
|
||||||
|
|
||||||
|
private readonly _decorations: IInternalDecoration[] = [];
|
||||||
private _animationFrame: number | undefined;
|
private _animationFrame: number | undefined;
|
||||||
|
|
||||||
private _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
|
private _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
|
||||||
public get onDecorationRegistered(): IEvent<IInternalDecoration> { return this._onDecorationRegistered.event; }
|
public get onDecorationRegistered(): IEvent<IInternalDecoration> { return this._onDecorationRegistered.event; }
|
||||||
private _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
|
private _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
|
||||||
public get onDecorationRemoved(): IEvent<IInternalDecoration> { return this._onDecorationRemoved.event; }
|
public get onDecorationRemoved(): IEvent<IInternalDecoration> { return this._onDecorationRemoved.event; }
|
||||||
private _decorations: IInternalDecoration[] = [];
|
|
||||||
|
|
||||||
public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
|
public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
|
||||||
|
|
||||||
@@ -45,7 +47,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
|||||||
this._onDecorationRemoved.fire(decoration);
|
this._onDecorationRemoved.fire(decoration);
|
||||||
decoration.dispose();
|
decoration.dispose();
|
||||||
}
|
}
|
||||||
this._decorations = [];
|
this._decorations.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _queueRefresh(): void {
|
private _queueRefresh(): void {
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ export interface IUnicodeVersionProvider {
|
|||||||
|
|
||||||
export const IDecorationService = createDecorator<IDecorationService>('DecorationService');
|
export const IDecorationService = createDecorator<IDecorationService>('DecorationService');
|
||||||
export interface IDecorationService extends IDisposable {
|
export interface IDecorationService extends IDisposable {
|
||||||
|
serviceBrand: undefined;
|
||||||
readonly decorations: IterableIterator<IInternalDecoration>;
|
readonly decorations: IterableIterator<IInternalDecoration>;
|
||||||
readonly onDecorationRegistered: IEvent<IInternalDecoration>;
|
readonly onDecorationRegistered: IEvent<IInternalDecoration>;
|
||||||
readonly onDecorationRemoved: IEvent<IInternalDecoration>;
|
readonly onDecorationRemoved: IEvent<IInternalDecoration>;
|
||||||
|
|||||||
Reference in New Issue
Block a user