Support customGlyph in webgl options

This commit is contained in:
Daniel Imms 2025-12-25 13:24:48 -08:00
parent 0fa7421669
commit 874799b352
No known key found for this signature in database
GPG Key ID: 5F0FF45B19E3A5D2
2 changed files with 13 additions and 7 deletions

View File

@ -120,6 +120,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
private _searchAddon?: SearchAddonType;
private _unicode11Addon?: Unicode11AddonType;
private _webglAddon?: WebglAddonType;
private _webglAddonCustomGlyphs?: boolean = false;
private _serializeAddon?: SerializeAddonType;
private _imageAddon?: ImageAddonType;
private readonly _ligaturesAddon: MutableDisposable<LigaturesAddonType> = this._register(new MutableDisposable());
@ -228,7 +229,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
macOptionIsMeta: config.macOptionIsMeta,
macOptionClickForcesSelection: config.macOptionClickForcesSelection,
rightClickSelectsWord: config.rightClickBehavior === 'selectWord',
fastScrollModifier: 'alt',
fastScrollSensitivity: config.fastScrollSensitivity,
scrollSensitivity: config.mouseWheelScrollSensitivity,
scrollOnEraseInDisplay: true,
@ -531,7 +531,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
this.raw.options.macOptionClickForcesSelection = config.macOptionClickForcesSelection;
this.raw.options.rightClickSelectsWord = config.rightClickBehavior === 'selectWord';
this.raw.options.wordSeparator = config.wordSeparators;
this.raw.options.customGlyphs = config.customGlyphs;
this.raw.options.ignoreBracketedPasteMode = config.ignoreBracketedPasteMode;
this.raw.options.rescaleOverlappingGlyphs = config.rescaleOverlappingGlyphs;
@ -790,12 +789,16 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
}
private async _enableWebglRenderer(): Promise<void> {
if (!this.raw.element || this._webglAddon) {
// Currently webgl options can only be specified on addon creation
if (!this.raw.element || this._webglAddon && this._webglAddonCustomGlyphs === this._terminalConfigurationService.config.customGlyphs) {
return;
}
this._webglAddonCustomGlyphs = this._terminalConfigurationService.config.customGlyphs;
const Addon = await this._xtermAddonLoader.importAddon('webgl');
this._webglAddon = new Addon();
this._webglAddon = new Addon({
customGlyphs: this._terminalConfigurationService.config.customGlyphs
});
try {
this.raw.loadAddon(this._webglAddon);
this._logService.trace('Webgl was loaded');
@ -885,6 +888,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
// ignore
}
this._webglAddon = undefined;
this._webglAddonCustomGlyphs = undefined;
this._refreshImageAddon();
// WebGL renderer cell dimensions differ from the DOM renderer, make sure the terminal
// gets resized after the webgl addon is disposed

View File

@ -51,6 +51,7 @@ export class TerminalStickyScrollOverlay extends Disposable {
private readonly _xtermAddonLoader = new XtermAddonImporter();
private _serializeAddon?: SerializeAddonType;
private _webglAddon?: WebglAddonType;
private _webglAddonCustomGlyphs?: boolean;
private _ligaturesAddon?: LigaturesAddonType;
private _element?: HTMLElement;
@ -491,18 +492,19 @@ export class TerminalStickyScrollOverlay extends Disposable {
drawBoldTextInBrightColors: o.drawBoldTextInBrightColors,
minimumContrastRatio: o.minimumContrastRatio,
tabStopWidth: o.tabStopWidth,
customGlyphs: o.customGlyphs,
};
}
@throttle(0)
private async _refreshGpuAcceleration() {
if (this._shouldLoadWebgl() && !this._webglAddon) {
if (this._shouldLoadWebgl() && (!this._webglAddon || this._webglAddonCustomGlyphs !== this._terminalConfigurationService.config.customGlyphs)) {
const WebglAddon = await this._xtermAddonLoader.importAddon('webgl');
if (this._store.isDisposed) {
return;
}
this._webglAddon = this._register(new WebglAddon());
this._webglAddon = this._register(new WebglAddon({
customGlyphs: this._terminalConfigurationService.config.customGlyphs
}));
this._stickyScrollOverlay?.loadAddon(this._webglAddon);
} else if (!this._shouldLoadWebgl() && this._webglAddon) {
this._webglAddon.dispose();