@xterm/addon-webgl 0.20.0-beta.3 → 0.20.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xterm/addon-webgl",
3
- "version": "0.20.0-beta.3",
3
+ "version": "0.20.0-beta.4",
4
4
  "author": {
5
5
  "name": "The xterm.js authors",
6
6
  "url": "https://xtermjs.org/"
@@ -23,8 +23,8 @@
23
23
  "prepublishOnly": "npm run package",
24
24
  "start": "node ../../demo/start"
25
25
  },
26
- "commit": "8308ede3f5a74b24e1a7aaed89be68404951e5bc",
26
+ "commit": "7fee40ddcd4fbec5cdbd8fb7851d77803ea65b82",
27
27
  "peerDependencies": {
28
- "@xterm/xterm": "^6.1.0-beta.3"
28
+ "@xterm/xterm": "^6.1.0-beta.4"
29
29
  }
30
30
  }
@@ -298,6 +298,31 @@ export const symbolsForLegacyComputingDefinitions: { [index: string]: DrawFuncti
298
298
  '\u{1FB6F}': () => 'M0,1 L1,1 L0.5,0.5 Z' // LOWER TRIANGULAR ONE QUARTER BLOCK
299
299
  };
300
300
 
301
+ /**
302
+ * Rectangular shade characters - these use medium shade pattern with region bounds.
303
+ * Pattern is a checkerboard that shifts 1px each row (same as medium shade).
304
+ * Region is defined as [x, y, width, height] in 0-1 normalized coordinates.
305
+ */
306
+ export const rectangularShadeDefinitions: { [index: string]: [number, number, number, number] | undefined } = {
307
+ '\u{1FB8C}': [0, 0, 0.5, 1], // LEFT HALF MEDIUM SHADE
308
+ '\u{1FB8D}': [0.5, 0, 0.5, 1], // RIGHT HALF MEDIUM SHADE
309
+ '\u{1FB8E}': [0, 0, 1, 0.5], // UPPER HALF MEDIUM SHADE
310
+ '\u{1FB8F}': [0, 0.5, 1, 0.5], // LOWER HALF MEDIUM SHADE
311
+ '\u{1FB90}': [0, 0, 1, 1] // INVERSE MEDIUM SHADE
312
+ };
313
+
314
+ /**
315
+ * Block + inverse shade combo characters.
316
+ * Each entry: [solidRegion, shadeRegion] where regions are [x, y, w, h] in 0-1 coords.
317
+ * Shade region uses inverse medium shade pattern.
318
+ */
319
+ export const blockShadeComboDefinitions: { [index: string]: [[number, number, number, number], [number, number, number, number]] | undefined } = {
320
+ '\u{1FB91}': [[0, 0, 1, 0.5], [0, 0.5, 1, 0.5]], // UPPER HALF BLOCK AND LOWER HALF INVERSE MEDIUM SHADE
321
+ '\u{1FB92}': [[0, 0.5, 1, 0.5], [0, 0, 1, 0.5]], // UPPER HALF INVERSE MEDIUM SHADE AND LOWER HALF BLOCK
322
+ // 1FB93 is reserved
323
+ '\u{1FB94}': [[0.5, 0, 0.5, 1], [0, 0, 0.5, 1]] // LEFT HALF INVERSE MEDIUM SHADE AND RIGHT HALF BLOCK
324
+ };
325
+
301
326
  type PatternDefinition = number[][];
302
327
 
303
328
  /**
@@ -602,6 +627,18 @@ export function tryDrawCustomChar(
602
627
  return true;
603
628
  }
604
629
 
630
+ const rectangularShadeDefinition = rectangularShadeDefinitions[c];
631
+ if (rectangularShadeDefinition) {
632
+ drawRectangularShadeChar(ctx, rectangularShadeDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight, c === '\u{1FB90}');
633
+ return true;
634
+ }
635
+
636
+ const blockShadeComboDefinition = blockShadeComboDefinitions[c];
637
+ if (blockShadeComboDefinition) {
638
+ drawBlockShadeComboChar(ctx, blockShadeComboDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
639
+ return true;
640
+ }
641
+
605
642
  const patternDefinition = patternCharacterDefinitions[c];
606
643
  if (patternDefinition) {
607
644
  drawPatternChar(ctx, patternDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
@@ -739,6 +776,81 @@ function drawPatternChar(
739
776
  ctx.fillRect(xOffset, yOffset, deviceCellWidth, deviceCellHeight);
740
777
  }
741
778
 
779
+ /**
780
+ * Draws rectangular shade characters - medium shade pattern clipped to a region.
781
+ * Uses a checkerboard pattern that shifts 1px each row (same as medium shade U+2592).
782
+ */
783
+ function drawRectangularShadeChar(
784
+ ctx: CanvasRenderingContext2D,
785
+ region: [number, number, number, number],
786
+ xOffset: number,
787
+ yOffset: number,
788
+ deviceCellWidth: number,
789
+ deviceCellHeight: number,
790
+ isInverse: boolean
791
+ ): void {
792
+ const [rx, ry, rw, rh] = region;
793
+ const regionX = Math.round(xOffset + rx * deviceCellWidth);
794
+ const regionY = Math.round(yOffset + ry * deviceCellHeight);
795
+ const regionW = Math.round(rw * deviceCellWidth);
796
+ const regionH = Math.round(rh * deviceCellHeight);
797
+
798
+ // For inverse medium shade, we use the opposite pattern (fill where medium shade doesn't)
799
+ // Medium shade pattern: fills at (x+y) % 2 === 0, so inverse fills at (x+y) % 2 === 1
800
+ const patternOffset = isInverse ? 1 : 0;
801
+
802
+ for (let py = 0; py < regionH; py++) {
803
+ // Calculate the absolute y position for pattern calculation
804
+ const absY = regionY + py - yOffset;
805
+ for (let px = 0; px < regionW; px++) {
806
+ const absX = regionX + px - xOffset;
807
+ // Checkerboard pattern: fill if (x + y) % 2 matches the offset
808
+ if (((absX + absY) % 2) === patternOffset) {
809
+ ctx.fillRect(regionX + px, regionY + py, 1, 1);
810
+ }
811
+ }
812
+ }
813
+ }
814
+
815
+ /**
816
+ * Draws block + inverse shade combo characters.
817
+ * Fills the solid region completely, then draws inverse medium shade in the shade region.
818
+ */
819
+ function drawBlockShadeComboChar(
820
+ ctx: CanvasRenderingContext2D,
821
+ regions: [[number, number, number, number], [number, number, number, number]],
822
+ xOffset: number,
823
+ yOffset: number,
824
+ deviceCellWidth: number,
825
+ deviceCellHeight: number
826
+ ): void {
827
+ const [solidRegion, shadeRegion] = regions;
828
+
829
+ // Draw solid block region
830
+ const solidX = Math.round(xOffset + solidRegion[0] * deviceCellWidth);
831
+ const solidY = Math.round(yOffset + solidRegion[1] * deviceCellHeight);
832
+ const solidW = Math.round(solidRegion[2] * deviceCellWidth);
833
+ const solidH = Math.round(solidRegion[3] * deviceCellHeight);
834
+ ctx.fillRect(solidX, solidY, solidW, solidH);
835
+
836
+ // Draw inverse medium shade region
837
+ const shadeX = Math.round(xOffset + shadeRegion[0] * deviceCellWidth);
838
+ const shadeY = Math.round(yOffset + shadeRegion[1] * deviceCellHeight);
839
+ const shadeW = Math.round(shadeRegion[2] * deviceCellWidth);
840
+ const shadeH = Math.round(shadeRegion[3] * deviceCellHeight);
841
+
842
+ for (let py = 0; py < shadeH; py++) {
843
+ const absY = shadeY + py - yOffset;
844
+ for (let px = 0; px < shadeW; px++) {
845
+ const absX = shadeX + px - xOffset;
846
+ // Inverse checkerboard: fill at (x + y) % 2 === 1
847
+ if (((absX + absY) % 2) === 1) {
848
+ ctx.fillRect(shadeX + px, shadeY + py, 1, 1);
849
+ }
850
+ }
851
+ }
852
+ }
853
+
742
854
  /**
743
855
  * Draws the following box drawing characters by mapping a subset of SVG d attribute instructions to
744
856
  * canvas draw calls.