Skip to content

Commit 93c1650

Browse files
committed
Move variant handling out of CellColorResolver.ts
1 parent dc4ebfd commit 93c1650

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

addons/addon-webgl/src/CellColorResolver.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class CellColorResolver {
4242
* Resolves colors for the cell, putting the result into the shared {@link result}. This resolves
4343
* overrides, inverse and selection for the cell which can then be used to feed into the renderer.
4444
*/
45-
public resolve(cell: ICellData, x: number, y: number, deviceCellWidth: number, deviceCellHeight: number): void {
45+
public resolve(cell: ICellData, x: number, y: number, deviceCellWidth: number): void {
4646
this.result.bg = cell.bg;
4747
this.result.fg = cell.fg;
4848
this.result.ext = cell.bg & BgFlags.HAS_EXTENDED ? cell.extended.ext : 0;
@@ -63,12 +63,6 @@ export class CellColorResolver {
6363
const lineWidth = Math.max(1, Math.floor(this._optionService.rawOptions.fontSize * this._coreBrowserService.dpr / 15));
6464
$variantOffset = x * deviceCellWidth % (Math.round(lineWidth) * 2);
6565
}
66-
if ($variantOffset === 0) {
67-
if ((code >= 0x2591 && code <= 0x2593) || (code >= 0x1FB8C && code <= 0x1FB94)) {
68-
$variantOffset = ((x * deviceCellWidth) % 2) * 2 + ((y * deviceCellHeight) % 2);
69-
}
70-
}
71-
7266
// Apply decorations on the bottom layer
7367
this._decorationService.forEachDecorationAtCell(x, y, 'bottom', d => {
7468
if (d.backgroundColorRGB) {

addons/addon-webgl/src/WebglRenderer.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, IThemeS
1313
import { CharData, IBufferLine, ICellData } from 'common/Types';
1414
import { AttributeData } from 'common/buffer/AttributeData';
1515
import { CellData } from 'common/buffer/CellData';
16-
import { Attributes, Content, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants';
16+
import { Attributes, Content, ExtFlags, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants';
1717
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
1818
import { Terminal } from '@xterm/xterm';
1919
import { GlyphRenderer } from './GlyphRenderer';
@@ -26,6 +26,7 @@ import { Emitter, EventUtils } from 'common/Event';
2626
import { addDisposableListener } from 'vs/base/browser/dom';
2727
import { combinedDisposable, Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
2828
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
29+
import { blockPatternCodepoints } from './customGlyphs/CustomGlyphDefinitions';
2930

3031
export class WebglRenderer extends Disposable implements IRenderer {
3132
private _renderLayers: IRenderLayer[];
@@ -478,7 +479,12 @@ export class WebglRenderer extends Disposable implements IRenderer {
478479
i = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
479480

480481
// Load colors/resolve overrides into work colors
481-
this._cellColorResolver.resolve(cell, x, row, this.dimensions.device.cell.width, this.dimensions.device.cell.height);
482+
this._cellColorResolver.resolve(cell, x, row, this.dimensions.device.cell.width);
483+
if ((this._cellColorResolver.result.ext & ExtFlags.VARIANT_OFFSET) === 0 && blockPatternCodepoints.has(code)) {
484+
const variantOffset = ((x * this.dimensions.device.cell.width) % 2) * 2 + ((row * this.dimensions.device.cell.height) % 2);
485+
this._cellColorResolver.result.ext &= ~ExtFlags.VARIANT_OFFSET;
486+
this._cellColorResolver.result.ext |= (variantOffset << 29) & ExtFlags.VARIANT_OFFSET;
487+
}
482488

483489
// Override colors for cursor cell
484490
if (isCursorVisible && row === cursorY) {

addons/addon-webgl/src/customGlyphs/CustomGlyphDefinitions.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,20 @@ export const customGlyphDefinitions: { [index: string]: CustomGlyphCharacterDefi
820820
// #endregion
821821
};
822822

823+
export const blockPatternCodepoints = new Set<number>();
824+
for (const [char, definition] of Object.entries(customGlyphDefinitions)) {
825+
if (!definition) {
826+
continue;
827+
}
828+
const parts = Array.isArray(definition) ? definition : [definition];
829+
if (parts.some(part => part.type === CustomGlyphDefinitionType.BLOCK_PATTERN)) {
830+
const codepoint = char.codePointAt(0);
831+
if (codepoint !== undefined) {
832+
blockPatternCodepoints.add(codepoint);
833+
}
834+
}
835+
}
836+
823837
/**
824838
* Generates a drawing function for sextant characters. Sextants are a 2x3 grid where each cell
825839
* can be on or off.

0 commit comments

Comments
 (0)