@xterm/addon-webgl 0.20.0-beta.10 → 0.20.0-beta.12

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.10",
3
+ "version": "0.20.0-beta.12",
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": "b4f4946ccaec77fdf60cb81f2566e2c6188e6237",
26
+ "commit": "d605803866c7ad5a51e980fb692cf658d60ff6af",
27
27
  "peerDependencies": {
28
- "@xterm/xterm": "^6.1.0-beta.11"
28
+ "@xterm/xterm": "^6.1.0-beta.13"
29
29
  }
30
30
  }
@@ -637,6 +637,20 @@ export const customGlyphDefinitions: { [index: string]: CustomGlyphCharacterDefi
637
637
  '\u{1FBFA}': { type: CustomGlyphDefinitionType.VECTOR_SHAPE, data: { d: 'M.5,.175 C.2,.175,.15,.305,.15,.435 L.05,.63 L.35,.63 C.35,.682,.42,.76,.5,.76 C.58,.76,.65,.682,.65,.63 L.95,.63 L.85,.435 C.85,.305,.8,.175,.5,.175 Z', type: CustomGlyphVectorType.FILL } }, // ALARM BELL SYMBOL
638
638
 
639
639
  // #endregion
640
+
641
+ // #region Braille Patterns (2800-28FF)
642
+
643
+ // https://www.unicode.org/charts/PDF/U2800.pdf
644
+
645
+ // Braille patterns (2800-28FF)
646
+ ...Object.fromEntries(
647
+ Array.from({ length: 256 }, (_, i) => [
648
+ String.fromCodePoint(0x2800 + i),
649
+ { type: CustomGlyphDefinitionType.BRAILLE, data: i }
650
+ ])
651
+ ),
652
+
653
+ // #endregion
640
654
  };
641
655
 
642
656
  /**
@@ -71,6 +71,9 @@ function drawDefinitionPart(
71
71
  case CustomGlyphDefinitionType.VECTOR_SHAPE:
72
72
  drawVectorShape(ctx, part.data, xOffset, yOffset, deviceCellWidth, deviceCellHeight, fontSize, devicePixelRatio);
73
73
  break;
74
+ case CustomGlyphDefinitionType.BRAILLE:
75
+ drawBrailleCharacter(ctx, part.data, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
76
+ break;
74
77
  }
75
78
 
76
79
  if (part.clipPath) {
@@ -99,6 +102,52 @@ function drawBlockVectorChar(
99
102
  }
100
103
  }
101
104
 
105
+ /**
106
+ * Braille dot positions in octant coordinates (x, y for center of each dot area)
107
+ * Columns: left=1-2, right=5-6 (leaving 0 and 7 as margins, 3-4 as gap)
108
+ * Rows: 0-1, 2-3, 4-5, 6-7 for the 4 rows
109
+ */
110
+ const brailleDotPositions = new Uint8Array([
111
+ 1, 0, // dot 1 - bit 0
112
+ 1, 2, // dot 2 - bit 1
113
+ 1, 4, // dot 3 - bit 2
114
+ 5, 0, // dot 4 - bit 3
115
+ 5, 2, // dot 5 - bit 4
116
+ 5, 4, // dot 6 - bit 5
117
+ 1, 6, // dot 7 - bit 6
118
+ 5, 6, // dot 8 - bit 7
119
+ ]);
120
+
121
+ /**
122
+ * Draws a braille pattern
123
+ */
124
+ function drawBrailleCharacter(
125
+ ctx: CanvasRenderingContext2D,
126
+ pattern: number,
127
+ xOffset: number,
128
+ yOffset: number,
129
+ deviceCellWidth: number,
130
+ deviceCellHeight: number
131
+ ): void {
132
+ const xEighth = deviceCellWidth / 8;
133
+ const paddingY = deviceCellHeight * 0.1;
134
+ const usableHeight = deviceCellHeight * 0.8;
135
+ const yEighth = usableHeight / 8;
136
+ const radius = Math.min(xEighth, yEighth);
137
+
138
+ for (let bit = 0; bit < 8; bit++) {
139
+ if (pattern & (1 << bit)) {
140
+ const x = brailleDotPositions[bit * 2];
141
+ const y = brailleDotPositions[bit * 2 + 1];
142
+ const cx = xOffset + (x + 1) * xEighth;
143
+ const cy = yOffset + paddingY + (y + 1) * yEighth;
144
+ ctx.beginPath();
145
+ ctx.arc(cx, cy, radius, 0, Math.PI * 2);
146
+ ctx.fill();
147
+ }
148
+ }
149
+ }
150
+
102
151
  function drawPathDefinitionCharacter(
103
152
  ctx: CanvasRenderingContext2D,
104
153
  charDefinition: CustomGlyphPathDrawFunctionDefinition | string,
@@ -426,9 +475,7 @@ function drawPathFunctionCharacter(
426
475
  devicePixelRatio: number,
427
476
  strokeWidth?: number
428
477
  ): void {
429
- ctx.strokeStyle = ctx.fillStyle;
430
478
  ctx.beginPath();
431
- ctx.lineWidth = devicePixelRatio * (strokeWidth ?? 1);
432
479
  let actualInstructions: string;
433
480
  if (typeof charDefinition === 'function') {
434
481
  const xp = .15;
@@ -454,7 +501,13 @@ function drawPathFunctionCharacter(
454
501
  }
455
502
  f(ctx, translateArgs(args, deviceCellWidth, deviceCellHeight, xOffset, yOffset, true, devicePixelRatio));
456
503
  }
457
- ctx.stroke();
504
+ if (strokeWidth !== undefined) {
505
+ ctx.strokeStyle = ctx.fillStyle;
506
+ ctx.lineWidth = devicePixelRatio * strokeWidth;
507
+ ctx.stroke();
508
+ } else {
509
+ ctx.fill();
510
+ }
458
511
  ctx.closePath();
459
512
  }
460
513
 
@@ -37,6 +37,7 @@ export const enum CustomGlyphDefinitionType {
37
37
  PATH,
38
38
  PATH_NEGATIVE,
39
39
  VECTOR_SHAPE,
40
+ BRAILLE,
40
41
  }
41
42
 
42
43
  export type CustomGlyphDefinitionPartRaw = (
@@ -45,7 +46,8 @@ export type CustomGlyphDefinitionPartRaw = (
45
46
  { type: CustomGlyphDefinitionType.PATH_FUNCTION, data: CustomGlyphPathDrawFunctionDefinition | string } |
46
47
  { type: CustomGlyphDefinitionType.PATH, data: string } |
47
48
  { type: CustomGlyphDefinitionType.PATH_NEGATIVE, data: ICustomGlyphVectorShape } |
48
- { type: CustomGlyphDefinitionType.VECTOR_SHAPE, data: ICustomGlyphVectorShape}
49
+ { type: CustomGlyphDefinitionType.VECTOR_SHAPE, data: ICustomGlyphVectorShape} |
50
+ { type: CustomGlyphDefinitionType.BRAILLE, data: number }
49
51
  );
50
52
 
51
53
  export interface ICustomGlyphDefinitionCommon {