Fix internal usages that needed Required<ITerminalOptions>
This commit is contained in:
@@ -122,7 +122,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._charAtlasDisposable?.dispose();
|
this._charAtlasDisposable?.dispose();
|
||||||
this._charAtlas = acquireTextureAtlas(this._terminal, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
|
this._charAtlas = acquireTextureAtlas(this._terminal, this._optionsService.rawOptions, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
|
||||||
this._charAtlasDisposable = forwardEvent(this._charAtlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas);
|
this._charAtlasDisposable = forwardEvent(this._charAtlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas);
|
||||||
this._charAtlas.warmUp();
|
this._charAtlas.warmUp();
|
||||||
for (let i = 0; i < this._charAtlas.pages.length; i++) {
|
for (let i = 0; i < this._charAtlas.pages.length; i++) {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
private readonly _coreBrowserService: ICoreBrowserService,
|
private readonly _coreBrowserService: ICoreBrowserService,
|
||||||
coreService: ICoreService,
|
coreService: ICoreService,
|
||||||
private readonly _decorationService: IDecorationService,
|
private readonly _decorationService: IDecorationService,
|
||||||
optionsService: IOptionsService,
|
private readonly _optionsService: IOptionsService,
|
||||||
private readonly _themeService: IThemeService,
|
private readonly _themeService: IThemeService,
|
||||||
preserveDrawingBuffer?: boolean
|
preserveDrawingBuffer?: boolean
|
||||||
) {
|
) {
|
||||||
@@ -80,13 +80,13 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
this._core = (this._terminal as any)._core;
|
this._core = (this._terminal as any)._core;
|
||||||
|
|
||||||
this._renderLayers = [
|
this._renderLayers = [
|
||||||
new LinkRenderLayer(this._core.screenElement!, 2, this._terminal, this._core.linkifier2, this._coreBrowserService, this._themeService),
|
new LinkRenderLayer(this._core.screenElement!, 2, this._terminal, this._core.linkifier2, this._coreBrowserService, _optionsService, this._themeService),
|
||||||
new CursorRenderLayer(_terminal, this._core.screenElement!, 3, this._onRequestRedraw, this._coreBrowserService, coreService, this._themeService, optionsService)
|
new CursorRenderLayer(_terminal, this._core.screenElement!, 3, this._onRequestRedraw, this._coreBrowserService, coreService, _optionsService, this._themeService)
|
||||||
];
|
];
|
||||||
this.dimensions = createRenderDimensions();
|
this.dimensions = createRenderDimensions();
|
||||||
this._devicePixelRatio = this._coreBrowserService.dpr;
|
this._devicePixelRatio = this._coreBrowserService.dpr;
|
||||||
this._updateDimensions();
|
this._updateDimensions();
|
||||||
this.register(optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
this.register(_optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||||
|
|
||||||
this._canvas = document.createElement('canvas');
|
this._canvas = document.createElement('canvas');
|
||||||
|
|
||||||
@@ -259,6 +259,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
const atlas = acquireTextureAtlas(
|
const atlas = acquireTextureAtlas(
|
||||||
this._terminal,
|
this._terminal,
|
||||||
|
this._optionsService.rawOptions,
|
||||||
this._themeService.colors,
|
this._themeService.colors,
|
||||||
this.dimensions.device.cell.width,
|
this.dimensions.device.cell.width,
|
||||||
this.dimensions.device.cell.height,
|
this.dimensions.device.cell.height,
|
||||||
@@ -469,18 +470,18 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
// Calculate the device cell height, if lineHeight is _not_ 1, the resulting value will be
|
// Calculate the device cell height, if lineHeight is _not_ 1, the resulting value will be
|
||||||
// floored since lineHeight can never be lower then 1, this guarentees the device cell height
|
// floored since lineHeight can never be lower then 1, this guarentees the device cell height
|
||||||
// will always be larger than device char height.
|
// will always be larger than device char height.
|
||||||
this.dimensions.device.cell.height = Math.floor(this.dimensions.device.char.height * this._terminal.options.lineHeight);
|
this.dimensions.device.cell.height = Math.floor(this.dimensions.device.char.height * this._optionsService.rawOptions.lineHeight);
|
||||||
|
|
||||||
// Calculate the y offset within a cell that glyph should draw at in order for it to be centered
|
// Calculate the y offset within a cell that glyph should draw at in order for it to be centered
|
||||||
// correctly within the cell.
|
// correctly within the cell.
|
||||||
this.dimensions.device.char.top = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.device.cell.height - this.dimensions.device.char.height) / 2);
|
this.dimensions.device.char.top = this._optionsService.rawOptions.lineHeight === 1 ? 0 : Math.round((this.dimensions.device.cell.height - this.dimensions.device.char.height) / 2);
|
||||||
|
|
||||||
// Calculate the device cell width, taking the letterSpacing into account.
|
// Calculate the device cell width, taking the letterSpacing into account.
|
||||||
this.dimensions.device.cell.width = this.dimensions.device.char.width + Math.round(this._terminal.options.letterSpacing);
|
this.dimensions.device.cell.width = this.dimensions.device.char.width + Math.round(this._optionsService.rawOptions.letterSpacing);
|
||||||
|
|
||||||
// Calculate the x offset with a cell that text should draw from in order for it to be centered
|
// Calculate the x offset with a cell that text should draw from in order for it to be centered
|
||||||
// correctly within the cell.
|
// correctly within the cell.
|
||||||
this.dimensions.device.char.left = Math.floor(this._terminal.options.letterSpacing / 2);
|
this.dimensions.device.char.left = Math.floor(this._optionsService.rawOptions.letterSpacing / 2);
|
||||||
|
|
||||||
// Recalculate the canvas dimensions, the device dimensions define the actual number of pixel in
|
// Recalculate the canvas dimensions, the device dimensions define the actual number of pixel in
|
||||||
// the canvas
|
// the canvas
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { IRenderDimensions, ITextureAtlas } from 'browser/renderer/shared/Types'
|
|||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
||||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||||
|
import { IOptionsService } from 'common/services/Services';
|
||||||
|
|
||||||
export abstract class BaseRenderLayer extends Disposable implements IRenderLayer {
|
export abstract class BaseRenderLayer extends Disposable implements IRenderLayer {
|
||||||
private _canvas: HTMLCanvasElement;
|
private _canvas: HTMLCanvasElement;
|
||||||
@@ -33,6 +34,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
|
|||||||
zIndex: number,
|
zIndex: number,
|
||||||
private _alpha: boolean,
|
private _alpha: boolean,
|
||||||
protected readonly _coreBrowserService: ICoreBrowserService,
|
protected readonly _coreBrowserService: ICoreBrowserService,
|
||||||
|
protected readonly _optionsService: IOptionsService,
|
||||||
protected readonly _themeService: IThemeService
|
protected readonly _themeService: IThemeService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
@@ -93,7 +95,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
|
|||||||
if (this._deviceCharWidth <= 0 && this._deviceCharHeight <= 0) {
|
if (this._deviceCharWidth <= 0 && this._deviceCharHeight <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._charAtlas = acquireTextureAtlas(terminal, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
|
this._charAtlas = acquireTextureAtlas(terminal, this._optionsService.rawOptions, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
|
||||||
this._charAtlas.warmUp();
|
this._charAtlas.warmUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
|||||||
private _onRequestRefreshRowsEvent: IEventEmitter<IRequestRedrawEvent>,
|
private _onRequestRefreshRowsEvent: IEventEmitter<IRequestRedrawEvent>,
|
||||||
coreBrowserService: ICoreBrowserService,
|
coreBrowserService: ICoreBrowserService,
|
||||||
private readonly _coreService: ICoreService,
|
private readonly _coreService: ICoreService,
|
||||||
themeService: IThemeService,
|
optionsService: IOptionsService,
|
||||||
optionsService: IOptionsService
|
themeService: IThemeService
|
||||||
) {
|
) {
|
||||||
super(terminal, container, 'cursor', zIndex, true, coreBrowserService, themeService);
|
super(terminal, container, 'cursor', zIndex, true, coreBrowserService, optionsService, themeService);
|
||||||
this._state = {
|
this._state = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
@@ -213,7 +213,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
|||||||
private _renderBarCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
|
private _renderBarCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
|
||||||
this._ctx.save();
|
this._ctx.save();
|
||||||
this._ctx.fillStyle = this._themeService.colors.cursor.css;
|
this._ctx.fillStyle = this._themeService.colors.cursor.css;
|
||||||
this._fillLeftLineAtCell(x, y, terminal.options.cursorWidth);
|
this._fillLeftLineAtCell(x, y, this._optionsService.rawOptions.cursorWidth);
|
||||||
this._ctx.restore();
|
this._ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/shared/Constants';
|
|||||||
import { IRenderDimensions } from 'browser/renderer/shared/Types';
|
import { IRenderDimensions } from 'browser/renderer/shared/Types';
|
||||||
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
|
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
|
||||||
import { ILinkifier2, ILinkifierEvent } from 'browser/Types';
|
import { ILinkifier2, ILinkifierEvent } from 'browser/Types';
|
||||||
|
import { IOptionsService } from 'common/services/Services';
|
||||||
import { Terminal } from 'xterm';
|
import { Terminal } from 'xterm';
|
||||||
import { BaseRenderLayer } from './BaseRenderLayer';
|
import { BaseRenderLayer } from './BaseRenderLayer';
|
||||||
|
|
||||||
@@ -20,9 +21,10 @@ export class LinkRenderLayer extends BaseRenderLayer {
|
|||||||
terminal: Terminal,
|
terminal: Terminal,
|
||||||
linkifier2: ILinkifier2,
|
linkifier2: ILinkifier2,
|
||||||
coreBrowserService: ICoreBrowserService,
|
coreBrowserService: ICoreBrowserService,
|
||||||
|
optionsService: IOptionsService,
|
||||||
themeService: IThemeService
|
themeService: IThemeService
|
||||||
) {
|
) {
|
||||||
super(terminal, container, 'link', zIndex, true, coreBrowserService, themeService);
|
super(terminal, container, 'link', zIndex, true, coreBrowserService, optionsService, themeService);
|
||||||
|
|
||||||
this.register(linkifier2.onShowLinkUnderline(e => this._handleShowLinkUnderline(e)));
|
this.register(linkifier2.onShowLinkUnderline(e => this._handleShowLinkUnderline(e)));
|
||||||
this.register(linkifier2.onHideLinkUnderline(e => this._handleHideLinkUnderline(e)));
|
this.register(linkifier2.onHideLinkUnderline(e => this._handleHideLinkUnderline(e)));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { TextureAtlas } from 'browser/renderer/shared/TextureAtlas';
|
import { TextureAtlas } from 'browser/renderer/shared/TextureAtlas';
|
||||||
import { Terminal } from 'xterm';
|
import { ITerminalOptions, Terminal } from 'xterm';
|
||||||
import { ITerminal, ReadonlyColorSet } from 'browser/Types';
|
import { ITerminal, ReadonlyColorSet } from 'browser/Types';
|
||||||
import { ICharAtlasConfig, ITextureAtlas } from 'browser/renderer/shared/Types';
|
import { ICharAtlasConfig, ITextureAtlas } from 'browser/renderer/shared/Types';
|
||||||
import { generateConfig, configEquals } from 'browser/renderer/shared/CharAtlasUtils';
|
import { generateConfig, configEquals } from 'browser/renderer/shared/CharAtlasUtils';
|
||||||
@@ -22,11 +22,10 @@ const charAtlasCache: ITextureAtlasCacheEntry[] = [];
|
|||||||
/**
|
/**
|
||||||
* Acquires a char atlas, either generating a new one or returning an existing
|
* Acquires a char atlas, either generating a new one or returning an existing
|
||||||
* one that is in use by another terminal.
|
* one that is in use by another terminal.
|
||||||
* @param terminal The terminal.
|
|
||||||
* @param colors The colors to use.
|
|
||||||
*/
|
*/
|
||||||
export function acquireTextureAtlas(
|
export function acquireTextureAtlas(
|
||||||
terminal: Terminal,
|
terminal: Terminal,
|
||||||
|
options: Required<ITerminalOptions>,
|
||||||
colors: ReadonlyColorSet,
|
colors: ReadonlyColorSet,
|
||||||
deviceCellWidth: number,
|
deviceCellWidth: number,
|
||||||
deviceCellHeight: number,
|
deviceCellHeight: number,
|
||||||
@@ -34,7 +33,7 @@ export function acquireTextureAtlas(
|
|||||||
deviceCharHeight: number,
|
deviceCharHeight: number,
|
||||||
devicePixelRatio: number
|
devicePixelRatio: number
|
||||||
): ITextureAtlas {
|
): ITextureAtlas {
|
||||||
const newConfig = generateConfig(deviceCellWidth, deviceCellHeight, deviceCharWidth, deviceCharHeight, terminal, colors, devicePixelRatio);
|
const newConfig = generateConfig(deviceCellWidth, deviceCellHeight, deviceCharWidth, deviceCharHeight, options, colors, devicePixelRatio);
|
||||||
|
|
||||||
// Check to see if the terminal already owns this config
|
// Check to see if the terminal already owns this config
|
||||||
for (let i = 0; i < charAtlasCache.length; i++) {
|
for (let i = 0; i < charAtlasCache.length; i++) {
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
import { ICharAtlasConfig } from './Types';
|
import { ICharAtlasConfig } from './Types';
|
||||||
import { Attributes } from 'common/buffer/Constants';
|
import { Attributes } from 'common/buffer/Constants';
|
||||||
import { Terminal } from 'xterm';
|
import { ITerminalOptions } from 'xterm';
|
||||||
import { IColorSet, ReadonlyColorSet } from 'browser/Types';
|
import { IColorSet, ReadonlyColorSet } from 'browser/Types';
|
||||||
import { NULL_COLOR } from 'common/Color';
|
import { NULL_COLOR } from 'common/Color';
|
||||||
|
|
||||||
export function generateConfig(deviceCellWidth: number, deviceCellHeight: number, deviceCharWidth: number, deviceCharHeight: number, terminal: Terminal, colors: ReadonlyColorSet, devicePixelRatio: number): ICharAtlasConfig {
|
export function generateConfig(deviceCellWidth: number, deviceCellHeight: number, deviceCharWidth: number, deviceCharHeight: number, options: Required<ITerminalOptions>, colors: ReadonlyColorSet, devicePixelRatio: number): ICharAtlasConfig {
|
||||||
// null out some fields that don't matter
|
// null out some fields that don't matter
|
||||||
const clonedColors: IColorSet = {
|
const clonedColors: IColorSet = {
|
||||||
foreground: colors.foreground,
|
foreground: colors.foreground,
|
||||||
@@ -27,21 +27,21 @@ export function generateConfig(deviceCellWidth: number, deviceCellHeight: number
|
|||||||
contrastCache: colors.contrastCache
|
contrastCache: colors.contrastCache
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
customGlyphs: terminal.options.customGlyphs,
|
customGlyphs: options.customGlyphs,
|
||||||
devicePixelRatio,
|
devicePixelRatio,
|
||||||
letterSpacing: terminal.options.letterSpacing,
|
letterSpacing: options.letterSpacing,
|
||||||
lineHeight: terminal.options.lineHeight,
|
lineHeight: options.lineHeight,
|
||||||
deviceCellWidth: deviceCellWidth,
|
deviceCellWidth: deviceCellWidth,
|
||||||
deviceCellHeight: deviceCellHeight,
|
deviceCellHeight: deviceCellHeight,
|
||||||
deviceCharWidth: deviceCharWidth,
|
deviceCharWidth: deviceCharWidth,
|
||||||
deviceCharHeight: deviceCharHeight,
|
deviceCharHeight: deviceCharHeight,
|
||||||
fontFamily: terminal.options.fontFamily,
|
fontFamily: options.fontFamily,
|
||||||
fontSize: terminal.options.fontSize,
|
fontSize: options.fontSize,
|
||||||
fontWeight: terminal.options.fontWeight,
|
fontWeight: options.fontWeight,
|
||||||
fontWeightBold: terminal.options.fontWeightBold,
|
fontWeightBold: options.fontWeightBold,
|
||||||
allowTransparency: terminal.options.allowTransparency,
|
allowTransparency: options.allowTransparency,
|
||||||
drawBoldTextInBrightColors: terminal.options.drawBoldTextInBrightColors,
|
drawBoldTextInBrightColors: options.drawBoldTextInBrightColors,
|
||||||
minimumContrastRatio: terminal.options.minimumContrastRatio,
|
minimumContrastRatio: options.minimumContrastRatio,
|
||||||
colors: clonedColors
|
colors: clonedColors
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user