Use options service directly in renderers

This commit is contained in:
Daniel Imms
2022-10-09 09:28:18 -07:00
parent 8ac88bc6bf
commit e47296c1b9
6 changed files with 11 additions and 9 deletions
@@ -70,6 +70,7 @@ export class CanvasRenderer extends Disposable implements IRenderer {
this.register(observeDevicePixelDimensions(this._renderLayers[0].canvas, this._coreBrowserService.window, (w, h) => this._setCanvasDevicePixelDimensions(w, h)));
this.handleOptionsChanged();
this.register(this._optionsService.onOptionChange(() => this.handleOptionsChanged()));
this.register(toDisposable(() => {
for (const l of this._renderLayers) {
+6 -6
View File
@@ -3,14 +3,13 @@
* @license MIT
*/
import { Terminal, ITerminalAddon, IEvent } from 'xterm';
import { WebglRenderer } from './WebglRenderer';
import { ICharacterJoinerService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
import { IColorSet } from 'browser/Types';
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
import { isSafari } from 'common/Platform';
import { ICoreService, IDecorationService } from 'common/services/Services';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { isSafari } from 'common/Platform';
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
import { ITerminalAddon, Terminal } from 'xterm';
import { WebglRenderer } from './WebglRenderer';
export class WebglAddon extends Disposable implements ITerminalAddon {
private _terminal?: Terminal;
@@ -43,7 +42,8 @@ export class WebglAddon extends Disposable implements ITerminalAddon {
const coreService: ICoreService = core.coreService;
const decorationService: IDecorationService = core._decorationService;
const themeService: IThemeService = core._themeService;
this._renderer = this.register(new WebglRenderer(terminal, themeService, characterJoinerService, coreBrowserService, coreService, decorationService, this._preserveDrawingBuffer));
const optionsService: IOptionsService = core.optionsService;
this._renderer = this.register(new WebglRenderer(terminal, themeService, characterJoinerService, coreBrowserService, optionsService, coreService, decorationService, this._preserveDrawingBuffer));
this.register(forwardEvent(this._renderer.onContextLoss, this._onContextLoss));
this.register(forwardEvent(this._renderer.onChangeTextureAtlas, this._onChangeTextureAtlas));
renderService.setRenderer(this._renderer);
@@ -15,7 +15,7 @@ import { CellData } from 'common/buffer/CellData';
import { Content, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants';
import { EventEmitter } from 'common/EventEmitter';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { ICoreService, IDecorationService } from 'common/services/Services';
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
import { CharData, IBufferLine, ICellData } from 'common/Types';
import { Terminal } from 'xterm';
import { GlyphRenderer } from './GlyphRenderer';
@@ -58,6 +58,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
private readonly _themeService: IThemeService,
private readonly _characterJoinerService: ICharacterJoinerService,
private readonly _coreBrowserService: ICoreBrowserService,
optionsService: IOptionsService,
coreService: ICoreService,
private readonly _decorationService: IDecorationService,
preserveDrawingBuffer?: boolean
@@ -90,6 +91,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
};
this._devicePixelRatio = this._coreBrowserService.dpr;
this._updateDimensions();
this.register(optionsService.onOptionChange(() => this.handleOptionsChanged()));
this._canvas = document.createElement('canvas');
+1
View File
@@ -79,6 +79,7 @@ export class DomRenderer extends Disposable implements IRenderer {
actualCellHeight: 0
};
this._updateDimensions();
this.register(this._optionsService.onOptionChange(() => this.handleOptionsChanged()));
this.register(themeService.onChangeColors(e => this._injectCss(e)));
this._injectCss(themeService.colors);
-1
View File
@@ -68,7 +68,6 @@ export interface IRenderer extends IDisposable {
handleFocus(): void;
handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
handleCursorMove(): void;
handleOptionsChanged(): void;
clear(): void;
renderRows(start: number, end: number): void;
clearTextureAtlas?(): void;
-1
View File
@@ -177,7 +177,6 @@ export class RenderService extends Disposable implements IRenderService {
if (!this._renderer) {
return;
}
this._renderer.handleOptionsChanged();
this.refreshRows(0, this._rowCount - 1);
this._fireOnCanvasResize();
}