@oh-my-pi/pi-tui 17.2.14 → 17.3.0

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/src/utils.ts CHANGED
@@ -371,6 +371,34 @@ export function visibleWidth(str: string): number {
371
371
  return correctHangulCompatibilityJamoWidth(width, str);
372
372
  }
373
373
 
374
+ /**
375
+ * True when a row carries a Kitty OSC 66 text-sizing span (`\x1b]66;…`).
376
+ * Scaled spans must bypass wrapping/padding and, when scaled up, reserve the
377
+ * terminal rows their multicell glyphs flow into.
378
+ */
379
+ export function isOsc66Line(line: string): boolean {
380
+ return line.includes(OSC66_PREFIX);
381
+ }
382
+
383
+ /**
384
+ * Largest `s=` scale among the OSC 66 spans in a line (1 when none is scaled).
385
+ * A scale-`s` heading occupies `s` terminal rows, so the `s - 1` blank rows
386
+ * beneath it are the glyph's lower half and must never be erased or overdrawn.
387
+ */
388
+ export function osc66MaxScale(line: string): number {
389
+ if (!line.includes(OSC66_PREFIX)) return 1;
390
+ let max = 1;
391
+ OSC66_SPAN_REGEX.lastIndex = 0;
392
+ for (let m = OSC66_SPAN_REGEX.exec(line); m !== null; m = OSC66_SPAN_REGEX.exec(line)) {
393
+ for (const part of m[1].split(":")) {
394
+ if (part.indexOf("=") !== 1 || part[0] !== "s") continue;
395
+ const value = Number.parseInt(part.slice(2), 10);
396
+ if (Number.isFinite(value) && value > max && value <= 7) max = value;
397
+ }
398
+ }
399
+ return max;
400
+ }
401
+
374
402
  const THAI_LAO_AM_GLOBAL_REGEX = /[\u0e33\u0eb3]/g;
375
403
 
376
404
  /**