@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.
@@ -620,7 +620,7 @@ function toNodeFFIType(type, position) {
620
620
  case FFIType.napi_value:
621
621
  throw new Error(NODE_NAPI_UNSUPPORTED);
622
622
  case FFIType.buffer:
623
- return "buffer";
623
+ return "pointer";
624
624
  default:
625
625
  return unsupportedNodeFFIType(type);
626
626
  }
@@ -6071,9 +6071,11 @@ class Selection {
6071
6071
  _isActive = true;
6072
6072
  _isDragging = true;
6073
6073
  _isStart = false;
6074
- constructor(anchorRenderable, anchor, focus) {
6074
+ behavior;
6075
+ constructor(anchorRenderable, anchor, focus, behavior = "cell") {
6075
6076
  this._anchor = new SelectionAnchor(anchorRenderable, anchor.x, anchor.y);
6076
6077
  this._focus = { ...focus };
6078
+ this.behavior = behavior;
6077
6079
  }
6078
6080
  get isStart() {
6079
6081
  return this._isStart;
@@ -6164,7 +6166,8 @@ function convertGlobalToLocalSelection(globalSelection, localX, localY) {
6164
6166
  anchorY: globalSelection.anchor.y - localY,
6165
6167
  focusX: globalSelection.focus.x - localX,
6166
6168
  focusY: globalSelection.focus.y - localY,
6167
- isActive: true
6169
+ isActive: true,
6170
+ behavior: globalSelection.behavior
6168
6171
  };
6169
6172
  }
6170
6173
 
@@ -6199,36 +6202,37 @@ class ASCIIFontSelectionHelper {
6199
6202
  }
6200
6203
  const text = this.getText();
6201
6204
  const font = this.getFont();
6202
- const selStart = { x: localSelection.anchorX, y: localSelection.anchorY };
6203
- const selEnd = { x: localSelection.focusX, y: localSelection.focusY };
6204
- if (height - 1 < selStart.y || 0 > selEnd.y) {
6205
+ const positions = getCharacterPositions(text, font);
6206
+ const minY = Math.min(localSelection.anchorY, localSelection.focusY);
6207
+ const maxY = Math.max(localSelection.anchorY, localSelection.focusY);
6208
+ if (maxY < 0 || minY > height - 1) {
6205
6209
  this.localSelection = null;
6206
6210
  return previousSelection !== null;
6207
6211
  }
6208
- let startCharIndex = 0;
6209
- let endCharIndex = text.length;
6210
- if (selStart.y > height - 1) {
6211
- this.localSelection = null;
6212
- return previousSelection !== null;
6213
- } else if (selStart.y >= 0 && selStart.y <= height - 1) {
6214
- if (selStart.x > 0) {
6215
- startCharIndex = coordinateToCharacterIndex(selStart.x, text, font);
6212
+ const indexAt = (x, y) => {
6213
+ if (y < 0)
6214
+ return 0;
6215
+ if (y > height - 1)
6216
+ return text.length;
6217
+ if (x < 0)
6218
+ return 0;
6219
+ if (x >= width)
6220
+ return text.length;
6221
+ for (let index = 1;index < positions.length; index += 1) {
6222
+ if (x < positions[index])
6223
+ return index - 1;
6216
6224
  }
6217
- }
6218
- if (selEnd.y < 0) {
6225
+ return text.length;
6226
+ };
6227
+ const anchorIndex = indexAt(localSelection.anchorX, localSelection.anchorY);
6228
+ const focusIndex = indexAt(localSelection.focusX, localSelection.focusY);
6229
+ const start = Math.min(anchorIndex, focusIndex);
6230
+ const end = Math.min(Math.max(anchorIndex, focusIndex) + 1, text.length);
6231
+ const samePoint = localSelection.anchorX === localSelection.focusX && localSelection.anchorY === localSelection.focusY;
6232
+ if (samePoint || start >= end) {
6219
6233
  this.localSelection = null;
6220
- return previousSelection !== null;
6221
- } else if (selEnd.y >= 0 && selEnd.y <= height - 1) {
6222
- if (selEnd.x >= 0) {
6223
- endCharIndex = coordinateToCharacterIndex(selEnd.x, text, font);
6224
- } else {
6225
- endCharIndex = 0;
6226
- }
6227
- }
6228
- if (startCharIndex < endCharIndex && startCharIndex >= 0 && endCharIndex <= text.length) {
6229
- this.localSelection = { start: startCharIndex, end: endCharIndex };
6230
6234
  } else {
6231
- this.localSelection = null;
6235
+ this.localSelection = { start, end };
6232
6236
  }
6233
6237
  return previousSelection?.start !== this.localSelection?.start || previousSelection?.end !== this.localSelection?.end;
6234
6238
  }
@@ -11416,7 +11420,7 @@ class OptimizedBuffer {
11416
11420
  if (matrix.length !== 16)
11417
11421
  throw new RangeError(`colorMatrix matrix must have length 16, got ${matrix.length}`);
11418
11422
  const cellMaskCount = Math.floor(cellMask.length / 3);
11419
- this.lib.bufferColorMatrix(this.bufferPtr, ptr(matrix), ptr(cellMask), cellMaskCount, strength, target);
11423
+ this.lib.bufferColorMatrix(this.bufferPtr, matrix, cellMask, cellMaskCount, strength, target);
11420
11424
  }
11421
11425
  colorMatrixUniform(matrix, strength = 1, target = 3 /* Both */) {
11422
11426
  this.guard();
@@ -11424,7 +11428,7 @@ class OptimizedBuffer {
11424
11428
  throw new RangeError(`colorMatrixUniform matrix must have length 16, got ${matrix.length}`);
11425
11429
  if (strength === 0)
11426
11430
  return;
11427
- this.lib.bufferColorMatrixUniform(this.bufferPtr, ptr(matrix), strength, target);
11431
+ this.lib.bufferColorMatrixUniform(this.bufferPtr, matrix, strength, target);
11428
11432
  }
11429
11433
  drawFrameBuffer(destX, destY, frameBuffer, sourceX, sourceY, sourceWidth, sourceHeight) {
11430
11434
  this.guard();
@@ -11445,9 +11449,9 @@ class OptimizedBuffer {
11445
11449
  this.guard();
11446
11450
  this.lib.bufferDrawEditorView(this.bufferPtr, editorView.ptr, x, y);
11447
11451
  }
11448
- drawSuperSampleBuffer(x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
11452
+ drawSuperSampleBuffer(x, y, pixelData, pixelDataLength, format, alignedBytesPerRow) {
11449
11453
  this.guard();
11450
- this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, toPointer(pixelDataPtr), pixelDataLength, format, alignedBytesPerRow);
11454
+ this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, typeof pixelData === "number" || typeof pixelData === "bigint" ? toPointer(pixelData) : pixelData, pixelDataLength, format, alignedBytesPerRow);
11451
11455
  }
11452
11456
  drawImage(image, x, y, width, height, pixelWidth = 0, pixelHeight = 0, sourceX = 0, sourceY = 0, sourceWidth = image.width, sourceHeight = image.height, protocol = "auto") {
11453
11457
  this.guard();
@@ -11466,17 +11470,17 @@ class OptimizedBuffer {
11466
11470
  }
11467
11471
  return this.lib.bufferDrawImage(this.bufferPtr, image.ptr, x, y, width, height, pixelWidth, pixelHeight, sourceX, sourceY, sourceWidth, sourceHeight, protocol);
11468
11472
  }
11469
- drawPackedBuffer(dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
11473
+ drawPackedBuffer(data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
11470
11474
  this.guard();
11471
- this.lib.bufferDrawPackedBuffer(this.bufferPtr, toPointer(dataPtr), dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
11475
+ this.lib.bufferDrawPackedBuffer(this.bufferPtr, typeof data === "number" || typeof data === "bigint" ? toPointer(data) : data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
11472
11476
  }
11473
11477
  drawGrayscaleBuffer(posX, posY, intensities, srcWidth, srcHeight, fg2 = null, bg2 = null) {
11474
11478
  this.guard();
11475
- this.lib.bufferDrawGrayscaleBuffer(this.bufferPtr, posX, posY, ptr(intensities), srcWidth, srcHeight, fg2, bg2);
11479
+ this.lib.bufferDrawGrayscaleBuffer(this.bufferPtr, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2);
11476
11480
  }
11477
11481
  drawGrayscaleBufferSupersampled(posX, posY, intensities, srcWidth, srcHeight, fg2 = null, bg2 = null) {
11478
11482
  this.guard();
11479
- this.lib.bufferDrawGrayscaleBufferSupersampled(this.bufferPtr, posX, posY, ptr(intensities), srcWidth, srcHeight, fg2, bg2);
11483
+ this.lib.bufferDrawGrayscaleBufferSupersampled(this.bufferPtr, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2);
11480
11484
  }
11481
11485
  resize(width, height) {
11482
11486
  this.guard();
@@ -13180,6 +13184,28 @@ var CursorStateStruct = defineStruct([
13180
13184
  ["b", "f32"],
13181
13185
  ["a", "f32"]
13182
13186
  ]);
13187
+ var EmbeddedTerminalCursorStruct = defineStruct([
13188
+ ["x", "u16"],
13189
+ ["y", "u16"],
13190
+ ["hasValue", "bool_u8"],
13191
+ ["visible", "bool_u8"],
13192
+ ["blinking", "bool_u8"],
13193
+ ["wideTail", "bool_u8"],
13194
+ ["style", "u8"],
13195
+ ["colorHasValue", "bool_u8"],
13196
+ ["colorR", "u8"],
13197
+ ["colorG", "u8"],
13198
+ ["colorB", "u8"],
13199
+ ["padding", "u8"]
13200
+ ]);
13201
+ var EmbeddedTerminalKeyOptionsStruct = defineStruct([
13202
+ ["action", "u8"],
13203
+ ["composing", "u8"],
13204
+ ["mods", "u16"],
13205
+ ["consumedMods", "u16"],
13206
+ ["padding", "u16"],
13207
+ ["unshiftedCodepoint", "u32"]
13208
+ ]);
13183
13209
  var CursorStyleOptionsStruct = defineStruct([
13184
13210
  ["style", "u8", { default: 255 }],
13185
13211
  ["blinking", "u8", { default: 255 }],
@@ -13496,14 +13522,56 @@ function toSafeFFIU32Length(value, label) {
13496
13522
  function isFFIU32(value) {
13497
13523
  return Number.isInteger(value) && value >= 0 && value <= MAX_FFI_U32;
13498
13524
  }
13499
- function ptrOrNull(value) {
13500
- return value.byteLength === 0 ? null : ptr(value);
13525
+ function viewOrNull(value) {
13526
+ return value.byteLength === 0 ? null : value;
13501
13527
  }
13502
- function rgbaPtr(value) {
13503
- return ptr(value.buffer);
13528
+ function retainedPtrOrNull(value) {
13529
+ if (value.byteLength === 0)
13530
+ return null;
13531
+ value.buffer;
13532
+ return ptr(value);
13533
+ }
13534
+ var EMBEDDED_TERMINAL_ERRORS = {
13535
+ [-1]: "invalid value or handle",
13536
+ [-2]: "out of memory",
13537
+ [-3]: "embedded terminal support is unavailable",
13538
+ [-4]: "output buffer is too small",
13539
+ [-5]: "processing failed"
13540
+ };
13541
+ function embeddedTerminalResult(status, operation) {
13542
+ if (status >= 0)
13543
+ return status;
13544
+ throw new Error(`Embedded terminal ${operation} failed: ${EMBEDDED_TERMINAL_ERRORS[status] ?? `status ${status}`}`);
13545
+ }
13546
+ function embeddedTerminalDimension(value, name) {
13547
+ if (!Number.isInteger(value) || value < 1 || value > 65535) {
13548
+ throw new RangeError(`Embedded terminal ${name} must be an integer between 1 and 65535`);
13549
+ }
13550
+ return value;
13504
13551
  }
13505
- function optionalRgbaPtr(value) {
13506
- return value ? rgbaPtr(value) : null;
13552
+ function embeddedTerminalI32(value, name) {
13553
+ if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) {
13554
+ throw new RangeError(`Embedded terminal ${name} must be a signed 32-bit integer`);
13555
+ }
13556
+ return value;
13557
+ }
13558
+ function embeddedTerminalF32(value, name) {
13559
+ if (!Number.isFinite(value) || Math.abs(value) > 340282346638528860000000000000000000000) {
13560
+ throw new RangeError(`Embedded terminal ${name} must be a finite 32-bit float`);
13561
+ }
13562
+ return value;
13563
+ }
13564
+ function rgbaBuffer(value) {
13565
+ return value.buffer;
13566
+ }
13567
+ function optionalRgbaBuffer(value) {
13568
+ return value ? rgbaBuffer(value) : null;
13569
+ }
13570
+ function selectionBehaviorByte(behavior) {
13571
+ return behavior === "word" ? 1 : behavior === "line" ? 2 : 0;
13572
+ }
13573
+ function editorLocalSelectionFlags(updateCursor, followCursor, behavior) {
13574
+ return ffiBool(updateCursor) | ffiBool(followCursor) << 1 | selectionBehaviorByte(behavior) << 2;
13507
13575
  }
13508
13576
  function getOpenTUILib(libPath) {
13509
13577
  const resolvedLibPath = libPath || targetLibPath;
@@ -13539,6 +13607,70 @@ function getOpenTUILib(libPath) {
13539
13607
  args: ["u32", "u32", "u32"],
13540
13608
  returns: "bool"
13541
13609
  },
13610
+ createEmbeddedTerminal: {
13611
+ args: ["u16", "u16", "u32", "ptr"],
13612
+ returns: "i32"
13613
+ },
13614
+ destroyEmbeddedTerminal: {
13615
+ args: ["u32"],
13616
+ returns: "void"
13617
+ },
13618
+ embeddedTerminalWrite: {
13619
+ args: ["u32", "ptr", "u32"],
13620
+ returns: "i32"
13621
+ },
13622
+ embeddedTerminalResize: {
13623
+ args: ["u32", "u16", "u16"],
13624
+ returns: "i32"
13625
+ },
13626
+ embeddedTerminalInvalidate: {
13627
+ args: ["u32"],
13628
+ returns: "i32"
13629
+ },
13630
+ embeddedTerminalScroll: {
13631
+ args: ["u32", "i32"],
13632
+ returns: "i32"
13633
+ },
13634
+ embeddedTerminalSetSelection: {
13635
+ args: ["u32", "u16", "u16", "u16", "u16"],
13636
+ returns: "i32"
13637
+ },
13638
+ embeddedTerminalClearSelection: {
13639
+ args: ["u32"],
13640
+ returns: "i32"
13641
+ },
13642
+ embeddedTerminalGetSelectedText: {
13643
+ args: ["u32", "buffer", "u32", "buffer"],
13644
+ returns: "i32"
13645
+ },
13646
+ embeddedTerminalCompose: {
13647
+ args: ["u32", "u32", "i32", "i32"],
13648
+ returns: "i32"
13649
+ },
13650
+ embeddedTerminalCursor: {
13651
+ args: ["u32", "ptr"],
13652
+ returns: "i32"
13653
+ },
13654
+ embeddedTerminalEncodeKey: {
13655
+ args: ["u32", "ptr", "ptr", "u32", "ptr", "u32", "ptr", "u32", "ptr"],
13656
+ returns: "i32"
13657
+ },
13658
+ embeddedTerminalEncodeMouse: {
13659
+ args: ["u32", "u8", "i8", "u16", "f32", "f32", "u8", "ptr", "u32"],
13660
+ returns: "i32"
13661
+ },
13662
+ embeddedTerminalEncodePaste: {
13663
+ args: ["u32", "ptr", "u32", "ptr", "u32"],
13664
+ returns: "i32"
13665
+ },
13666
+ embeddedTerminalEncodeFocus: {
13667
+ args: ["u32", "u8", "ptr", "u32"],
13668
+ returns: "i32"
13669
+ },
13670
+ embeddedTerminalDrainResponses: {
13671
+ args: ["u32", "ptr", "u32"],
13672
+ returns: "i32"
13673
+ },
13542
13674
  createRenderer: {
13543
13675
  args: ["u32", "u32", "u8", "u8", "ptr"],
13544
13676
  returns: "u32"
@@ -13560,7 +13692,7 @@ function getOpenTUILib(libPath) {
13560
13692
  returns: "void"
13561
13693
  },
13562
13694
  setBackgroundColor: {
13563
- args: ["u32", "ptr"],
13695
+ args: ["u32", "buffer"],
13564
13696
  returns: "void"
13565
13697
  },
13566
13698
  setRenderOffset: {
@@ -13608,7 +13740,7 @@ function getOpenTUILib(libPath) {
13608
13740
  returns: "u64"
13609
13741
  },
13610
13742
  commitSplitFooterSnapshot: {
13611
- args: ["u32", "u32", "u32", "bool", "bool", "u32", "bool", "bool", "bool"],
13743
+ args: ["u32", "u32", "u32", "u8", "u32"],
13612
13744
  returns: "u64"
13613
13745
  },
13614
13746
  getNextBuffer: {
@@ -13620,7 +13752,7 @@ function getOpenTUILib(libPath) {
13620
13752
  returns: "u32"
13621
13753
  },
13622
13754
  rendererSetPaletteState: {
13623
- args: ["u32", "ptr", "u32", "ptr", "ptr", "u32"],
13755
+ args: ["u32", "buffer", "u32", "buffer", "buffer", "u32"],
13624
13756
  returns: "void"
13625
13757
  },
13626
13758
  queryPixelResolution: {
@@ -13632,7 +13764,7 @@ function getOpenTUILib(libPath) {
13632
13764
  returns: "void"
13633
13765
  },
13634
13766
  createOptimizedBuffer: {
13635
- args: ["u32", "u32", "bool", "u8", "ptr", "u32"],
13767
+ args: ["u32", "u32", "u8", "u8", "buffer", "u32"],
13636
13768
  returns: "u32"
13637
13769
  },
13638
13770
  destroyOptimizedBuffer: {
@@ -13652,7 +13784,7 @@ function getOpenTUILib(libPath) {
13652
13784
  returns: "u32"
13653
13785
  },
13654
13786
  bufferClear: {
13655
- args: ["u32", "ptr"],
13787
+ args: ["u32", "buffer"],
13656
13788
  returns: "void"
13657
13789
  },
13658
13790
  bufferGetCharPtr: {
@@ -13680,7 +13812,7 @@ function getOpenTUILib(libPath) {
13680
13812
  returns: "void"
13681
13813
  },
13682
13814
  bufferGetId: {
13683
- args: ["u32", "ptr", "u32"],
13815
+ args: ["u32", "buffer", "u32"],
13684
13816
  returns: "u32"
13685
13817
  },
13686
13818
  bufferGetRealCharSize: {
@@ -13692,19 +13824,19 @@ function getOpenTUILib(libPath) {
13692
13824
  returns: "u32"
13693
13825
  },
13694
13826
  bufferDrawText: {
13695
- args: ["u32", "ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
13827
+ args: ["u32", "ptr", "u32", "u32", "u32", "buffer", "ptr", "u32"],
13696
13828
  returns: "void"
13697
13829
  },
13698
13830
  bufferSetCellWithAlphaBlending: {
13699
- args: ["u32", "u32", "u32", "u32", "ptr", "ptr", "u32"],
13831
+ args: ["u32", "u32", "u32", "u32", "buffer", "buffer", "u32"],
13700
13832
  returns: "void"
13701
13833
  },
13702
13834
  bufferSetCell: {
13703
- args: ["u32", "u32", "u32", "u32", "ptr", "ptr", "u32"],
13835
+ args: ["u32", "u32", "u32", "u32", "buffer", "buffer", "u32"],
13704
13836
  returns: "void"
13705
13837
  },
13706
13838
  bufferFillRect: {
13707
- args: ["u32", "u32", "u32", "u32", "u32", "ptr"],
13839
+ args: ["u32", "u32", "u32", "u32", "u32", "buffer"],
13708
13840
  returns: "void"
13709
13841
  },
13710
13842
  bufferColorMatrix: {
@@ -13744,7 +13876,7 @@ function getOpenTUILib(libPath) {
13744
13876
  returns: "void"
13745
13877
  },
13746
13878
  setCursorColor: {
13747
- args: ["u32", "ptr"],
13879
+ args: ["u32", "buffer"],
13748
13880
  returns: "void"
13749
13881
  },
13750
13882
  getCursorState: {
@@ -13756,7 +13888,7 @@ function getOpenTUILib(libPath) {
13756
13888
  returns: "void"
13757
13889
  },
13758
13890
  setDebugOverlay: {
13759
- args: ["u32", "bool", "u8"],
13891
+ args: ["u32", "u8", "u8"],
13760
13892
  returns: "void"
13761
13893
  },
13762
13894
  clearTerminal: {
@@ -13872,11 +14004,26 @@ function getOpenTUILib(libPath) {
13872
14004
  returns: "void"
13873
14005
  },
13874
14006
  bufferDrawGrid: {
13875
- args: ["u32", "ptr", "ptr", "ptr", "ptr", "u32", "ptr", "u32", "ptr"],
14007
+ args: ["u32", "buffer", "buffer", "buffer", "buffer", "u32", "buffer", "u32", "ptr"],
13876
14008
  returns: "void"
13877
14009
  },
13878
14010
  bufferDrawBox: {
13879
- args: ["u32", "i32", "i32", "u32", "u32", "ptr", "u32", "ptr", "ptr", "ptr", "ptr", "u32", "ptr", "u32"],
14011
+ args: [
14012
+ "u32",
14013
+ "i32",
14014
+ "i32",
14015
+ "u32",
14016
+ "u32",
14017
+ "buffer",
14018
+ "u32",
14019
+ "buffer",
14020
+ "buffer",
14021
+ "buffer",
14022
+ "ptr",
14023
+ "u32",
14024
+ "ptr",
14025
+ "u32"
14026
+ ],
13880
14027
  returns: "void"
13881
14028
  },
13882
14029
  bufferPushScissorRect: {
@@ -14148,7 +14295,7 @@ function getOpenTUILib(libPath) {
14148
14295
  returns: "u64"
14149
14296
  },
14150
14297
  textBufferViewSetLocalSelection: {
14151
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr"],
14298
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14152
14299
  returns: "bool"
14153
14300
  },
14154
14301
  textBufferViewUpdateSelection: {
@@ -14156,13 +14303,21 @@ function getOpenTUILib(libPath) {
14156
14303
  returns: "void"
14157
14304
  },
14158
14305
  textBufferViewUpdateLocalSelection: {
14159
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr"],
14306
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14160
14307
  returns: "bool"
14161
14308
  },
14162
14309
  textBufferViewResetLocalSelection: {
14163
14310
  args: ["u32"],
14164
14311
  returns: "void"
14165
14312
  },
14313
+ textBufferViewSetSelectionOccupancy: {
14314
+ args: ["u32", "u8"],
14315
+ returns: "void"
14316
+ },
14317
+ textBufferViewGetSelectionOccupancy: {
14318
+ args: ["u32"],
14319
+ returns: "u8"
14320
+ },
14166
14321
  textBufferViewSetWrapWidth: {
14167
14322
  args: ["u32", "u32"],
14168
14323
  returns: "void"
@@ -14208,7 +14363,7 @@ function getOpenTUILib(libPath) {
14208
14363
  returns: "void"
14209
14364
  },
14210
14365
  textBufferViewSetTabIndicatorColor: {
14211
- args: ["u32", "ptr"],
14366
+ args: ["u32", "buffer"],
14212
14367
  returns: "void"
14213
14368
  },
14214
14369
  textBufferViewSetTruncate: {
@@ -14244,7 +14399,7 @@ function getOpenTUILib(libPath) {
14244
14399
  returns: "void"
14245
14400
  },
14246
14401
  editorViewGetViewport: {
14247
- args: ["u32", "ptr", "ptr", "ptr", "ptr"],
14402
+ args: ["u32", "buffer", "buffer", "buffer", "buffer"],
14248
14403
  returns: "void"
14249
14404
  },
14250
14405
  editorViewSetScrollMargin: {
@@ -14448,7 +14603,7 @@ function getOpenTUILib(libPath) {
14448
14603
  returns: "u64"
14449
14604
  },
14450
14605
  editorViewSetLocalSelection: {
14451
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "bool", "bool"],
14606
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14452
14607
  returns: "bool"
14453
14608
  },
14454
14609
  editorViewUpdateSelection: {
@@ -14456,19 +14611,35 @@ function getOpenTUILib(libPath) {
14456
14611
  returns: "void"
14457
14612
  },
14458
14613
  editorViewUpdateLocalSelection: {
14459
- args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "bool", "bool"],
14614
+ args: ["u32", "i32", "i32", "i32", "i32", "ptr", "ptr", "u8"],
14460
14615
  returns: "bool"
14461
14616
  },
14462
14617
  editorViewResetLocalSelection: {
14463
14618
  args: ["u32"],
14464
14619
  returns: "void"
14465
14620
  },
14621
+ editorViewConvertSelectionToCell: {
14622
+ args: ["u32"],
14623
+ returns: "bool"
14624
+ },
14625
+ editorViewSetSelectionOccupancy: {
14626
+ args: ["u32", "u8"],
14627
+ returns: "void"
14628
+ },
14629
+ editorViewSetSelectionInclusive: {
14630
+ args: ["u32", "u32", "u32", "ptr", "ptr"],
14631
+ returns: "void"
14632
+ },
14633
+ editorViewSetSelectionColors: {
14634
+ args: ["u32", "ptr", "ptr"],
14635
+ returns: "void"
14636
+ },
14466
14637
  editorViewGetSelectedTextBytes: {
14467
14638
  args: ["u32", "ptr", "u32"],
14468
14639
  returns: "u32"
14469
14640
  },
14470
14641
  editorViewGetCursor: {
14471
- args: ["u32", "ptr", "ptr"],
14642
+ args: ["u32", "buffer", "buffer"],
14472
14643
  returns: "void"
14473
14644
  },
14474
14645
  editorViewGetText: {
@@ -14515,6 +14686,10 @@ function getOpenTUILib(libPath) {
14515
14686
  args: ["u32", "ptr"],
14516
14687
  returns: "void"
14517
14688
  },
14689
+ editorViewGotoVisualLineEnd: {
14690
+ args: ["u32"],
14691
+ returns: "void"
14692
+ },
14518
14693
  editorViewSetPlaceholderStyledText: {
14519
14694
  args: ["u32", "ptr", "u32"],
14520
14695
  returns: "void"
@@ -14524,7 +14699,7 @@ function getOpenTUILib(libPath) {
14524
14699
  returns: "void"
14525
14700
  },
14526
14701
  editorViewSetTabIndicatorColor: {
14527
- args: ["u32", "ptr"],
14702
+ args: ["u32", "buffer"],
14528
14703
  returns: "void"
14529
14704
  },
14530
14705
  getArenaAllocatedBytes: {
@@ -14563,21 +14738,21 @@ function getOpenTUILib(libPath) {
14563
14738
  imageRetainIccCache: { args: [], returns: "void" },
14564
14739
  imageReleaseIccCache: { args: [], returns: "void" },
14565
14740
  imageTestFailIccProfileCopyAllocationOnce: { args: [], returns: "void" },
14566
- imageDecode: { args: ["ptr", "u32", "ptr"], returns: "u32" },
14567
- imageCreateFromRgba: { args: ["ptr", "u64", "u32", "u32", "u32", "ptr"], returns: "u32" },
14741
+ imageDecode: { args: ["ptr", "u32", "buffer"], returns: "u32" },
14742
+ imageCreateFromRgba: { args: ["ptr", "u64", "u32", "u32", "u32", "buffer"], returns: "u32" },
14568
14743
  imageDestroy: { args: ["u32"], returns: "void" },
14569
- imageRetain: { args: ["u32", "ptr"], returns: "u32" },
14744
+ imageRetain: { args: ["u32", "buffer"], returns: "u32" },
14570
14745
  imageGetInfo: { args: ["u32", "ptr"], returns: "u32" },
14571
14746
  imageMaterialize: { args: ["u32"], returns: "u32" },
14572
14747
  imageEnsureEncodedPng: { args: ["u32"], returns: "u32" },
14573
14748
  imageGetPixelsPtr: { args: ["u32"], returns: "ptr" },
14574
- imageClone: { args: ["u32", "ptr"], returns: "u32" },
14749
+ imageClone: { args: ["u32", "buffer"], returns: "u32" },
14575
14750
  imageCopyPixels: { args: ["u32", "ptr", "u64", "u32", "u8"], returns: "u32" },
14576
- imageResize: { args: ["u32", "u32", "u32", "u32", "ptr"], returns: "u32" },
14577
- imageExtract: { args: ["u32", "u32", "u32", "u32", "u32", "ptr"], returns: "u32" },
14578
- imageExtend: { args: ["u32", "u32", "u32", "u32", "u32", "ptr", "ptr"], returns: "u32" },
14579
- imageTransform: { args: ["u32", "u32", "ptr"], returns: "u32" },
14580
- imageComposite: { args: ["u32", "u32", "i32", "i32", "u32", "u8", "ptr"], returns: "u32" },
14751
+ imageResize: { args: ["u32", "u32", "u32", "u32", "buffer"], returns: "u32" },
14752
+ imageExtract: { args: ["u32", "u32", "u32", "u32", "u32", "buffer"], returns: "u32" },
14753
+ imageExtend: { args: ["u32", "u32", "u32", "u32", "u32", "buffer", "buffer"], returns: "u32" },
14754
+ imageTransform: { args: ["u32", "u32", "buffer"], returns: "u32" },
14755
+ imageComposite: { args: ["u32", "u32", "i32", "i32", "u32", "u8", "buffer"], returns: "u32" },
14581
14756
  getTerminalCapabilities: {
14582
14757
  args: ["u32", "ptr"],
14583
14758
  returns: "void"
@@ -14595,7 +14770,7 @@ function getOpenTUILib(libPath) {
14595
14770
  returns: "void"
14596
14771
  },
14597
14772
  bufferDrawChar: {
14598
- args: ["u32", "u32", "u32", "u32", "ptr", "ptr", "u32"],
14773
+ args: ["u32", "u32", "u32", "u32", "buffer", "buffer", "u32"],
14599
14774
  returns: "void"
14600
14775
  },
14601
14776
  yogaConfigCreate: {
@@ -14815,7 +14990,7 @@ function getOpenTUILib(libPath) {
14815
14990
  returns: "u32"
14816
14991
  },
14817
14992
  audioGetPlaybackDeviceName: {
14818
- args: ["u32", "u32", "ptr", "u32"],
14993
+ args: ["u32", "u32", "buffer", "u32"],
14819
14994
  returns: "u32"
14820
14995
  },
14821
14996
  audioIsPlaybackDeviceDefault: {
@@ -14839,7 +15014,7 @@ function getOpenTUILib(libPath) {
14839
15014
  returns: "u32"
14840
15015
  },
14841
15016
  audioGetCaptureDeviceName: {
14842
- args: ["u32", "u32", "ptr", "u32"],
15017
+ args: ["u32", "u32", "buffer", "u32"],
14843
15018
  returns: "u32"
14844
15019
  },
14845
15020
  audioIsCaptureDeviceDefault: {
@@ -14867,7 +15042,7 @@ function getOpenTUILib(libPath) {
14867
15042
  returns: "bool"
14868
15043
  },
14869
15044
  audioReadCapture: {
14870
- args: ["u32", "ptr", "u32", "u32", "ptr"],
15045
+ args: ["u32", "buffer", "u32", "u32", "ptr"],
14871
15046
  returns: "i32"
14872
15047
  },
14873
15048
  audioGetCaptureStats: {
@@ -14923,7 +15098,7 @@ function getOpenTUILib(libPath) {
14923
15098
  returns: "i32"
14924
15099
  },
14925
15100
  audioLoad: {
14926
- args: ["u32", "ptr", "u32", "ptr"],
15101
+ args: ["u32", "buffer", "u32", "ptr"],
14927
15102
  returns: "i32"
14928
15103
  },
14929
15104
  audioUnload: {
@@ -14943,7 +15118,7 @@ function getOpenTUILib(libPath) {
14943
15118
  returns: "i32"
14944
15119
  },
14945
15120
  audioCreateGroup: {
14946
- args: ["u32", "ptr", "u32", "ptr"],
15121
+ args: ["u32", "buffer", "u32", "ptr"],
14947
15122
  returns: "i32"
14948
15123
  },
14949
15124
  audioSetGroupVolume: {
@@ -14955,15 +15130,15 @@ function getOpenTUILib(libPath) {
14955
15130
  returns: "i32"
14956
15131
  },
14957
15132
  audioMixToBuffer: {
14958
- args: ["u32", "ptr", "u32", "u8"],
15133
+ args: ["u32", "buffer", "u32", "u8"],
14959
15134
  returns: "i32"
14960
15135
  },
14961
15136
  audioEnableTap: {
14962
- args: ["u32", "bool", "u32"],
15137
+ args: ["u32", "u8", "u32"],
14963
15138
  returns: "i32"
14964
15139
  },
14965
15140
  audioReadTap: {
14966
- args: ["u32", "ptr", "u32", "u8", "ptr"],
15141
+ args: ["u32", "buffer", "u32", "u8", "ptr"],
14967
15142
  returns: "i32"
14968
15143
  },
14969
15144
  audioGetStats: {
@@ -14991,7 +15166,7 @@ function getOpenTUILib(libPath) {
14991
15166
  returns: "i32"
14992
15167
  },
14993
15168
  streamDrainSpans: {
14994
- args: ["ptr", "ptr", "u32"],
15169
+ args: ["ptr", "buffer", "u32"],
14995
15170
  returns: "u32"
14996
15171
  },
14997
15172
  streamClose: {
@@ -15178,7 +15353,6 @@ class FFIRenderLib {
15178
15353
  opentui;
15179
15354
  iccCacheClient = false;
15180
15355
  yogaLayout = new Float32Array(6);
15181
- yogaLayoutPtr = ptr(this.yogaLayout);
15182
15356
  ffiStructStorage = {
15183
15357
  logicalCursor: {
15184
15358
  ...allocStruct(LogicalCursorStruct),
@@ -15198,6 +15372,8 @@ class FFIRenderLib {
15198
15372
  ...allocStruct(MeasureResultStruct),
15199
15373
  result: { lineCount: 0, widthColsMax: 0 }
15200
15374
  },
15375
+ embeddedTerminalCursor: allocStruct(EmbeddedTerminalCursorStruct),
15376
+ embeddedTerminalKeyOptions: allocStruct(EmbeddedTerminalKeyOptionsStruct),
15201
15377
  audioStreamStats: {
15202
15378
  ...allocStruct(AudioStreamStatsStruct),
15203
15379
  result: {
@@ -15243,6 +15419,134 @@ class FFIRenderLib {
15243
15419
  nativeRenderableSetMeasureTarget(handle, kind, target) {
15244
15420
  return Boolean(this.opentui.symbols.nativeRenderableSetMeasureTarget(handle, kind, target));
15245
15421
  }
15422
+ createEmbeddedTerminal(options) {
15423
+ const cols = embeddedTerminalDimension(options.cols, "columns");
15424
+ const rows = embeddedTerminalDimension(options.rows, "rows");
15425
+ const maxScrollback = toSafeFFIU32Length(options.maxScrollback ?? 1e4, "Embedded terminal maxScrollback");
15426
+ const out = new Uint32Array(1);
15427
+ embeddedTerminalResult(this.opentui.symbols.createEmbeddedTerminal(cols, rows, maxScrollback, out), "creation");
15428
+ if (!out[0])
15429
+ throw new Error("Embedded terminal creation returned an invalid handle");
15430
+ return out[0];
15431
+ }
15432
+ destroyEmbeddedTerminal(handle) {
15433
+ this.opentui.symbols.destroyEmbeddedTerminal(handle);
15434
+ }
15435
+ embeddedTerminalWrite(handle, data) {
15436
+ const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
15437
+ const length = toSafeFFIU32Length(bytes.byteLength, "Embedded terminal write length");
15438
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalWrite(handle, length === 0 ? null : bytes, length), "write");
15439
+ }
15440
+ embeddedTerminalResize(handle, cols, rows) {
15441
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalResize(handle, embeddedTerminalDimension(cols, "columns"), embeddedTerminalDimension(rows, "rows")), "resize");
15442
+ }
15443
+ embeddedTerminalInvalidate(handle) {
15444
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalInvalidate(handle), "invalidation");
15445
+ }
15446
+ embeddedTerminalScroll(handle, delta) {
15447
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalScroll(handle, embeddedTerminalI32(delta, "scroll delta")), "scroll");
15448
+ }
15449
+ embeddedTerminalSetSelection(handle, start, end) {
15450
+ 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");
15451
+ }
15452
+ embeddedTerminalClearSelection(handle) {
15453
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalClearSelection(handle), "selection clear");
15454
+ }
15455
+ embeddedTerminalGetSelectedText(handle) {
15456
+ const required = new Uint32Array(1);
15457
+ const read = (output2) => this.opentui.symbols.embeddedTerminalGetSelectedText(handle, viewOrNull(output2), output2.byteLength, required);
15458
+ const initial = new Uint8Array(256);
15459
+ const status = read(initial);
15460
+ if (status >= 0)
15461
+ return initial.slice(0, status);
15462
+ if (status !== -4 || required[0] <= initial.byteLength)
15463
+ embeddedTerminalResult(status, "selection query");
15464
+ const output = new Uint8Array(required[0]);
15465
+ const length = embeddedTerminalResult(read(output), "selection query");
15466
+ return output.slice(0, length);
15467
+ }
15468
+ embeddedTerminalCompose(handle, target, x, y) {
15469
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalCompose(handle, target, embeddedTerminalI32(x, "composition x"), embeddedTerminalI32(y, "composition y")), "compose");
15470
+ }
15471
+ embeddedTerminalCursor(handle) {
15472
+ const storage = this.ffiStructStorage.embeddedTerminalCursor;
15473
+ embeddedTerminalResult(this.opentui.symbols.embeddedTerminalCursor(handle, storage.buffer), "cursor query");
15474
+ const result = EmbeddedTerminalCursorStruct.unpack(storage.buffer);
15475
+ return {
15476
+ x: result.x,
15477
+ y: result.y,
15478
+ hasValue: result.hasValue,
15479
+ visible: result.visible,
15480
+ blinking: result.blinking,
15481
+ wideTail: result.wideTail,
15482
+ style: ["bar", "block", "underline", "block-hollow"][result.style] ?? "block",
15483
+ ...result.colorHasValue ? { color: { r: result.colorR, g: result.colorG, b: result.colorB } } : {}
15484
+ };
15485
+ }
15486
+ embeddedTerminalEncodeKey(handle, key) {
15487
+ const options = this.ffiStructStorage.embeddedTerminalKeyOptions;
15488
+ EmbeddedTerminalKeyOptionsStruct.packInto({
15489
+ action: { release: 0, press: 1, repeat: 2 }[key.action ?? "press"],
15490
+ composing: key.composing ? 1 : 0,
15491
+ mods: key.mods ?? 0,
15492
+ consumedMods: key.consumedMods ?? 0,
15493
+ padding: 0,
15494
+ unshiftedCodepoint: key.unshiftedCodepoint ?? 0
15495
+ }, options.view, 0);
15496
+ const keyCode = key.key ? this.encoder.encode(key.key) : new Uint8Array;
15497
+ const keyCodeLength = toSafeFFIU32Length(keyCode.byteLength, "Embedded terminal physical key length");
15498
+ const text = key.text ? this.encoder.encode(key.text) : new Uint8Array;
15499
+ const textLength = toSafeFFIU32Length(text.byteLength, "Embedded terminal key text length");
15500
+ const required = new Uint32Array(1);
15501
+ const encode = (output2) => this.opentui.symbols.embeddedTerminalEncodeKey(handle, options.buffer, keyCodeLength === 0 ? null : keyCode, keyCodeLength, textLength === 0 ? null : text, textLength, output2, output2.byteLength, required);
15502
+ const initial = new Uint8Array(Math.max(64, textLength));
15503
+ const status = encode(initial);
15504
+ if (status >= 0)
15505
+ return initial.slice(0, status);
15506
+ if (status !== -4 || required[0] <= initial.byteLength)
15507
+ embeddedTerminalResult(status, "key encoding");
15508
+ const output = new Uint8Array(required[0]);
15509
+ const length = embeddedTerminalResult(encode(output), "key encoding");
15510
+ return output.slice(0, length);
15511
+ }
15512
+ embeddedTerminalEncodeMouse(handle, mouse) {
15513
+ const output = new Uint8Array(128);
15514
+ 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");
15515
+ return output.slice(0, length);
15516
+ }
15517
+ embeddedTerminalEncodePaste(handle, input) {
15518
+ const inputLength = toSafeFFIU32Length(input.byteLength, "Embedded terminal paste length");
15519
+ const outputLength = toSafeFFIU32Length(inputLength + 16, "Embedded terminal paste output length");
15520
+ const output = new Uint8Array(outputLength);
15521
+ const length = embeddedTerminalResult(this.opentui.symbols.embeddedTerminalEncodePaste(handle, inputLength === 0 ? null : input, inputLength, output, output.byteLength), "paste encoding");
15522
+ return output.slice(0, length);
15523
+ }
15524
+ embeddedTerminalEncodeFocus(handle, focused) {
15525
+ const output = new Uint8Array(16);
15526
+ const length = embeddedTerminalResult(this.opentui.symbols.embeddedTerminalEncodeFocus(handle, focused ? 1 : 0, output, output.byteLength), "focus encoding");
15527
+ return output.slice(0, length);
15528
+ }
15529
+ embeddedTerminalDrainResponses(handle) {
15530
+ const chunks = [];
15531
+ while (true) {
15532
+ const output = new Uint8Array(64 * 1024);
15533
+ const status = this.opentui.symbols.embeddedTerminalDrainResponses(handle, output, output.byteLength);
15534
+ if (status === -4)
15535
+ continue;
15536
+ const length = embeddedTerminalResult(status, "response drain");
15537
+ if (length > 0)
15538
+ chunks.push(output.slice(0, length));
15539
+ if (length < output.byteLength)
15540
+ break;
15541
+ }
15542
+ const result = new Uint8Array(chunks.reduce((total, chunk) => total + chunk.byteLength, 0));
15543
+ let offset = 0;
15544
+ for (const chunk of chunks) {
15545
+ result.set(chunk, offset);
15546
+ offset += chunk.byteLength;
15547
+ }
15548
+ return result;
15549
+ }
15246
15550
  constructor(libPath) {
15247
15551
  this.opentui = getOpenTUILib(libPath);
15248
15552
  this.imageRetainIccCache();
@@ -15396,7 +15700,7 @@ class FFIRenderLib {
15396
15700
  setTerminalEnvVar(renderer, key, value) {
15397
15701
  const keyBytes = this.encoder.encode(key);
15398
15702
  const valueBytes = this.encoder.encode(value);
15399
- return this.opentui.symbols.setTerminalEnvVar(renderer, ptrOrNull(keyBytes), keyBytes.byteLength, ptrOrNull(valueBytes), valueBytes.byteLength);
15703
+ return this.opentui.symbols.setTerminalEnvVar(renderer, viewOrNull(keyBytes), keyBytes.byteLength, viewOrNull(valueBytes), valueBytes.byteLength);
15400
15704
  }
15401
15705
  destroyRenderer(renderer, flushInput = false) {
15402
15706
  this.opentui.symbols.destroyRenderer(renderer, ffiBool(flushInput));
@@ -15408,7 +15712,7 @@ class FFIRenderLib {
15408
15712
  this.opentui.symbols.setClearOnShutdown(renderer, ffiBool(clear));
15409
15713
  }
15410
15714
  setBackgroundColor(renderer, color) {
15411
- this.opentui.symbols.setBackgroundColor(renderer, rgbaPtr(color));
15715
+ this.opentui.symbols.setBackgroundColor(renderer, rgbaBuffer(color));
15412
15716
  }
15413
15717
  setRenderOffset(renderer, offset) {
15414
15718
  this.opentui.symbols.setRenderOffset(renderer, offset);
@@ -15436,7 +15740,7 @@ class FFIRenderLib {
15436
15740
  }
15437
15741
  getRenderStats(renderer) {
15438
15742
  const statsBuffer = new ArrayBuffer(NativeRenderStatsStruct.size);
15439
- this.opentui.symbols.getRenderStats(renderer, ptr(statsBuffer));
15743
+ this.opentui.symbols.getRenderStats(renderer, statsBuffer);
15440
15744
  const stats = NativeRenderStatsStruct.unpack(statsBuffer);
15441
15745
  return {
15442
15746
  nativeLastFrameTime: stats.lastFrameTime,
@@ -15471,7 +15775,7 @@ class FFIRenderLib {
15471
15775
  for (let index = 0;index < palette.length; index++) {
15472
15776
  paletteBuffer.set(palette[index].buffer, index * 4);
15473
15777
  }
15474
- this.opentui.symbols.rendererSetPaletteState(renderer, ptr(paletteBuffer), palette.length, rgbaPtr(defaultForeground), rgbaPtr(defaultBackground), paletteEpoch >>> 0);
15778
+ this.opentui.symbols.rendererSetPaletteState(renderer, paletteBuffer, palette.length, rgbaBuffer(defaultForeground), rgbaBuffer(defaultBackground), paletteEpoch >>> 0);
15475
15779
  }
15476
15780
  bufferGetCharPtr(buffer) {
15477
15781
  const ptr3 = this.opentui.symbols.bufferGetCharPtr(buffer);
@@ -15510,14 +15814,14 @@ class FFIRenderLib {
15510
15814
  bufferGetId(buffer) {
15511
15815
  const maxLen = 256;
15512
15816
  const outBuffer = new Uint8Array(maxLen);
15513
- const actualLen = this.opentui.symbols.bufferGetId(buffer, ptr(outBuffer), maxLen);
15817
+ const actualLen = this.opentui.symbols.bufferGetId(buffer, outBuffer, maxLen);
15514
15818
  return this.decoder.decode(outBuffer.slice(0, actualLen));
15515
15819
  }
15516
15820
  bufferGetRealCharSize(buffer) {
15517
15821
  return this.opentui.symbols.bufferGetRealCharSize(buffer);
15518
15822
  }
15519
15823
  bufferWriteResolvedChars(buffer, outputBuffer, addLineBreaks) {
15520
- return this.opentui.symbols.bufferWriteResolvedChars(buffer, ptrOrNull(outputBuffer), outputBuffer.byteLength, ffiBool(addLineBreaks));
15824
+ return this.opentui.symbols.bufferWriteResolvedChars(buffer, viewOrNull(outputBuffer), outputBuffer.byteLength, ffiBool(addLineBreaks));
15521
15825
  }
15522
15826
  getBufferWidth(buffer) {
15523
15827
  return this.opentui.symbols.getBufferWidth(buffer);
@@ -15526,39 +15830,39 @@ class FFIRenderLib {
15526
15830
  return this.opentui.symbols.getBufferHeight(buffer);
15527
15831
  }
15528
15832
  bufferClear(buffer, color) {
15529
- this.opentui.symbols.bufferClear(buffer, rgbaPtr(color));
15833
+ this.opentui.symbols.bufferClear(buffer, rgbaBuffer(color));
15530
15834
  }
15531
15835
  bufferDrawText(buffer, text, x, y, color, bgColor, attributes) {
15532
15836
  const textBytes = this.encoder.encode(text);
15533
- const bg2 = optionalRgbaPtr(bgColor);
15534
- const fg2 = rgbaPtr(color);
15535
- this.opentui.symbols.bufferDrawText(buffer, ptrOrNull(textBytes), textBytes.byteLength, x, y, fg2, bg2, attributes ?? 0);
15837
+ const bg2 = optionalRgbaBuffer(bgColor);
15838
+ const fg2 = rgbaBuffer(color);
15839
+ this.opentui.symbols.bufferDrawText(buffer, viewOrNull(textBytes), textBytes.byteLength, x, y, fg2, bg2, attributes ?? 0);
15536
15840
  }
15537
15841
  bufferSetCellWithAlphaBlending(buffer, x, y, char, color, bgColor, attributes) {
15538
15842
  const charPtr = char.codePointAt(0) ?? " ".codePointAt(0);
15539
- const bg2 = rgbaPtr(bgColor);
15540
- const fg2 = rgbaPtr(color);
15843
+ const bg2 = rgbaBuffer(bgColor);
15844
+ const fg2 = rgbaBuffer(color);
15541
15845
  this.opentui.symbols.bufferSetCellWithAlphaBlending(buffer, x, y, charPtr, fg2, bg2, attributes ?? 0);
15542
15846
  }
15543
15847
  bufferSetCell(buffer, x, y, char, color, bgColor, attributes) {
15544
15848
  const charPtr = char.codePointAt(0) ?? " ".codePointAt(0);
15545
- const bg2 = rgbaPtr(bgColor);
15546
- const fg2 = rgbaPtr(color);
15849
+ const bg2 = rgbaBuffer(bgColor);
15850
+ const fg2 = rgbaBuffer(color);
15547
15851
  this.opentui.symbols.bufferSetCell(buffer, x, y, charPtr, fg2, bg2, attributes ?? 0);
15548
15852
  }
15549
15853
  bufferFillRect(buffer, x, y, width, height, color) {
15550
- const bg2 = rgbaPtr(color);
15854
+ const bg2 = rgbaBuffer(color);
15551
15855
  this.opentui.symbols.bufferFillRect(buffer, x, y, width, height, bg2);
15552
15856
  }
15553
- bufferColorMatrix(buffer, matrixPtr, cellMaskPtr, cellMaskCount, strength, target) {
15554
- this.opentui.symbols.bufferColorMatrix(buffer, matrixPtr, cellMaskPtr, cellMaskCount, strength, target);
15857
+ bufferColorMatrix(buffer, matrix, cellMask, cellMaskCount, strength, target) {
15858
+ this.opentui.symbols.bufferColorMatrix(buffer, matrix, cellMask, cellMaskCount, strength, target);
15555
15859
  }
15556
- bufferColorMatrixUniform(buffer, matrixPtr, strength, target) {
15557
- this.opentui.symbols.bufferColorMatrixUniform(buffer, matrixPtr, strength, target);
15860
+ bufferColorMatrixUniform(buffer, matrix, strength, target) {
15861
+ this.opentui.symbols.bufferColorMatrixUniform(buffer, matrix, strength, target);
15558
15862
  }
15559
- bufferDrawSuperSampleBuffer(buffer, x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
15863
+ bufferDrawSuperSampleBuffer(buffer, x, y, pixelData, pixelDataLength, format, alignedBytesPerRow) {
15560
15864
  const formatId = format === "bgra8unorm" ? 0 : 1;
15561
- this.opentui.symbols.bufferDrawSuperSampleBuffer(buffer, x, y, pixelDataPtr, pixelDataLength, formatId, alignedBytesPerRow);
15865
+ this.opentui.symbols.bufferDrawSuperSampleBuffer(buffer, x, y, pixelData, pixelDataLength, formatId, alignedBytesPerRow);
15562
15866
  }
15563
15867
  bufferDrawImage(buffer, image, x, y, width, height, pixelWidth, pixelHeight, sourceX, sourceY, sourceWidth, sourceHeight, protocol) {
15564
15868
  const protocolId = { auto: 0, kitty: 1, sixel: 2, blocks: 3 }[protocol];
@@ -15578,38 +15882,38 @@ class FFIRenderLib {
15578
15882
  }, storage.view, 0);
15579
15883
  return Boolean(this.opentui.symbols.bufferDrawImage(buffer, image, storage.buffer));
15580
15884
  }
15581
- bufferDrawPackedBuffer(buffer, dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
15582
- this.opentui.symbols.bufferDrawPackedBuffer(buffer, dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
15885
+ bufferDrawPackedBuffer(buffer, data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
15886
+ this.opentui.symbols.bufferDrawPackedBuffer(buffer, data, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
15583
15887
  }
15584
- bufferDrawGrayscaleBuffer(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, fg2, bg2) {
15585
- this.opentui.symbols.bufferDrawGrayscaleBuffer(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, optionalRgbaPtr(fg2), optionalRgbaPtr(bg2));
15888
+ bufferDrawGrayscaleBuffer(buffer, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2) {
15889
+ this.opentui.symbols.bufferDrawGrayscaleBuffer(buffer, posX, posY, intensities, srcWidth, srcHeight, optionalRgbaBuffer(fg2), optionalRgbaBuffer(bg2));
15586
15890
  }
15587
- bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, fg2, bg2) {
15588
- this.opentui.symbols.bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, optionalRgbaPtr(fg2), optionalRgbaPtr(bg2));
15891
+ bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensities, srcWidth, srcHeight, fg2, bg2) {
15892
+ this.opentui.symbols.bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensities, srcWidth, srcHeight, optionalRgbaBuffer(fg2), optionalRgbaBuffer(bg2));
15589
15893
  }
15590
15894
  bufferDrawGrid(buffer, borderChars, borderFg, borderBg, columnOffsets, columnCount, rowOffsets, rowCount, options) {
15591
15895
  GridDrawOptionsStruct.packInto({ drawInner: options.drawInner, drawOuter: options.drawOuter }, this.ffiStructStorage.gridDrawOptions.view, 0);
15592
- this.opentui.symbols.bufferDrawGrid(buffer, ptr(borderChars), rgbaPtr(borderFg), rgbaPtr(borderBg), ptr(columnOffsets), columnCount, ptr(rowOffsets), rowCount, this.ffiStructStorage.gridDrawOptions.buffer);
15896
+ this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaBuffer(borderFg), rgbaBuffer(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, this.ffiStructStorage.gridDrawOptions.buffer);
15593
15897
  }
15594
15898
  bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, titleColor, title, bottomTitle) {
15595
15899
  const titleBytes = title ? this.encoder.encode(title) : null;
15596
15900
  const titleLen = titleBytes?.byteLength ?? 0;
15597
- const titlePtr = titleBytes ? ptr(titleBytes) : null;
15901
+ const titleBuffer = titleBytes ? titleBytes : null;
15598
15902
  const bottomTitleBytes = bottomTitle ? this.encoder.encode(bottomTitle) : null;
15599
15903
  const bottomTitleLen = bottomTitleBytes?.byteLength ?? 0;
15600
- const bottomTitlePtr = bottomTitleBytes ? ptr(bottomTitleBytes) : null;
15601
- this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, ptr(borderChars), packedOptions, rgbaPtr(borderColor), rgbaPtr(backgroundColor), rgbaPtr(titleColor), titlePtr, titleLen, bottomTitlePtr, bottomTitleLen);
15904
+ const bottomTitleBuffer = bottomTitleBytes ? bottomTitleBytes : null;
15905
+ this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, rgbaBuffer(borderColor), rgbaBuffer(backgroundColor), rgbaBuffer(titleColor), titleBuffer, titleLen, bottomTitleBuffer, bottomTitleLen);
15602
15906
  }
15603
15907
  bufferResize(buffer, width, height) {
15604
15908
  this.opentui.symbols.bufferResize(buffer, width, height);
15605
15909
  }
15606
15910
  linkAlloc(url) {
15607
15911
  const urlBytes = this.encoder.encode(url);
15608
- return this.opentui.symbols.linkAlloc(ptrOrNull(urlBytes), urlBytes.byteLength);
15912
+ return this.opentui.symbols.linkAlloc(viewOrNull(urlBytes), urlBytes.byteLength);
15609
15913
  }
15610
15914
  linkGetUrl(linkId, maxLen = 512) {
15611
15915
  const outBuffer = new Uint8Array(maxLen);
15612
- const actualLen = this.opentui.symbols.linkGetUrl(linkId, ptrOrNull(outBuffer), maxLen);
15916
+ const actualLen = this.opentui.symbols.linkGetUrl(linkId, viewOrNull(outBuffer), maxLen);
15613
15917
  return this.decoder.decode(outBuffer.slice(0, actualLen));
15614
15918
  }
15615
15919
  attributesWithLink(baseAttributes, linkId) {
@@ -15625,11 +15929,11 @@ class FFIRenderLib {
15625
15929
  this.opentui.symbols.setCursorPosition(renderer, x, y, ffiBool(visible));
15626
15930
  }
15627
15931
  setCursorColor(renderer, color) {
15628
- this.opentui.symbols.setCursorColor(renderer, rgbaPtr(color));
15932
+ this.opentui.symbols.setCursorColor(renderer, rgbaBuffer(color));
15629
15933
  }
15630
15934
  getCursorState(renderer) {
15631
15935
  const cursorBuffer = new ArrayBuffer(CursorStateStruct.size);
15632
- this.opentui.symbols.getCursorState(renderer, ptr(cursorBuffer));
15936
+ this.opentui.symbols.getCursorState(renderer, cursorBuffer);
15633
15937
  const struct = CursorStateStruct.unpack(cursorBuffer);
15634
15938
  return {
15635
15939
  x: struct.x,
@@ -15661,7 +15965,8 @@ class FFIRenderLib {
15661
15965
  return this.unpackRenderOperationResult(this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, ffiBool(force)));
15662
15966
  }
15663
15967
  commitSplitFooterSnapshot(renderer, snapshot, rowColumns, startOnNewLine, trailingNewline, pinnedRenderOffset, force, beginFrame = true, finalizeFrame = true) {
15664
- return this.unpackRenderOperationResult(this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, ffiBool(startOnNewLine), ffiBool(trailingNewline), pinnedRenderOffset, ffiBool(force), ffiBool(beginFrame), ffiBool(finalizeFrame)));
15968
+ const flags = ffiBool(startOnNewLine) | ffiBool(trailingNewline) << 1 | ffiBool(force) << 2 | ffiBool(beginFrame) << 3 | ffiBool(finalizeFrame) << 4;
15969
+ return this.unpackRenderOperationResult(this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, flags, pinnedRenderOffset));
15665
15970
  }
15666
15971
  createOptimizedBuffer(width, height, widthMethod, respectAlpha = false, id) {
15667
15972
  if (Number.isNaN(width) || Number.isNaN(height)) {
@@ -15670,7 +15975,7 @@ class FFIRenderLib {
15670
15975
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
15671
15976
  const idToUse = id || "unnamed buffer";
15672
15977
  const idBytes = this.encoder.encode(idToUse);
15673
- const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, ffiBool(respectAlpha), widthMethodCode, ptr(idBytes), idBytes.byteLength);
15978
+ const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, ffiBool(respectAlpha), widthMethodCode, idBytes, idBytes.byteLength);
15674
15979
  if (!bufferPtr) {
15675
15980
  throw new Error(`Failed to create optimized buffer: ${width}x${height}`);
15676
15981
  }
@@ -15694,12 +15999,12 @@ class FFIRenderLib {
15694
15999
  }
15695
16000
  setTerminalTitle(renderer, title) {
15696
16001
  const titleBytes = this.encoder.encode(title);
15697
- this.opentui.symbols.setTerminalTitle(renderer, ptrOrNull(titleBytes), titleBytes.byteLength);
16002
+ this.opentui.symbols.setTerminalTitle(renderer, viewOrNull(titleBytes), titleBytes.byteLength);
15698
16003
  }
15699
16004
  copyToClipboardOSC52(renderer, target, textUtf8) {
15700
16005
  if (textUtf8.byteLength > 4294967295)
15701
16006
  return false;
15702
- return Boolean(this.opentui.symbols.copyToClipboardOSC52(renderer, target, ptrOrNull(textUtf8), textUtf8.byteLength));
16007
+ return Boolean(this.opentui.symbols.copyToClipboardOSC52(renderer, target, viewOrNull(textUtf8), textUtf8.byteLength));
15703
16008
  }
15704
16009
  clearClipboardOSC52(renderer, target) {
15705
16010
  return Boolean(this.opentui.symbols.clearClipboardOSC52(renderer, target));
@@ -15874,7 +16179,7 @@ class FFIRenderLib {
15874
16179
  const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
15875
16180
  if (bytes.length === 0)
15876
16181
  return;
15877
- this.opentui.symbols.writeOut(renderer, ptrOrNull(bytes), bytes.byteLength);
16182
+ this.opentui.symbols.writeOut(renderer, viewOrNull(bytes), bytes.byteLength);
15878
16183
  }
15879
16184
  yogaConfigCreate() {
15880
16185
  const config = this.opentui.symbols.yogaConfigCreate();
@@ -15986,7 +16291,7 @@ class FFIRenderLib {
15986
16291
  }
15987
16292
  yogaNodeGetComputedLayout(node) {
15988
16293
  const layout = this.yogaLayout;
15989
- this.opentui.symbols.yogaNodeGetComputedLayout(node, this.yogaLayoutPtr);
16294
+ this.opentui.symbols.yogaNodeGetComputedLayout(node, this.yogaLayout);
15990
16295
  return {
15991
16296
  left: layout[0],
15992
16297
  top: layout[1],
@@ -16083,16 +16388,16 @@ class FFIRenderLib {
16083
16388
  this.opentui.symbols.textBufferClear(buffer);
16084
16389
  }
16085
16390
  textBufferSetDefaultFg(buffer, fg2) {
16086
- const fgPtr = optionalRgbaPtr(fg2);
16087
- this.opentui.symbols.textBufferSetDefaultFg(buffer, fgPtr);
16391
+ const fgBuffer = optionalRgbaBuffer(fg2);
16392
+ this.opentui.symbols.textBufferSetDefaultFg(buffer, fgBuffer);
16088
16393
  }
16089
16394
  textBufferSetDefaultBg(buffer, bg2) {
16090
- const bgPtr = optionalRgbaPtr(bg2);
16091
- this.opentui.symbols.textBufferSetDefaultBg(buffer, bgPtr);
16395
+ const bgBuffer = optionalRgbaBuffer(bg2);
16396
+ this.opentui.symbols.textBufferSetDefaultBg(buffer, bgBuffer);
16092
16397
  }
16093
16398
  textBufferSetDefaultAttributes(buffer, attributes) {
16094
16399
  const attrValue = attributes === null ? null : new Uint32Array([attributes]);
16095
- this.opentui.symbols.textBufferSetDefaultAttributes(buffer, attrValue ? ptr(attrValue) : null);
16400
+ this.opentui.symbols.textBufferSetDefaultAttributes(buffer, attrValue);
16096
16401
  }
16097
16402
  textBufferResetDefaults(buffer) {
16098
16403
  this.opentui.symbols.textBufferResetDefaults(buffer);
@@ -16104,14 +16409,14 @@ class FFIRenderLib {
16104
16409
  this.opentui.symbols.textBufferSetTabWidth(buffer, width);
16105
16410
  }
16106
16411
  textBufferRegisterMemBuffer(buffer, bytes, owned = false) {
16107
- const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, ptrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16412
+ const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, retainedPtrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16108
16413
  if (result === 65535) {
16109
16414
  throw new Error("Failed to register memory buffer");
16110
16415
  }
16111
16416
  return result;
16112
16417
  }
16113
16418
  textBufferReplaceMemBuffer(buffer, memId, bytes, owned = false) {
16114
- return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, ptrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16419
+ return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, retainedPtrOrNull(bytes), bytes.byteLength, ffiBool(owned));
16115
16420
  }
16116
16421
  textBufferClearMemRegistry(buffer) {
16117
16422
  this.opentui.symbols.textBufferClearMemRegistry(buffer);
@@ -16120,14 +16425,14 @@ class FFIRenderLib {
16120
16425
  this.opentui.symbols.textBufferSetTextFromMem(buffer, memId);
16121
16426
  }
16122
16427
  textBufferAppend(buffer, bytes) {
16123
- this.opentui.symbols.textBufferAppend(buffer, ptrOrNull(bytes), bytes.byteLength);
16428
+ this.opentui.symbols.textBufferAppend(buffer, retainedPtrOrNull(bytes), bytes.byteLength);
16124
16429
  }
16125
16430
  textBufferAppendFromMemId(buffer, memId) {
16126
16431
  this.opentui.symbols.textBufferAppendFromMemId(buffer, memId);
16127
16432
  }
16128
16433
  textBufferLoadFile(buffer, path3) {
16129
16434
  const pathBytes = this.encoder.encode(path3);
16130
- return this.opentui.symbols.textBufferLoadFile(buffer, ptrOrNull(pathBytes), pathBytes.byteLength);
16435
+ return this.opentui.symbols.textBufferLoadFile(buffer, viewOrNull(pathBytes), pathBytes.byteLength);
16131
16436
  }
16132
16437
  textBufferSetStyledText(buffer, chunks) {
16133
16438
  if (chunks.length === 0) {
@@ -16140,12 +16445,12 @@ class FFIRenderLib {
16140
16445
  textBufferGetLineCount(buffer) {
16141
16446
  return this.opentui.symbols.textBufferGetLineCount(buffer);
16142
16447
  }
16143
- textBufferGetPlainText(buffer, outPtr, maxLen) {
16144
- return this.opentui.symbols.textBufferGetPlainText(buffer, outPtr, maxLen);
16448
+ textBufferGetPlainText(buffer, outBuffer, maxLen) {
16449
+ return this.opentui.symbols.textBufferGetPlainText(buffer, outBuffer, maxLen);
16145
16450
  }
16146
16451
  getPlainTextBytes(buffer, maxLength) {
16147
16452
  const outBuffer = new Uint8Array(maxLength);
16148
- const actualLen = this.textBufferGetPlainText(buffer, ptrOrNull(outBuffer), maxLength);
16453
+ const actualLen = this.textBufferGetPlainText(buffer, viewOrNull(outBuffer), maxLength);
16149
16454
  if (actualLen === 0) {
16150
16455
  return null;
16151
16456
  }
@@ -16153,7 +16458,7 @@ class FFIRenderLib {
16153
16458
  }
16154
16459
  textBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
16155
16460
  const outBuffer = new Uint8Array(maxLength);
16156
- const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, ptrOrNull(outBuffer), maxLength);
16461
+ const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, viewOrNull(outBuffer), maxLength);
16157
16462
  const len = actualLen;
16158
16463
  if (len === 0) {
16159
16464
  return null;
@@ -16162,7 +16467,7 @@ class FFIRenderLib {
16162
16467
  }
16163
16468
  textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
16164
16469
  const outBuffer = new Uint8Array(maxLength);
16165
- const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptrOrNull(outBuffer), maxLength);
16470
+ const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, viewOrNull(outBuffer), maxLength);
16166
16471
  const len = actualLen;
16167
16472
  if (len === 0) {
16168
16473
  return null;
@@ -16180,8 +16485,8 @@ class FFIRenderLib {
16180
16485
  this.opentui.symbols.destroyTextBufferView(view);
16181
16486
  }
16182
16487
  textBufferViewSetSelection(view, start, end, bgColor, fgColor) {
16183
- const bg2 = optionalRgbaPtr(bgColor);
16184
- const fg2 = optionalRgbaPtr(fgColor);
16488
+ const bg2 = optionalRgbaBuffer(bgColor);
16489
+ const fg2 = optionalRgbaBuffer(fgColor);
16185
16490
  this.opentui.symbols.textBufferViewSetSelection(view, start, end, bg2, fg2);
16186
16491
  }
16187
16492
  textBufferViewResetSelection(view) {
@@ -16199,24 +16504,30 @@ class FFIRenderLib {
16199
16504
  textBufferViewGetSelectionInfo(view) {
16200
16505
  return this.opentui.symbols.textBufferViewGetSelectionInfo(view);
16201
16506
  }
16202
- textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
16203
- const bg2 = optionalRgbaPtr(bgColor);
16204
- const fg2 = optionalRgbaPtr(fgColor);
16205
- return Boolean(this.opentui.symbols.textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2));
16507
+ textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior) {
16508
+ const bg2 = optionalRgbaBuffer(bgColor);
16509
+ const fg2 = optionalRgbaBuffer(fgColor);
16510
+ return Boolean(this.opentui.symbols.textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, selectionBehaviorByte(behavior)));
16206
16511
  }
16207
16512
  textBufferViewUpdateSelection(view, end, bgColor, fgColor) {
16208
- const bg2 = optionalRgbaPtr(bgColor);
16209
- const fg2 = optionalRgbaPtr(fgColor);
16513
+ const bg2 = optionalRgbaBuffer(bgColor);
16514
+ const fg2 = optionalRgbaBuffer(fgColor);
16210
16515
  this.opentui.symbols.textBufferViewUpdateSelection(view, end, bg2, fg2);
16211
16516
  }
16212
- textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
16213
- const bg2 = optionalRgbaPtr(bgColor);
16214
- const fg2 = optionalRgbaPtr(fgColor);
16215
- return Boolean(this.opentui.symbols.textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2));
16517
+ textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior) {
16518
+ const bg2 = optionalRgbaBuffer(bgColor);
16519
+ const fg2 = optionalRgbaBuffer(fgColor);
16520
+ return Boolean(this.opentui.symbols.textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, selectionBehaviorByte(behavior)));
16216
16521
  }
16217
16522
  textBufferViewResetLocalSelection(view) {
16218
16523
  this.opentui.symbols.textBufferViewResetLocalSelection(view);
16219
16524
  }
16525
+ textBufferViewSetSelectionOccupancy(view, occupancy) {
16526
+ this.opentui.symbols.textBufferViewSetSelectionOccupancy(view, occupancy === "boundary" ? 1 : 0);
16527
+ }
16528
+ textBufferViewGetSelectionOccupancy(view) {
16529
+ return this.opentui.symbols.textBufferViewGetSelectionOccupancy(view) === 1 ? "boundary" : "cell";
16530
+ }
16220
16531
  textBufferViewSetWrapWidth(view, width) {
16221
16532
  this.opentui.symbols.textBufferViewSetWrapWidth(view, width);
16222
16533
  }
@@ -16235,7 +16546,7 @@ class FFIRenderLib {
16235
16546
  }
16236
16547
  textBufferViewGetLineInfo(view) {
16237
16548
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16238
- this.textBufferViewGetLineInfoDirect(view, ptr(outBuffer));
16549
+ this.textBufferViewGetLineInfoDirect(view, outBuffer);
16239
16550
  const struct = LineInfoStruct.unpack(outBuffer);
16240
16551
  const lineStartCols = struct.startCols;
16241
16552
  const lineWidthCols = struct.widthCols;
@@ -16250,7 +16561,7 @@ class FFIRenderLib {
16250
16561
  }
16251
16562
  textBufferViewGetLogicalLineInfo(view) {
16252
16563
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16253
- this.textBufferViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
16564
+ this.textBufferViewGetLogicalLineInfoDirect(view, outBuffer);
16254
16565
  const struct = LineInfoStruct.unpack(outBuffer);
16255
16566
  const lineStartCols = struct.startCols;
16256
16567
  const lineWidthCols = struct.widthCols;
@@ -16266,21 +16577,21 @@ class FFIRenderLib {
16266
16577
  textBufferViewGetVirtualLineCount(view) {
16267
16578
  return this.opentui.symbols.textBufferViewGetVirtualLineCount(view);
16268
16579
  }
16269
- textBufferViewGetLineInfoDirect(view, outPtr) {
16270
- this.opentui.symbols.textBufferViewGetLineInfoDirect(view, outPtr);
16580
+ textBufferViewGetLineInfoDirect(view, outBuffer) {
16581
+ this.opentui.symbols.textBufferViewGetLineInfoDirect(view, outBuffer);
16271
16582
  }
16272
- textBufferViewGetLogicalLineInfoDirect(view, outPtr) {
16273
- this.opentui.symbols.textBufferViewGetLogicalLineInfoDirect(view, outPtr);
16583
+ textBufferViewGetLogicalLineInfoDirect(view, outBuffer) {
16584
+ this.opentui.symbols.textBufferViewGetLogicalLineInfoDirect(view, outBuffer);
16274
16585
  }
16275
- textBufferViewGetSelectedText(view, outPtr, maxLen) {
16276
- return this.opentui.symbols.textBufferViewGetSelectedText(view, outPtr, maxLen);
16586
+ textBufferViewGetSelectedText(view, outBuffer, maxLen) {
16587
+ return this.opentui.symbols.textBufferViewGetSelectedText(view, outBuffer, maxLen);
16277
16588
  }
16278
- textBufferViewGetPlainText(view, outPtr, maxLen) {
16279
- return this.opentui.symbols.textBufferViewGetPlainText(view, outPtr, maxLen);
16589
+ textBufferViewGetPlainText(view, outBuffer, maxLen) {
16590
+ return this.opentui.symbols.textBufferViewGetPlainText(view, outBuffer, maxLen);
16280
16591
  }
16281
16592
  textBufferViewGetSelectedTextBytes(view, maxLength) {
16282
16593
  const outBuffer = new Uint8Array(maxLength);
16283
- const actualLen = this.textBufferViewGetSelectedText(view, ptrOrNull(outBuffer), maxLength);
16594
+ const actualLen = this.textBufferViewGetSelectedText(view, viewOrNull(outBuffer), maxLength);
16284
16595
  if (actualLen === 0) {
16285
16596
  return null;
16286
16597
  }
@@ -16288,7 +16599,7 @@ class FFIRenderLib {
16288
16599
  }
16289
16600
  textBufferViewGetPlainTextBytes(view, maxLength) {
16290
16601
  const outBuffer = new Uint8Array(maxLength);
16291
- const actualLen = this.textBufferViewGetPlainText(view, ptrOrNull(outBuffer), maxLength);
16602
+ const actualLen = this.textBufferViewGetPlainText(view, viewOrNull(outBuffer), maxLength);
16292
16603
  if (actualLen === 0) {
16293
16604
  return null;
16294
16605
  }
@@ -16298,7 +16609,7 @@ class FFIRenderLib {
16298
16609
  this.opentui.symbols.textBufferViewSetTabIndicator(view, indicator);
16299
16610
  }
16300
16611
  textBufferViewSetTabIndicatorColor(view, color) {
16301
- this.opentui.symbols.textBufferViewSetTabIndicatorColor(view, rgbaPtr(color));
16612
+ this.opentui.symbols.textBufferViewSetTabIndicatorColor(view, rgbaBuffer(color));
16302
16613
  }
16303
16614
  textBufferViewSetTruncate(view, truncate) {
16304
16615
  this.opentui.symbols.textBufferViewSetTruncate(view, ffiBool(truncate));
@@ -16313,11 +16624,11 @@ class FFIRenderLib {
16313
16624
  }
16314
16625
  textBufferAddHighlightByCharRange(buffer, highlight) {
16315
16626
  const packedHighlight = HighlightStruct.pack(highlight);
16316
- this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, ptr(packedHighlight));
16627
+ this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, packedHighlight);
16317
16628
  }
16318
16629
  textBufferAddHighlight(buffer, lineIdx, highlight) {
16319
16630
  const packedHighlight = HighlightStruct.pack(highlight);
16320
- this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, ptr(packedHighlight));
16631
+ this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, packedHighlight);
16321
16632
  }
16322
16633
  textBufferRemoveHighlightsByRef(buffer, hlRef) {
16323
16634
  this.opentui.symbols.textBufferRemoveHighlightsByRef(buffer, hlRef);
@@ -16333,7 +16644,7 @@ class FFIRenderLib {
16333
16644
  }
16334
16645
  textBufferGetLineHighlights(buffer, lineIdx) {
16335
16646
  const outCountBuf = new Uint32Array(1);
16336
- const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, ptr(outCountBuf));
16647
+ const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, outCountBuf);
16337
16648
  if (!nativePtr)
16338
16649
  return [];
16339
16650
  const count = outCountBuf[0];
@@ -16352,7 +16663,7 @@ class FFIRenderLib {
16352
16663
  }
16353
16664
  getBuildOptions() {
16354
16665
  const optionsBuffer = new ArrayBuffer(BuildOptionsStruct.size);
16355
- this.opentui.symbols.getBuildOptions(ptr(optionsBuffer));
16666
+ this.opentui.symbols.getBuildOptions(optionsBuffer);
16356
16667
  const options = BuildOptionsStruct.unpack(optionsBuffer);
16357
16668
  return {
16358
16669
  gpaSafeStats: !!options.gpaSafeStats,
@@ -16361,7 +16672,7 @@ class FFIRenderLib {
16361
16672
  }
16362
16673
  getAllocatorStats() {
16363
16674
  const statsBuffer = new ArrayBuffer(AllocatorStatsStruct.size);
16364
- this.opentui.symbols.getAllocatorStats(ptr(statsBuffer));
16675
+ this.opentui.symbols.getAllocatorStats(statsBuffer);
16365
16676
  const stats = AllocatorStatsStruct.unpack(statsBuffer);
16366
16677
  return {
16367
16678
  totalRequestedBytes: toNumber(stats.totalRequestedBytes),
@@ -16398,7 +16709,7 @@ class FFIRenderLib {
16398
16709
  const y = new Uint32Array(1);
16399
16710
  const width = new Uint32Array(1);
16400
16711
  const height = new Uint32Array(1);
16401
- this.opentui.symbols.editorViewGetViewport(view, ptr(x), ptr(y), ptr(width), ptr(height));
16712
+ this.opentui.symbols.editorViewGetViewport(view, x, y, width, height);
16402
16713
  return {
16403
16714
  offsetX: x[0],
16404
16715
  offsetY: y[0],
@@ -16428,7 +16739,7 @@ class FFIRenderLib {
16428
16739
  }
16429
16740
  editorViewGetLineInfo(view) {
16430
16741
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16431
- this.opentui.symbols.editorViewGetLineInfoDirect(view, ptr(outBuffer));
16742
+ this.opentui.symbols.editorViewGetLineInfoDirect(view, outBuffer);
16432
16743
  const struct = LineInfoStruct.unpack(outBuffer);
16433
16744
  const lineStartCols = struct.startCols;
16434
16745
  const lineWidthCols = struct.widthCols;
@@ -16443,7 +16754,7 @@ class FFIRenderLib {
16443
16754
  }
16444
16755
  editorViewGetLogicalLineInfo(view) {
16445
16756
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
16446
- this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
16757
+ this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, outBuffer);
16447
16758
  const struct = LineInfoStruct.unpack(outBuffer);
16448
16759
  const lineStartCols = struct.startCols;
16449
16760
  const lineWidthCols = struct.widthCols;
@@ -16468,20 +16779,20 @@ class FFIRenderLib {
16468
16779
  this.opentui.symbols.destroyEditBuffer(buffer);
16469
16780
  }
16470
16781
  editBufferSetText(buffer, textBytes) {
16471
- this.opentui.symbols.editBufferSetText(buffer, ptrOrNull(textBytes), textBytes.byteLength);
16782
+ this.opentui.symbols.editBufferSetText(buffer, viewOrNull(textBytes), textBytes.byteLength);
16472
16783
  }
16473
16784
  editBufferSetTextFromMem(buffer, memId) {
16474
16785
  this.opentui.symbols.editBufferSetTextFromMem(buffer, memId);
16475
16786
  }
16476
16787
  editBufferReplaceText(buffer, textBytes) {
16477
- this.opentui.symbols.editBufferReplaceText(buffer, ptrOrNull(textBytes), textBytes.byteLength);
16788
+ this.opentui.symbols.editBufferReplaceText(buffer, viewOrNull(textBytes), textBytes.byteLength);
16478
16789
  }
16479
16790
  editBufferReplaceTextFromMem(buffer, memId) {
16480
16791
  this.opentui.symbols.editBufferReplaceTextFromMem(buffer, memId);
16481
16792
  }
16482
16793
  editBufferGetText(buffer, maxLength) {
16483
16794
  const outBuffer = new Uint8Array(maxLength);
16484
- const actualLen = this.opentui.symbols.editBufferGetText(buffer, ptrOrNull(outBuffer), maxLength);
16795
+ const actualLen = this.opentui.symbols.editBufferGetText(buffer, viewOrNull(outBuffer), maxLength);
16485
16796
  const len = actualLen;
16486
16797
  if (len === 0)
16487
16798
  return null;
@@ -16489,11 +16800,11 @@ class FFIRenderLib {
16489
16800
  }
16490
16801
  editBufferInsertChar(buffer, char) {
16491
16802
  const charBytes = this.encoder.encode(char);
16492
- this.opentui.symbols.editBufferInsertChar(buffer, ptrOrNull(charBytes), charBytes.byteLength);
16803
+ this.opentui.symbols.editBufferInsertChar(buffer, viewOrNull(charBytes), charBytes.byteLength);
16493
16804
  }
16494
16805
  editBufferInsertText(buffer, text) {
16495
16806
  const textBytes = this.encoder.encode(text);
16496
- this.opentui.symbols.editBufferInsertText(buffer, ptrOrNull(textBytes), textBytes.byteLength);
16807
+ this.opentui.symbols.editBufferInsertText(buffer, viewOrNull(textBytes), textBytes.byteLength);
16497
16808
  }
16498
16809
  editBufferDeleteChar(buffer) {
16499
16810
  this.opentui.symbols.editBufferDeleteChar(buffer);
@@ -16555,7 +16866,7 @@ class FFIRenderLib {
16555
16866
  }
16556
16867
  editBufferUndo(buffer, maxLength) {
16557
16868
  const outBuffer = new Uint8Array(maxLength);
16558
- const actualLen = this.opentui.symbols.editBufferUndo(buffer, ptrOrNull(outBuffer), maxLength);
16869
+ const actualLen = this.opentui.symbols.editBufferUndo(buffer, viewOrNull(outBuffer), maxLength);
16559
16870
  const len = actualLen;
16560
16871
  if (len === 0)
16561
16872
  return null;
@@ -16563,7 +16874,7 @@ class FFIRenderLib {
16563
16874
  }
16564
16875
  editBufferRedo(buffer, maxLength) {
16565
16876
  const outBuffer = new Uint8Array(maxLength);
16566
- const actualLen = this.opentui.symbols.editBufferRedo(buffer, ptrOrNull(outBuffer), maxLength);
16877
+ const actualLen = this.opentui.symbols.editBufferRedo(buffer, viewOrNull(outBuffer), maxLength);
16567
16878
  const len = actualLen;
16568
16879
  if (len === 0)
16569
16880
  return null;
@@ -16615,7 +16926,7 @@ class FFIRenderLib {
16615
16926
  }
16616
16927
  editBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
16617
16928
  const outBuffer = new Uint8Array(maxLength);
16618
- const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, ptrOrNull(outBuffer), maxLength);
16929
+ const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, viewOrNull(outBuffer), maxLength);
16619
16930
  const len = actualLen;
16620
16931
  if (len === 0)
16621
16932
  return null;
@@ -16623,15 +16934,15 @@ class FFIRenderLib {
16623
16934
  }
16624
16935
  editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
16625
16936
  const outBuffer = new Uint8Array(maxLength);
16626
- const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptrOrNull(outBuffer), maxLength);
16937
+ const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, viewOrNull(outBuffer), maxLength);
16627
16938
  const len = actualLen;
16628
16939
  if (len === 0)
16629
16940
  return null;
16630
16941
  return usesBunFFI ? outBuffer.slice(0, len) : trimNodeFFIOutputBytes(outBuffer, len);
16631
16942
  }
16632
16943
  editorViewSetSelection(view, start, end, bgColor, fgColor) {
16633
- const bg2 = optionalRgbaPtr(bgColor);
16634
- const fg2 = optionalRgbaPtr(fgColor);
16944
+ const bg2 = optionalRgbaBuffer(bgColor);
16945
+ const fg2 = optionalRgbaBuffer(fgColor);
16635
16946
  this.opentui.symbols.editorViewSetSelection(view, start, end, bg2, fg2);
16636
16947
  }
16637
16948
  editorViewResetSelection(view) {
@@ -16646,27 +16957,43 @@ class FFIRenderLib {
16646
16957
  const end = Number(packedInfo & 0xffff_ffffn);
16647
16958
  return { start, end };
16648
16959
  }
16649
- editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
16650
- const bg2 = optionalRgbaPtr(bgColor);
16651
- const fg2 = optionalRgbaPtr(fgColor);
16652
- return Boolean(this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor)));
16960
+ editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior) {
16961
+ const bg2 = optionalRgbaBuffer(bgColor);
16962
+ const fg2 = optionalRgbaBuffer(fgColor);
16963
+ return Boolean(this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, editorLocalSelectionFlags(updateCursor, followCursor, behavior)));
16653
16964
  }
16654
16965
  editorViewUpdateSelection(view, end, bgColor, fgColor) {
16655
- const bg2 = optionalRgbaPtr(bgColor);
16656
- const fg2 = optionalRgbaPtr(fgColor);
16966
+ const bg2 = optionalRgbaBuffer(bgColor);
16967
+ const fg2 = optionalRgbaBuffer(fgColor);
16657
16968
  this.opentui.symbols.editorViewUpdateSelection(view, end, bg2, fg2);
16658
16969
  }
16659
- editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
16660
- const bg2 = optionalRgbaPtr(bgColor);
16661
- const fg2 = optionalRgbaPtr(fgColor);
16662
- return Boolean(this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor)));
16970
+ editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior) {
16971
+ const bg2 = optionalRgbaBuffer(bgColor);
16972
+ const fg2 = optionalRgbaBuffer(fgColor);
16973
+ return Boolean(this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, editorLocalSelectionFlags(updateCursor, followCursor, behavior)));
16663
16974
  }
16664
16975
  editorViewResetLocalSelection(view) {
16665
16976
  this.opentui.symbols.editorViewResetLocalSelection(view);
16666
16977
  }
16978
+ editorViewConvertSelectionToCell(view) {
16979
+ return Boolean(this.opentui.symbols.editorViewConvertSelectionToCell(view));
16980
+ }
16981
+ editorViewSetSelectionOccupancy(view, occupancy) {
16982
+ this.opentui.symbols.editorViewSetSelectionOccupancy(view, occupancy === "boundary" ? 1 : 0);
16983
+ }
16984
+ editorViewSetSelectionInclusive(view, start, end, bgColor, fgColor) {
16985
+ const bg2 = optionalRgbaBuffer(bgColor);
16986
+ const fg2 = optionalRgbaBuffer(fgColor);
16987
+ this.opentui.symbols.editorViewSetSelectionInclusive(view, start, end, bg2, fg2);
16988
+ }
16989
+ editorViewSetSelectionColors(view, bgColor, fgColor) {
16990
+ const bg2 = optionalRgbaBuffer(bgColor);
16991
+ const fg2 = optionalRgbaBuffer(fgColor);
16992
+ this.opentui.symbols.editorViewSetSelectionColors(view, bg2, fg2);
16993
+ }
16667
16994
  editorViewGetSelectedTextBytes(view, maxLength) {
16668
16995
  const outBuffer = new Uint8Array(maxLength);
16669
- const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, ptrOrNull(outBuffer), maxLength);
16996
+ const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, viewOrNull(outBuffer), maxLength);
16670
16997
  const len = actualLen;
16671
16998
  if (len === 0)
16672
16999
  return null;
@@ -16675,12 +17002,12 @@ class FFIRenderLib {
16675
17002
  editorViewGetCursor(view) {
16676
17003
  const row = new Uint32Array(1);
16677
17004
  const col = new Uint32Array(1);
16678
- this.opentui.symbols.editorViewGetCursor(view, ptr(row), ptr(col));
17005
+ this.opentui.symbols.editorViewGetCursor(view, row, col);
16679
17006
  return { row: row[0], col: col[0] };
16680
17007
  }
16681
17008
  editorViewGetText(view, maxLength) {
16682
17009
  const outBuffer = new Uint8Array(maxLength);
16683
- const actualLen = this.opentui.symbols.editorViewGetText(view, ptrOrNull(outBuffer), maxLength);
17010
+ const actualLen = this.opentui.symbols.editorViewGetText(view, viewOrNull(outBuffer), maxLength);
16684
17011
  const len = actualLen;
16685
17012
  if (len === 0)
16686
17013
  return null;
@@ -16734,6 +17061,9 @@ class FFIRenderLib {
16734
17061
  const cursor = VisualCursorStruct.unpackInto(storage.view, storage.result);
16735
17062
  return { ...cursor };
16736
17063
  }
17064
+ editorViewGotoVisualLineEnd(view) {
17065
+ this.opentui.symbols.editorViewGotoVisualLineEnd(view);
17066
+ }
16737
17067
  bufferPushScissorRect(buffer, x, y, width, height) {
16738
17068
  this.opentui.symbols.bufferPushScissorRect(buffer, x, y, width, height);
16739
17069
  }
@@ -16757,7 +17087,7 @@ class FFIRenderLib {
16757
17087
  }
16758
17088
  getTerminalCapabilities(renderer) {
16759
17089
  const capsBuffer = new ArrayBuffer(TerminalCapabilitiesStruct.size);
16760
- this.opentui.symbols.getTerminalCapabilities(renderer, ptr(capsBuffer));
17090
+ this.opentui.symbols.getTerminalCapabilities(renderer, capsBuffer);
16761
17091
  const caps = TerminalCapabilitiesStruct.unpack(capsBuffer);
16762
17092
  return {
16763
17093
  kitty_keyboard: caps.kitty_keyboard,
@@ -16790,14 +17120,14 @@ class FFIRenderLib {
16790
17120
  }
16791
17121
  processCapabilityResponse(renderer, response) {
16792
17122
  const responseBytes = this.encoder.encode(response);
16793
- this.opentui.symbols.processCapabilityResponse(renderer, ptrOrNull(responseBytes), responseBytes.byteLength);
17123
+ this.opentui.symbols.processCapabilityResponse(renderer, viewOrNull(responseBytes), responseBytes.byteLength);
16794
17124
  }
16795
17125
  encodeUnicode(text, widthMethod) {
16796
17126
  const textBytes = this.encoder.encode(text);
16797
17127
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
16798
17128
  const outPtrBuffer = new ArrayBuffer(8);
16799
17129
  const outLenBuffer = new ArrayBuffer(8);
16800
- const success = this.opentui.symbols.encodeUnicode(ptrOrNull(textBytes), textBytes.byteLength, ptr(outPtrBuffer), ptr(outLenBuffer), widthMethodCode);
17130
+ const success = this.opentui.symbols.encodeUnicode(viewOrNull(textBytes), textBytes.byteLength, outPtrBuffer, outLenBuffer, widthMethodCode);
16801
17131
  if (!success) {
16802
17132
  return null;
16803
17133
  }
@@ -16817,11 +17147,11 @@ class FFIRenderLib {
16817
17147
  this.opentui.symbols.freeUnicode(encoded.ptr, encoded.data.length);
16818
17148
  }
16819
17149
  bufferDrawChar(buffer, char, x, y, fg2, bg2, attributes = 0) {
16820
- this.opentui.symbols.bufferDrawChar(buffer, char, x, y, rgbaPtr(fg2), rgbaPtr(bg2), attributes);
17150
+ this.opentui.symbols.bufferDrawChar(buffer, char, x, y, rgbaBuffer(fg2), rgbaBuffer(bg2), attributes);
16821
17151
  }
16822
17152
  createAudioEngine(options) {
16823
17153
  const optionsBuffer = options == null ? null : AudioCreateOptionsStruct.pack(options);
16824
- const engineHandle = this.opentui.symbols.createAudioEngine(optionsBuffer ? ptr(optionsBuffer) : null);
17154
+ const engineHandle = this.opentui.symbols.createAudioEngine(optionsBuffer);
16825
17155
  return engineHandle ? engineHandle : null;
16826
17156
  }
16827
17157
  destroyAudioEngine(engine) {
@@ -16835,7 +17165,7 @@ class FFIRenderLib {
16835
17165
  }
16836
17166
  audioGetPlaybackDeviceName(engine, index) {
16837
17167
  const outBuffer = new Uint8Array(512);
16838
- const bytesWritten = toNumber(this.opentui.symbols.audioGetPlaybackDeviceName(engine, index, ptr(outBuffer), outBuffer.length));
17168
+ const bytesWritten = toNumber(this.opentui.symbols.audioGetPlaybackDeviceName(engine, index, outBuffer, outBuffer.length));
16839
17169
  const safeBytesWritten = Math.max(0, Math.min(outBuffer.length, bytesWritten));
16840
17170
  return this.decoder.decode(outBuffer.subarray(0, safeBytesWritten));
16841
17171
  }
@@ -16925,7 +17255,7 @@ class FFIRenderLib {
16925
17255
  } catch {
16926
17256
  return -1;
16927
17257
  }
16928
- return this.opentui.symbols.audioStart(engine, optionsBuffer ? ptr(optionsBuffer) : null);
17258
+ return this.opentui.symbols.audioStart(engine, optionsBuffer);
16929
17259
  }
16930
17260
  audioStartMixer(engine) {
16931
17261
  return this.opentui.symbols.audioStartMixer(engine);
@@ -16984,7 +17314,7 @@ class FFIRenderLib {
16984
17314
  audioLoad(engine, data) {
16985
17315
  const outBuffer = new ArrayBuffer(4);
16986
17316
  const dataLength = toSafeFFIU32Length(data.byteLength, "Audio data length");
16987
- const status = this.opentui.symbols.audioLoad(engine, ptr(data), dataLength, ptr(outBuffer));
17317
+ const status = this.opentui.symbols.audioLoad(engine, data, dataLength, outBuffer);
16988
17318
  if (status !== 0) {
16989
17319
  return { status, soundId: null };
16990
17320
  }
@@ -16999,7 +17329,7 @@ class FFIRenderLib {
16999
17329
  return { status: -1, voiceId: null };
17000
17330
  const outBuffer = new ArrayBuffer(4);
17001
17331
  const optionsBuffer = options ? AudioVoiceOptionsStruct.pack(options) : null;
17002
- const status = this.opentui.symbols.audioPlay(engine, soundId, optionsBuffer ? ptr(optionsBuffer) : null, ptr(outBuffer));
17332
+ const status = this.opentui.symbols.audioPlay(engine, soundId, optionsBuffer, outBuffer);
17003
17333
  if (status !== 0) {
17004
17334
  return { status, voiceId: null };
17005
17335
  }
@@ -17018,7 +17348,7 @@ class FFIRenderLib {
17018
17348
  const outBuffer = new ArrayBuffer(4);
17019
17349
  const nameBytes = this.encoder.encode(name);
17020
17350
  const nameLength = toSafeFFIU32Length(nameBytes.byteLength, "Audio group name length");
17021
- const status = this.opentui.symbols.audioCreateGroup(engine, ptr(nameBytes), nameLength, ptr(outBuffer));
17351
+ const status = this.opentui.symbols.audioCreateGroup(engine, nameBytes, nameLength, outBuffer);
17022
17352
  if (status !== 0) {
17023
17353
  return { status, groupId: null };
17024
17354
  }
@@ -17032,14 +17362,14 @@ class FFIRenderLib {
17032
17362
  return this.opentui.symbols.audioSetMasterVolume(engine, volume);
17033
17363
  }
17034
17364
  audioMixToBuffer(engine, outBuffer, frameCount, channels) {
17035
- return this.opentui.symbols.audioMixToBuffer(engine, ptr(outBuffer), frameCount, channels);
17365
+ return this.opentui.symbols.audioMixToBuffer(engine, outBuffer, frameCount, channels);
17036
17366
  }
17037
17367
  audioEnableTap(engine, enabled, capacityFrames) {
17038
17368
  return this.opentui.symbols.audioEnableTap(engine, ffiBool(enabled), capacityFrames);
17039
17369
  }
17040
17370
  audioReadTap(engine, outBuffer, frameCount, channels) {
17041
17371
  const outFramesReadBuffer = new ArrayBuffer(4);
17042
- const status = this.opentui.symbols.audioReadTap(engine, ptr(outBuffer), frameCount, channels, ptr(outFramesReadBuffer));
17372
+ const status = this.opentui.symbols.audioReadTap(engine, outBuffer, frameCount, channels, outFramesReadBuffer);
17043
17373
  if (status !== 0) {
17044
17374
  return { status, framesRead: 0 };
17045
17375
  }
@@ -17048,7 +17378,7 @@ class FFIRenderLib {
17048
17378
  }
17049
17379
  audioGetStats(engine) {
17050
17380
  const statsBuffer = new ArrayBuffer(AudioStatsStruct.size);
17051
- const status = this.opentui.symbols.audioGetStats(engine, ptr(statsBuffer));
17381
+ const status = this.opentui.symbols.audioGetStats(engine, statsBuffer);
17052
17382
  if (status !== 0) {
17053
17383
  return null;
17054
17384
  }
@@ -17073,7 +17403,7 @@ class FFIRenderLib {
17073
17403
  }
17074
17404
  createNativeSpanFeed(options) {
17075
17405
  const optionsBuffer = options == null ? null : NativeSpanFeedOptionsStruct.pack(options);
17076
- const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ? ptr(optionsBuffer) : null);
17406
+ const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer);
17077
17407
  if (!streamPtr) {
17078
17408
  throw new Error("Failed to create stream");
17079
17409
  }
@@ -17088,13 +17418,13 @@ class FFIRenderLib {
17088
17418
  }
17089
17419
  streamWrite(stream, data) {
17090
17420
  const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
17091
- return this.opentui.symbols.streamWrite(stream, ptrOrNull(bytes), bytes.byteLength);
17421
+ return this.opentui.symbols.streamWrite(stream, viewOrNull(bytes), bytes.byteLength);
17092
17422
  }
17093
17423
  streamCommit(stream) {
17094
17424
  return this.opentui.symbols.streamCommit(stream);
17095
17425
  }
17096
17426
  streamDrainSpans(stream, outBuffer, maxSpans) {
17097
- const count = this.opentui.symbols.streamDrainSpans(stream, ptr(outBuffer), maxSpans);
17427
+ const count = this.opentui.symbols.streamDrainSpans(stream, outBuffer, maxSpans);
17098
17428
  return toNumber(count);
17099
17429
  }
17100
17430
  streamClose(stream) {
@@ -17102,11 +17432,11 @@ class FFIRenderLib {
17102
17432
  }
17103
17433
  streamSetOptions(stream, options) {
17104
17434
  const optionsBuffer = NativeSpanFeedOptionsStruct.pack(options);
17105
- return this.opentui.symbols.streamSetOptions(stream, ptr(optionsBuffer));
17435
+ return this.opentui.symbols.streamSetOptions(stream, optionsBuffer);
17106
17436
  }
17107
17437
  streamGetStats(stream) {
17108
17438
  const statsBuffer = new ArrayBuffer(NativeSpanFeedStatsStruct.size);
17109
- const status = this.opentui.symbols.streamGetStats(stream, ptr(statsBuffer));
17439
+ const status = this.opentui.symbols.streamGetStats(stream, statsBuffer);
17110
17440
  if (status !== 0) {
17111
17441
  return null;
17112
17442
  }
@@ -17120,7 +17450,7 @@ class FFIRenderLib {
17120
17450
  }
17121
17451
  streamReserve(stream, minLen) {
17122
17452
  const reserveBuffer = new ArrayBuffer(ReserveInfoStruct.size);
17123
- const status = this.opentui.symbols.streamReserve(stream, minLen, ptr(reserveBuffer));
17453
+ const status = this.opentui.symbols.streamReserve(stream, minLen, reserveBuffer);
17124
17454
  if (status !== 0) {
17125
17455
  return { status, info: null };
17126
17456
  }
@@ -17141,13 +17471,13 @@ class FFIRenderLib {
17141
17471
  }
17142
17472
  syntaxStyleRegister(style, name, fg2, bg2, attributes) {
17143
17473
  const nameBytes = this.encoder.encode(name);
17144
- const fgPtr = optionalRgbaPtr(fg2);
17145
- const bgPtr = optionalRgbaPtr(bg2);
17146
- return this.opentui.symbols.syntaxStyleRegister(style, ptrOrNull(nameBytes), nameBytes.byteLength, fgPtr, bgPtr, attributes);
17474
+ const fgBuffer = optionalRgbaBuffer(fg2);
17475
+ const bgBuffer = optionalRgbaBuffer(bg2);
17476
+ return this.opentui.symbols.syntaxStyleRegister(style, viewOrNull(nameBytes), nameBytes.byteLength, fgBuffer, bgBuffer, attributes);
17147
17477
  }
17148
17478
  syntaxStyleResolveByName(style, name) {
17149
17479
  const nameBytes = this.encoder.encode(name);
17150
- const id = this.opentui.symbols.syntaxStyleResolveByName(style, ptrOrNull(nameBytes), nameBytes.byteLength);
17480
+ const id = this.opentui.symbols.syntaxStyleResolveByName(style, viewOrNull(nameBytes), nameBytes.byteLength);
17151
17481
  return id === 0 ? null : id;
17152
17482
  }
17153
17483
  syntaxStyleGetStyleCount(style) {
@@ -17245,7 +17575,7 @@ class FFIRenderLib {
17245
17575
  this.opentui.symbols.editorViewSetTabIndicator(view, indicator);
17246
17576
  }
17247
17577
  editorViewSetTabIndicatorColor(view, color) {
17248
- this.opentui.symbols.editorViewSetTabIndicatorColor(view, rgbaPtr(color));
17578
+ this.opentui.symbols.editorViewSetTabIndicatorColor(view, rgbaBuffer(color));
17249
17579
  }
17250
17580
  onNativeEvent(name, handler) {
17251
17581
  this._nativeEvents.on(name, handler);
@@ -18248,5 +18578,5 @@ var yoga_default = Yoga;
18248
18578
 
18249
18579
  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 };
18250
18580
 
18251
- //# debugId=4265DEC0A1B9AE8C64756E2164756E21
18252
- //# sourceMappingURL=chunk-node-crchpns1.js.map
18581
+ //# debugId=4B7BC8814EED9E3164756E2164756E21
18582
+ //# sourceMappingURL=chunk-node-267dafd8.js.map