@xterm/addon-webgl 0.20.0-beta.2 → 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.2",
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": "937deb9f4ba0dbfb8d99eb0ea75cffdd2ecabc06",
26
+ "commit": "7fee40ddcd4fbec5cdbd8fb7851d77803ea65b82",
27
27
  "peerDependencies": {
28
- "@xterm/xterm": "^6.1.0-beta.2"
28
+ "@xterm/xterm": "^6.1.0-beta.4"
29
29
  }
30
30
  }
@@ -3,6 +3,8 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
+ /* eslint-disable @typescript-eslint/naming-convention */
7
+
6
8
  import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
7
9
 
8
10
  interface IBlockVector {
@@ -219,8 +221,106 @@ export const symbolsForLegacyComputingDefinitions: { [index: string]: DrawFuncti
219
221
  '\u{1FB38}': sextant(0b111011), // BLOCK SEXTANT-12456
220
222
  '\u{1FB39}': sextant(0b111100), // BLOCK SEXTANT-3456 (lower two thirds block)
221
223
  '\u{1FB3A}': sextant(0b111101), // BLOCK SEXTANT-13456
222
- '\u{1FB3B}': sextant(0b111110) // BLOCK SEXTANT-23456
224
+ '\u{1FB3B}': sextant(0b111110), // BLOCK SEXTANT-23456
223
225
  // Pattern 63 (0x3F = 0b111111) = full block, skipped (exists as U+2588)
226
+
227
+ // Smooth mosaic terminal graphic characters (0x1FB3C-0x1FB6F)
228
+ // These are triangular/diagonal shapes. "X BLOCK DIAGONAL A TO B" means the X region is filled,
229
+ // with a diagonal edge from point A to point B.
230
+ // Reference points: upper/lower = y (0/1), left/right = x (0/1), centre = x=0.5
231
+ // Vertical uses sextant grid: upper-middle = y=1/3, lower-middle = y=2/3
232
+
233
+ // LOWER LEFT BLOCK variants (1FB3C-1FB40) - filled region in lower-left
234
+ '\u{1FB3C}': () => `M0,${2/3} L0,1 L0.5,1 Z`, // LOWER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER CENTRE
235
+ '\u{1FB3D}': () => `M0,${2/3} L0,1 L1,1 Z`, // LOWER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER RIGHT
236
+ '\u{1FB3E}': () => `M0,${1/3} L0,1 L0.5,1 Z`, // LOWER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER CENTRE
237
+ '\u{1FB3F}': () => `M0,${1/3} L0,1 L1,1 Z`, // LOWER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER RIGHT
238
+ '\u{1FB40}': () => 'M0,0 L0,1 L0.5,1 Z', // LOWER LEFT BLOCK DIAGONAL UPPER LEFT TO LOWER CENTRE
239
+
240
+ // LOWER RIGHT BLOCK variants (1FB41-1FB4B) - filled region in lower-right
241
+ '\u{1FB41}': () => `M0,${1/3} L0.5,0 L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER CENTRE
242
+ '\u{1FB42}': () => `M0,${1/3} L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER RIGHT
243
+ '\u{1FB43}': () => `M0,${2/3} L0.5,0 L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER CENTRE
244
+ '\u{1FB44}': () => `M0,${2/3} L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER RIGHT
245
+ '\u{1FB45}': () => 'M0,1 L0.5,0 L1,0 L1,1 Z', // LOWER RIGHT BLOCK DIAGONAL LOWER LEFT TO UPPER CENTRE
246
+ '\u{1FB46}': () => `M0,${2/3} L1,${1/3} L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER MIDDLE RIGHT
247
+ '\u{1FB47}': () => `M0.5,1 L1,${2/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER CENTRE TO LOWER MIDDLE RIGHT
248
+ '\u{1FB48}': () => `M0,1 L1,${2/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER LEFT TO LOWER MIDDLE RIGHT
249
+ '\u{1FB49}': () => `M0.5,1 L1,${1/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER CENTRE TO UPPER MIDDLE RIGHT
250
+ '\u{1FB4A}': () => `M0,1 L1,${1/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER LEFT TO UPPER MIDDLE RIGHT
251
+ '\u{1FB4B}': () => 'M0.5,1 L1,0 L1,1 Z', // LOWER RIGHT BLOCK DIAGONAL LOWER CENTRE TO UPPER RIGHT
252
+
253
+ // LOWER LEFT BLOCK variants continued (1FB4C-1FB51) - large fills with upper-right cut
254
+ '\u{1FB4C}': () => `M0.5,0 L0,0 L0,1 L1,1 L1,${1/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER CENTRE TO UPPER MIDDLE RIGHT
255
+ '\u{1FB4D}': () => `M0,0 L0,1 L1,1 L1,${1/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER LEFT TO UPPER MIDDLE RIGHT
256
+ '\u{1FB4E}': () => `M0.5,0 L0,0 L0,1 L1,1 L1,${2/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER CENTRE TO LOWER MIDDLE RIGHT
257
+ '\u{1FB4F}': () => `M0,0 L0,1 L1,1 L1,${2/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER LEFT TO LOWER MIDDLE RIGHT
258
+ '\u{1FB50}': () => 'M0.5,0 L0,0 L0,1 L1,1 Z', // LOWER LEFT BLOCK DIAGONAL UPPER CENTRE TO LOWER RIGHT
259
+ '\u{1FB51}': () => `M0,${1/3} L0,1 L1,1 L1,${2/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER MIDDLE RIGHT
260
+
261
+ // UPPER RIGHT BLOCK variants (1FB52-1FB56) - large fills with lower-left cut
262
+ '\u{1FB52}': () => `M0,${2/3} L0.5,1 L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER CENTRE
263
+ '\u{1FB53}': () => `M0,${2/3} L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER RIGHT
264
+ '\u{1FB54}': () => `M0,${1/3} L0.5,1 L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER CENTRE
265
+ '\u{1FB55}': () => `M0,${1/3} L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER RIGHT
266
+ '\u{1FB56}': () => 'M0,0 L0.5,1 L1,1 L1,0 Z', // UPPER RIGHT BLOCK DIAGONAL UPPER LEFT TO LOWER CENTRE
267
+
268
+ // UPPER LEFT BLOCK variants (1FB57-1FB61) - small to large fills in upper-left
269
+ '\u{1FB57}': () => `M0,${1/3} L0,0 L0.5,0 Z`, // UPPER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER CENTRE
270
+ '\u{1FB58}': () => `M0,${1/3} L0,0 L1,0 Z`, // UPPER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER RIGHT
271
+ '\u{1FB59}': () => `M0,${2/3} L0,0 L0.5,0 Z`, // UPPER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER CENTRE
272
+ '\u{1FB5A}': () => `M0,${2/3} L0,0 L1,0 Z`, // UPPER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER RIGHT
273
+ '\u{1FB5B}': () => 'M0,1 L0,0 L0.5,0 Z', // UPPER LEFT BLOCK DIAGONAL LOWER LEFT TO UPPER CENTRE
274
+ '\u{1FB5C}': () => `M0,${2/3} L0,0 L1,0 L1,${1/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER MIDDLE RIGHT
275
+ '\u{1FB5D}': () => `M0.5,1 L0,1 L0,0 L1,0 L1,${2/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER CENTRE TO LOWER MIDDLE RIGHT
276
+ '\u{1FB5E}': () => `M0,1 L0,0 L1,0 L1,${2/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER LEFT TO LOWER MIDDLE RIGHT
277
+ '\u{1FB5F}': () => `M0.5,1 L0,1 L0,0 L1,0 L1,${1/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER CENTRE TO UPPER MIDDLE RIGHT
278
+ '\u{1FB60}': () => `M0,1 L0,0 L1,0 L1,${1/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER LEFT TO UPPER MIDDLE RIGHT
279
+ '\u{1FB61}': () => 'M0.5,1 L0,1 L0,0 L1,0 Z', // UPPER LEFT BLOCK DIAGONAL LOWER CENTRE TO UPPER RIGHT
280
+
281
+ // UPPER RIGHT BLOCK variants continued (1FB62-1FB67) - small to medium fills in upper-right
282
+ '\u{1FB62}': () => `M0.5,0 L1,0 L1,${1/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER CENTRE TO UPPER MIDDLE RIGHT
283
+ '\u{1FB63}': () => `M0,0 L1,0 L1,${1/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER LEFT TO UPPER MIDDLE RIGHT
284
+ '\u{1FB64}': () => `M0.5,0 L1,0 L1,${2/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER CENTRE TO LOWER MIDDLE RIGHT
285
+ '\u{1FB65}': () => `M0,0 L1,0 L1,${2/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER LEFT TO LOWER MIDDLE RIGHT
286
+ '\u{1FB66}': () => 'M0.5,0 L1,0 L1,1 Z', // UPPER RIGHT BLOCK DIAGONAL UPPER CENTRE TO LOWER RIGHT
287
+ '\u{1FB67}': () => `M0,${1/3} L1,${2/3} L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER MIDDLE RIGHT
288
+
289
+ // Triangular blocks (1FB68-1FB6F)
290
+ // Three-quarter blocks: full block minus one triangular quarter pointing to center
291
+ '\u{1FB68}': () => 'M0,0 L1,0 L1,1 L0,1 L0.5,0.5 Z', // UPPER AND RIGHT AND LOWER TRIANGULAR THREE QUARTERS BLOCK (missing left)
292
+ '\u{1FB69}': () => 'M0,0 L0.5,0.5 L1,0 L1,1 L0,1 Z', // LEFT AND LOWER AND RIGHT TRIANGULAR THREE QUARTERS BLOCK (missing upper)
293
+ '\u{1FB6A}': () => 'M0,0 L1,0 L0.5,0.5 L1,1 L0,1 Z', // UPPER AND LEFT AND LOWER TRIANGULAR THREE QUARTERS BLOCK (missing right)
294
+ '\u{1FB6B}': () => 'M0,0 L1,0 L1,1 L0.5,0.5 L0,1 Z', // LEFT AND UPPER AND RIGHT TRIANGULAR THREE QUARTERS BLOCK (missing lower)
295
+ '\u{1FB6C}': () => 'M0,0 L0.5,0.5 L0,1 Z', // LEFT TRIANGULAR ONE QUARTER BLOCK
296
+ '\u{1FB6D}': () => 'M0,0 L1,0 L0.5,0.5 Z', // UPPER TRIANGULAR ONE QUARTER BLOCK
297
+ '\u{1FB6E}': () => 'M1,0 L1,1 L0.5,0.5 Z', // RIGHT TRIANGULAR ONE QUARTER BLOCK
298
+ '\u{1FB6F}': () => 'M0,1 L1,1 L0.5,0.5 Z' // LOWER TRIANGULAR ONE QUARTER BLOCK
299
+ };
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
224
324
  };
225
325
 
226
326
  type PatternDefinition = number[][];
@@ -523,7 +623,19 @@ export function tryDrawCustomChar(
523
623
 
524
624
  const symbolsForLegacyComputingDefinition = symbolsForLegacyComputingDefinitions[c];
525
625
  if (symbolsForLegacyComputingDefinition) {
526
- drawSextantChar(ctx, symbolsForLegacyComputingDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
626
+ drawPathDefinitionCharacter(ctx, symbolsForLegacyComputingDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
627
+ return true;
628
+ }
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);
527
639
  return true;
528
640
  }
529
641
 
@@ -569,7 +681,7 @@ function drawBlockVectorChar(
569
681
  }
570
682
  }
571
683
 
572
- function drawSextantChar(
684
+ function drawPathDefinitionCharacter(
573
685
  ctx: CanvasRenderingContext2D,
574
686
  charDefinition: DrawFunctionDefinition,
575
687
  xOffset: number,
@@ -664,6 +776,81 @@ function drawPatternChar(
664
776
  ctx.fillRect(xOffset, yOffset, deviceCellWidth, deviceCellHeight);
665
777
  }
666
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
+
667
854
  /**
668
855
  * Draws the following box drawing characters by mapping a subset of SVG d attribute instructions to
669
856
  * canvas draw calls.