commit before reverting

This commit is contained in:
meganrogge
2022-03-14 15:50:40 -04:00
parent ced06629d4
commit 7dc3332b05
4 changed files with 22 additions and 23 deletions
+4 -3
View File
@@ -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'});
}
}
@@ -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);
}
}
+7 -7
View File
@@ -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)));
+4 -10
View File
@@ -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;
}
}