Use onRender() instead of onData() and onScroll()

This commit is contained in:
Jon Bockhorst
2019-11-08 11:08:50 -06:00
parent f93939ef20
commit 8924aa736e
3 changed files with 14 additions and 13 deletions
+2 -2
View File
@@ -281,7 +281,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this.register(this._inputHandler);
this.linkifier = this.linkifier || new Linkifier(this._bufferService, this._logService);
this.linkifier2 = this.linkifier2 || new Linkifier2(this._bufferService, this._coreService, this.onScroll.bind(this));
this.linkifier2 = this.linkifier2 || new Linkifier2(this._bufferService);
if (this.options.windowsMode) {
this._windowsMode = applyWindowsMode(this);
@@ -600,7 +600,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this.register(this._mouseZoneManager);
this.register(this.onScroll(() => this._mouseZoneManager.clearAll()));
this.linkifier.attachToDom(this.element, this._mouseZoneManager);
this.linkifier2.attachToDom(this.element, this._mouseService);
this.linkifier2.attachToDom(this.element, this._mouseService, this._renderService);
// This event listener must be registered aftre MouseZoneManager is created
this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService.onMouseDown(e)));
+10 -9
View File
@@ -5,14 +5,15 @@
import { ILinkifier2, ILinkProvider, IBufferCellPosition, ILink, ILinkifierEvent } from './Types';
import { IDisposable } from 'common/Types';
import { IMouseService } from './services/Services';
import { IMouseService, IRenderService } from './services/Services';
import { IBufferService, ICoreService } from 'common/services/Services';
import { EventEmitter, IEvent } from 'common/EventEmitter';
export class Linkifier2 implements ILinkifier2 {
private _element: HTMLElement | undefined;
private _linkProviders: ILinkProvider[] = [];
private _mouseService: IMouseService | undefined;
private _renderService: IRenderService | undefined;
private _linkProviders: ILinkProvider[] = [];
private _currentLink: ILink | undefined;
private _lastMouseEvent: MouseEvent | undefined;
private _linkCacheDisposables: IDisposable[] = [];
@@ -24,9 +25,7 @@ export class Linkifier2 implements ILinkifier2 {
public get onHideTooltip(): IEvent<ILinkifierEvent> { return this._onHideTooltip.event; }
constructor(
private readonly _bufferService: IBufferService,
private readonly _coreService: ICoreService,
private readonly _onScroll: IEvent<number>
private readonly _bufferService: IBufferService
) {
}
@@ -45,9 +44,10 @@ export class Linkifier2 implements ILinkifier2 {
};
}
public attachToDom(element: HTMLElement, mouseService: IMouseService): void {
public attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void {
this._element = element;
this._mouseService = mouseService;
this._renderService = renderService;
this._element.addEventListener('mousemove', this._onMouseMove.bind(this));
this._element.addEventListener('click', this._onMouseDown.bind(this));
@@ -162,9 +162,10 @@ export class Linkifier2 implements ILinkifier2 {
this._currentLink = link;
this._showTooltip(this._element, link, this._lastMouseEvent);
// Add listeners for onData and onScroll
this._linkCacheDisposables.push(this._coreService.onData(() => this._clearCurrentLink()));
this._linkCacheDisposables.push(this._onScroll(() => this._clearCurrentLink()));
// Add listener for rerendering
if (this._renderService) {
this._linkCacheDisposables.push(this._renderService.onRender(() => this._clearCurrentLink()));
}
}
}
+2 -2
View File
@@ -5,7 +5,7 @@
import { IEvent } from 'common/EventEmitter';
import { IDisposable } from 'common/Types';
import { IMouseService } from './services/Services';
import { IMouseService, IRenderService } from './services/Services';
export interface IColorManager {
colors: IColorSet;
@@ -98,7 +98,7 @@ export interface ILinkifier2 {
onShowTooltip: IEvent<ILinkifierEvent>;
onHideTooltip: IEvent<ILinkifierEvent>;
attachToDom(element: HTMLElement, mouseService: IMouseService): void;
attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void;
registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
}