@opentui/core 0.5.7 → 0.5.9

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/edit-buffer.d.ts CHANGED
@@ -46,6 +46,8 @@ export declare class EditBuffer extends EventEmitter {
46
46
  */
47
47
  replaceTextOwned(text: string): void;
48
48
  getLineCount(): number;
49
+ setTabWidth(width: number): void;
50
+ getTabWidth(): number;
49
51
  getText(): string;
50
52
  insertChar(char: string): void;
51
53
  insertText(text: string): void;
package/index.bun.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  mergeKeyAliases,
45
45
  mergeKeyBindings,
46
46
  wrapWithDelegates
47
- } from "./chunk-bun-z4gs6jzg.js";
47
+ } from "./chunk-bun-jxfx3h5k.js";
48
48
  import {
49
49
  ASCIIFontSelectionHelper,
50
50
  ATTRIBUTE_BASE_BITS,
@@ -204,7 +204,7 @@ import {
204
204
  visualizeRenderableTree,
205
205
  white,
206
206
  yellow
207
- } from "./chunk-bun-xmsp0nqq.js";
207
+ } from "./chunk-bun-b0662dgp.js";
208
208
  // src/post/effects.ts
209
209
  function toU8(value) {
210
210
  return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
@@ -219,6 +219,9 @@ function setRgb(buffer, base, r, g, b) {
219
219
  buffer[base + 2] = toU8(b);
220
220
  buffer[base + 3] = a;
221
221
  }
222
+ function isGraphemeCell(char) {
223
+ return char >>> 30 >= 2;
224
+ }
222
225
 
223
226
  class DistortionEffect {
224
227
  glitchChancePerSecond = 0.5;
@@ -403,6 +406,7 @@ class DistortionEffect {
403
406
  class VignetteEffect {
404
407
  _strength;
405
408
  precomputedAttenuationCellMask = null;
409
+ precomputedAttenuation = null;
406
410
  cachedWidth = -1;
407
411
  cachedHeight = -1;
408
412
  static zeroMatrix = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
@@ -414,12 +418,14 @@ class VignetteEffect {
414
418
  this.cachedWidth = -1;
415
419
  this.cachedHeight = -1;
416
420
  this.precomputedAttenuationCellMask = null;
421
+ this.precomputedAttenuation = null;
417
422
  }
418
423
  get strength() {
419
424
  return this._strength;
420
425
  }
421
426
  _computeFactors(width, height) {
422
427
  this.precomputedAttenuationCellMask = new Float32Array(width * height * 3);
428
+ this.precomputedAttenuation = new Float32Array(width * height);
423
429
  const centerX = width / 2;
424
430
  const centerY = height / 2;
425
431
  const maxDistSq = centerX * centerX + centerY * centerY;
@@ -437,17 +443,42 @@ class VignetteEffect {
437
443
  this.precomputedAttenuationCellMask[i++] = x;
438
444
  this.precomputedAttenuationCellMask[i++] = y;
439
445
  this.precomputedAttenuationCellMask[i++] = attenuation;
446
+ this.precomputedAttenuation[y * width + x] = attenuation;
440
447
  }
441
448
  }
442
449
  this.cachedWidth = width;
443
450
  this.cachedHeight = height;
444
451
  }
452
+ _preserveGraphemeRuns(buffer) {
453
+ const baseAttenuation = this.precomputedAttenuation;
454
+ const cellMask = this.precomputedAttenuationCellMask;
455
+ const chars = buffer.buffers.char;
456
+ const width = buffer.width;
457
+ for (let y = 0;y < buffer.height; y++) {
458
+ let x = 0;
459
+ while (x < width) {
460
+ const cell = y * width + x;
461
+ if (!isGraphemeCell(chars[cell])) {
462
+ cellMask[cell * 3 + 2] = baseAttenuation[cell];
463
+ x++;
464
+ continue;
465
+ }
466
+ const start = x;
467
+ while (x < width && isGraphemeCell(chars[y * width + x]))
468
+ x++;
469
+ const attenuation = baseAttenuation[y * width + start + Math.floor((x - start) / 2)];
470
+ for (let runX = start;runX < x; runX++)
471
+ cellMask[(y * width + runX) * 3 + 2] = attenuation;
472
+ }
473
+ }
474
+ }
445
475
  apply(buffer) {
446
476
  const width = buffer.width;
447
477
  const height = buffer.height;
448
478
  if (width !== this.cachedWidth || height !== this.cachedHeight || !this.precomputedAttenuationCellMask) {
449
479
  this._computeFactors(width, height);
450
480
  }
481
+ this._preserveGraphemeRuns(buffer);
451
482
  buffer.colorMatrix(VignetteEffect.zeroMatrix, this.precomputedAttenuationCellMask, 1, 3);
452
483
  }
453
484
  }
@@ -8321,12 +8352,13 @@ class EmbeddedTerminalRenderable extends Renderable {
8321
8352
  if (!this.handle)
8322
8353
  return new Uint8Array;
8323
8354
  const text = textualKey(key);
8355
+ const physical = physicalKey(key);
8324
8356
  return this.lib.embeddedTerminalEncodeKey(this.handle, {
8325
8357
  action: key.eventType === "release" ? "release" : key.repeated ? "repeat" : "press",
8326
- key: physicalKey(key),
8358
+ key: physical,
8327
8359
  mods: modifiers(key),
8328
8360
  text,
8329
- unshiftedCodepoint: key.baseCode ?? physicalUnshiftedCodepoint(key.code)
8361
+ unshiftedCodepoint: key.baseCode ?? physicalUnshiftedCodepoint(physical)
8330
8362
  });
8331
8363
  }
8332
8364
  encodePaste(bytes) {
@@ -8353,6 +8385,8 @@ class EmbeddedTerminalRenderable extends Renderable {
8353
8385
  this.requestRender();
8354
8386
  return false;
8355
8387
  }
8388
+ if (!this.selection && local.behavior === "cell" && local.anchorX === local.focusX && local.anchorY === local.focusY)
8389
+ return false;
8356
8390
  const point = (x, y) => {
8357
8391
  if (y < 0)
8358
8392
  return { x: 0, y: 0 };
@@ -8543,8 +8577,12 @@ function modifiers(input) {
8543
8577
  return value;
8544
8578
  }
8545
8579
  function physicalKey(key) {
8546
- if (key.code)
8580
+ if (key.code && !key.code.startsWith("["))
8547
8581
  return key.code;
8582
+ if (/^[a-z]$/i.test(key.name))
8583
+ return `Key${key.name.toUpperCase()}`;
8584
+ if (/^[0-9]$/.test(key.name))
8585
+ return `Digit${key.name}`;
8548
8586
  return {
8549
8587
  backspace: "Backspace",
8550
8588
  enter: "Enter",
@@ -15570,5 +15608,5 @@ export {
15570
15608
  ACHROMATOPSIA_MATRIX
15571
15609
  };
15572
15610
 
15573
- //# debugId=C0029738F074C79064756E2164756E21
15611
+ //# debugId=281D25630B33385064756E2164756E21
15574
15612
  //# sourceMappingURL=index.bun.js.map