From 7dc3332b05d91d5a00857bfb361aab2f309578be Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 14 Mar 2022 15:50:40 -0400 Subject: [PATCH] commit before reverting --- demo/client.ts | 7 ++++--- .../Decorations/BufferDecorationRenderer.ts | 10 +++++++--- src/browser/Terminal.ts | 14 +++++++------- src/common/services/DecorationService.ts | 14 ++++---------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 586114d1..0f2148c9 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -547,8 +547,9 @@ function loadTest() { function addDecoration() { const marker = term.addMarker(1); const decoration = term.registerDecoration({ marker }); - decoration.onRender(() => { - decoration.element.style.backgroundColor = 'red'; + decoration.onRender((e) => { + console.log(e); + e.style.backgroundColor = 'red'; }); } @@ -557,5 +558,5 @@ function addOverviewRuler() { canvas.element!.style.left = `${document.querySelector('.xterm-viewport').clientWidth + 5}px`; term.registerDecoration({marker: term.addMarker(3), overviewRulerItemColor: 'green'}); term.registerDecoration({marker: term.addMarker(5), overviewRulerItemColor: 'blue'}); -} +} diff --git a/src/browser/Decorations/BufferDecorationRenderer.ts b/src/browser/Decorations/BufferDecorationRenderer.ts index 56559ad9..efb97c16 100644 --- a/src/browser/Decorations/BufferDecorationRenderer.ts +++ b/src/browser/Decorations/BufferDecorationRenderer.ts @@ -48,11 +48,14 @@ export class BufferDecorationRenderer extends Disposable implements IDecorationR } public renderDecoration(decorationOptions: IDecorationOptions): void { - const decoration = new BufferDecoration(this._bufferService, decorationOptions); - if (this._decorationContainer && decoration.element && !this._decorationContainer.contains(decoration.element)) { - this._decorationContainer.append(decoration.element); + if (decorationOptions.overviewRulerItemColor) { + return; } + const decoration = new BufferDecoration(this._bufferService, decorationOptions); (decoration as BufferDecoration).render(this._decorationContainer, this._renderService, true); + if (this._decorationContainer && decoration.element && !this._decorationContainer.contains(decoration.element)) { + this._decorationContainer.append(decoration.element!); + } } public override dispose(): void { @@ -108,6 +111,7 @@ export class BufferDecoration extends Disposable implements IDecoration { } this._refreshStyle(renderService); if (this._element) { + console.log('firing on render'); this._onRender.fire(this._element); } } diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 39f0a68a..2c00d79b 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -586,13 +586,13 @@ export class Terminal extends CoreTerminal implements ITerminal { if (this._decorationService) { this._bufferDecorationRenderer = new BufferDecorationRenderer(this._bufferService, this._renderService, this._decorationService, this.screenElement); } - // if (this.options.overviewRulerWidth && this._decorationService) { - // this._overviewRulerRenderer = new OverviewRulerRenderer(this._bufferService, this._renderService, this._decorationService, this._viewportElement, this.screenElement); - // } - // this.optionsService.onOptionChange(() => { - // 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._viewportElement, this.screenElement); - // }}); + if (this.options.overviewRulerWidth && this._decorationService) { + this._overviewRulerRenderer = new OverviewRulerRenderer(this._bufferService, this._renderService, this._decorationService, this._instantiationService, this._viewportElement, this.screenElement); + } + this.optionsService.onOptionChange(() => { + 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 event listener must be registered aftre MouseZoneManager is created this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e))); diff --git a/src/common/services/DecorationService.ts b/src/common/services/DecorationService.ts index 206d50e8..1bd67e0c 100644 --- a/src/common/services/DecorationService.ts +++ b/src/common/services/DecorationService.ts @@ -6,8 +6,8 @@ import { EventEmitter } from 'common/EventEmitter'; import { Disposable } from 'common/Lifecycle'; -import { IBufferService, IInstantiationService, IDecorationService } from 'common/services/Services'; -import { IDecorationOptions, IDecoration, IMarker, IDisposable, IEvent } from 'xterm'; +import { IDecorationService } from 'common/services/Services'; +import { IDecorationOptions, IDecoration, IMarker, IEvent } from 'xterm'; export class DecorationService extends Disposable implements IDecorationService { private _animationFrame: number | undefined; @@ -34,9 +34,6 @@ export class DecorationService extends Disposable implements IDecorationService }); this._decorations.push(decoration); this._onDecorationRegistered.fire(options); - decoration.onRender(d => { - decoration.setElement(d); - }); } return decoration; } @@ -71,11 +68,8 @@ class Decoration implements IDecoration { public dispose(): void { throw new Error('Method not implemented.'); } - constructor(decorationOptions?: IDecorationOptions) { - this.marker = decorationOptions?.marker!; + constructor(decorationOptions: IDecorationOptions) { + this.marker = decorationOptions?.marker; this.element = undefined; } - public setElement(element: HTMLElement): void { - this.element = element; - } }