@opentui/core 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NativeScene.d.ts +1 -1
- package/Renderable.d.ts +6 -0
- package/{chunk-bun-ywheza3e.js → chunk-bun-v1wzs0bj.js} +25 -12
- package/chunk-bun-v1wzs0bj.js.map +35 -0
- package/{chunk-bun-rgb7yx3r.js → chunk-bun-xartp4ps.js} +41 -19
- package/{chunk-bun-rgb7yx3r.js.map → chunk-bun-xartp4ps.js.map} +9 -9
- package/{chunk-node-fcberveq.js → chunk-node-5cqzgmq3.js} +41 -19
- package/{chunk-node-fcberveq.js.map → chunk-node-5cqzgmq3.js.map} +9 -9
- package/{chunk-node-k5s8s41v.js → chunk-node-mcdre3zn.js} +25 -12
- package/chunk-node-mcdre3zn.js.map +34 -0
- package/edit-buffer.d.ts +7 -1
- package/index.bun.js +108 -4
- package/index.bun.js.map +3 -3
- package/index.node.js +108 -4
- package/index.node.js.map +3 -3
- package/native-abi.generated.d.ts +9 -1
- package/package.json +9 -9
- package/renderables/TextBufferRenderable.d.ts +2 -0
- package/renderables/TextTable.d.ts +16 -0
- package/testing.bun.js +2 -2
- package/testing.js +2 -2
- package/text-buffer-view.d.ts +4 -0
- package/text-buffer.d.ts +12 -1
- package/yoga.bun.js +1 -1
- package/yoga.js +1 -1
- package/zig.d.ts +4 -1
- package/chunk-bun-ywheza3e.js.map +0 -35
- package/chunk-node-k5s8s41v.js.map +0 -34
package/index.node.js
CHANGED
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
Gutter2,
|
|
111
111
|
MeasureMode2,
|
|
112
112
|
exports_yoga
|
|
113
|
-
} from "./chunk-node-
|
|
113
|
+
} from "./chunk-node-mcdre3zn.js";
|
|
114
114
|
import {
|
|
115
115
|
isValidBorderStyle2,
|
|
116
116
|
parseBorderStyle2,
|
|
@@ -243,7 +243,7 @@ import {
|
|
|
243
243
|
CliRenderEvents2,
|
|
244
244
|
RendererControlState2,
|
|
245
245
|
CliRenderer2
|
|
246
|
-
} from "./chunk-node-
|
|
246
|
+
} from "./chunk-node-5cqzgmq3.js";
|
|
247
247
|
// src/syntax-style.ts
|
|
248
248
|
var attributeNames = ["bold", "italic", "underline", "dim", "strikethrough"];
|
|
249
249
|
function cloneStyle(style) {
|
|
@@ -9545,6 +9545,12 @@ var MEASURE_HEIGHT = 1e4;
|
|
|
9545
9545
|
|
|
9546
9546
|
class TextTableRenderable extends Renderable2 {
|
|
9547
9547
|
_content;
|
|
9548
|
+
_cellWidthMethod;
|
|
9549
|
+
_selectionInCells = false;
|
|
9550
|
+
_pressedCell = null;
|
|
9551
|
+
_pressPinned = false;
|
|
9552
|
+
_pressAnchor = null;
|
|
9553
|
+
_pressMoved = false;
|
|
9548
9554
|
_wrapMode;
|
|
9549
9555
|
_columnWidthMode;
|
|
9550
9556
|
_columnFitter;
|
|
@@ -9625,10 +9631,35 @@ class TextTableRenderable extends Renderable2 {
|
|
|
9625
9631
|
this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
|
|
9626
9632
|
this.setupMeasureFunc();
|
|
9627
9633
|
this.runMutation(() => this.rebuildCells(this._content));
|
|
9634
|
+
this.setBuiltinLifecyclePass(() => {
|
|
9635
|
+
if (this._ctx.widthMethod !== this._cellWidthMethod)
|
|
9636
|
+
this.runMutation(() => this.followWidthMethod());
|
|
9637
|
+
});
|
|
9628
9638
|
} catch (error) {
|
|
9629
9639
|
this.abortConstruction(error, () => this.destroyCells());
|
|
9630
9640
|
}
|
|
9631
9641
|
}
|
|
9642
|
+
followWidthMethod() {
|
|
9643
|
+
const method = this._ctx.widthMethod;
|
|
9644
|
+
const pressed = this._pressedCell && this._cells[this._pressedCell.rowIdx]?.[this._pressedCell.colIdx];
|
|
9645
|
+
const anchor = this._pressAnchor !== null && pressed ? TextBufferView2.create(pressed.textBuffer) : null;
|
|
9646
|
+
if (this._pressPinned)
|
|
9647
|
+
this._pressMoved = true;
|
|
9648
|
+
try {
|
|
9649
|
+
anchor?._selectCharacter(this._pressAnchor);
|
|
9650
|
+
for (const row of this._cells)
|
|
9651
|
+
for (const cell of row)
|
|
9652
|
+
cell.textBuffer.setWidthMethod(method);
|
|
9653
|
+
if (anchor)
|
|
9654
|
+
this._pressAnchor = anchor.getSelection()?.start ?? this._pressAnchor;
|
|
9655
|
+
} finally {
|
|
9656
|
+
anchor?.destroy();
|
|
9657
|
+
}
|
|
9658
|
+
this._cellWidthMethod = method;
|
|
9659
|
+
if (this._lastLocalSelection?.isActive)
|
|
9660
|
+
this._selectionInCells = true;
|
|
9661
|
+
this.invalidateLayout();
|
|
9662
|
+
}
|
|
9632
9663
|
get content() {
|
|
9633
9664
|
return this._content;
|
|
9634
9665
|
}
|
|
@@ -9795,9 +9826,14 @@ class TextTableRenderable extends Renderable2 {
|
|
|
9795
9826
|
this.ensureLayoutReady();
|
|
9796
9827
|
const localSelection = convertGlobalToLocalSelection2(selection, Math.trunc(this.x), Math.trunc(this.y));
|
|
9797
9828
|
this._lastLocalSelection = localSelection;
|
|
9829
|
+
this._selectionInCells = false;
|
|
9798
9830
|
if (!localSelection?.isActive) {
|
|
9799
9831
|
this.resetCellSelections();
|
|
9800
9832
|
this._lastSelectionMode = null;
|
|
9833
|
+
this._pressedCell = null;
|
|
9834
|
+
this._pressPinned = false;
|
|
9835
|
+
this._pressAnchor = null;
|
|
9836
|
+
this._pressMoved = false;
|
|
9801
9837
|
} else {
|
|
9802
9838
|
this.applySelectionToCells(localSelection, selection?.isStart ?? false);
|
|
9803
9839
|
}
|
|
@@ -9921,6 +9957,13 @@ class TextTableRenderable extends Renderable2 {
|
|
|
9921
9957
|
cells.push(previous[rowIdx]?.slice(0, newColumnCount) ?? []);
|
|
9922
9958
|
}
|
|
9923
9959
|
assertCurrent();
|
|
9960
|
+
if (this._cellWidthMethod !== undefined && this._cellWidthMethod !== this._ctx.widthMethod)
|
|
9961
|
+
this.followWidthMethod();
|
|
9962
|
+
const kept = this._selectionInCells ? changes.flatMap(({ row, col }) => {
|
|
9963
|
+
const cell = previous[row]?.[col];
|
|
9964
|
+
const range = cell?.textBufferView.getSelection();
|
|
9965
|
+
return cell && range ? [{ row, col, range, text: cell.textBuffer.getPlainText() }] : [];
|
|
9966
|
+
}) : [];
|
|
9924
9967
|
const reused = newRowCount === this._rowCount && newColumnCount === this._columnCount && TextBuffer2._replaceStyledTextBatch(changes.map(({ row, col, text }) => ({ ...previous[row][col], text })), assertCurrent);
|
|
9925
9968
|
try {
|
|
9926
9969
|
if (!reused) {
|
|
@@ -9947,6 +9990,13 @@ class TextTableRenderable extends Renderable2 {
|
|
|
9947
9990
|
this._prevCellContent = refs;
|
|
9948
9991
|
this._rowCount = newRowCount;
|
|
9949
9992
|
this._columnCount = newColumnCount;
|
|
9993
|
+
this._cellWidthMethod = this._ctx.widthMethod;
|
|
9994
|
+
for (const { row, col, range, text } of kept) {
|
|
9995
|
+
const cell = cells[row][col];
|
|
9996
|
+
if (cell.textBuffer.getPlainText() === text) {
|
|
9997
|
+
cell.textBufferView.setSelection(range.start, range.end, this._selectionBg, this._selectionFg);
|
|
9998
|
+
}
|
|
9999
|
+
}
|
|
9950
10000
|
this.runCleanup((run) => {
|
|
9951
10001
|
run(() => this.invalidateLayout());
|
|
9952
10002
|
for (let rowIdx = 0;rowIdx < previous.length; rowIdx++) {
|
|
@@ -10018,7 +10068,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10018
10068
|
this._layout = layout;
|
|
10019
10069
|
this.applyLayoutToViews(layout);
|
|
10020
10070
|
this._layoutDirty = false;
|
|
10021
|
-
if (this._lastLocalSelection?.isActive) {
|
|
10071
|
+
if (this._lastLocalSelection?.isActive && !this._selectionInCells) {
|
|
10022
10072
|
this.applySelectionToCells(this._lastLocalSelection, true);
|
|
10023
10073
|
}
|
|
10024
10074
|
}
|
|
@@ -10321,9 +10371,23 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10321
10371
|
return { rowIdx, colIdx };
|
|
10322
10372
|
}
|
|
10323
10373
|
applySelectionToCells(localSelection, isStart) {
|
|
10374
|
+
if (this._pressMoved && !isStart && this._pressedCell)
|
|
10375
|
+
localSelection = { ...localSelection, ...this.movedAnchor() };
|
|
10324
10376
|
if (localSelection.anchorX === localSelection.focusX && localSelection.anchorY === localSelection.focusY) {
|
|
10325
10377
|
this.resetCellSelections();
|
|
10326
10378
|
this._lastSelectionMode = null;
|
|
10379
|
+
if (isStart) {
|
|
10380
|
+
this._pressAnchor = null;
|
|
10381
|
+
this._pressMoved = false;
|
|
10382
|
+
}
|
|
10383
|
+
this._pressedCell = this.getCellAtLocalPosition(localSelection.anchorX, localSelection.anchorY);
|
|
10384
|
+
this._pressPinned = this._pressedCell !== null;
|
|
10385
|
+
if (this._pressedCell) {
|
|
10386
|
+
const { rowIdx, colIdx } = this._pressedCell;
|
|
10387
|
+
const x = localSelection.anchorX - ((this._layout.columnOffsets[colIdx] ?? 0) + 1 + this._cellPaddingX);
|
|
10388
|
+
const y = localSelection.anchorY - ((this._layout.rowOffsets[rowIdx] ?? 0) + 1 + this._cellPaddingY);
|
|
10389
|
+
this._cells[rowIdx][colIdx].textBufferView.setLocalSelection(x, y, x, y, this._selectionBg, this._selectionFg);
|
|
10390
|
+
}
|
|
10327
10391
|
return;
|
|
10328
10392
|
}
|
|
10329
10393
|
const minSelY = Math.min(localSelection.anchorY, localSelection.focusY);
|
|
@@ -10364,6 +10428,9 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10364
10428
|
if (forceSet) {
|
|
10365
10429
|
coords = this.getFullCellSelectionCoords(rowIdx, colIdx);
|
|
10366
10430
|
}
|
|
10431
|
+
if (isAnchorCell && forceSet && this._pressPinned && this._pressAnchor === null) {
|
|
10432
|
+
this._pressAnchor = this.pressOffset(cell.textBufferView);
|
|
10433
|
+
}
|
|
10367
10434
|
const shouldUseSet = isStart || modeChanged || forceSet;
|
|
10368
10435
|
if (shouldUseSet) {
|
|
10369
10436
|
cell.textBufferView.setLocalSelection(coords.anchorX, coords.anchorY, coords.focusX, coords.focusY, this._selectionBg, this._selectionFg);
|
|
@@ -10373,6 +10440,43 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10373
10440
|
}
|
|
10374
10441
|
}
|
|
10375
10442
|
}
|
|
10443
|
+
movedAnchor() {
|
|
10444
|
+
const { rowIdx, colIdx } = this._pressedCell;
|
|
10445
|
+
const view = this._cells[rowIdx][colIdx].textBufferView;
|
|
10446
|
+
const offset = this._pressAnchor ?? this.pressOffset(view);
|
|
10447
|
+
this._pressAnchor = offset;
|
|
10448
|
+
const colors = [this._selectionBg, this._selectionFg];
|
|
10449
|
+
let y = 0;
|
|
10450
|
+
for (let row = 1;row < view.getVirtualLineCount(); row++) {
|
|
10451
|
+
view.setLocalSelection(0, row, 0, 1 << 20, ...colors);
|
|
10452
|
+
const start = view.getSelection()?.start;
|
|
10453
|
+
if (start === undefined || start > offset)
|
|
10454
|
+
break;
|
|
10455
|
+
y = row;
|
|
10456
|
+
}
|
|
10457
|
+
let [low, high] = [0, Math.max(0, (this._layout.columnWidths[colIdx] ?? 0) - this._cellPaddingX * 2)];
|
|
10458
|
+
while (low < high) {
|
|
10459
|
+
const middle = low + high >> 1;
|
|
10460
|
+
view.setLocalSelection(0, y, middle, y, ...colors);
|
|
10461
|
+
if ((view.getSelection()?.end ?? 0) > offset)
|
|
10462
|
+
high = middle;
|
|
10463
|
+
else
|
|
10464
|
+
low = middle + 1;
|
|
10465
|
+
}
|
|
10466
|
+
this._lastSelectionMode = null;
|
|
10467
|
+
return {
|
|
10468
|
+
anchorX: (this._layout.columnOffsets[colIdx] ?? 0) + 1 + this._cellPaddingX + low,
|
|
10469
|
+
anchorY: (this._layout.rowOffsets[rowIdx] ?? 0) + 1 + this._cellPaddingY + y
|
|
10470
|
+
};
|
|
10471
|
+
}
|
|
10472
|
+
pressOffset(view) {
|
|
10473
|
+
view.updateLocalSelection(0, 0, 0, 1 << 20, this._selectionBg, this._selectionFg);
|
|
10474
|
+
const below = view.getSelection();
|
|
10475
|
+
if (below)
|
|
10476
|
+
return below.start;
|
|
10477
|
+
view.updateLocalSelection(0, 0, 0, -1, this._selectionBg, this._selectionFg);
|
|
10478
|
+
return view.getSelection()?.end ?? 0;
|
|
10479
|
+
}
|
|
10376
10480
|
resolveSelectionResolution(localSelection) {
|
|
10377
10481
|
const anchorCell = this.getCellAtLocalPosition(localSelection.anchorX, localSelection.anchorY);
|
|
10378
10482
|
const focusCell = this.getCellAtLocalPosition(localSelection.focusX, localSelection.focusY);
|
|
@@ -12773,5 +12877,5 @@ export {
|
|
|
12773
12877
|
yellow2 as yellow
|
|
12774
12878
|
};
|
|
12775
12879
|
|
|
12776
|
-
//# debugId=
|
|
12880
|
+
//# debugId=655542861EC1EED564756E2164756E21
|
|
12777
12881
|
//# sourceMappingURL=index.node.js.map
|