@opentui/core 0.4.2 → 0.4.3
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/Renderable.d.ts +2 -7
- package/{index-x7n320jr.js → index-d5xqskty.js} +152 -68
- package/index-d5xqskty.js.map +58 -0
- package/{index-6xr3rbbe.js → index-xt9f071j.js} +147 -136
- package/{index-6xr3rbbe.js.map → index-xt9f071j.js.map} +8 -8
- package/index.js +55 -32
- package/index.js.map +7 -7
- package/package.json +10 -10
- package/renderables/EditBufferRenderable.d.ts +2 -1
- package/renderables/LineNumberRenderable.d.ts +2 -2
- package/renderables/ScrollBox.d.ts +3 -2
- package/renderables/Select.d.ts +5 -0
- package/renderables/Text.d.ts +1 -1
- package/renderables/TextBufferRenderable.d.ts +3 -2
- package/renderables/TextNode.d.ts +2 -1
- package/testing.js +2 -2
- package/yoga.d.ts +1 -4
- package/yoga.js +1 -1
- package/zig-structs.d.ts +3 -3
- package/zig.d.ts +17 -3
- package/index-x7n320jr.js.map +0 -58
package/index.js
CHANGED
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
mergeKeyAliases,
|
|
44
44
|
mergeKeyBindings,
|
|
45
45
|
wrapWithDelegates
|
|
46
|
-
} from "./index-
|
|
46
|
+
} from "./index-xt9f071j.js";
|
|
47
47
|
import {
|
|
48
48
|
ASCIIFontSelectionHelper,
|
|
49
49
|
ATTRIBUTE_BASE_BITS,
|
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
LogLevel,
|
|
65
65
|
MacOSScrollAccel,
|
|
66
66
|
MouseParser,
|
|
67
|
+
NativeMeasureTargetKind,
|
|
67
68
|
OptimizedBuffer,
|
|
68
69
|
PasteEvent,
|
|
69
70
|
RGBA,
|
|
@@ -184,7 +185,7 @@ import {
|
|
|
184
185
|
visualizeRenderableTree,
|
|
185
186
|
white,
|
|
186
187
|
yellow
|
|
187
|
-
} from "./index-
|
|
188
|
+
} from "./index-d5xqskty.js";
|
|
188
189
|
// src/post/effects.ts
|
|
189
190
|
function toU8(value) {
|
|
190
191
|
return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
|
|
@@ -2431,7 +2432,7 @@ class SlotRenderable extends Renderable {
|
|
|
2431
2432
|
}
|
|
2432
2433
|
_detachNodeFromMount(node) {
|
|
2433
2434
|
if (node.parent === this) {
|
|
2434
|
-
this.remove(node
|
|
2435
|
+
this.remove(node);
|
|
2435
2436
|
}
|
|
2436
2437
|
}
|
|
2437
2438
|
_cleanupInactivePluginNodes(nextActivePluginIds, registeredPluginIds) {
|
|
@@ -2504,7 +2505,7 @@ class SlotRenderable extends Renderable {
|
|
|
2504
2505
|
for (const node of this._mountedNodes) {
|
|
2505
2506
|
if (!desiredNodeSet.has(node)) {
|
|
2506
2507
|
if (node.parent === this) {
|
|
2507
|
-
this.remove(node
|
|
2508
|
+
this.remove(node);
|
|
2508
2509
|
}
|
|
2509
2510
|
}
|
|
2510
2511
|
}
|
|
@@ -2515,7 +2516,7 @@ class SlotRenderable extends Renderable {
|
|
|
2515
2516
|
continue;
|
|
2516
2517
|
}
|
|
2517
2518
|
const childAtIndex = this.getChildren()[index];
|
|
2518
|
-
if (childAtIndex
|
|
2519
|
+
if (childAtIndex !== node) {
|
|
2519
2520
|
this.add(node, index);
|
|
2520
2521
|
}
|
|
2521
2522
|
}
|
|
@@ -3435,10 +3436,10 @@ class LineNumberRenderable extends Renderable {
|
|
|
3435
3436
|
return;
|
|
3436
3437
|
if (this.target) {
|
|
3437
3438
|
this.target.off("line-info-change", this.handleLineInfoChange);
|
|
3438
|
-
super.remove(this.target
|
|
3439
|
+
super.remove(this.target);
|
|
3439
3440
|
}
|
|
3440
3441
|
if (this.gutter) {
|
|
3441
|
-
super.remove(this.gutter
|
|
3442
|
+
super.remove(this.gutter);
|
|
3442
3443
|
this.gutter = null;
|
|
3443
3444
|
}
|
|
3444
3445
|
this.target = target;
|
|
@@ -3467,18 +3468,18 @@ class LineNumberRenderable extends Renderable {
|
|
|
3467
3468
|
}
|
|
3468
3469
|
return -1;
|
|
3469
3470
|
}
|
|
3470
|
-
remove(
|
|
3471
|
+
remove(child) {
|
|
3471
3472
|
if (this._isDestroying) {
|
|
3472
|
-
super.remove(
|
|
3473
|
+
super.remove(child);
|
|
3473
3474
|
return;
|
|
3474
3475
|
}
|
|
3475
|
-
if (this.gutter &&
|
|
3476
|
+
if (this.gutter && child === this.gutter) {
|
|
3476
3477
|
throw new Error("LineNumberRenderable: Cannot remove gutter directly.");
|
|
3477
3478
|
}
|
|
3478
|
-
if (this.target &&
|
|
3479
|
+
if (this.target && child === this.target) {
|
|
3479
3480
|
throw new Error("LineNumberRenderable: Cannot remove target directly. Use clearTarget() instead.");
|
|
3480
3481
|
}
|
|
3481
|
-
super.remove(
|
|
3482
|
+
super.remove(child);
|
|
3482
3483
|
}
|
|
3483
3484
|
destroyRecursively() {
|
|
3484
3485
|
this._isDestroying = true;
|
|
@@ -3492,11 +3493,11 @@ class LineNumberRenderable extends Renderable {
|
|
|
3492
3493
|
clearTarget() {
|
|
3493
3494
|
if (this.target) {
|
|
3494
3495
|
this.target.off("line-info-change", this.handleLineInfoChange);
|
|
3495
|
-
super.remove(this.target
|
|
3496
|
+
super.remove(this.target);
|
|
3496
3497
|
this.target = null;
|
|
3497
3498
|
}
|
|
3498
3499
|
if (this.gutter) {
|
|
3499
|
-
super.remove(this.gutter
|
|
3500
|
+
super.remove(this.gutter);
|
|
3500
3501
|
this.gutter = null;
|
|
3501
3502
|
}
|
|
3502
3503
|
}
|
|
@@ -4209,11 +4210,11 @@ class DiffRenderable extends Renderable {
|
|
|
4209
4210
|
buildErrorView() {
|
|
4210
4211
|
this.flexDirection = "column";
|
|
4211
4212
|
if (this.leftSide && this.leftSideAdded) {
|
|
4212
|
-
super.remove(this.leftSide
|
|
4213
|
+
super.remove(this.leftSide);
|
|
4213
4214
|
this.leftSideAdded = false;
|
|
4214
4215
|
}
|
|
4215
4216
|
if (this.rightSide && this.rightSideAdded) {
|
|
4216
|
-
super.remove(this.rightSide
|
|
4217
|
+
super.remove(this.rightSide);
|
|
4217
4218
|
this.rightSideAdded = false;
|
|
4218
4219
|
}
|
|
4219
4220
|
const errorMessage = `Error parsing diff: ${this._parseError?.message || "Unknown error"}
|
|
@@ -4361,13 +4362,13 @@ class DiffRenderable extends Renderable {
|
|
|
4361
4362
|
if (this.errorTextRenderable) {
|
|
4362
4363
|
const errorTextIndex = this.getChildren().indexOf(this.errorTextRenderable);
|
|
4363
4364
|
if (errorTextIndex !== -1) {
|
|
4364
|
-
super.remove(this.errorTextRenderable
|
|
4365
|
+
super.remove(this.errorTextRenderable);
|
|
4365
4366
|
}
|
|
4366
4367
|
}
|
|
4367
4368
|
if (this.errorCodeRenderable) {
|
|
4368
4369
|
const errorCodeIndex = this.getChildren().indexOf(this.errorCodeRenderable);
|
|
4369
4370
|
if (errorCodeIndex !== -1) {
|
|
4370
|
-
super.remove(this.errorCodeRenderable
|
|
4371
|
+
super.remove(this.errorCodeRenderable);
|
|
4371
4372
|
}
|
|
4372
4373
|
}
|
|
4373
4374
|
const contentLines = [];
|
|
@@ -4442,7 +4443,7 @@ class DiffRenderable extends Renderable {
|
|
|
4442
4443
|
this.attachLineInfoListeners();
|
|
4443
4444
|
this.createOrUpdateSide("left", codeRenderable, lineColors, lineSigns, lineNumbers, new Set, "100%");
|
|
4444
4445
|
if (this.rightSide && this.rightSideAdded) {
|
|
4445
|
-
super.remove(this.rightSide
|
|
4446
|
+
super.remove(this.rightSide);
|
|
4446
4447
|
this.rightSideAdded = false;
|
|
4447
4448
|
}
|
|
4448
4449
|
}
|
|
@@ -4453,13 +4454,13 @@ class DiffRenderable extends Renderable {
|
|
|
4453
4454
|
if (this.errorTextRenderable) {
|
|
4454
4455
|
const errorTextIndex = this.getChildren().indexOf(this.errorTextRenderable);
|
|
4455
4456
|
if (errorTextIndex !== -1) {
|
|
4456
|
-
super.remove(this.errorTextRenderable
|
|
4457
|
+
super.remove(this.errorTextRenderable);
|
|
4457
4458
|
}
|
|
4458
4459
|
}
|
|
4459
4460
|
if (this.errorCodeRenderable) {
|
|
4460
4461
|
const errorCodeIndex = this.getChildren().indexOf(this.errorCodeRenderable);
|
|
4461
4462
|
if (errorCodeIndex !== -1) {
|
|
4462
|
-
super.remove(this.errorCodeRenderable
|
|
4463
|
+
super.remove(this.errorCodeRenderable);
|
|
4463
4464
|
}
|
|
4464
4465
|
}
|
|
4465
4466
|
const leftLogicalLines = [];
|
|
@@ -10375,12 +10376,19 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
10375
10376
|
insertBefore(obj, anchor) {
|
|
10376
10377
|
return this.content.insertBefore(obj, anchor);
|
|
10377
10378
|
}
|
|
10378
|
-
remove(
|
|
10379
|
-
this
|
|
10379
|
+
remove(child) {
|
|
10380
|
+
if (child.parent === this) {
|
|
10381
|
+
super.remove(child);
|
|
10382
|
+
return;
|
|
10383
|
+
}
|
|
10384
|
+
this.content.remove(child);
|
|
10380
10385
|
}
|
|
10381
10386
|
getChildren() {
|
|
10382
10387
|
return this.content.getChildren();
|
|
10383
10388
|
}
|
|
10389
|
+
getRenderable(id) {
|
|
10390
|
+
return this.content.getRenderable(id);
|
|
10391
|
+
}
|
|
10384
10392
|
onMouseEvent(event) {
|
|
10385
10393
|
if (event.type === "scroll") {
|
|
10386
10394
|
let dir = event.scroll?.direction;
|
|
@@ -10701,6 +10709,7 @@ class SelectRenderable extends Renderable {
|
|
|
10701
10709
|
_showScrollIndicator;
|
|
10702
10710
|
_wrapSelection;
|
|
10703
10711
|
_showDescription;
|
|
10712
|
+
_showSelectionIndicator;
|
|
10704
10713
|
_font;
|
|
10705
10714
|
_itemSpacing;
|
|
10706
10715
|
linesPerItem;
|
|
@@ -10722,6 +10731,7 @@ class SelectRenderable extends Renderable {
|
|
|
10722
10731
|
showScrollIndicator: false,
|
|
10723
10732
|
wrapSelection: false,
|
|
10724
10733
|
showDescription: true,
|
|
10734
|
+
showSelectionIndicator: true,
|
|
10725
10735
|
itemSpacing: 0,
|
|
10726
10736
|
fastScrollStep: 5
|
|
10727
10737
|
};
|
|
@@ -10737,6 +10747,7 @@ class SelectRenderable extends Renderable {
|
|
|
10737
10747
|
this._showScrollIndicator = options.showScrollIndicator ?? this._defaultOptions.showScrollIndicator;
|
|
10738
10748
|
this._wrapSelection = options.wrapSelection ?? this._defaultOptions.wrapSelection;
|
|
10739
10749
|
this._showDescription = options.showDescription ?? this._defaultOptions.showDescription;
|
|
10750
|
+
this._showSelectionIndicator = options.showSelectionIndicator ?? this._defaultOptions.showSelectionIndicator;
|
|
10740
10751
|
this._font = options.font;
|
|
10741
10752
|
this._itemSpacing = options.itemSpacing || this._defaultOptions.itemSpacing;
|
|
10742
10753
|
this.fontHeight = this._font ? measureText({ text: "A", font: this._font }).height : 1;
|
|
@@ -10785,29 +10796,30 @@ class SelectRenderable extends Renderable {
|
|
|
10785
10796
|
const contentHeight2 = this.linesPerItem - this._itemSpacing;
|
|
10786
10797
|
this.frameBuffer.fillRect(contentX, itemY, contentWidth, contentHeight2, this._selectedBackgroundColor);
|
|
10787
10798
|
}
|
|
10788
|
-
const
|
|
10799
|
+
const indicator = this._showSelectionIndicator ? isSelected ? "▶ " : " " : "";
|
|
10800
|
+
const indicatorWidth = this._showSelectionIndicator ? 2 : 0;
|
|
10801
|
+
const nameContent = `${indicator}${option.name}`;
|
|
10789
10802
|
const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
|
|
10790
10803
|
const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
|
|
10791
|
-
|
|
10804
|
+
const textX = contentX + 1 + indicatorWidth;
|
|
10792
10805
|
if (this._font) {
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10806
|
+
if (indicator) {
|
|
10807
|
+
this.frameBuffer.drawText(indicator, contentX + 1, itemY, nameColor);
|
|
10808
|
+
}
|
|
10796
10809
|
renderFontToFrameBuffer(this.frameBuffer, {
|
|
10797
10810
|
text: option.name,
|
|
10798
|
-
x:
|
|
10811
|
+
x: textX,
|
|
10799
10812
|
y: itemY,
|
|
10800
10813
|
color: nameColor,
|
|
10801
10814
|
backgroundColor: isSelected ? this._selectedBackgroundColor : bgColor,
|
|
10802
10815
|
font: this._font
|
|
10803
10816
|
});
|
|
10804
|
-
descX = contentX + 1 + indicatorWidth;
|
|
10805
10817
|
} else {
|
|
10806
10818
|
this.frameBuffer.drawText(nameContent, contentX + 1, itemY, nameColor);
|
|
10807
10819
|
}
|
|
10808
10820
|
if (this._showDescription && itemY + this.fontHeight < contentY + contentHeight) {
|
|
10809
10821
|
const descColor = isSelected ? this._selectedDescriptionColor : this._descriptionColor;
|
|
10810
|
-
this.frameBuffer.drawText(option.description,
|
|
10822
|
+
this.frameBuffer.drawText(option.description, textX, itemY + this.fontHeight, descColor);
|
|
10811
10823
|
}
|
|
10812
10824
|
}
|
|
10813
10825
|
if (this._showScrollIndicator && this._options.length > this.maxVisibleItems) {
|
|
@@ -10937,6 +10949,16 @@ class SelectRenderable extends Renderable {
|
|
|
10937
10949
|
this.requestRender();
|
|
10938
10950
|
}
|
|
10939
10951
|
}
|
|
10952
|
+
get showSelectionIndicator() {
|
|
10953
|
+
return this._showSelectionIndicator;
|
|
10954
|
+
}
|
|
10955
|
+
set showSelectionIndicator(show) {
|
|
10956
|
+
const next = show ?? this._defaultOptions.showSelectionIndicator;
|
|
10957
|
+
if (this._showSelectionIndicator !== next) {
|
|
10958
|
+
this._showSelectionIndicator = next;
|
|
10959
|
+
this.requestRender();
|
|
10960
|
+
}
|
|
10961
|
+
}
|
|
10940
10962
|
get wrapSelection() {
|
|
10941
10963
|
return this._wrapSelection;
|
|
10942
10964
|
}
|
|
@@ -11622,6 +11644,7 @@ export {
|
|
|
11622
11644
|
PROTANOPIA_COMP_MATRIX,
|
|
11623
11645
|
OptimizedBuffer,
|
|
11624
11646
|
NativeSpanFeed,
|
|
11647
|
+
NativeMeasureTargetKind,
|
|
11625
11648
|
MouseParser,
|
|
11626
11649
|
MouseEvent,
|
|
11627
11650
|
MouseButton,
|
|
@@ -11682,5 +11705,5 @@ export {
|
|
|
11682
11705
|
ACHROMATOPSIA_MATRIX
|
|
11683
11706
|
};
|
|
11684
11707
|
|
|
11685
|
-
//# debugId=
|
|
11708
|
+
//# debugId=9FCFC4351B1344F964756E2164756E21
|
|
11686
11709
|
//# sourceMappingURL=index.js.map
|