@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
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
Clipboard,
|
|
3
3
|
InternalKeyHandler,
|
|
4
4
|
KeyHandler,
|
|
5
|
+
NativeMeasureTargetKind,
|
|
5
6
|
OptimizedBuffer,
|
|
6
7
|
RGBA,
|
|
7
8
|
Selection,
|
|
@@ -39,7 +40,7 @@ import {
|
|
|
39
40
|
toArrayBuffer,
|
|
40
41
|
treeSitterToTextChunks,
|
|
41
42
|
yoga_default
|
|
42
|
-
} from "./index-
|
|
43
|
+
} from "./index-d5xqskty.js";
|
|
43
44
|
|
|
44
45
|
// src/Renderable.ts
|
|
45
46
|
import { EventEmitter } from "events";
|
|
@@ -122,8 +123,6 @@ var BrandedRenderable = Symbol.for("@opentui/core/Renderable");
|
|
|
122
123
|
var LayoutEvents;
|
|
123
124
|
((LayoutEvents2) => {
|
|
124
125
|
LayoutEvents2["LAYOUT_CHANGED"] = "layout-changed";
|
|
125
|
-
LayoutEvents2["ADDED"] = "added";
|
|
126
|
-
LayoutEvents2["REMOVED"] = "removed";
|
|
127
126
|
LayoutEvents2["RESIZED"] = "resized";
|
|
128
127
|
})(LayoutEvents ||= {});
|
|
129
128
|
var RenderableEvents;
|
|
@@ -226,7 +225,6 @@ class Renderable extends BaseRenderable {
|
|
|
226
225
|
_position = {};
|
|
227
226
|
_opacity = 1;
|
|
228
227
|
_flexShrink = 1;
|
|
229
|
-
renderableMapById = new Map;
|
|
230
228
|
_childrenInLayoutOrder = [];
|
|
231
229
|
_childrenInZIndexOrder = [];
|
|
232
230
|
needsZIndexSort = false;
|
|
@@ -267,16 +265,6 @@ class Renderable extends BaseRenderable {
|
|
|
267
265
|
this.createFrameBuffer();
|
|
268
266
|
}
|
|
269
267
|
}
|
|
270
|
-
get id() {
|
|
271
|
-
return this._id;
|
|
272
|
-
}
|
|
273
|
-
set id(value) {
|
|
274
|
-
if (this.parent) {
|
|
275
|
-
this.parent.renderableMapById.delete(this.id);
|
|
276
|
-
this.parent.renderableMapById.set(value, this);
|
|
277
|
-
}
|
|
278
|
-
super.id = value;
|
|
279
|
-
}
|
|
280
268
|
get focusable() {
|
|
281
269
|
return this._focusable;
|
|
282
270
|
}
|
|
@@ -982,7 +970,7 @@ class Renderable extends BaseRenderable {
|
|
|
982
970
|
}
|
|
983
971
|
replaceParent(obj) {
|
|
984
972
|
if (obj.parent) {
|
|
985
|
-
obj.parent.remove(obj
|
|
973
|
+
obj.parent.remove(obj);
|
|
986
974
|
}
|
|
987
975
|
obj.parent = this;
|
|
988
976
|
}
|
|
@@ -1010,7 +998,6 @@ class Renderable extends BaseRenderable {
|
|
|
1010
998
|
} else {
|
|
1011
999
|
this.replaceParent(renderable);
|
|
1012
1000
|
this.needsZIndexSort = true;
|
|
1013
|
-
this.renderableMapById.set(renderable.id, renderable);
|
|
1014
1001
|
this._childrenInZIndexOrder.push(renderable);
|
|
1015
1002
|
if (typeof renderable.onLifecyclePass === "function") {
|
|
1016
1003
|
this._ctx.registerLifecyclePass(renderable);
|
|
@@ -1055,13 +1042,13 @@ class Renderable extends BaseRenderable {
|
|
|
1055
1042
|
}
|
|
1056
1043
|
return -1;
|
|
1057
1044
|
}
|
|
1058
|
-
if (
|
|
1045
|
+
if (this._childrenInLayoutOrder.indexOf(anchor) === -1) {
|
|
1059
1046
|
if (true) {
|
|
1060
1047
|
console.warn(`Anchor with id ${anchor.id} does not exist within the parent ${this.id}, skipping insertBefore`);
|
|
1061
1048
|
}
|
|
1062
1049
|
return -1;
|
|
1063
1050
|
}
|
|
1064
|
-
if (renderable === anchor
|
|
1051
|
+
if (renderable === anchor) {
|
|
1065
1052
|
if (true) {
|
|
1066
1053
|
console.warn(`Anchor is the same as the node ${renderable.id} being inserted, skipping insertBefore`);
|
|
1067
1054
|
}
|
|
@@ -1073,7 +1060,6 @@ class Renderable extends BaseRenderable {
|
|
|
1073
1060
|
} else {
|
|
1074
1061
|
this.replaceParent(renderable);
|
|
1075
1062
|
this.needsZIndexSort = true;
|
|
1076
|
-
this.renderableMapById.set(renderable.id, renderable);
|
|
1077
1063
|
this._childrenInZIndexOrder.push(renderable);
|
|
1078
1064
|
if (typeof renderable.onLifecyclePass === "function") {
|
|
1079
1065
|
this._ctx.registerLifecyclePass(renderable);
|
|
@@ -1093,37 +1079,36 @@ class Renderable extends BaseRenderable {
|
|
|
1093
1079
|
return insertedIndex;
|
|
1094
1080
|
}
|
|
1095
1081
|
getRenderable(id) {
|
|
1096
|
-
return this.
|
|
1082
|
+
return this._childrenInLayoutOrder.find((child) => child.id === id);
|
|
1097
1083
|
}
|
|
1098
|
-
remove(
|
|
1099
|
-
if (!
|
|
1100
|
-
|
|
1084
|
+
remove(child) {
|
|
1085
|
+
if (!(child instanceof BaseRenderable)) {
|
|
1086
|
+
throw new Error("remove expects a renderable child object");
|
|
1101
1087
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
if (
|
|
1105
|
-
|
|
1106
|
-
this.propagateLiveCount(-obj._liveCount);
|
|
1107
|
-
}
|
|
1108
|
-
const childLayoutNode = obj.getLayoutNode();
|
|
1109
|
-
this.yogaNode.removeChild(childLayoutNode);
|
|
1110
|
-
this.requestRender();
|
|
1111
|
-
obj.onRemove();
|
|
1112
|
-
obj.parent = null;
|
|
1113
|
-
this._ctx.unregisterLifecyclePass(obj);
|
|
1114
|
-
this.renderableMapById.delete(id);
|
|
1115
|
-
const index = this._childrenInLayoutOrder.findIndex((obj2) => obj2.id === id);
|
|
1116
|
-
if (index !== -1) {
|
|
1117
|
-
this._childrenInLayoutOrder.splice(index, 1);
|
|
1118
|
-
}
|
|
1119
|
-
const zIndexIndex = this._childrenInZIndexOrder.findIndex((obj2) => obj2.id === id);
|
|
1120
|
-
if (zIndexIndex !== -1) {
|
|
1121
|
-
this._childrenInZIndexOrder.splice(zIndexIndex, 1);
|
|
1122
|
-
}
|
|
1123
|
-
this.childrenPrimarySortDirty = true;
|
|
1124
|
-
bumpRenderListRevision(this._ctx);
|
|
1088
|
+
const index = this._childrenInLayoutOrder.indexOf(child);
|
|
1089
|
+
if (index === -1) {
|
|
1090
|
+
if (true) {
|
|
1091
|
+
console.warn(`Renderable with id ${child.id} is not a child of ${this.id}, skipping remove`);
|
|
1125
1092
|
}
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
const renderable = this._childrenInLayoutOrder[index];
|
|
1096
|
+
if (renderable._liveCount > 0) {
|
|
1097
|
+
this.propagateLiveCount(-renderable._liveCount);
|
|
1126
1098
|
}
|
|
1099
|
+
this.yogaNode.removeChild(renderable.getLayoutNode());
|
|
1100
|
+
this._childrenInLayoutOrder.splice(index, 1);
|
|
1101
|
+
const zIndexIndex = this._childrenInZIndexOrder.indexOf(renderable);
|
|
1102
|
+
if (zIndexIndex !== -1) {
|
|
1103
|
+
this._childrenInZIndexOrder.splice(zIndexIndex, 1);
|
|
1104
|
+
}
|
|
1105
|
+
this._shouldUpdateBefore.delete(renderable);
|
|
1106
|
+
this.requestRender();
|
|
1107
|
+
renderable.onRemove();
|
|
1108
|
+
renderable.parent = null;
|
|
1109
|
+
this._ctx.unregisterLifecyclePass(renderable);
|
|
1110
|
+
this.childrenPrimarySortDirty = true;
|
|
1111
|
+
bumpRenderListRevision(this._ctx);
|
|
1127
1112
|
}
|
|
1128
1113
|
onRemove() {}
|
|
1129
1114
|
getChildren() {
|
|
@@ -1242,17 +1227,18 @@ class Renderable extends BaseRenderable {
|
|
|
1242
1227
|
this._isDestroyed = true;
|
|
1243
1228
|
this.emit("destroyed" /* DESTROYED */);
|
|
1244
1229
|
if (this.parent) {
|
|
1245
|
-
this.parent.remove(this
|
|
1230
|
+
this.parent.remove(this);
|
|
1246
1231
|
}
|
|
1247
1232
|
if (this.frameBuffer) {
|
|
1248
1233
|
this.frameBuffer.destroy();
|
|
1249
1234
|
this.frameBuffer = null;
|
|
1250
1235
|
}
|
|
1251
|
-
for (const child of this._childrenInLayoutOrder) {
|
|
1252
|
-
this.remove(child
|
|
1236
|
+
for (const child of [...this._childrenInLayoutOrder]) {
|
|
1237
|
+
this.remove(child);
|
|
1253
1238
|
}
|
|
1254
1239
|
this._childrenInLayoutOrder = [];
|
|
1255
|
-
this.
|
|
1240
|
+
this._childrenInZIndexOrder = [];
|
|
1241
|
+
this._shouldUpdateBefore.clear();
|
|
1256
1242
|
Renderable.renderablesByNumber.delete(this.num);
|
|
1257
1243
|
this.blur();
|
|
1258
1244
|
this.removeAllListeners();
|
|
@@ -1403,7 +1389,9 @@ class RootRenderable extends Renderable {
|
|
|
1403
1389
|
if (!this.visible)
|
|
1404
1390
|
return;
|
|
1405
1391
|
for (const renderable of this._ctx.getLifecyclePasses()) {
|
|
1406
|
-
renderable.
|
|
1392
|
+
if (!renderable.isDestroyed) {
|
|
1393
|
+
renderable.onLifecyclePass?.call(renderable);
|
|
1394
|
+
}
|
|
1407
1395
|
}
|
|
1408
1396
|
if (this.yogaNode.isDirty()) {
|
|
1409
1397
|
this.calculateLayout();
|
|
@@ -1564,19 +1552,8 @@ function maybeMakeRenderable(ctx, node) {
|
|
|
1564
1552
|
function wrapWithDelegates(instance, delegateMap) {
|
|
1565
1553
|
if (!delegateMap || Object.keys(delegateMap).length === 0)
|
|
1566
1554
|
return instance;
|
|
1567
|
-
const descendantCache = new Map;
|
|
1568
1555
|
const getDescendant = (id) => {
|
|
1569
|
-
|
|
1570
|
-
const cached = descendantCache.get(id);
|
|
1571
|
-
if (cached !== undefined) {
|
|
1572
|
-
return cached;
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
const descendant = instance.findDescendantById(id);
|
|
1576
|
-
if (descendant) {
|
|
1577
|
-
descendantCache.set(id, descendant);
|
|
1578
|
-
}
|
|
1579
|
-
return descendant;
|
|
1556
|
+
return instance.findDescendantById(id);
|
|
1580
1557
|
};
|
|
1581
1558
|
const proxy = new Proxy(instance, {
|
|
1582
1559
|
get(target, prop, receiver) {
|
|
@@ -2769,6 +2746,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2769
2746
|
textBuffer;
|
|
2770
2747
|
textBufferView;
|
|
2771
2748
|
_textBufferSyntaxStyle;
|
|
2749
|
+
nativeRenderable = null;
|
|
2772
2750
|
_defaultOptions = {
|
|
2773
2751
|
fg: RGBA.fromValues(1, 1, 1, 1),
|
|
2774
2752
|
bg: RGBA.fromValues(0, 0, 0, 0),
|
|
@@ -2800,7 +2778,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2800
2778
|
this.textBuffer.setSyntaxStyle(this._textBufferSyntaxStyle);
|
|
2801
2779
|
this.textBufferView.setWrapMode(this._wrapMode);
|
|
2802
2780
|
this.textBufferView.setFirstLineOffset(this._firstLineOffset);
|
|
2803
|
-
this.
|
|
2781
|
+
this.setupNativeRenderable();
|
|
2804
2782
|
this.textBuffer.setDefaultFg(this._defaultFg);
|
|
2805
2783
|
this.textBuffer.setDefaultBg(this._defaultBg);
|
|
2806
2784
|
this.textBuffer.setDefaultAttributes(this._defaultAttributes);
|
|
@@ -3034,30 +3012,18 @@ class TextBufferRenderable extends Renderable {
|
|
|
3034
3012
|
this.requestRender();
|
|
3035
3013
|
this.emit("line-info-change");
|
|
3036
3014
|
}
|
|
3037
|
-
|
|
3038
|
-
const
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
if (widthMode === 2 /* AtMost */ && this._positionType !== "absolute") {
|
|
3050
|
-
return {
|
|
3051
|
-
width: Math.min(effectiveWidth, measuredWidth),
|
|
3052
|
-
height: Math.min(effectiveHeight, measuredHeight)
|
|
3053
|
-
};
|
|
3054
|
-
}
|
|
3055
|
-
return {
|
|
3056
|
-
width: measuredWidth,
|
|
3057
|
-
height: measuredHeight
|
|
3058
|
-
};
|
|
3059
|
-
};
|
|
3060
|
-
this.yogaNode.setMeasureFunc(measureFunc);
|
|
3015
|
+
setupNativeRenderable() {
|
|
3016
|
+
const lib = resolveRenderLib();
|
|
3017
|
+
const nativeRenderable = lib.createNativeRenderable();
|
|
3018
|
+
if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
|
|
3019
|
+
lib.destroyNativeRenderable(nativeRenderable);
|
|
3020
|
+
throw new Error("Failed to attach native renderable Yoga node");
|
|
3021
|
+
}
|
|
3022
|
+
if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind.TextBufferView, this.textBufferView.ptr)) {
|
|
3023
|
+
lib.destroyNativeRenderable(nativeRenderable);
|
|
3024
|
+
throw new Error("Failed to attach text buffer native measure target");
|
|
3025
|
+
}
|
|
3026
|
+
this.nativeRenderable = nativeRenderable;
|
|
3061
3027
|
}
|
|
3062
3028
|
shouldStartSelection(x, y) {
|
|
3063
3029
|
if (!this.selectable)
|
|
@@ -3112,6 +3078,10 @@ class TextBufferRenderable extends Renderable {
|
|
|
3112
3078
|
destroy() {
|
|
3113
3079
|
if (this.isDestroyed)
|
|
3114
3080
|
return;
|
|
3081
|
+
if (this.nativeRenderable) {
|
|
3082
|
+
resolveRenderLib().destroyNativeRenderable(this.nativeRenderable);
|
|
3083
|
+
this.nativeRenderable = null;
|
|
3084
|
+
}
|
|
3115
3085
|
this.textBuffer.setSyntaxStyle(null);
|
|
3116
3086
|
this._textBufferSyntaxStyle.destroy();
|
|
3117
3087
|
this.textBufferView.destroy();
|
|
@@ -3592,6 +3562,19 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3592
3562
|
return this._children;
|
|
3593
3563
|
}
|
|
3594
3564
|
set children(children) {
|
|
3565
|
+
for (const child of this._children) {
|
|
3566
|
+
if (isTextNodeRenderable(child) && child.parent === this) {
|
|
3567
|
+
child.parent = null;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
for (const child of children) {
|
|
3571
|
+
if (isTextNodeRenderable(child)) {
|
|
3572
|
+
if (child.parent && child.parent !== this) {
|
|
3573
|
+
child.parent.remove(child);
|
|
3574
|
+
}
|
|
3575
|
+
child.parent = this;
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3595
3578
|
this._children = children;
|
|
3596
3579
|
this.requestRender();
|
|
3597
3580
|
}
|
|
@@ -3612,14 +3595,8 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3612
3595
|
return insertIndex;
|
|
3613
3596
|
}
|
|
3614
3597
|
if (isTextNodeRenderable(obj)) {
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
obj.parent = this;
|
|
3618
|
-
this.requestRender();
|
|
3619
|
-
return index;
|
|
3620
|
-
}
|
|
3621
|
-
const insertIndex = this._children.length;
|
|
3622
|
-
this._children.push(obj);
|
|
3598
|
+
const insertIndex = this.prepareChildInsert(obj, index);
|
|
3599
|
+
this._children.splice(insertIndex, 0, obj);
|
|
3623
3600
|
obj.parent = this;
|
|
3624
3601
|
this.requestRender();
|
|
3625
3602
|
return insertIndex;
|
|
@@ -3640,11 +3617,39 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3640
3617
|
}
|
|
3641
3618
|
throw new Error("TextNodeRenderable only accepts strings, TextNodeRenderable instances, or StyledText instances");
|
|
3642
3619
|
}
|
|
3620
|
+
prepareChildInsert(child, index) {
|
|
3621
|
+
let insertIndex = index ?? this._children.length;
|
|
3622
|
+
if (child.parent && child.parent !== this) {
|
|
3623
|
+
child.parent.remove(child);
|
|
3624
|
+
} else if (child.parent === this) {
|
|
3625
|
+
const currentIndex = this._children.indexOf(child);
|
|
3626
|
+
if (currentIndex !== -1) {
|
|
3627
|
+
this._children.splice(currentIndex, 1);
|
|
3628
|
+
if (currentIndex < insertIndex)
|
|
3629
|
+
insertIndex -= 1;
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
return Math.max(0, Math.min(insertIndex, this._children.length));
|
|
3633
|
+
}
|
|
3643
3634
|
replace(obj, index) {
|
|
3644
|
-
this._children[index]
|
|
3645
|
-
if (
|
|
3635
|
+
const existing = this._children[index];
|
|
3636
|
+
if (isTextNodeRenderable(existing) && existing.parent === this) {
|
|
3637
|
+
existing.parent = null;
|
|
3638
|
+
}
|
|
3639
|
+
if (isTextNodeRenderable(obj)) {
|
|
3640
|
+
if (obj.parent && obj.parent !== this) {
|
|
3641
|
+
obj.parent.remove(obj);
|
|
3642
|
+
} else if (obj.parent === this) {
|
|
3643
|
+
const currentIndex = this._children.indexOf(obj);
|
|
3644
|
+
if (currentIndex !== -1 && currentIndex !== index) {
|
|
3645
|
+
this._children.splice(currentIndex, 1);
|
|
3646
|
+
if (currentIndex < index)
|
|
3647
|
+
index -= 1;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3646
3650
|
obj.parent = this;
|
|
3647
3651
|
}
|
|
3652
|
+
this._children[index] = obj;
|
|
3648
3653
|
this.requestRender();
|
|
3649
3654
|
}
|
|
3650
3655
|
insertBefore(child, anchorNode) {
|
|
@@ -3655,12 +3660,16 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3655
3660
|
if (anchorIndex === -1) {
|
|
3656
3661
|
throw new Error("Anchor node not found in children");
|
|
3657
3662
|
}
|
|
3663
|
+
if (child === anchorNode) {
|
|
3664
|
+
return this;
|
|
3665
|
+
}
|
|
3666
|
+
if (isTextNodeRenderable(child)) {
|
|
3667
|
+
this.add(child, anchorIndex);
|
|
3668
|
+
return this;
|
|
3669
|
+
}
|
|
3658
3670
|
if (typeof child === "string") {
|
|
3659
3671
|
this._children.splice(anchorIndex, 0, child);
|
|
3660
|
-
} else if (
|
|
3661
|
-
this._children.splice(anchorIndex, 0, child);
|
|
3662
|
-
child.parent = this;
|
|
3663
|
-
} else if (child instanceof StyledText) {
|
|
3672
|
+
} else if (isStyledText(child)) {
|
|
3664
3673
|
const textNodes = styledTextToTextNodes(child);
|
|
3665
3674
|
this._children.splice(anchorIndex, 0, ...textNodes);
|
|
3666
3675
|
textNodes.forEach((node) => node.parent = this);
|
|
@@ -3670,18 +3679,27 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3670
3679
|
this.requestRender();
|
|
3671
3680
|
return this;
|
|
3672
3681
|
}
|
|
3673
|
-
remove(
|
|
3674
|
-
|
|
3682
|
+
remove(child) {
|
|
3683
|
+
if (!isTextNodeRenderable(child)) {
|
|
3684
|
+
throw new Error("remove expects a TextNodeRenderable child object");
|
|
3685
|
+
}
|
|
3686
|
+
const childIndex = this._children.indexOf(child);
|
|
3675
3687
|
if (childIndex === -1) {
|
|
3676
|
-
|
|
3688
|
+
if (true) {
|
|
3689
|
+
console.warn(`TextNodeRenderable with id ${child.id} is not a child of ${this.id}, skipping remove`);
|
|
3690
|
+
}
|
|
3691
|
+
return;
|
|
3677
3692
|
}
|
|
3678
|
-
const child = this._children[childIndex];
|
|
3679
3693
|
this._children.splice(childIndex, 1);
|
|
3680
3694
|
child.parent = null;
|
|
3681
3695
|
this.requestRender();
|
|
3682
|
-
return this;
|
|
3683
3696
|
}
|
|
3684
3697
|
clear() {
|
|
3698
|
+
for (const child of this._children) {
|
|
3699
|
+
if (isTextNodeRenderable(child) && child.parent === this) {
|
|
3700
|
+
child.parent = null;
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3685
3703
|
this._children = [];
|
|
3686
3704
|
this.requestRender();
|
|
3687
3705
|
}
|
|
@@ -3867,8 +3885,8 @@ class TextRenderable extends TextBufferRenderable {
|
|
|
3867
3885
|
add(obj, index) {
|
|
3868
3886
|
return this.rootTextNode.add(obj, index);
|
|
3869
3887
|
}
|
|
3870
|
-
remove(
|
|
3871
|
-
this.rootTextNode.remove(
|
|
3888
|
+
remove(child) {
|
|
3889
|
+
this.rootTextNode.remove(child);
|
|
3872
3890
|
}
|
|
3873
3891
|
insertBefore(obj, anchor) {
|
|
3874
3892
|
this.rootTextNode.insertBefore(obj, anchor);
|
|
@@ -5406,6 +5424,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5406
5424
|
_keyboardSelectionActive = false;
|
|
5407
5425
|
editBuffer;
|
|
5408
5426
|
editorView;
|
|
5427
|
+
nativeRenderable = null;
|
|
5409
5428
|
_defaultOptions = {
|
|
5410
5429
|
textColor: RGBA.fromValues(1, 1, 1, 1),
|
|
5411
5430
|
backgroundColor: "transparent",
|
|
@@ -5457,7 +5476,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5457
5476
|
if (this._tabIndicatorColor !== undefined) {
|
|
5458
5477
|
this.editorView.setTabIndicatorColor(this._tabIndicatorColor);
|
|
5459
5478
|
}
|
|
5460
|
-
this.
|
|
5479
|
+
this.setupNativeRenderable();
|
|
5461
5480
|
this.setupEventListeners(options);
|
|
5462
5481
|
}
|
|
5463
5482
|
get lineInfo() {
|
|
@@ -6086,30 +6105,18 @@ class EditBufferRenderable extends Renderable {
|
|
|
6086
6105
|
this.requestRender();
|
|
6087
6106
|
return true;
|
|
6088
6107
|
}
|
|
6089
|
-
|
|
6090
|
-
const
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
if (widthMode === 2 /* AtMost */ && this._positionType !== "absolute") {
|
|
6102
|
-
return {
|
|
6103
|
-
width: Math.min(effectiveWidth, measuredWidth),
|
|
6104
|
-
height: Math.min(effectiveHeight, measuredHeight)
|
|
6105
|
-
};
|
|
6106
|
-
}
|
|
6107
|
-
return {
|
|
6108
|
-
width: measuredWidth,
|
|
6109
|
-
height: measuredHeight
|
|
6110
|
-
};
|
|
6111
|
-
};
|
|
6112
|
-
this.yogaNode.setMeasureFunc(measureFunc);
|
|
6108
|
+
setupNativeRenderable() {
|
|
6109
|
+
const lib = resolveRenderLib();
|
|
6110
|
+
const nativeRenderable = lib.createNativeRenderable();
|
|
6111
|
+
if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
|
|
6112
|
+
lib.destroyNativeRenderable(nativeRenderable);
|
|
6113
|
+
throw new Error("Failed to attach native renderable Yoga node");
|
|
6114
|
+
}
|
|
6115
|
+
if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind.EditorView, this.editorView.ptr)) {
|
|
6116
|
+
lib.destroyNativeRenderable(nativeRenderable);
|
|
6117
|
+
throw new Error("Failed to attach editor native measure target");
|
|
6118
|
+
}
|
|
6119
|
+
this.nativeRenderable = nativeRenderable;
|
|
6113
6120
|
}
|
|
6114
6121
|
render(buffer, deltaTime) {
|
|
6115
6122
|
if (!this.visible)
|
|
@@ -6160,6 +6167,10 @@ class EditBufferRenderable extends Renderable {
|
|
|
6160
6167
|
this._ctx.setCursorPosition(0, 0, false);
|
|
6161
6168
|
this.blur();
|
|
6162
6169
|
}
|
|
6170
|
+
if (this.nativeRenderable) {
|
|
6171
|
+
resolveRenderLib().destroyNativeRenderable(this.nativeRenderable);
|
|
6172
|
+
this.nativeRenderable = null;
|
|
6173
|
+
}
|
|
6163
6174
|
this.editorView.destroy();
|
|
6164
6175
|
this.editBuffer.destroy();
|
|
6165
6176
|
super.destroy();
|
|
@@ -10030,5 +10041,5 @@ Captured external output:
|
|
|
10030
10041
|
|
|
10031
10042
|
export { h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, NativeSpanFeed, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
10032
10043
|
|
|
10033
|
-
//# debugId=
|
|
10034
|
-
//# sourceMappingURL=index-
|
|
10044
|
+
//# debugId=9F3FCD78D0AED08D64756E2164756E21
|
|
10045
|
+
//# sourceMappingURL=index-xt9f071j.js.map
|