Fix buffer decoration onRender, start using internal decoration
This commit is contained in:
@@ -6,16 +6,16 @@
|
||||
|
||||
import { EventEmitter } from 'common/EventEmitter';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IDecorationService } from 'common/services/Services';
|
||||
import { IDecorationService, IInternalDecoration } from 'common/services/Services';
|
||||
import { IDecorationOptions, IDecoration, IMarker, IEvent } from 'xterm';
|
||||
|
||||
export class DecorationService extends Disposable implements IDecorationService {
|
||||
private _animationFrame: number | undefined;
|
||||
private _onDecorationRegistered = this.register(new EventEmitter<IDecorationOptions>());
|
||||
public get onDecorationRegistered(): IEvent<IDecorationOptions> { return this._onDecorationRegistered.event; }
|
||||
private _onDecorationRemoved = this.register(new EventEmitter<IDecoration>());
|
||||
public get onDecorationRemoved(): IEvent<IDecoration> { return this._onDecorationRemoved.event; }
|
||||
private _decorations: IDecoration[] = [];
|
||||
private _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
|
||||
public get onDecorationRegistered(): IEvent<IInternalDecoration> { return this._onDecorationRegistered.event; }
|
||||
private _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
|
||||
public get onDecorationRemoved(): IEvent<IInternalDecoration> { return this._onDecorationRemoved.event; }
|
||||
private _decorations: IInternalDecoration[] = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -33,7 +33,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
}
|
||||
});
|
||||
this._decorations.push(decoration);
|
||||
this._onDecorationRegistered.fire(options);
|
||||
this._onDecorationRegistered.fire(decoration);
|
||||
}
|
||||
return decoration;
|
||||
}
|
||||
@@ -57,19 +57,21 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
}
|
||||
}
|
||||
|
||||
class Decoration implements IDecoration {
|
||||
class Decoration implements IInternalDecoration {
|
||||
public marker: IMarker;
|
||||
private _onRender = new EventEmitter<HTMLElement>();
|
||||
public get onRender(): IEvent<HTMLElement> { return this._onRender.event; }
|
||||
public readonly onRenderEmitter = new EventEmitter<HTMLElement>();
|
||||
public readonly onRender = this.onRenderEmitter.event;
|
||||
private _onDispose = new EventEmitter<void>();
|
||||
public get onDispose(): IEvent<void> { return this._onDispose.event; }
|
||||
public readonly onDispose = this._onDispose.event;
|
||||
public element: HTMLElement | undefined;
|
||||
public isDisposed: boolean = false;
|
||||
public dispose(): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
constructor(decorationOptions: IDecorationOptions) {
|
||||
this.marker = decorationOptions?.marker;
|
||||
constructor(
|
||||
public readonly options: IDecorationOptions
|
||||
) {
|
||||
this.marker = options.marker;
|
||||
this.element = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IEvent } from 'common/EventEmitter';
|
||||
import { IEvent, IEventEmitter } from 'common/EventEmitter';
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable } from 'common/Types';
|
||||
import { createDecorator } from 'common/services/ServiceRegistry';
|
||||
@@ -300,8 +300,14 @@ export interface IUnicodeVersionProvider {
|
||||
readonly version: string;
|
||||
wcwidth(ucs: number): 0 | 1 | 2;
|
||||
}
|
||||
|
||||
export const IDecorationService = createDecorator<IDecorationService>('DecorationService');
|
||||
export interface IDecorationService extends IDisposable {
|
||||
readonly onDecorationRegistered: IEvent<IDecorationOptions>;
|
||||
readonly onDecorationRemoved: IEvent<IDecoration>;
|
||||
readonly onDecorationRegistered: IEvent<IInternalDecoration>;
|
||||
readonly onDecorationRemoved: IEvent<IInternalDecoration>;
|
||||
registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined;
|
||||
}
|
||||
export interface IInternalDecoration extends IDecoration {
|
||||
readonly options: IDecorationOptions;
|
||||
readonly onRenderEmitter: IEventEmitter<HTMLElement>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user