@opentui/core 0.5.4 → 0.5.7

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.
@@ -585,7 +585,7 @@ function toNodeFFIType(type, position) {
585
585
  case FFIType.napi_value:
586
586
  throw new Error(NODE_NAPI_UNSUPPORTED);
587
587
  case FFIType.buffer:
588
- return "buffer";
588
+ return "pointer";
589
589
  default:
590
590
  return unsupportedNodeFFIType(type);
591
591
  }
@@ -6040,9 +6040,11 @@ class Selection {
6040
6040
  _isActive = true;
6041
6041
  _isDragging = true;
6042
6042
  _isStart = false;
6043
- constructor(anchorRenderable, anchor, focus) {
6043
+ behavior;
6044
+ constructor(anchorRenderable, anchor, focus, behavior = "cell") {
6044
6045
  this._anchor = new SelectionAnchor(anchorRenderable, anchor.x, anchor.y);
6045
6046
  this._focus = { ...focus };
6047
+ this.behavior = behavior;
6046
6048
  }
6047
6049
  get isStart() {
6048
6050
  return this._isStart;
@@ -6133,7 +6135,8 @@ function convertGlobalToLocalSelection(globalSelection, localX, localY) {
6133
6135
  anchorY: globalSelection.anchor.y - localY,
6134
6136
  focusX: globalSelection.focus.x - localX,
6135
6137
  focusY: globalSelection.focus.y - localY,
6136
- isActive: true
6138
+ isActive: true,
6139
+ behavior: globalSelection.behavior
6137
6140
  };
6138
6141
  }
6139
6142
 
@@ -6168,36 +6171,37 @@ class ASCIIFontSelectionHelper {
6168
6171
  }
6169
6172
  const text = this.getText();
6170
6173
  const font = this.getFont();
6171
- const selStart = { x: localSelection.anchorX, y: localSelection.anchorY };
6172
- const selEnd = { x: localSelection.focusX, y: localSelection.focusY };
6173
- if (height - 1 < selStart.y || 0 > selEnd.y) {
6174
+ const positions = getCharacterPositions(text, font);
6175
+ const minY = Math.min(localSelection.anchorY, localSelection.focusY);
6176
+ const maxY = Math.max(localSelection.anchorY, localSelection.focusY);
6177
+ if (maxY < 0 || minY > height - 1) {
6174
6178
  this.localSelection = null;
6175
6179
  return previousSelection !== null;
6176
6180
  }
6177
- let startCharIndex = 0;
6178
- let endCharIndex = text.length;
6179
- if (selStart.y > height - 1) {
6180
- this.localSelection = null;
6181
- return previousSelection !== null;
6182
- } else if (selStart.y >= 0 && selStart.y <= height - 1) {
6183
- if (selStart.x > 0) {
6184
- startCharIndex = coordinateToCharacterIndex(selStart.x, text, font);
6181
+ const indexAt = (x, y) => {
6182
+ if (y < 0)
6183
+ return 0;
6184
+ if (y > height - 1)
6185
+ return text.length;
6186
+ if (x < 0)
6187
+ return 0;
6188
+ if (x >= width)
6189
+ return text.length;
6190
+ for (let index = 1;index < positions.length; index += 1) {
6191
+ if (x < positions[index])
6192
+ return index - 1;
6185
6193
  }
6186
- }
6187
- if (selEnd.y < 0) {
6194
+ return text.length;
6195
+ };
6196
+ const anchorIndex = indexAt(localSelection.anchorX, localSelection.anchorY);
6197
+ const focusIndex = indexAt(localSelection.focusX, localSelection.focusY);
6198
+ const start = Math.min(anchorIndex, focusIndex);
6199
+ const end = Math.min(Math.max(anchorIndex, focusIndex) + 1, text.length);
6200
+ const samePoint = localSelection.anchorX === localSelection.focusX && localSelection.anchorY === localSelection.focusY;
6201
+ if (samePoint || start >= end) {
6188
6202
  this.localSelection = null;
6189
- return previousSelection !== null;
6190
- } else if (selEnd.y >= 0 && selEnd.y <= height - 1) {
6191
- if (selEnd.x >= 0) {
6192
- endCharIndex = coordinateToCharacterIndex(selEnd.x, text, font);
6193
- } else {
6194
- endCharIndex = 0;
6195
- }
6196
- }
6197
- if (startCharIndex < endCharIndex && startCharIndex >= 0 && endCharIndex <= text.length) {
6198
- this.localSelection = { start: startCharIndex, end: endCharIndex };
6199
6203
  } else {
6200
- this.localSelection = null;
6204
+ this.localSelection = { start, end };
6201
6205
  }
6202
6206
  return previousSelection?.start !== this.localSelection?.start || previousSelection?.end !== this.localSelection?.end;
6203
6207
  }
@@ -11437,7 +11441,7 @@ class OptimizedBuffer {
11437
11441
  if (matrix.length !== 16)
11438
11442
  throw new RangeError(`colorMatrix matrix must have length 16, got ${matrix.length}`);
11439
11443
  const cellMaskCount = Math.floor(cellMask.length / 3);
11440
- this.lib.bufferColorMatrix(this.bufferPtr, ptr(matrix), ptr(cellMask), cellMaskCount, strength, target);
11444
+ this.lib.bufferColorMatrix(this.bufferPtr, matrix, cellMask, cellMaskCount, strength, target);
11441
11445
  }
11442
11446
  colorMatrixUniform(matrix, strength = 1, target = 3 /* Both */) {
11443
11447
  this.guard();
@@ -11445,7 +11449,7 @@ class OptimizedBuffer {
11445
11449
  throw new RangeError(`colorMatrixUniform matrix must have length 16, got ${matrix.length}`);
11446
11450
  if (strength === 0)
11447
11451
  return;
11448
- this.lib.bufferColorMatrixUniform(this.bufferPtr, ptr(matrix), strength, target);
11452
+ this.lib.bufferColorMatrixUniform(this.bufferPtr, matrix, strength, target);
11449
11453
  }
11450
11454
  drawFrameBuffer(destX, destY, frameBuffer, sourceX, sourceY, sourceWidth, sourceHeight) {
11451
11455
  this.guard();
@@ -11466,9 +11470,9 @@ class OptimizedBuffer {
11466
11470
  this.guard();
11467
11471
  this.lib.bufferDrawEditorView(this.bufferPtr, editorView.ptr, x, y);
11468
11472
  }
11469
- drawSuperSampleBuffer(x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
11473
+ drawSuperSampleBuffer(x, y, pixelData, pixelDataLength, format, alignedBytesPerRow) {
11470
11474
  this.guard();
11471
- this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, toPointer(pixelDataPtr), pixelDataLength, format, alignedBytesPerRow);
11475
+ this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, typeof pixelData === "number" || typeof pixelData === "bigint" ? toPointer(pixelData) : pixelData, pixelDataLength, format, alignedBytesPerRow);
11472
11476
  }
11473
11477
  drawImage(image, x, y, width, height, pixelWidth = 0, pixelHeight = 0, sourceX = 0, sourceY = 0, sourceWidth = image.width, sourceHeight = image.height, protocol = "auto") {
11474
11478
  this.guard();
@@ -11487,17 +11491,17 @@ class OptimizedBuffer {
11487
11491
  }
11488
11492
  return this.lib.bufferDrawImage(this.bufferPtr, image.ptr, x, y, width, height, pixelWidth, pixelHeight, sourceX, sourceY, sourceWidth, sourceHeight, protocol);
11489
11493
  }
11490
- drawPackedBuffer(dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
11494
+ drawPackedBuffer(data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
11491
11495
  this.guard();
11492
- this.lib.bufferDrawPackedBuffer(this.bufferPtr, toPointer(dataPtr), dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
11496
+ this.lib.bufferDrawPackedBuffer(this.bufferPtr, typeof data === "number" || typeof data === "bigint" ? toPointer(data) : data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
11493
11497
  }
11494
11498
  drawGrayscaleBuffer(posX, posY, intensities, srcWidth, srcHeight, fg2 = null, bg2 = null) {
11495
11499
  this.guard();
11496
- this.lib.bufferDrawGrayscaleBuffer(this.bufferPtr, posX, posY, ptr(intensities), srcWidth, srcHeight, fg2, bg2);
11500
+ this.lib.bufferDrawGrayscaleBuffer(this.bufferPtr, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2);
11497
11501
  }
11498
11502
  drawGrayscaleBufferSupersampled(posX, posY, intensities, srcWidth, srcHeight, fg2 = null, bg2 = null) {
11499
11503
  this.guard();
11500
- this.lib.bufferDrawGrayscaleBufferSupersampled(this.bufferPtr, posX, posY, ptr(intensities), srcWidth, srcHeight, fg2, bg2);
11504
+ this.lib.bufferDrawGrayscaleBufferSupersampled(this.bufferPtr, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2);
11501
11505
  }
11502
11506
  resize(width, height) {
11503
11507
  this.guard();
@@ -13201,6 +13205,28 @@ var CursorStateStruct = defineStruct([
13201
13205
  ["b", "f32"],
13202
13206
  ["a", "f32"]
13203
13207
  ]);
13208
+ var EmbeddedTerminalCursorStruct = defineStruct([
13209
+ ["x", "u16"],
13210
+ ["y", "u16"],
13211
+ ["hasValue", "bool_u8"],
13212
+ ["visible", "bool_u8"],
13213
+ ["blinking", "bool_u8"],
13214
+ ["wideTail", "bool_u8"],
13215
+ ["style", "u8"],
13216
+ ["colorHasValue", "bool_u8"],
13217
+ ["colorR", "u8"],
13218
+ ["colorG", "u8"],
13219
+ ["colorB", "u8"],
13220
+ ["padding", "u8"]
13221
+ ]);
13222
+ var EmbeddedTerminalKeyOptionsStruct = defineStruct([
13223
+ ["action", "u8"],
13224
+ ["composing", "u8"],
13225
+ ["mods", "u16"],
13226
+ ["consumedMods", "u16"],
13227
+ ["padding", "u16"],
13228
+ ["unshiftedCodepoint", "u32"]
13229
+ ]);
13204
13230
  var CursorStyleOptionsStruct = defineStruct([
13205
13231
  ["style", "u8", { default: 255 }],
13206
13232
  ["blinking", "u8", { default: 255 }],
@@ -13517,14 +13543,56 @@ function toSafeFFIU32Length(value, label) {
13517
13543
  function isFFIU32(value) {
13518
13544
  return Number.isInteger(value) && value >= 0 && value <= MAX_FFI_U32;
13519
13545
  }
13520
- function ptrOrNull(value) {
13521
- return value.byteLength === 0 ? null : ptr(value);
13546
+ function viewOrNull(value) {
13547
+ return value.byteLength === 0 ? null : value;
13522
13548
  }
13523
- function rgbaPtr(value) {
13524
- return ptr(value.buffer);
13549
+ function retainedPtrOrNull(value) {
13550
+ if (value.byteLength === 0)
13551
+ return null;
13552
+ value.buffer;
13553
+ return ptr(value);
13554
+ }
13555
+ var EMBEDDED_TERMINAL_ERRORS = {
13556
+ [-1]: "invalid value or handle",
13557
+ [-2]: "out of memory",
13558
+ [-3]: "embedded terminal support is unavailable",
13559
+ [-4]: "output buffer is too small",
13560
+ [-5]: "processing failed"
13561
+ };
13562
+ function embeddedTerminalResult(status, operation) {
13563
+ if (status >= 0)
13564
+ return status;
13565
+ throw new Error(`Embedded terminal ${operation} failed: ${EMBEDDED_TERMINAL_ERRORS[status] ?? `status ${status}`}`);
13566
+ }
13567
+ function embeddedTerminalDimension(value, name) {
13568
+ if (!Number.isInteger(value) || value < 1 || value > 65535) {
13569
+ throw new RangeError(`Embedded terminal ${name} must be an integer between 1 and 65535`);
13570
+ }
13571
+ return value;
13525
13572
  }
13526
- function optionalRgbaPtr(value) {
13527
- return value ? rgbaPtr(value) : null;
13573
+ function embeddedTerminalI32(value, name) {
13574
+ if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) {
13575
+ throw new RangeError(`Embedded terminal ${name} must be a signed 32-bit integer`);
13576
+ }
13577
+ return value;
13578
+ }
13579
+ function embeddedTerminalF32(value, name) {
13580
+ if (!Number.isFinite(value) || Math.abs(value) > 340282346638528860000000000000000000000) {
13581
+ throw new RangeError(`Embedded terminal ${name} must be a finite 32-bit float`);
13582
+ }
13583
+ return value;
13584
+ }
13585
+ function rgbaBuffer(value) {
13586
+ return value.buffer;
13587
+ }
13588
+ function optionalRgbaBuffer(value) {
13589
+ return value ? rgbaBuffer(value) : null;
13590
+ }
13591
+ function selectionBehaviorByte(behavior) {
13592
+ return behavior === "word" ? 1 : behavior === "line" ? 2 : 0;
13593
+ }
13594
+ function editorLocalSelectionFlags(updateCursor, followCursor, behavior) {
13595
+ return ffiBool(updateCursor) | ffiBool(followCursor) << 1 | selectionBehaviorByte(behavior) << 2;
13528
13596
  }
13529
13597
  function getOpenTUILib(libPath) {
13530
13598
  const resolvedLibPath = libPath || targetLibPath;
@@ -13560,6 +13628,70 @@ function getOpenTUILib(libPath) {
13560
13628
  args: ["u32", "u32", "u32"],
13561
13629
  returns: "bool"
13562
13630
  },
13631
+ createEmbeddedTerminal: {
13632
+ args: ["u16", "u16", "u32", "ptr"],
13633
+ returns: "i32"
13634
+ },
13635
+ destroyEmbeddedTerminal: {
13636
+ args: ["u32"],
13637
+ returns: "void"
13638
+ },
13639
+ embeddedTerminalWrite: {
13640
+ args: ["u32", "ptr", "u32"],
13641
+ returns: "i32"
13642
+ },
13643
+ embeddedTerminalResize: {
13644
+ args: ["u32", "u16", "u16"],
13645
+ returns: "i32"
13646
+ },
13647
+ embeddedTerminalInvalidate: {
13648
+ args: ["u32"],
13649
+ returns: "i32"
13650
+ },
13651
+ embeddedTerminalScroll: {
13652
+ args: ["u32", "i32"],
13653
+ returns: "i32"
13654
+ },
13655
+ embeddedTerminalSetSelection: {
13656
+ args: ["u32", "u16", "u16", "u16", "u16"],
13657
+ returns: "i32"
13658
+ },
13659
+ embeddedTerminalClearSelection: {
13660
+ args: ["u32"],
13661
+ returns: "i32"
13662
+ },
13663
+ embeddedTerminalGetSelectedText: {
13664
+ args: ["u32", "buffer", "u32", "buffer"],
13665
+ returns: "i32"
13666
+ },
13667
+ embeddedTerminalCompose: {
13668
+ args: ["u32", "u32", "i32", "i32"],
13669
+ returns: "i32"
13670
+ },
13671
+ embeddedTerminalCursor: {
13672
+ args: ["u32", "ptr"],
13673
+ returns: "i32"
13674
+ },
13675
+ embeddedTerminalEncodeKey: {
13676
+ args: ["u32", "ptr", "ptr", "u32", "ptr", "u32", "ptr", "u32", "ptr"],
13677
+ returns: "i32"
13678
+ },
13679
+ embeddedTerminalEncodeMouse: {
13680
+ args: ["u32", "u8", "i8", "u16", "f32", "f32", "u8", "ptr", "u32"],
13681
+ returns: "i32"
13682
+ },
13683
+ embeddedTerminalEncodePaste: {
13684
+ args: ["u32", "ptr", "u32", "ptr", "u32"],
13685
+ returns: "i32"
13686
+ },
13687
+ embeddedTerminalEncodeFocus: {
13688
+ args: ["u32", "u8", "ptr", "u32"],
13689
+ returns: "i32"
13690
+ },
13691
+ embeddedTerminalDrainResponses: {
13692
+ args: ["u32", "ptr", "u32"],
13693
+ returns: "i32"
13694
+ },
13563
13695
  createRenderer: {
13564
13696
  args: ["u32", "u32", "u8", "u8", "ptr"],
13565
13697
  returns: "u32"
@@ -13581,7 +13713,7 @@ function getOpenTUILib(libPath) {
13581
13713
  returns: "void"
13582
13714
  },
13583
13715
  setBackgroundColor: {
13584
- args: ["u32", "ptr"],
13716
+ args: ["u32", "buffer"],
13585
13717
  returns: "void"
13586
13718
  },
13587
13719
  setRenderOffset: {
@@ -13629,7 +13761,7 @@ function getOpenTUILib(libPath) {
13629
13761
  returns: "u64"
13630
13762
  },
13631
13763
  commitSplitFooterSnapshot: {
13632
- args: ["u32", "u32", "u32", "bool", "bool", "u32", "bool", "bool", "bool"],
13764
+ args: ["u32", "u32", "u32", "u8", "u32"],
13633
13765
  returns: "u64"
13634
13766
  },
13635
13767
  getNextBuffer: {
@@ -13641,7 +13773,7 @@ function getOpenTUILib(libPath) {
13641
13773
  returns: "u32"
13642
13774
  },
13643
13775
  rendererSetPaletteState: {
13644
- args: ["u32", "ptr", "u32", "ptr", "ptr", "u32"],
13776
+ args: ["u32", "buffer", "u32", "buffer", "buffer", "u32"],
13645
13777
  returns: "void"
13646
13778
  },
13647
13779
  queryPixelResolution: {
@@ -13653,7 +13785,7 @@ function getOpenTUILib(libPath) {
13653
13785
  returns: "void"
13654
13786
  },
13655
13787
  createOptimizedBuffer: {
13656
- args: ["u32", "u32", "bool", "u8", "ptr", "u32"],
13788
+ args: ["u32", "u32", "u8", "u8", "buffer", "u32"],
13657
13789
  returns: "u32"
13658
13790
  },
13659
13791
  destroyOptimizedBuffer: {
@@ -13673,7 +13805,7 @@ function getOpenTUILib(libPath) {
13673
13805
  returns: "u32"
13674
13806
  },
13675
13807
  bufferClear: {
13676
- args: ["u32", "ptr"],
13808
+ args: ["u32", "buffer"],
13677
13809
  returns: "void"
13678
13810
  },
13679
13811
  bufferGetCharPtr: {
@@ -13701,7 +13833,7 @@ function getOpenTUILib(libPath) {
13701
13833
  returns: "void"
13702
13834
  },
13703
13835
  bufferGetId: {
13704
- args: ["u32", "ptr", "u32"],
13836
+ args: ["u32", "buffer", "u32"],
13705
13837
  returns: "u32"
13706
13838
  },
13707
13839
  bufferGetRealCharSize: {
@@ -13713,19 +13845,19 @@ function getOpenTUILib(libPath) {
13713
13845
  returns: "u32"
13714
13846
  },
13715
13847
  bufferDrawText: {
13716
- args: ["u32", "ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
13848
+ args: ["u32", "ptr", "u32", "u32", "u32", "buffer", "ptr", "u32"],
13717
13849
  returns: "void"
13718
13850
  },
13719
13851
  bufferSetCellWithAlphaBlending: {
13720
- args: ["u32", "u32", "u32", "u32", "ptr", "ptr", "u32"],
13852
+ args: ["u32", "u32", "u32", "u32", "buffer", "buffer", "u32"],
13721
13853
  returns: "void"
13722
13854
  },
13723
13855
  bufferSetCell: {
13724
- args: ["u32", "u32", "u32", "u32", "ptr", "ptr", "u32"],
13856
+ args: ["u32", "u32", "u32", "u32", "buffer", "buffer", "u32"],
13725
13857
  returns: "void"
13726
13858
  },
13727
13859
  bufferFillRect: {
13728
- args: ["u32", "u32", "u32", "u32", "u32", "ptr"],
13860
+ args: ["u32", "u32", "u32", "u32", "u32", "buffer"],
13729
13861
  returns: "void"
13730
13862
  },
13731
13863
  bufferColorMatrix: {
@@ -13765,7 +13897,7 @@ function getOpenTUILib(libPath) {
13765
13897
  returns: "void"
13766
13898
  },
13767
13899
  setCursorColor: {
13768
- args: ["u32", "ptr"],
13900
+ args: ["u32", "buffer"],
13769
13901
  returns: "void"
13770
13902
  },
13771
13903
  getCursorState: {
@@ -13777,7 +13909,7 @@ function getOpenTUILib(libPath) {
13777
13909
  returns: "void"
13778
13910
  },
13779
13911
  setDebugOverlay: {
13780
- args: ["u32", "bool", "u8"],
13912
+ args: ["u32", "u8", "u8"],
13781
13913
  returns: "void"
13782
13914
  },
13783
13915
  clearTerminal: {
@@ -13893,11 +14025,26 @@ function getOpenTUILib(libPath) {
13893
14025
  returns: "void"
13894
14026
  },
13895
14027
  bufferDrawGrid: {
13896
- args: ["u32", "ptr", "ptr", "ptr", "ptr", "u32", "ptr", "u32", "ptr"],
14028
+ args: ["u32", "buffer", "buffer", "buffer", "buffer", "u32", "buffer", "u32", "ptr"],
13897
14029
  returns: "void"
13898
14030
  },
13899
14031
  bufferDrawBox: {
13900
- args: ["u32", "i32", "i32", "u32", "u32", "ptr", "u32", "ptr", "ptr", "ptr", "ptr", "u32", "ptr", "u32"],
14032
+ args: [
14033
+ "u32",
14034
+ "i32",
14035
+ "i32",
14036
+ "u32",
14037
+ "u32",
14038
+ "buffer",
14039
+ "u32",
14040
+ "buffer",
14041
+ "buffer",
14042
+ "buffer",
14043
+ "ptr",
14044
+ "u32",
14045
+ "ptr",
14046
+ "u32"
14047
+ ],
13901
14048
  returns: "void"
13902
14049
  },
13903
14050
  bufferPushScissorRect: {
@@ -14169,7 +14316,7 @@ function getOpenTUILib(libPath) {
14169
14316
  returns: "u64"
14170
14317
  },
14171
14318
  textBufferViewSetLocalSelection: {
14172
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr"],
14319
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14173
14320
  returns: "bool"
14174
14321
  },
14175
14322
  textBufferViewUpdateSelection: {
@@ -14177,13 +14324,21 @@ function getOpenTUILib(libPath) {
14177
14324
  returns: "void"
14178
14325
  },
14179
14326
  textBufferViewUpdateLocalSelection: {
14180
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr"],
14327
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14181
14328
  returns: "bool"
14182
14329
  },
14183
14330
  textBufferViewResetLocalSelection: {
14184
14331
  args: ["u32"],
14185
14332
  returns: "void"
14186
14333
  },
14334
+ textBufferViewSetSelectionOccupancy: {
14335
+ args: ["u32", "u8"],
14336
+ returns: "void"
14337
+ },
14338
+ textBufferViewGetSelectionOccupancy: {
14339
+ args: ["u32"],
14340
+ returns: "u8"
14341
+ },
14187
14342
  textBufferViewSetWrapWidth: {
14188
14343
  args: ["u32", "u32"],
14189
14344
  returns: "void"
@@ -14229,7 +14384,7 @@ function getOpenTUILib(libPath) {
14229
14384
  returns: "void"
14230
14385
  },
14231
14386
  textBufferViewSetTabIndicatorColor: {
14232
- args: ["u32", "ptr"],
14387
+ args: ["u32", "buffer"],
14233
14388
  returns: "void"
14234
14389
  },
14235
14390
  textBufferViewSetTruncate: {
@@ -14265,7 +14420,7 @@ function getOpenTUILib(libPath) {
14265
14420
  returns: "void"
14266
14421
  },
14267
14422
  editorViewGetViewport: {
14268
- args: ["u32", "ptr", "ptr", "ptr", "ptr"],
14423
+ args: ["u32", "buffer", "buffer", "buffer", "buffer"],
14269
14424
  returns: "void"
14270
14425
  },
14271
14426
  editorViewSetScrollMargin: {
@@ -14469,7 +14624,7 @@ function getOpenTUILib(libPath) {
14469
14624
  returns: "u64"
14470
14625
  },
14471
14626
  editorViewSetLocalSelection: {
14472
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "bool", "bool"],
14627
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14473
14628
  returns: "bool"
14474
14629
  },
14475
14630
  editorViewUpdateSelection: {
@@ -14477,19 +14632,35 @@ function getOpenTUILib(libPath) {
14477
14632
  returns: "void"
14478
14633
  },
14479
14634
  editorViewUpdateLocalSelection: {
14480
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "bool", "bool"],
14635
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14481
14636
  returns: "bool"
14482
14637
  },
14483
14638
  editorViewResetLocalSelection: {
14484
14639
  args: ["u32"],
14485
14640
  returns: "void"
14486
14641
  },
14642
+ editorViewConvertSelectionToCell: {
14643
+ args: ["u32"],
14644
+ returns: "bool"
14645
+ },
14646
+ editorViewSetSelectionOccupancy: {
14647
+ args: ["u32", "u8"],
14648
+ returns: "void"
14649
+ },
14650
+ editorViewSetSelectionInclusive: {
14651
+ args: ["u32", "u32", "u32", "ptr", "ptr"],
14652
+ returns: "void"
14653
+ },
14654
+ editorViewSetSelectionColors: {
14655
+ args: ["u32", "ptr", "ptr"],
14656
+ returns: "void"
14657
+ },
14487
14658
  editorViewGetSelectedTextBytes: {
14488
14659
  args: ["u32", "ptr", "u32"],
14489
14660
  returns: "u32"
14490
14661
  },
14491
14662
  editorViewGetCursor: {
14492
- args: ["u32", "ptr", "ptr"],
14663
+ args: ["u32", "buffer", "buffer"],
14493
14664
  returns: "void"
14494
14665
  },
14495
14666
  editorViewGetText: {
@@ -14536,6 +14707,10 @@ function getOpenTUILib(libPath) {
14536
14707
  args: ["u32", "ptr"],
14537
14708
  returns: "void"
14538
14709
  },
14710
+ editorViewGotoVisualLineEnd: {
14711
+ args: ["u32"],
14712
+ returns: "void"
14713
+ },
14539
14714
  editorViewSetPlaceholderStyledText: {
14540
14715
  args: ["u32", "ptr", "u32"],
14541
14716
  returns: "void"
@@ -14545,7 +14720,7 @@ function getOpenTUILib(libPath) {
14545
14720
  returns: "void"
14546
14721
  },
14547
14722
  editorViewSetTabIndicatorColor: {
14548
- args: ["u32", "ptr"],
14723
+ args: ["u32", "buffer"],
14549
14724
  returns: "void"
14550
14725
  },
14551
14726
  getArenaAllocatedBytes: {
@@ -14584,21 +14759,21 @@ function getOpenTUILib(libPath) {
14584
14759
  imageRetainIccCache: { args: [], returns: "void" },
14585
14760
  imageReleaseIccCache: { args: [], returns: "void" },
14586
14761
  imageTestFailIccProfileCopyAllocationOnce: { args: [], returns: "void" },
14587
- imageDecode: { args: ["ptr", "u32", "ptr"], returns: "u32" },
14588
- imageCreateFromRgba: { args: ["ptr", "u64", "u32", "u32", "u32", "ptr"], returns: "u32" },
14762
+ imageDecode: { args: ["ptr", "u32", "buffer"], returns: "u32" },
14763
+ imageCreateFromRgba: { args: ["ptr", "u64", "u32", "u32", "u32", "buffer"], returns: "u32" },
14589
14764
  imageDestroy: { args: ["u32"], returns: "void" },
14590
- imageRetain: { args: ["u32", "ptr"], returns: "u32" },
14765
+ imageRetain: { args: ["u32", "buffer"], returns: "u32" },
14591
14766
  imageGetInfo: { args: ["u32", "ptr"], returns: "u32" },
14592
14767
  imageMaterialize: { args: ["u32"], returns: "u32" },
14593
14768
  imageEnsureEncodedPng: { args: ["u32"], returns: "u32" },
14594
14769
  imageGetPixelsPtr: { args: ["u32"], returns: "ptr" },
14595
- imageClone: { args: ["u32", "ptr"], returns: "u32" },
14770
+ imageClone: { args: ["u32", "buffer"], returns: "u32" },
14596
14771
  imageCopyPixels: { args: ["u32", "ptr", "u64", "u32", "u8"], returns: "u32" },
14597
- imageResize: { args: ["u32", "u32", "u32", "u32", "ptr"], returns: "u32" },
14598
- imageExtract: { args: ["u32", "u32", "u32", "u32", "u32", "ptr"], returns: "u32" },
14599
- imageExtend: { args: ["u32", "u32", "u32", "u32", "u32", "ptr", "ptr"], returns: "u32" },
14600
- imageTransform: { args: ["u32", "u32", "ptr"], returns: "u32" },
14601
- imageComposite: { args: ["u32", "u32", "i32", "i32", "u32", "u8", "ptr"], returns: "u32" },
14772
+ imageResize: { args: ["u32", "u32", "u32", "u32", "buffer"], returns: "u32" },
14773
+ imageExtract: { args: ["u32", "u32", "u32", "u32", "u32", "buffer"], returns: "u32" },
14774
+ imageExtend: { args: ["u32", "u32", "u32", "u32", "u32", "buffer", "buffer"], returns: "u32" },
14775
+ imageTransform: { args: ["u32", "u32", "buffer"], returns: "u32" },
14776
+ imageComposite: { args: ["u32", "u32", "i32", "i32", "u32", "u8", "buffer"], returns: "u32" },
14602
14777
  getTerminalCapabilities: {
14603
14778
  args: ["u32", "ptr"],
14604
14779
  returns: "void"
@@ -14616,7 +14791,7 @@ function getOpenTUILib(libPath) {
14616
14791
  returns: "void"
14617
14792
  },
14618
14793
  bufferDrawChar: {
14619
- args: ["u32", "u32", "u32", "u32", "ptr", "ptr", "u32"],
14794
+ args: ["u32", "u32", "u32", "u32", "buffer", "buffer", "u32"],
14620
14795
  returns: "void"
14621
14796
  },
14622
14797
  yogaConfigCreate: {
@@ -14836,7 +15011,7 @@ function getOpenTUILib(libPath) {
14836
15011
  returns: "u32"
14837
15012
  },
14838
15013
  audioGetPlaybackDeviceName: {
14839
- args: ["u32", "u32", "ptr", "u32"],
15014
+ args: ["u32", "u32", "buffer", "u32"],
14840
15015
  returns: "u32"
14841
15016
  },
14842
15017
  audioIsPlaybackDeviceDefault: {
@@ -14860,7 +15035,7 @@ function getOpenTUILib(libPath) {
14860
15035
  returns: "u32"
14861
15036
  },
14862
15037
  audioGetCaptureDeviceName: {
14863
- args: ["u32", "u32", "ptr", "u32"],
15038
+ args: ["u32", "u32", "buffer", "u32"],
14864
15039
  returns: "u32"
14865
15040
  },
14866
15041
  audioIsCaptureDeviceDefault: {
@@ -14888,7 +15063,7 @@ function getOpenTUILib(libPath) {
14888
15063
  returns: "bool"
14889
15064
  },
14890
15065
  audioReadCapture: {
14891
- args: ["u32", "ptr", "u32", "u32", "ptr"],
15066
+ args: ["u32", "buffer", "u32", "u32", "ptr"],
14892
15067
  returns: "i32"
14893
15068
  },
14894
15069
  audioGetCaptureStats: {
@@ -14944,7 +15119,7 @@ function getOpenTUILib(libPath) {
14944
15119
  returns: "i32"
14945
15120
  },
14946
15121
  audioLoad: {
14947
- args: ["u32", "ptr", "u32", "ptr"],
15122
+ args: ["u32", "buffer", "u32", "ptr"],
14948
15123
  returns: "i32"
14949
15124
  },
14950
15125
  audioUnload: {
@@ -14964,7 +15139,7 @@ function getOpenTUILib(libPath) {
14964
15139
  returns: "i32"
14965
15140
  },
14966
15141
  audioCreateGroup: {
14967
- args: ["u32", "ptr", "u32", "ptr"],
15142
+ args: ["u32", "buffer", "u32", "ptr"],
14968
15143
  returns: "i32"
14969
15144
  },
14970
15145
  audioSetGroupVolume: {
@@ -14976,15 +15151,15 @@ function getOpenTUILib(libPath) {
14976
15151
  returns: "i32"
14977
15152
  },
14978
15153
  audioMixToBuffer: {
14979
- args: ["u32", "ptr", "u32", "u8"],
15154
+ args: ["u32", "buffer", "u32", "u8"],
14980
15155
  returns: "i32"
14981
15156
  },
14982
15157
  audioEnableTap: {
14983
- args: ["u32", "bool", "u32"],
15158
+ args: ["u32", "u8", "u32"],
14984
15159
  returns: "i32"
14985
15160
  },
14986
15161
  audioReadTap: {
14987
- args: ["u32", "ptr", "u32", "u8", "ptr"],
15162
+ args: ["u32", "buffer", "u32", "u8", "ptr"],
14988
15163
  returns: "i32"
14989
15164
  },
14990
15165
  audioGetStats: {
@@ -15012,7 +15187,7 @@ function getOpenTUILib(libPath) {
15012
15187
  returns: "i32"
15013
15188
  },
15014
15189
  streamDrainSpans: {
15015
- args: ["ptr", "ptr", "u32"],
15190
+ args: ["ptr", "buffer", "u32"],
15016
15191
  returns: "u32"
15017
15192
  },
15018
15193
  streamClose: {
@@ -15199,7 +15374,6 @@ class FFIRenderLib {
15199
15374
  opentui;
15200
15375
  iccCacheClient = false;
15201
15376
  yogaLayout = new Float32Array(6);
15202
- yogaLayoutPtr = ptr(this.yogaLayout);
15203
15377
  ffiStructStorage = {
15204
15378
  logicalCursor: {
15205
15379
  ...allocStruct(LogicalCursorStruct),
@@ -15219,6 +15393,8 @@ class FFIRenderLib {
15219
15393
  ...allocStruct(MeasureResultStruct),
15220
15394
  result: { lineCount: 0, widthColsMax: 0 }
15221
15395
  },
15396
+ embeddedTerminalCursor: allocStruct(EmbeddedTerminalCursorStruct),
15397
+ embeddedTerminalKeyOptions: allocStruct(EmbeddedTerminalKeyOptionsStruct),
15222
15398
  audioStreamStats: {
15223
15399
  ...allocStruct(AudioStreamStatsStruct),
15224
15400
  result: {
@@ -15264,6 +15440,134 @@ class FFIRenderLib {
15264
15440
  nativeRenderableSetMeasureTarget(handle, kind, target) {
15265
15441
  return Boolean(this.opentui.symbols.nativeRenderableSetMeasureTarget(handle, kind, target));
15266
15442
  }
15443
+ createEmbeddedTerminal(options) {
15444
+ const cols = embeddedTerminalDimension(options.cols, "columns");
15445
+ const rows = embeddedTerminalDimension(options.rows, "rows");
15446
+ const maxScrollback = toSafeFFIU32Length(options.maxScrollback ?? 1e4, "Embedded terminal maxScrollback");
15447
+ const out = new Uint32Array(1);
15448
+ embeddedTerminalResult(this.opentui.symbols.createEmbeddedTerminal(cols, rows, maxScrollback, out), "creation");
15449
+ if (!out[0])
15450
+ throw new Error("Embedded terminal creation returned an invalid handle");
15451
+ return out[0];
15452
+ }
15453
+ destroyEmbeddedTerminal(handle) {
15454
+ this.opentui.symbols.destroyEmbeddedTerminal(handle);
15455
+ }
15456
+ embeddedTerminalWrite(handle, data) {
15457
+ const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
15458
+ const length = toSafeFFIU32Length(bytes.byteLength, "Embedded terminal write length");
15459
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalWrite(handle, length === 0 ? null : bytes, length), "write");
15460
+ }
15461
+ embeddedTerminalResize(handle, cols, rows) {
15462
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalResize(handle, embeddedTerminalDimension(cols, "columns"), embeddedTerminalDimension(rows, "rows")), "resize");
15463
+ }
15464
+ embeddedTerminalInvalidate(handle) {
15465
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalInvalidate(handle), "invalidation");
15466
+ }
15467
+ embeddedTerminalScroll(handle, delta) {
15468
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalScroll(handle, embeddedTerminalI32(delta, "scroll delta")), "scroll");
15469
+ }
15470
+ embeddedTerminalSetSelection(handle, start, end) {
15471
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalSetSelection(handle, embeddedTerminalDimension(start.x + 1, "selection start x") - 1, embeddedTerminalDimension(start.y + 1, "selection start y") - 1, embeddedTerminalDimension(end.x + 1, "selection end x") - 1, embeddedTerminalDimension(end.y + 1, "selection end y") - 1), "selection update");
15472
+ }
15473
+ embeddedTerminalClearSelection(handle) {
15474
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalClearSelection(handle), "selection clear");
15475
+ }
15476
+ embeddedTerminalGetSelectedText(handle) {
15477
+ const required = new Uint32Array(1);
15478
+ const read = (output2) => this.opentui.symbols.embeddedTerminalGetSelectedText(handle, viewOrNull(output2), output2.byteLength, required);
15479
+ const initial = new Uint8Array(256);
15480
+ const status = read(initial);
15481
+ if (status >= 0)
15482
+ return initial.slice(0, status);
15483
+ if (status !== -4 || required[0] <= initial.byteLength)
15484
+ embeddedTerminalResult(status, "selection query");
15485
+ const output = new Uint8Array(required[0]);
15486
+ const length = embeddedTerminalResult(read(output), "selection query");
15487
+ return output.slice(0, length);
15488
+ }
15489
+ embeddedTerminalCompose(handle, target, x, y) {
15490
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalCompose(handle, target, embeddedTerminalI32(x, "composition x"), embeddedTerminalI32(y, "composition y")), "compose");
15491
+ }
15492
+ embeddedTerminalCursor(handle) {
15493
+ const storage = this.ffiStructStorage.embeddedTerminalCursor;
15494
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalCursor(handle, storage.buffer), "cursor query");
15495
+ const result = EmbeddedTerminalCursorStruct.unpack(storage.buffer);
15496
+ return {
15497
+ x: result.x,
15498
+ y: result.y,
15499
+ hasValue: result.hasValue,
15500
+ visible: result.visible,
15501
+ blinking: result.blinking,
15502
+ wideTail: result.wideTail,
15503
+ style: ["bar", "block", "underline", "block-hollow"][result.style] ?? "block",
15504
+ ...result.colorHasValue ? { color: { r: result.colorR, g: result.colorG, b: result.colorB } } : {}
15505
+ };
15506
+ }
15507
+ embeddedTerminalEncodeKey(handle, key) {
15508
+ const options = this.ffiStructStorage.embeddedTerminalKeyOptions;
15509
+ EmbeddedTerminalKeyOptionsStruct.packInto({
15510
+ action: { release: 0, press: 1, repeat: 2 }[key.action ?? "press"],
15511
+ composing: key.composing ? 1 : 0,
15512
+ mods: key.mods ?? 0,
15513
+ consumedMods: key.consumedMods ?? 0,
15514
+ padding: 0,
15515
+ unshiftedCodepoint: key.unshiftedCodepoint ?? 0
15516
+ }, options.view, 0);
15517
+ const keyCode = key.key ? this.encoder.encode(key.key) : new Uint8Array;
15518
+ const keyCodeLength = toSafeFFIU32Length(keyCode.byteLength, "Embedded terminal physical key length");
15519
+ const text = key.text ? this.encoder.encode(key.text) : new Uint8Array;
15520
+ const textLength = toSafeFFIU32Length(text.byteLength, "Embedded terminal key text length");
15521
+ const required = new Uint32Array(1);
15522
+ const encode = (output2) => this.opentui.symbols.embeddedTerminalEncodeKey(handle, options.buffer, keyCodeLength === 0 ? null : keyCode, keyCodeLength, textLength === 0 ? null : text, textLength, output2, output2.byteLength, required);
15523
+ const initial = new Uint8Array(Math.max(64, textLength));
15524
+ const status = encode(initial);
15525
+ if (status >= 0)
15526
+ return initial.slice(0, status);
15527
+ if (status !== -4 || required[0] <= initial.byteLength)
15528
+ embeddedTerminalResult(status, "key encoding");
15529
+ const output = new Uint8Array(required[0]);
15530
+ const length = embeddedTerminalResult(encode(output), "key encoding");
15531
+ return output.slice(0, length);
15532
+ }
15533
+ embeddedTerminalEncodeMouse(handle, mouse) {
15534
+ const output = new Uint8Array(128);
15535
+ const length = embeddedTerminalResult(this.opentui.symbols.embeddedTerminalEncodeMouse(handle, { press: 0, release: 1, motion: 2 }[mouse.action], mouse.button ? { unknown: 0, left: 1, right: 2, middle: 3, four: 4, five: 5, six: 6, seven: 7 }[mouse.button] : -1, mouse.mods ?? 0, embeddedTerminalF32(mouse.x, "mouse x"), embeddedTerminalF32(mouse.y, "mouse y"), mouse.anyButtonPressed ? 1 : 0, output, output.byteLength), "mouse encoding");
15536
+ return output.slice(0, length);
15537
+ }
15538
+ embeddedTerminalEncodePaste(handle, input) {
15539
+ const inputLength = toSafeFFIU32Length(input.byteLength, "Embedded terminal paste length");
15540
+ const outputLength = toSafeFFIU32Length(inputLength + 16, "Embedded terminal paste output length");
15541
+ const output = new Uint8Array(outputLength);
15542
+ const length = embeddedTerminalResult(this.opentui.symbols.embeddedTerminalEncodePaste(handle, inputLength === 0 ? null : input, inputLength, output, output.byteLength), "paste encoding");
15543
+ return output.slice(0, length);
15544
+ }
15545
+ embeddedTerminalEncodeFocus(handle, focused) {
15546
+ const output = new Uint8Array(16);
15547
+ const length = embeddedTerminalResult(this.opentui.symbols.embeddedTerminalEncodeFocus(handle, focused ? 1 : 0, output, output.byteLength), "focus encoding");
15548
+ return output.slice(0, length);
15549
+ }
15550
+ embeddedTerminalDrainResponses(handle) {
15551
+ const chunks = [];
15552
+ while (true) {
15553
+ const output = new Uint8Array(64 * 1024);
15554
+ const status = this.opentui.symbols.embeddedTerminalDrainResponses(handle, output, output.byteLength);
15555
+ if (status === -4)
15556
+ continue;
15557
+ const length = embeddedTerminalResult(status, "response drain");
15558
+ if (length > 0)
15559
+ chunks.push(output.slice(0, length));
15560
+ if (length < output.byteLength)
15561
+ break;
15562
+ }
15563
+ const result = new Uint8Array(chunks.reduce((total, chunk) => total + chunk.byteLength, 0));
15564
+ let offset = 0;
15565
+ for (const chunk of chunks) {
15566
+ result.set(chunk, offset);
15567
+ offset += chunk.byteLength;
15568
+ }
15569
+ return result;
15570
+ }
15267
15571
  constructor(libPath) {
15268
15572
  this.opentui = getOpenTUILib(libPath);
15269
15573
  this.imageRetainIccCache();
@@ -15417,7 +15721,7 @@ class FFIRenderLib {
15417
15721
  setTerminalEnvVar(renderer, key, value) {
15418
15722
  const keyBytes = this.encoder.encode(key);
15419
15723
  const valueBytes = this.encoder.encode(value);
15420
- return this.opentui.symbols.setTerminalEnvVar(renderer, ptrOrNull(keyBytes), keyBytes.byteLength, ptrOrNull(valueBytes), valueBytes.byteLength);
15724
+ return this.opentui.symbols.setTerminalEnvVar(renderer, viewOrNull(keyBytes), keyBytes.byteLength, viewOrNull(valueBytes), valueBytes.byteLength);
15421
15725
  }
15422
15726
  destroyRenderer(renderer, flushInput = false) {
15423
15727
  this.opentui.symbols.destroyRenderer(renderer, ffiBool(flushInput));
@@ -15429,7 +15733,7 @@ class FFIRenderLib {
15429
15733
  this.opentui.symbols.setClearOnShutdown(renderer, ffiBool(clear));
15430
15734
  }
15431
15735
  setBackgroundColor(renderer, color) {
15432
- this.opentui.symbols.setBackgroundColor(renderer, rgbaPtr(color));
15736
+ this.opentui.symbols.setBackgroundColor(renderer, rgbaBuffer(color));
15433
15737
  }
15434
15738
  setRenderOffset(renderer, offset) {
15435
15739
  this.opentui.symbols.setRenderOffset(renderer, offset);
@@ -15457,7 +15761,7 @@ class FFIRenderLib {
15457
15761
  }
15458
15762
  getRenderStats(renderer) {
15459
15763
  const statsBuffer = new ArrayBuffer(NativeRenderStatsStruct.size);
15460
- this.opentui.symbols.getRenderStats(renderer, ptr(statsBuffer));
15764
+ this.opentui.symbols.getRenderStats(renderer, statsBuffer);
15461
15765
  const stats = NativeRenderStatsStruct.unpack(statsBuffer);
15462
15766
  return {
15463
15767
  nativeLastFrameTime: stats.lastFrameTime,
@@ -15492,7 +15796,7 @@ class FFIRenderLib {
15492
15796
  for (let index = 0;index < palette.length; index++) {
15493
15797
  paletteBuffer.set(palette[index].buffer, index * 4);
15494
15798
  }
15495
- this.opentui.symbols.rendererSetPaletteState(renderer, ptr(paletteBuffer), palette.length, rgbaPtr(defaultForeground), rgbaPtr(defaultBackground), paletteEpoch >>> 0);
15799
+ this.opentui.symbols.rendererSetPaletteState(renderer, paletteBuffer, palette.length, rgbaBuffer(defaultForeground), rgbaBuffer(defaultBackground), paletteEpoch >>> 0);
15496
15800
  }
15497
15801
  bufferGetCharPtr(buffer) {
15498
15802
  const ptr3 = this.opentui.symbols.bufferGetCharPtr(buffer);
@@ -15531,14 +15835,14 @@ class FFIRenderLib {
15531
15835
  bufferGetId(buffer) {
15532
15836
  const maxLen = 256;
15533
15837
  const outBuffer = new Uint8Array(maxLen);
15534
- const actualLen = this.opentui.symbols.bufferGetId(buffer, ptr(outBuffer), maxLen);
15838
+ const actualLen = this.opentui.symbols.bufferGetId(buffer, outBuffer, maxLen);
15535
15839
  return this.decoder.decode(outBuffer.slice(0, actualLen));
15536
15840
  }
15537
15841
  bufferGetRealCharSize(buffer) {
15538
15842
  return this.opentui.symbols.bufferGetRealCharSize(buffer);
15539
15843
  }
15540
15844
  bufferWriteResolvedChars(buffer, outputBuffer, addLineBreaks) {
15541
- return this.opentui.symbols.bufferWriteResolvedChars(buffer, ptrOrNull(outputBuffer), outputBuffer.byteLength, ffiBool(addLineBreaks));
15845
+ return this.opentui.symbols.bufferWriteResolvedChars(buffer, viewOrNull(outputBuffer), outputBuffer.byteLength, ffiBool(addLineBreaks));
15542
15846
  }
15543
15847
  getBufferWidth(buffer) {
15544
15848
  return this.opentui.symbols.getBufferWidth(buffer);
@@ -15547,39 +15851,39 @@ class FFIRenderLib {
15547
15851
  return this.opentui.symbols.getBufferHeight(buffer);
15548
15852
  }
15549
15853
  bufferClear(buffer, color) {
15550
- this.opentui.symbols.bufferClear(buffer, rgbaPtr(color));
15854
+ this.opentui.symbols.bufferClear(buffer, rgbaBuffer(color));
15551
15855
  }
15552
15856
  bufferDrawText(buffer, text, x, y, color, bgColor, attributes) {
15553
15857
  const textBytes = this.encoder.encode(text);
15554
- const bg2 = optionalRgbaPtr(bgColor);
15555
- const fg2 = rgbaPtr(color);
15556
- this.opentui.symbols.bufferDrawText(buffer, ptrOrNull(textBytes), textBytes.byteLength, x, y, fg2, bg2, attributes ?? 0);
15858
+ const bg2 = optionalRgbaBuffer(bgColor);
15859
+ const fg2 = rgbaBuffer(color);
15860
+ this.opentui.symbols.bufferDrawText(buffer, viewOrNull(textBytes), textBytes.byteLength, x, y, fg2, bg2, attributes ?? 0);
15557
15861
  }
15558
15862
  bufferSetCellWithAlphaBlending(buffer, x, y, char, color, bgColor, attributes) {
15559
15863
  const charPtr = char.codePointAt(0) ?? " ".codePointAt(0);
15560
- const bg2 = rgbaPtr(bgColor);
15561
- const fg2 = rgbaPtr(color);
15864
+ const bg2 = rgbaBuffer(bgColor);
15865
+ const fg2 = rgbaBuffer(color);
15562
15866
  this.opentui.symbols.bufferSetCellWithAlphaBlending(buffer, x, y, charPtr, fg2, bg2, attributes ?? 0);
15563
15867
  }
15564
15868
  bufferSetCell(buffer, x, y, char, color, bgColor, attributes) {
15565
15869
  const charPtr = char.codePointAt(0) ?? " ".codePointAt(0);
15566
- const bg2 = rgbaPtr(bgColor);
15567
- const fg2 = rgbaPtr(color);
15870
+ const bg2 = rgbaBuffer(bgColor);
15871
+ const fg2 = rgbaBuffer(color);
15568
15872
  this.opentui.symbols.bufferSetCell(buffer, x, y, charPtr, fg2, bg2, attributes ?? 0);
15569
15873
  }
15570
15874
  bufferFillRect(buffer, x, y, width, height, color) {
15571
- const bg2 = rgbaPtr(color);
15875
+ const bg2 = rgbaBuffer(color);
15572
15876
  this.opentui.symbols.bufferFillRect(buffer, x, y, width, height, bg2);
15573
15877
  }
15574
- bufferColorMatrix(buffer, matrixPtr, cellMaskPtr, cellMaskCount, strength, target) {
15575
- this.opentui.symbols.bufferColorMatrix(buffer, matrixPtr, cellMaskPtr, cellMaskCount, strength, target);
15878
+ bufferColorMatrix(buffer, matrix, cellMask, cellMaskCount, strength, target) {
15879
+ this.opentui.symbols.bufferColorMatrix(buffer, matrix, cellMask, cellMaskCount, strength, target);
15576
15880
  }
15577
- bufferColorMatrixUniform(buffer, matrixPtr, strength, target) {
15578
- this.opentui.symbols.bufferColorMatrixUniform(buffer, matrixPtr, strength, target);
15881
+ bufferColorMatrixUniform(buffer, matrix, strength, target) {
15882
+ this.opentui.symbols.bufferColorMatrixUniform(buffer, matrix, strength, target);
15579
15883
  }
15580
- bufferDrawSuperSampleBuffer(buffer, x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
15884
+ bufferDrawSuperSampleBuffer(buffer, x, y, pixelData, pixelDataLength, format, alignedBytesPerRow) {
15581
15885
  const formatId = format === "bgra8unorm" ? 0 : 1;
15582
- this.opentui.symbols.bufferDrawSuperSampleBuffer(buffer, x, y, pixelDataPtr, pixelDataLength, formatId, alignedBytesPerRow);
15886
+ this.opentui.symbols.bufferDrawSuperSampleBuffer(buffer, x, y, pixelData, pixelDataLength, formatId, alignedBytesPerRow);
15583
15887
  }
15584
15888
  bufferDrawImage(buffer, image, x, y, width, height, pixelWidth, pixelHeight, sourceX, sourceY, sourceWidth, sourceHeight, protocol) {
15585
15889
  const protocolId = { auto: 0, kitty: 1, sixel: 2, blocks: 3 }[protocol];
@@ -15599,38 +15903,38 @@ class FFIRenderLib {
15599
15903
  }, storage.view, 0);
15600
15904
  return Boolean(this.opentui.symbols.bufferDrawImage(buffer, image, storage.buffer));
15601
15905
  }
15602
- bufferDrawPackedBuffer(buffer, dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
15603
- this.opentui.symbols.bufferDrawPackedBuffer(buffer, dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
15906
+ bufferDrawPackedBuffer(buffer, data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
15907
+ this.opentui.symbols.bufferDrawPackedBuffer(buffer, data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
15604
15908
  }
15605
- bufferDrawGrayscaleBuffer(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, fg2, bg2) {
15606
- this.opentui.symbols.bufferDrawGrayscaleBuffer(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, optionalRgbaPtr(fg2), optionalRgbaPtr(bg2));
15909
+ bufferDrawGrayscaleBuffer(buffer, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2) {
15910
+ this.opentui.symbols.bufferDrawGrayscaleBuffer(buffer, posX, posY, intensities, srcWidth, srcHeight, optionalRgbaBuffer(fg2), optionalRgbaBuffer(bg2));
15607
15911
  }
15608
- bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, fg2, bg2) {
15609
- this.opentui.symbols.bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, optionalRgbaPtr(fg2), optionalRgbaPtr(bg2));
15912
+ bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2) {
15913
+ this.opentui.symbols.bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensities, srcWidth, srcHeight, optionalRgbaBuffer(fg2), optionalRgbaBuffer(bg2));
15610
15914
  }
15611
15915
  bufferDrawGrid(buffer, borderChars, borderFg, borderBg, columnOffsets, columnCount, rowOffsets, rowCount, options) {
15612
15916
  GridDrawOptionsStruct.packInto({ drawInner: options.drawInner, drawOuter: options.drawOuter }, this.ffiStructStorage.gridDrawOptions.view, 0);
15613
- this.opentui.symbols.bufferDrawGrid(buffer, ptr(borderChars), rgbaPtr(borderFg), rgbaPtr(borderBg), ptr(columnOffsets), columnCount, ptr(rowOffsets), rowCount, this.ffiStructStorage.gridDrawOptions.buffer);
15917
+ this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaBuffer(borderFg), rgbaBuffer(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, this.ffiStructStorage.gridDrawOptions.buffer);
15614
15918
  }
15615
15919
  bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, titleColor, title, bottomTitle) {
15616
15920
  const titleBytes = title ? this.encoder.encode(title) : null;
15617
15921
  const titleLen = titleBytes?.byteLength ?? 0;
15618
- const titlePtr = titleBytes ? ptr(titleBytes) : null;
15922
+ const titleBuffer = titleBytes ? titleBytes : null;
15619
15923
  const bottomTitleBytes = bottomTitle ? this.encoder.encode(bottomTitle) : null;
15620
15924
  const bottomTitleLen = bottomTitleBytes?.byteLength ?? 0;
15621
- const bottomTitlePtr = bottomTitleBytes ? ptr(bottomTitleBytes) : null;
15622
- this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, ptr(borderChars), packedOptions, rgbaPtr(borderColor), rgbaPtr(backgroundColor), rgbaPtr(titleColor), titlePtr, titleLen, bottomTitlePtr, bottomTitleLen);
15925
+ const bottomTitleBuffer = bottomTitleBytes ? bottomTitleBytes : null;
15926
+ this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, rgbaBuffer(borderColor), rgbaBuffer(backgroundColor), rgbaBuffer(titleColor), titleBuffer, titleLen, bottomTitleBuffer, bottomTitleLen);
15623
15927
  }
15624
15928
  bufferResize(buffer, width, height) {
15625
15929
  this.opentui.symbols.bufferResize(buffer, width, height);
15626
15930
  }
15627
15931
  linkAlloc(url) {
15628
15932
  const urlBytes = this.encoder.encode(url);
15629
- return this.opentui.symbols.linkAlloc(ptrOrNull(urlBytes), urlBytes.byteLength);
15933
+ return this.opentui.symbols.linkAlloc(viewOrNull(urlBytes), urlBytes.byteLength);
15630
15934
  }
15631
15935
  linkGetUrl(linkId, maxLen = 512) {
15632
15936
  const outBuffer = new Uint8Array(maxLen);
15633
- const actualLen = this.opentui.symbols.linkGetUrl(linkId, ptrOrNull(outBuffer), maxLen);
15937
+ const actualLen = this.opentui.symbols.linkGetUrl(linkId, viewOrNull(outBuffer), maxLen);
15634
15938
  return this.decoder.decode(outBuffer.slice(0, actualLen));
15635
15939
  }
15636
15940
  attributesWithLink(baseAttributes, linkId) {
@@ -15646,11 +15950,11 @@ class FFIRenderLib {
15646
15950
  this.opentui.symbols.setCursorPosition(renderer, x, y, ffiBool(visible));
15647
15951
  }
15648
15952
  setCursorColor(renderer, color) {
15649
- this.opentui.symbols.setCursorColor(renderer, rgbaPtr(color));
15953
+ this.opentui.symbols.setCursorColor(renderer, rgbaBuffer(color));
15650
15954
  }
15651
15955
  getCursorState(renderer) {
15652
15956
  const cursorBuffer = new ArrayBuffer(CursorStateStruct.size);
15653
- this.opentui.symbols.getCursorState(renderer, ptr(cursorBuffer));
15957
+ this.opentui.symbols.getCursorState(renderer, cursorBuffer);
15654
15958
  const struct = CursorStateStruct.unpack(cursorBuffer);
15655
15959
  return {
15656
15960
  x: struct.x,
@@ -15682,7 +15986,8 @@ class FFIRenderLib {
15682
15986
  return this.unpackRenderOperationResult(this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, ffiBool(force)));
15683
15987
  }
15684
15988
  commitSplitFooterSnapshot(renderer, snapshot, rowColumns, startOnNewLine, trailingNewline, pinnedRenderOffset, force, beginFrame = true, finalizeFrame = true) {
15685
- return this.unpackRenderOperationResult(this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, ffiBool(startOnNewLine), ffiBool(trailingNewline), pinnedRenderOffset, ffiBool(force), ffiBool(beginFrame), ffiBool(finalizeFrame)));
15989
+ const flags = ffiBool(startOnNewLine) | ffiBool(trailingNewline) << 1 | ffiBool(force) << 2 | ffiBool(beginFrame) << 3 | ffiBool(finalizeFrame) << 4;
15990
+ return this.unpackRenderOperationResult(this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, flags, pinnedRenderOffset));
15686
15991
  }
15687
15992
  createOptimizedBuffer(width, height, widthMethod, respectAlpha = false, id) {
15688
15993
  if (Number.isNaN(width) || Number.isNaN(height)) {
@@ -15691,7 +15996,7 @@ class FFIRenderLib {
15691
15996
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
15692
15997
  const idToUse = id || "unnamed buffer";
15693
15998
  const idBytes = this.encoder.encode(idToUse);
15694
- const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, ffiBool(respectAlpha), widthMethodCode, ptr(idBytes), idBytes.byteLength);
15999
+ const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, ffiBool(respectAlpha), widthMethodCode, idBytes, idBytes.byteLength);
15695
16000
  if (!bufferPtr) {
15696
16001
  throw new Error(`Failed to create optimized buffer: ${width}x${height}`);
15697
16002
  }
@@ -15715,12 +16020,12 @@ class FFIRenderLib {
15715
16020
  }
15716
16021
  setTerminalTitle(renderer, title) {
15717
16022
  const titleBytes = this.encoder.encode(title);
15718
- this.opentui.symbols.setTerminalTitle(renderer, ptrOrNull(titleBytes), titleBytes.byteLength);
16023
+ this.opentui.symbols.setTerminalTitle(renderer, viewOrNull(titleBytes), titleBytes.byteLength);
15719
16024
  }
15720
16025
  copyToClipboardOSC52(renderer, target, textUtf8) {
15721
16026
  if (textUtf8.byteLength > 4294967295)
15722
16027
  return false;
15723
- return Boolean(this.opentui.symbols.copyToClipboardOSC52(renderer, target, ptrOrNull(textUtf8), textUtf8.byteLength));
16028
+ return Boolean(this.opentui.symbols.copyToClipboardOSC52(renderer, target, viewOrNull(textUtf8), textUtf8.byteLength));
15724
16029
  }
15725
16030
  clearClipboardOSC52(renderer, target) {
15726
16031
  return Boolean(this.opentui.symbols.clearClipboardOSC52(renderer, target));
@@ -15895,7 +16200,7 @@ class FFIRenderLib {
15895
16200
  const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
15896
16201
  if (bytes.length === 0)
15897
16202
  return;
15898
- this.opentui.symbols.writeOut(renderer, ptrOrNull(bytes), bytes.byteLength);
16203
+ this.opentui.symbols.writeOut(renderer, viewOrNull(bytes), bytes.byteLength);
15899
16204
  }
15900
16205
  yogaConfigCreate() {
15901
16206
  const config = this.opentui.symbols.yogaConfigCreate();
@@ -16007,7 +16312,7 @@ class FFIRenderLib {
16007
16312
  }
16008
16313
  yogaNodeGetComputedLayout(node) {
16009
16314
  const layout = this.yogaLayout;
16010
- this.opentui.symbols.yogaNodeGetComputedLayout(node, this.yogaLayoutPtr);
16315
+ this.opentui.symbols.yogaNodeGetComputedLayout(node, this.yogaLayout);
16011
16316
  return {
16012
16317
  left: layout[0],
16013
16318
  top: layout[1],
@@ -16104,16 +16409,16 @@ class FFIRenderLib {
16104
16409
  this.opentui.symbols.textBufferClear(buffer);
16105
16410
  }
16106
16411
  textBufferSetDefaultFg(buffer, fg2) {
16107
- const fgPtr = optionalRgbaPtr(fg2);
16108
- this.opentui.symbols.textBufferSetDefaultFg(buffer, fgPtr);
16412
+ const fgBuffer = optionalRgbaBuffer(fg2);
16413
+ this.opentui.symbols.textBufferSetDefaultFg(buffer, fgBuffer);
16109
16414
  }
16110
16415
  textBufferSetDefaultBg(buffer, bg2) {
16111
- const bgPtr = optionalRgbaPtr(bg2);
16112
- this.opentui.symbols.textBufferSetDefaultBg(buffer, bgPtr);
16416
+ const bgBuffer = optionalRgbaBuffer(bg2);
16417
+ this.opentui.symbols.textBufferSetDefaultBg(buffer, bgBuffer);
16113
16418
  }
16114
16419
  textBufferSetDefaultAttributes(buffer, attributes) {
16115
16420
  const attrValue = attributes === null ? null : new Uint32Array([attributes]);
16116
- this.opentui.symbols.textBufferSetDefaultAttributes(buffer, attrValue ? ptr(attrValue) : null);
16421
+ this.opentui.symbols.textBufferSetDefaultAttributes(buffer, attrValue);
16117
16422
  }
16118
16423
  textBufferResetDefaults(buffer) {
16119
16424
  this.opentui.symbols.textBufferResetDefaults(buffer);
@@ -16125,14 +16430,14 @@ class FFIRenderLib {
16125
16430
  this.opentui.symbols.textBufferSetTabWidth(buffer, width);
16126
16431
  }
16127
16432
  textBufferRegisterMemBuffer(buffer, bytes, owned = false) {
16128
- const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, ptrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16433
+ const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, retainedPtrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16129
16434
  if (result === 65535) {
16130
16435
  throw new Error("Failed to register memory buffer");
16131
16436
  }
16132
16437
  return result;
16133
16438
  }
16134
16439
  textBufferReplaceMemBuffer(buffer, memId, bytes, owned = false) {
16135
- return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, ptrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16440
+ return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, retainedPtrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16136
16441
  }
16137
16442
  textBufferClearMemRegistry(buffer) {
16138
16443
  this.opentui.symbols.textBufferClearMemRegistry(buffer);
@@ -16141,14 +16446,14 @@ class FFIRenderLib {
16141
16446
  this.opentui.symbols.textBufferSetTextFromMem(buffer, memId);
16142
16447
  }
16143
16448
  textBufferAppend(buffer, bytes) {
16144
- this.opentui.symbols.textBufferAppend(buffer, ptrOrNull(bytes), bytes.byteLength);
16449
+ this.opentui.symbols.textBufferAppend(buffer, retainedPtrOrNull(bytes), bytes.byteLength);
16145
16450
  }
16146
16451
  textBufferAppendFromMemId(buffer, memId) {
16147
16452
  this.opentui.symbols.textBufferAppendFromMemId(buffer, memId);
16148
16453
  }
16149
16454
  textBufferLoadFile(buffer, path3) {
16150
16455
  const pathBytes = this.encoder.encode(path3);
16151
- return this.opentui.symbols.textBufferLoadFile(buffer, ptrOrNull(pathBytes), pathBytes.byteLength);
16456
+ return this.opentui.symbols.textBufferLoadFile(buffer, viewOrNull(pathBytes), pathBytes.byteLength);
16152
16457
  }
16153
16458
  textBufferSetStyledText(buffer, chunks) {
16154
16459
  if (chunks.length === 0) {
@@ -16161,12 +16466,12 @@ class FFIRenderLib {
16161
16466
  textBufferGetLineCount(buffer) {
16162
16467
  return this.opentui.symbols.textBufferGetLineCount(buffer);
16163
16468
  }
16164
- textBufferGetPlainText(buffer, outPtr, maxLen) {
16165
- return this.opentui.symbols.textBufferGetPlainText(buffer, outPtr, maxLen);
16469
+ textBufferGetPlainText(buffer, outBuffer, maxLen) {
16470
+ return this.opentui.symbols.textBufferGetPlainText(buffer, outBuffer, maxLen);
16166
16471
  }
16167
16472
  getPlainTextBytes(buffer, maxLength) {
16168
16473
  const outBuffer = new Uint8Array(maxLength);
16169
- const actualLen = this.textBufferGetPlainText(buffer, ptrOrNull(outBuffer), maxLength);
16474
+ const actualLen = this.textBufferGetPlainText(buffer, viewOrNull(outBuffer), maxLength);
16170
16475
  if (actualLen === 0) {
16171
16476
  return null;
16172
16477
  }
@@ -16174,7 +16479,7 @@ class FFIRenderLib {
16174
16479
  }
16175
16480
  textBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
16176
16481
  const outBuffer = new Uint8Array(maxLength);
16177
- const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, ptrOrNull(outBuffer), maxLength);
16482
+ const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, viewOrNull(outBuffer), maxLength);
16178
16483
  const len = actualLen;
16179
16484
  if (len === 0) {
16180
16485
  return null;
@@ -16183,7 +16488,7 @@ class FFIRenderLib {
16183
16488
  }
16184
16489
  textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
16185
16490
  const outBuffer = new Uint8Array(maxLength);
16186
- const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptrOrNull(outBuffer), maxLength);
16491
+ const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, viewOrNull(outBuffer), maxLength);
16187
16492
  const len = actualLen;
16188
16493
  if (len === 0) {
16189
16494
  return null;
@@ -16201,8 +16506,8 @@ class FFIRenderLib {
16201
16506
  this.opentui.symbols.destroyTextBufferView(view);
16202
16507
  }
16203
16508
  textBufferViewSetSelection(view, start, end, bgColor, fgColor) {
16204
- const bg2 = optionalRgbaPtr(bgColor);
16205
- const fg2 = optionalRgbaPtr(fgColor);
16509
+ const bg2 = optionalRgbaBuffer(bgColor);
16510
+ const fg2 = optionalRgbaBuffer(fgColor);
16206
16511
  this.opentui.symbols.textBufferViewSetSelection(view, start, end, bg2, fg2);
16207
16512
  }
16208
16513
  textBufferViewResetSelection(view) {
@@ -16220,24 +16525,30 @@ class FFIRenderLib {
16220
16525
  textBufferViewGetSelectionInfo(view) {
16221
16526
  return this.opentui.symbols.textBufferViewGetSelectionInfo(view);
16222
16527
  }
16223
- textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
16224
- const bg2 = optionalRgbaPtr(bgColor);
16225
- const fg2 = optionalRgbaPtr(fgColor);
16226
- return Boolean(this.opentui.symbols.textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2));
16528
+ textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior) {
16529
+ const bg2 = optionalRgbaBuffer(bgColor);
16530
+ const fg2 = optionalRgbaBuffer(fgColor);
16531
+ return Boolean(this.opentui.symbols.textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, selectionBehaviorByte(behavior)));
16227
16532
  }
16228
16533
  textBufferViewUpdateSelection(view, end, bgColor, fgColor) {
16229
- const bg2 = optionalRgbaPtr(bgColor);
16230
- const fg2 = optionalRgbaPtr(fgColor);
16534
+ const bg2 = optionalRgbaBuffer(bgColor);
16535
+ const fg2 = optionalRgbaBuffer(fgColor);
16231
16536
  this.opentui.symbols.textBufferViewUpdateSelection(view, end, bg2, fg2);
16232
16537
  }
16233
- textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
16234
- const bg2 = optionalRgbaPtr(bgColor);
16235
- const fg2 = optionalRgbaPtr(fgColor);
16236
- return Boolean(this.opentui.symbols.textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2));
16538
+ textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior) {
16539
+ const bg2 = optionalRgbaBuffer(bgColor);
16540
+ const fg2 = optionalRgbaBuffer(fgColor);
16541
+ return Boolean(this.opentui.symbols.textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, selectionBehaviorByte(behavior)));
16237
16542
  }
16238
16543
  textBufferViewResetLocalSelection(view) {
16239
16544
  this.opentui.symbols.textBufferViewResetLocalSelection(view);
16240
16545
  }
16546
+ textBufferViewSetSelectionOccupancy(view, occupancy) {
16547
+ this.opentui.symbols.textBufferViewSetSelectionOccupancy(view, occupancy === "boundary" ? 1 : 0);
16548
+ }
16549
+ textBufferViewGetSelectionOccupancy(view) {
16550
+ return this.opentui.symbols.textBufferViewGetSelectionOccupancy(view) === 1 ? "boundary" : "cell";
16551
+ }
16241
16552
  textBufferViewSetWrapWidth(view, width) {
16242
16553
  this.opentui.symbols.textBufferViewSetWrapWidth(view, width);
16243
16554
  }
@@ -16256,7 +16567,7 @@ class FFIRenderLib {
16256
16567
  }
16257
16568
  textBufferViewGetLineInfo(view) {
16258
16569
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16259
- this.textBufferViewGetLineInfoDirect(view, ptr(outBuffer));
16570
+ this.textBufferViewGetLineInfoDirect(view, outBuffer);
16260
16571
  const struct = LineInfoStruct.unpack(outBuffer);
16261
16572
  const lineStartCols = struct.startCols;
16262
16573
  const lineWidthCols = struct.widthCols;
@@ -16271,7 +16582,7 @@ class FFIRenderLib {
16271
16582
  }
16272
16583
  textBufferViewGetLogicalLineInfo(view) {
16273
16584
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16274
- this.textBufferViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
16585
+ this.textBufferViewGetLogicalLineInfoDirect(view, outBuffer);
16275
16586
  const struct = LineInfoStruct.unpack(outBuffer);
16276
16587
  const lineStartCols = struct.startCols;
16277
16588
  const lineWidthCols = struct.widthCols;
@@ -16287,21 +16598,21 @@ class FFIRenderLib {
16287
16598
  textBufferViewGetVirtualLineCount(view) {
16288
16599
  return this.opentui.symbols.textBufferViewGetVirtualLineCount(view);
16289
16600
  }
16290
- textBufferViewGetLineInfoDirect(view, outPtr) {
16291
- this.opentui.symbols.textBufferViewGetLineInfoDirect(view, outPtr);
16601
+ textBufferViewGetLineInfoDirect(view, outBuffer) {
16602
+ this.opentui.symbols.textBufferViewGetLineInfoDirect(view, outBuffer);
16292
16603
  }
16293
- textBufferViewGetLogicalLineInfoDirect(view, outPtr) {
16294
- this.opentui.symbols.textBufferViewGetLogicalLineInfoDirect(view, outPtr);
16604
+ textBufferViewGetLogicalLineInfoDirect(view, outBuffer) {
16605
+ this.opentui.symbols.textBufferViewGetLogicalLineInfoDirect(view, outBuffer);
16295
16606
  }
16296
- textBufferViewGetSelectedText(view, outPtr, maxLen) {
16297
- return this.opentui.symbols.textBufferViewGetSelectedText(view, outPtr, maxLen);
16607
+ textBufferViewGetSelectedText(view, outBuffer, maxLen) {
16608
+ return this.opentui.symbols.textBufferViewGetSelectedText(view, outBuffer, maxLen);
16298
16609
  }
16299
- textBufferViewGetPlainText(view, outPtr, maxLen) {
16300
- return this.opentui.symbols.textBufferViewGetPlainText(view, outPtr, maxLen);
16610
+ textBufferViewGetPlainText(view, outBuffer, maxLen) {
16611
+ return this.opentui.symbols.textBufferViewGetPlainText(view, outBuffer, maxLen);
16301
16612
  }
16302
16613
  textBufferViewGetSelectedTextBytes(view, maxLength) {
16303
16614
  const outBuffer = new Uint8Array(maxLength);
16304
- const actualLen = this.textBufferViewGetSelectedText(view, ptrOrNull(outBuffer), maxLength);
16615
+ const actualLen = this.textBufferViewGetSelectedText(view, viewOrNull(outBuffer), maxLength);
16305
16616
  if (actualLen === 0) {
16306
16617
  return null;
16307
16618
  }
@@ -16309,7 +16620,7 @@ class FFIRenderLib {
16309
16620
  }
16310
16621
  textBufferViewGetPlainTextBytes(view, maxLength) {
16311
16622
  const outBuffer = new Uint8Array(maxLength);
16312
- const actualLen = this.textBufferViewGetPlainText(view, ptrOrNull(outBuffer), maxLength);
16623
+ const actualLen = this.textBufferViewGetPlainText(view, viewOrNull(outBuffer), maxLength);
16313
16624
  if (actualLen === 0) {
16314
16625
  return null;
16315
16626
  }
@@ -16319,7 +16630,7 @@ class FFIRenderLib {
16319
16630
  this.opentui.symbols.textBufferViewSetTabIndicator(view, indicator);
16320
16631
  }
16321
16632
  textBufferViewSetTabIndicatorColor(view, color) {
16322
- this.opentui.symbols.textBufferViewSetTabIndicatorColor(view, rgbaPtr(color));
16633
+ this.opentui.symbols.textBufferViewSetTabIndicatorColor(view, rgbaBuffer(color));
16323
16634
  }
16324
16635
  textBufferViewSetTruncate(view, truncate) {
16325
16636
  this.opentui.symbols.textBufferViewSetTruncate(view, ffiBool(truncate));
@@ -16334,11 +16645,11 @@ class FFIRenderLib {
16334
16645
  }
16335
16646
  textBufferAddHighlightByCharRange(buffer, highlight) {
16336
16647
  const packedHighlight = HighlightStruct.pack(highlight);
16337
- this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, ptr(packedHighlight));
16648
+ this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, packedHighlight);
16338
16649
  }
16339
16650
  textBufferAddHighlight(buffer, lineIdx, highlight) {
16340
16651
  const packedHighlight = HighlightStruct.pack(highlight);
16341
- this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, ptr(packedHighlight));
16652
+ this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, packedHighlight);
16342
16653
  }
16343
16654
  textBufferRemoveHighlightsByRef(buffer, hlRef) {
16344
16655
  this.opentui.symbols.textBufferRemoveHighlightsByRef(buffer, hlRef);
@@ -16354,7 +16665,7 @@ class FFIRenderLib {
16354
16665
  }
16355
16666
  textBufferGetLineHighlights(buffer, lineIdx) {
16356
16667
  const outCountBuf = new Uint32Array(1);
16357
- const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, ptr(outCountBuf));
16668
+ const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, outCountBuf);
16358
16669
  if (!nativePtr)
16359
16670
  return [];
16360
16671
  const count = outCountBuf[0];
@@ -16373,7 +16684,7 @@ class FFIRenderLib {
16373
16684
  }
16374
16685
  getBuildOptions() {
16375
16686
  const optionsBuffer = new ArrayBuffer(BuildOptionsStruct.size);
16376
- this.opentui.symbols.getBuildOptions(ptr(optionsBuffer));
16687
+ this.opentui.symbols.getBuildOptions(optionsBuffer);
16377
16688
  const options = BuildOptionsStruct.unpack(optionsBuffer);
16378
16689
  return {
16379
16690
  gpaSafeStats: !!options.gpaSafeStats,
@@ -16382,7 +16693,7 @@ class FFIRenderLib {
16382
16693
  }
16383
16694
  getAllocatorStats() {
16384
16695
  const statsBuffer = new ArrayBuffer(AllocatorStatsStruct.size);
16385
- this.opentui.symbols.getAllocatorStats(ptr(statsBuffer));
16696
+ this.opentui.symbols.getAllocatorStats(statsBuffer);
16386
16697
  const stats = AllocatorStatsStruct.unpack(statsBuffer);
16387
16698
  return {
16388
16699
  totalRequestedBytes: toNumber(stats.totalRequestedBytes),
@@ -16419,7 +16730,7 @@ class FFIRenderLib {
16419
16730
  const y = new Uint32Array(1);
16420
16731
  const width = new Uint32Array(1);
16421
16732
  const height = new Uint32Array(1);
16422
- this.opentui.symbols.editorViewGetViewport(view, ptr(x), ptr(y), ptr(width), ptr(height));
16733
+ this.opentui.symbols.editorViewGetViewport(view, x, y, width, height);
16423
16734
  return {
16424
16735
  offsetX: x[0],
16425
16736
  offsetY: y[0],
@@ -16449,7 +16760,7 @@ class FFIRenderLib {
16449
16760
  }
16450
16761
  editorViewGetLineInfo(view) {
16451
16762
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16452
- this.opentui.symbols.editorViewGetLineInfoDirect(view, ptr(outBuffer));
16763
+ this.opentui.symbols.editorViewGetLineInfoDirect(view, outBuffer);
16453
16764
  const struct = LineInfoStruct.unpack(outBuffer);
16454
16765
  const lineStartCols = struct.startCols;
16455
16766
  const lineWidthCols = struct.widthCols;
@@ -16464,7 +16775,7 @@ class FFIRenderLib {
16464
16775
  }
16465
16776
  editorViewGetLogicalLineInfo(view) {
16466
16777
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16467
- this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
16778
+ this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, outBuffer);
16468
16779
  const struct = LineInfoStruct.unpack(outBuffer);
16469
16780
  const lineStartCols = struct.startCols;
16470
16781
  const lineWidthCols = struct.widthCols;
@@ -16489,20 +16800,20 @@ class FFIRenderLib {
16489
16800
  this.opentui.symbols.destroyEditBuffer(buffer);
16490
16801
  }
16491
16802
  editBufferSetText(buffer, textBytes) {
16492
- this.opentui.symbols.editBufferSetText(buffer, ptrOrNull(textBytes), textBytes.byteLength);
16803
+ this.opentui.symbols.editBufferSetText(buffer, viewOrNull(textBytes), textBytes.byteLength);
16493
16804
  }
16494
16805
  editBufferSetTextFromMem(buffer, memId) {
16495
16806
  this.opentui.symbols.editBufferSetTextFromMem(buffer, memId);
16496
16807
  }
16497
16808
  editBufferReplaceText(buffer, textBytes) {
16498
- this.opentui.symbols.editBufferReplaceText(buffer, ptrOrNull(textBytes), textBytes.byteLength);
16809
+ this.opentui.symbols.editBufferReplaceText(buffer, viewOrNull(textBytes), textBytes.byteLength);
16499
16810
  }
16500
16811
  editBufferReplaceTextFromMem(buffer, memId) {
16501
16812
  this.opentui.symbols.editBufferReplaceTextFromMem(buffer, memId);
16502
16813
  }
16503
16814
  editBufferGetText(buffer, maxLength) {
16504
16815
  const outBuffer = new Uint8Array(maxLength);
16505
- const actualLen = this.opentui.symbols.editBufferGetText(buffer, ptrOrNull(outBuffer), maxLength);
16816
+ const actualLen = this.opentui.symbols.editBufferGetText(buffer, viewOrNull(outBuffer), maxLength);
16506
16817
  const len = actualLen;
16507
16818
  if (len === 0)
16508
16819
  return null;
@@ -16510,11 +16821,11 @@ class FFIRenderLib {
16510
16821
  }
16511
16822
  editBufferInsertChar(buffer, char) {
16512
16823
  const charBytes = this.encoder.encode(char);
16513
- this.opentui.symbols.editBufferInsertChar(buffer, ptrOrNull(charBytes), charBytes.byteLength);
16824
+ this.opentui.symbols.editBufferInsertChar(buffer, viewOrNull(charBytes), charBytes.byteLength);
16514
16825
  }
16515
16826
  editBufferInsertText(buffer, text) {
16516
16827
  const textBytes = this.encoder.encode(text);
16517
- this.opentui.symbols.editBufferInsertText(buffer, ptrOrNull(textBytes), textBytes.byteLength);
16828
+ this.opentui.symbols.editBufferInsertText(buffer, viewOrNull(textBytes), textBytes.byteLength);
16518
16829
  }
16519
16830
  editBufferDeleteChar(buffer) {
16520
16831
  this.opentui.symbols.editBufferDeleteChar(buffer);
@@ -16576,7 +16887,7 @@ class FFIRenderLib {
16576
16887
  }
16577
16888
  editBufferUndo(buffer, maxLength) {
16578
16889
  const outBuffer = new Uint8Array(maxLength);
16579
- const actualLen = this.opentui.symbols.editBufferUndo(buffer, ptrOrNull(outBuffer), maxLength);
16890
+ const actualLen = this.opentui.symbols.editBufferUndo(buffer, viewOrNull(outBuffer), maxLength);
16580
16891
  const len = actualLen;
16581
16892
  if (len === 0)
16582
16893
  return null;
@@ -16584,7 +16895,7 @@ class FFIRenderLib {
16584
16895
  }
16585
16896
  editBufferRedo(buffer, maxLength) {
16586
16897
  const outBuffer = new Uint8Array(maxLength);
16587
- const actualLen = this.opentui.symbols.editBufferRedo(buffer, ptrOrNull(outBuffer), maxLength);
16898
+ const actualLen = this.opentui.symbols.editBufferRedo(buffer, viewOrNull(outBuffer), maxLength);
16588
16899
  const len = actualLen;
16589
16900
  if (len === 0)
16590
16901
  return null;
@@ -16636,7 +16947,7 @@ class FFIRenderLib {
16636
16947
  }
16637
16948
  editBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
16638
16949
  const outBuffer = new Uint8Array(maxLength);
16639
- const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, ptrOrNull(outBuffer), maxLength);
16950
+ const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, viewOrNull(outBuffer), maxLength);
16640
16951
  const len = actualLen;
16641
16952
  if (len === 0)
16642
16953
  return null;
@@ -16644,15 +16955,15 @@ class FFIRenderLib {
16644
16955
  }
16645
16956
  editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
16646
16957
  const outBuffer = new Uint8Array(maxLength);
16647
- const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptrOrNull(outBuffer), maxLength);
16958
+ const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, viewOrNull(outBuffer), maxLength);
16648
16959
  const len = actualLen;
16649
16960
  if (len === 0)
16650
16961
  return null;
16651
16962
  return usesBunFFI ? outBuffer.slice(0, len) : trimNodeFFIOutputBytes(outBuffer, len);
16652
16963
  }
16653
16964
  editorViewSetSelection(view, start, end, bgColor, fgColor) {
16654
- const bg2 = optionalRgbaPtr(bgColor);
16655
- const fg2 = optionalRgbaPtr(fgColor);
16965
+ const bg2 = optionalRgbaBuffer(bgColor);
16966
+ const fg2 = optionalRgbaBuffer(fgColor);
16656
16967
  this.opentui.symbols.editorViewSetSelection(view, start, end, bg2, fg2);
16657
16968
  }
16658
16969
  editorViewResetSelection(view) {
@@ -16667,27 +16978,43 @@ class FFIRenderLib {
16667
16978
  const end = Number(packedInfo & 0xffff_ffffn);
16668
16979
  return { start, end };
16669
16980
  }
16670
- editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
16671
- const bg2 = optionalRgbaPtr(bgColor);
16672
- const fg2 = optionalRgbaPtr(fgColor);
16673
- return Boolean(this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor)));
16981
+ editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior) {
16982
+ const bg2 = optionalRgbaBuffer(bgColor);
16983
+ const fg2 = optionalRgbaBuffer(fgColor);
16984
+ return Boolean(this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, editorLocalSelectionFlags(updateCursor, followCursor, behavior)));
16674
16985
  }
16675
16986
  editorViewUpdateSelection(view, end, bgColor, fgColor) {
16676
- const bg2 = optionalRgbaPtr(bgColor);
16677
- const fg2 = optionalRgbaPtr(fgColor);
16987
+ const bg2 = optionalRgbaBuffer(bgColor);
16988
+ const fg2 = optionalRgbaBuffer(fgColor);
16678
16989
  this.opentui.symbols.editorViewUpdateSelection(view, end, bg2, fg2);
16679
16990
  }
16680
- editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
16681
- const bg2 = optionalRgbaPtr(bgColor);
16682
- const fg2 = optionalRgbaPtr(fgColor);
16683
- return Boolean(this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor)));
16991
+ editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior) {
16992
+ const bg2 = optionalRgbaBuffer(bgColor);
16993
+ const fg2 = optionalRgbaBuffer(fgColor);
16994
+ return Boolean(this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, editorLocalSelectionFlags(updateCursor, followCursor, behavior)));
16684
16995
  }
16685
16996
  editorViewResetLocalSelection(view) {
16686
16997
  this.opentui.symbols.editorViewResetLocalSelection(view);
16687
16998
  }
16999
+ editorViewConvertSelectionToCell(view) {
17000
+ return Boolean(this.opentui.symbols.editorViewConvertSelectionToCell(view));
17001
+ }
17002
+ editorViewSetSelectionOccupancy(view, occupancy) {
17003
+ this.opentui.symbols.editorViewSetSelectionOccupancy(view, occupancy === "boundary" ? 1 : 0);
17004
+ }
17005
+ editorViewSetSelectionInclusive(view, start, end, bgColor, fgColor) {
17006
+ const bg2 = optionalRgbaBuffer(bgColor);
17007
+ const fg2 = optionalRgbaBuffer(fgColor);
17008
+ this.opentui.symbols.editorViewSetSelectionInclusive(view, start, end, bg2, fg2);
17009
+ }
17010
+ editorViewSetSelectionColors(view, bgColor, fgColor) {
17011
+ const bg2 = optionalRgbaBuffer(bgColor);
17012
+ const fg2 = optionalRgbaBuffer(fgColor);
17013
+ this.opentui.symbols.editorViewSetSelectionColors(view, bg2, fg2);
17014
+ }
16688
17015
  editorViewGetSelectedTextBytes(view, maxLength) {
16689
17016
  const outBuffer = new Uint8Array(maxLength);
16690
- const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, ptrOrNull(outBuffer), maxLength);
17017
+ const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, viewOrNull(outBuffer), maxLength);
16691
17018
  const len = actualLen;
16692
17019
  if (len === 0)
16693
17020
  return null;
@@ -16696,12 +17023,12 @@ class FFIRenderLib {
16696
17023
  editorViewGetCursor(view) {
16697
17024
  const row = new Uint32Array(1);
16698
17025
  const col = new Uint32Array(1);
16699
- this.opentui.symbols.editorViewGetCursor(view, ptr(row), ptr(col));
17026
+ this.opentui.symbols.editorViewGetCursor(view, row, col);
16700
17027
  return { row: row[0], col: col[0] };
16701
17028
  }
16702
17029
  editorViewGetText(view, maxLength) {
16703
17030
  const outBuffer = new Uint8Array(maxLength);
16704
- const actualLen = this.opentui.symbols.editorViewGetText(view, ptrOrNull(outBuffer), maxLength);
17031
+ const actualLen = this.opentui.symbols.editorViewGetText(view, viewOrNull(outBuffer), maxLength);
16705
17032
  const len = actualLen;
16706
17033
  if (len === 0)
16707
17034
  return null;
@@ -16755,6 +17082,9 @@ class FFIRenderLib {
16755
17082
  const cursor = VisualCursorStruct.unpackInto(storage.view, storage.result);
16756
17083
  return { ...cursor };
16757
17084
  }
17085
+ editorViewGotoVisualLineEnd(view) {
17086
+ this.opentui.symbols.editorViewGotoVisualLineEnd(view);
17087
+ }
16758
17088
  bufferPushScissorRect(buffer, x, y, width, height) {
16759
17089
  this.opentui.symbols.bufferPushScissorRect(buffer, x, y, width, height);
16760
17090
  }
@@ -16778,7 +17108,7 @@ class FFIRenderLib {
16778
17108
  }
16779
17109
  getTerminalCapabilities(renderer) {
16780
17110
  const capsBuffer = new ArrayBuffer(TerminalCapabilitiesStruct.size);
16781
- this.opentui.symbols.getTerminalCapabilities(renderer, ptr(capsBuffer));
17111
+ this.opentui.symbols.getTerminalCapabilities(renderer, capsBuffer);
16782
17112
  const caps = TerminalCapabilitiesStruct.unpack(capsBuffer);
16783
17113
  return {
16784
17114
  kitty_keyboard: caps.kitty_keyboard,
@@ -16811,14 +17141,14 @@ class FFIRenderLib {
16811
17141
  }
16812
17142
  processCapabilityResponse(renderer, response) {
16813
17143
  const responseBytes = this.encoder.encode(response);
16814
- this.opentui.symbols.processCapabilityResponse(renderer, ptrOrNull(responseBytes), responseBytes.byteLength);
17144
+ this.opentui.symbols.processCapabilityResponse(renderer, viewOrNull(responseBytes), responseBytes.byteLength);
16815
17145
  }
16816
17146
  encodeUnicode(text, widthMethod) {
16817
17147
  const textBytes = this.encoder.encode(text);
16818
17148
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
16819
17149
  const outPtrBuffer = new ArrayBuffer(8);
16820
17150
  const outLenBuffer = new ArrayBuffer(8);
16821
- const success = this.opentui.symbols.encodeUnicode(ptrOrNull(textBytes), textBytes.byteLength, ptr(outPtrBuffer), ptr(outLenBuffer), widthMethodCode);
17151
+ const success = this.opentui.symbols.encodeUnicode(viewOrNull(textBytes), textBytes.byteLength, outPtrBuffer, outLenBuffer, widthMethodCode);
16822
17152
  if (!success) {
16823
17153
  return null;
16824
17154
  }
@@ -16838,11 +17168,11 @@ class FFIRenderLib {
16838
17168
  this.opentui.symbols.freeUnicode(encoded.ptr, encoded.data.length);
16839
17169
  }
16840
17170
  bufferDrawChar(buffer, char, x, y, fg2, bg2, attributes = 0) {
16841
- this.opentui.symbols.bufferDrawChar(buffer, char, x, y, rgbaPtr(fg2), rgbaPtr(bg2), attributes);
17171
+ this.opentui.symbols.bufferDrawChar(buffer, char, x, y, rgbaBuffer(fg2), rgbaBuffer(bg2), attributes);
16842
17172
  }
16843
17173
  createAudioEngine(options) {
16844
17174
  const optionsBuffer = options == null ? null : AudioCreateOptionsStruct.pack(options);
16845
- const engineHandle = this.opentui.symbols.createAudioEngine(optionsBuffer ? ptr(optionsBuffer) : null);
17175
+ const engineHandle = this.opentui.symbols.createAudioEngine(optionsBuffer);
16846
17176
  return engineHandle ? engineHandle : null;
16847
17177
  }
16848
17178
  destroyAudioEngine(engine) {
@@ -16856,7 +17186,7 @@ class FFIRenderLib {
16856
17186
  }
16857
17187
  audioGetPlaybackDeviceName(engine, index) {
16858
17188
  const outBuffer = new Uint8Array(512);
16859
- const bytesWritten = toNumber(this.opentui.symbols.audioGetPlaybackDeviceName(engine, index, ptr(outBuffer), outBuffer.length));
17189
+ const bytesWritten = toNumber(this.opentui.symbols.audioGetPlaybackDeviceName(engine, index, outBuffer, outBuffer.length));
16860
17190
  const safeBytesWritten = Math.max(0, Math.min(outBuffer.length, bytesWritten));
16861
17191
  return this.decoder.decode(outBuffer.subarray(0, safeBytesWritten));
16862
17192
  }
@@ -16946,7 +17276,7 @@ class FFIRenderLib {
16946
17276
  } catch {
16947
17277
  return -1;
16948
17278
  }
16949
- return this.opentui.symbols.audioStart(engine, optionsBuffer ? ptr(optionsBuffer) : null);
17279
+ return this.opentui.symbols.audioStart(engine, optionsBuffer);
16950
17280
  }
16951
17281
  audioStartMixer(engine) {
16952
17282
  return this.opentui.symbols.audioStartMixer(engine);
@@ -17005,7 +17335,7 @@ class FFIRenderLib {
17005
17335
  audioLoad(engine, data) {
17006
17336
  const outBuffer = new ArrayBuffer(4);
17007
17337
  const dataLength = toSafeFFIU32Length(data.byteLength, "Audio data length");
17008
- const status = this.opentui.symbols.audioLoad(engine, ptr(data), dataLength, ptr(outBuffer));
17338
+ const status = this.opentui.symbols.audioLoad(engine, data, dataLength, outBuffer);
17009
17339
  if (status !== 0) {
17010
17340
  return { status, soundId: null };
17011
17341
  }
@@ -17020,7 +17350,7 @@ class FFIRenderLib {
17020
17350
  return { status: -1, voiceId: null };
17021
17351
  const outBuffer = new ArrayBuffer(4);
17022
17352
  const optionsBuffer = options ? AudioVoiceOptionsStruct.pack(options) : null;
17023
- const status = this.opentui.symbols.audioPlay(engine, soundId, optionsBuffer ? ptr(optionsBuffer) : null, ptr(outBuffer));
17353
+ const status = this.opentui.symbols.audioPlay(engine, soundId, optionsBuffer, outBuffer);
17024
17354
  if (status !== 0) {
17025
17355
  return { status, voiceId: null };
17026
17356
  }
@@ -17039,7 +17369,7 @@ class FFIRenderLib {
17039
17369
  const outBuffer = new ArrayBuffer(4);
17040
17370
  const nameBytes = this.encoder.encode(name);
17041
17371
  const nameLength = toSafeFFIU32Length(nameBytes.byteLength, "Audio group name length");
17042
- const status = this.opentui.symbols.audioCreateGroup(engine, ptr(nameBytes), nameLength, ptr(outBuffer));
17372
+ const status = this.opentui.symbols.audioCreateGroup(engine, nameBytes, nameLength, outBuffer);
17043
17373
  if (status !== 0) {
17044
17374
  return { status, groupId: null };
17045
17375
  }
@@ -17053,14 +17383,14 @@ class FFIRenderLib {
17053
17383
  return this.opentui.symbols.audioSetMasterVolume(engine, volume);
17054
17384
  }
17055
17385
  audioMixToBuffer(engine, outBuffer, frameCount, channels) {
17056
- return this.opentui.symbols.audioMixToBuffer(engine, ptr(outBuffer), frameCount, channels);
17386
+ return this.opentui.symbols.audioMixToBuffer(engine, outBuffer, frameCount, channels);
17057
17387
  }
17058
17388
  audioEnableTap(engine, enabled, capacityFrames) {
17059
17389
  return this.opentui.symbols.audioEnableTap(engine, ffiBool(enabled), capacityFrames);
17060
17390
  }
17061
17391
  audioReadTap(engine, outBuffer, frameCount, channels) {
17062
17392
  const outFramesReadBuffer = new ArrayBuffer(4);
17063
- const status = this.opentui.symbols.audioReadTap(engine, ptr(outBuffer), frameCount, channels, ptr(outFramesReadBuffer));
17393
+ const status = this.opentui.symbols.audioReadTap(engine, outBuffer, frameCount, channels, outFramesReadBuffer);
17064
17394
  if (status !== 0) {
17065
17395
  return { status, framesRead: 0 };
17066
17396
  }
@@ -17069,7 +17399,7 @@ class FFIRenderLib {
17069
17399
  }
17070
17400
  audioGetStats(engine) {
17071
17401
  const statsBuffer = new ArrayBuffer(AudioStatsStruct.size);
17072
- const status = this.opentui.symbols.audioGetStats(engine, ptr(statsBuffer));
17402
+ const status = this.opentui.symbols.audioGetStats(engine, statsBuffer);
17073
17403
  if (status !== 0) {
17074
17404
  return null;
17075
17405
  }
@@ -17094,7 +17424,7 @@ class FFIRenderLib {
17094
17424
  }
17095
17425
  createNativeSpanFeed(options) {
17096
17426
  const optionsBuffer = options == null ? null : NativeSpanFeedOptionsStruct.pack(options);
17097
- const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ? ptr(optionsBuffer) : null);
17427
+ const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer);
17098
17428
  if (!streamPtr) {
17099
17429
  throw new Error("Failed to create stream");
17100
17430
  }
@@ -17109,13 +17439,13 @@ class FFIRenderLib {
17109
17439
  }
17110
17440
  streamWrite(stream, data) {
17111
17441
  const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
17112
- return this.opentui.symbols.streamWrite(stream, ptrOrNull(bytes), bytes.byteLength);
17442
+ return this.opentui.symbols.streamWrite(stream, viewOrNull(bytes), bytes.byteLength);
17113
17443
  }
17114
17444
  streamCommit(stream) {
17115
17445
  return this.opentui.symbols.streamCommit(stream);
17116
17446
  }
17117
17447
  streamDrainSpans(stream, outBuffer, maxSpans) {
17118
- const count = this.opentui.symbols.streamDrainSpans(stream, ptr(outBuffer), maxSpans);
17448
+ const count = this.opentui.symbols.streamDrainSpans(stream, outBuffer, maxSpans);
17119
17449
  return toNumber(count);
17120
17450
  }
17121
17451
  streamClose(stream) {
@@ -17123,11 +17453,11 @@ class FFIRenderLib {
17123
17453
  }
17124
17454
  streamSetOptions(stream, options) {
17125
17455
  const optionsBuffer = NativeSpanFeedOptionsStruct.pack(options);
17126
- return this.opentui.symbols.streamSetOptions(stream, ptr(optionsBuffer));
17456
+ return this.opentui.symbols.streamSetOptions(stream, optionsBuffer);
17127
17457
  }
17128
17458
  streamGetStats(stream) {
17129
17459
  const statsBuffer = new ArrayBuffer(NativeSpanFeedStatsStruct.size);
17130
- const status = this.opentui.symbols.streamGetStats(stream, ptr(statsBuffer));
17460
+ const status = this.opentui.symbols.streamGetStats(stream, statsBuffer);
17131
17461
  if (status !== 0) {
17132
17462
  return null;
17133
17463
  }
@@ -17141,7 +17471,7 @@ class FFIRenderLib {
17141
17471
  }
17142
17472
  streamReserve(stream, minLen) {
17143
17473
  const reserveBuffer = new ArrayBuffer(ReserveInfoStruct.size);
17144
- const status = this.opentui.symbols.streamReserve(stream, minLen, ptr(reserveBuffer));
17474
+ const status = this.opentui.symbols.streamReserve(stream, minLen, reserveBuffer);
17145
17475
  if (status !== 0) {
17146
17476
  return { status, info: null };
17147
17477
  }
@@ -17162,13 +17492,13 @@ class FFIRenderLib {
17162
17492
  }
17163
17493
  syntaxStyleRegister(style, name, fg2, bg2, attributes) {
17164
17494
  const nameBytes = this.encoder.encode(name);
17165
- const fgPtr = optionalRgbaPtr(fg2);
17166
- const bgPtr = optionalRgbaPtr(bg2);
17167
- return this.opentui.symbols.syntaxStyleRegister(style, ptrOrNull(nameBytes), nameBytes.byteLength, fgPtr, bgPtr, attributes);
17495
+ const fgBuffer = optionalRgbaBuffer(fg2);
17496
+ const bgBuffer = optionalRgbaBuffer(bg2);
17497
+ return this.opentui.symbols.syntaxStyleRegister(style, viewOrNull(nameBytes), nameBytes.byteLength, fgBuffer, bgBuffer, attributes);
17168
17498
  }
17169
17499
  syntaxStyleResolveByName(style, name) {
17170
17500
  const nameBytes = this.encoder.encode(name);
17171
- const id = this.opentui.symbols.syntaxStyleResolveByName(style, ptrOrNull(nameBytes), nameBytes.byteLength);
17501
+ const id = this.opentui.symbols.syntaxStyleResolveByName(style, viewOrNull(nameBytes), nameBytes.byteLength);
17172
17502
  return id === 0 ? null : id;
17173
17503
  }
17174
17504
  syntaxStyleGetStyleCount(style) {
@@ -17266,7 +17596,7 @@ class FFIRenderLib {
17266
17596
  this.opentui.symbols.editorViewSetTabIndicator(view, indicator);
17267
17597
  }
17268
17598
  editorViewSetTabIndicatorColor(view, color) {
17269
- this.opentui.symbols.editorViewSetTabIndicatorColor(view, rgbaPtr(color));
17599
+ this.opentui.symbols.editorViewSetTabIndicatorColor(view, rgbaBuffer(color));
17270
17600
  }
17271
17601
  onNativeEvent(name, handler) {
17272
17602
  this._nativeEvents.on(name, handler);
@@ -18269,5 +18599,5 @@ var yoga_default = Yoga;
18269
18599
 
18270
18600
  export { toArrayBuffer, singleton, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, sleep, stringWidth2 as stringWidth, resolveBundledFilePath, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, getTreeSitterClient, destroyTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, createHostClipboard, createClipboard, ClipboardTarget, createRendererClipboardAdapter, Clipboard, detectLinks, OptimizedBuffer, TextBuffer, SpanInfoStruct, NativeAudioStreamFormat, NativeAudioStreamState, NativeAudioStreamStateNames, NativeAudioStreamCloseReason, NativeAudioStreamState2 as NativeAudioStreamState1, NativeAudioStreamCloseReason2 as NativeAudioStreamCloseReason1, NativeAudioStreamFormat2 as NativeAudioStreamFormat1, NativeClipboardOperationStatus, NativeClipboardStartStatus, NativeClipboardCancelStatus, NativeClipboardCopyStatus, NativeClipboardDestroyStatus, NativeClipboardShutdownStatus, LogLevel2 as LogLevel, NativeMeasureTargetKind, setRenderLibPath, resolveRenderLib, Align, BoxSizing, Dimension, Direction, Display, Edge, Errata, ExperimentalFeature, FlexDirection, Gutter, Justify, LogLevel as LogLevel1, MeasureMode, NodeType, Overflow, PositionType, Unit, Wrap, ALIGN_AUTO, ALIGN_FLEX_START, ALIGN_CENTER, ALIGN_FLEX_END, ALIGN_STRETCH, ALIGN_BASELINE, ALIGN_SPACE_BETWEEN, ALIGN_SPACE_AROUND, ALIGN_SPACE_EVENLY, BOX_SIZING_BORDER_BOX, BOX_SIZING_CONTENT_BOX, DIMENSION_WIDTH, DIMENSION_HEIGHT, DIRECTION_INHERIT, DIRECTION_LTR, DIRECTION_RTL, DISPLAY_FLEX, DISPLAY_NONE, DISPLAY_CONTENTS, EDGE_LEFT, EDGE_TOP, EDGE_RIGHT, EDGE_BOTTOM, EDGE_START, EDGE_END, EDGE_HORIZONTAL, EDGE_VERTICAL, EDGE_ALL, ERRATA_NONE, ERRATA_STRETCH_FLEX_BASIS, ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING, ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE, ERRATA_ALL, ERRATA_CLASSIC, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS, FLEX_DIRECTION_COLUMN, FLEX_DIRECTION_COLUMN_REVERSE, FLEX_DIRECTION_ROW, FLEX_DIRECTION_ROW_REVERSE, GUTTER_COLUMN, GUTTER_ROW, GUTTER_ALL, JUSTIFY_FLEX_START, JUSTIFY_CENTER, JUSTIFY_FLEX_END, JUSTIFY_SPACE_BETWEEN, JUSTIFY_SPACE_AROUND, JUSTIFY_SPACE_EVENLY, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_VERBOSE, LOG_LEVEL_FATAL, MEASURE_MODE_UNDEFINED, MEASURE_MODE_EXACTLY, MEASURE_MODE_AT_MOST, NODE_TYPE_DEFAULT, NODE_TYPE_TEXT, OVERFLOW_VISIBLE, OVERFLOW_HIDDEN, OVERFLOW_SCROLL, POSITION_TYPE_STATIC, POSITION_TYPE_RELATIVE, POSITION_TYPE_ABSOLUTE, UNIT_UNDEFINED, UNIT_POINT, UNIT_PERCENT, UNIT_AUTO, WRAP_NO_WRAP, WRAP_WRAP, WRAP_WRAP_REVERSE, Config, Node, exports_yoga, yoga_default };
18271
18601
 
18272
- //# debugId=8AC4CFB5CFC8941664756E2164756E21
18273
- //# sourceMappingURL=chunk-bun-1n307cze.js.map
18602
+ //# debugId=CCD1F52D948CB76B64756E2164756E21
18603
+ //# sourceMappingURL=chunk-bun-xmsp0nqq.js.map