@opentui/core 0.1.32 → 0.1.34
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/3d.js +1 -1
- package/edit-buffer.d.ts +2 -0
- package/{index-3f9h747j.js → index-x37wckj8.js} +100 -17
- package/{index-3f9h747j.js.map → index-x37wckj8.js.map} +6 -6
- package/index.js +47 -4
- package/index.js.map +5 -5
- package/package.json +7 -7
- package/renderables/Code.d.ts +5 -0
- package/renderables/EditBufferRenderable.d.ts +2 -0
- package/renderer.d.ts +2 -0
- package/testing/mock-tree-sitter-client.d.ts +20 -0
- package/testing.d.ts +1 -0
- package/testing.js +35 -2
- package/testing.js.map +4 -3
- package/text-buffer.d.ts +1 -0
- package/zig.d.ts +6 -0
package/index.js
CHANGED
|
@@ -134,7 +134,7 @@ import {
|
|
|
134
134
|
white,
|
|
135
135
|
wrapWithDelegates,
|
|
136
136
|
yellow
|
|
137
|
-
} from "./index-
|
|
137
|
+
} from "./index-x37wckj8.js";
|
|
138
138
|
// src/text-buffer-view.ts
|
|
139
139
|
class TextBufferView {
|
|
140
140
|
lib;
|
|
@@ -431,6 +431,24 @@ class EditBuffer extends EventEmitter {
|
|
|
431
431
|
this.guard();
|
|
432
432
|
return this.lib.editBufferGetLineStartOffset(this.bufferPtr, row);
|
|
433
433
|
}
|
|
434
|
+
getTextRange(startOffset, endOffset) {
|
|
435
|
+
this.guard();
|
|
436
|
+
if (startOffset >= endOffset)
|
|
437
|
+
return "";
|
|
438
|
+
const maxSize = 1024 * 1024;
|
|
439
|
+
const textBytes = this.lib.editBufferGetTextRange(this.bufferPtr, startOffset, endOffset, maxSize);
|
|
440
|
+
if (!textBytes)
|
|
441
|
+
return "";
|
|
442
|
+
return this.lib.decoder.decode(textBytes);
|
|
443
|
+
}
|
|
444
|
+
getTextRangeByCoords(startRow, startCol, endRow, endCol) {
|
|
445
|
+
this.guard();
|
|
446
|
+
const maxSize = 1024 * 1024;
|
|
447
|
+
const textBytes = this.lib.editBufferGetTextRangeByCoords(this.bufferPtr, startRow, startCol, endRow, endCol, maxSize);
|
|
448
|
+
if (!textBytes)
|
|
449
|
+
return "";
|
|
450
|
+
return this.lib.decoder.decode(textBytes);
|
|
451
|
+
}
|
|
434
452
|
debugLogRope() {
|
|
435
453
|
this.guard();
|
|
436
454
|
this.lib.editBufferDebugLogRope(this.bufferPtr);
|
|
@@ -2646,6 +2664,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2646
2664
|
_currentHighlightId = 0;
|
|
2647
2665
|
_conceal;
|
|
2648
2666
|
_drawUnstyledText;
|
|
2667
|
+
_shouldRenderTextBuffer = true;
|
|
2649
2668
|
_contentDefaultOptions = {
|
|
2650
2669
|
content: "",
|
|
2651
2670
|
conceal: true,
|
|
@@ -2706,6 +2725,15 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2706
2725
|
this.scheduleUpdate();
|
|
2707
2726
|
}
|
|
2708
2727
|
}
|
|
2728
|
+
get treeSitterClient() {
|
|
2729
|
+
return this._treeSitterClient;
|
|
2730
|
+
}
|
|
2731
|
+
set treeSitterClient(value) {
|
|
2732
|
+
if (this._treeSitterClient !== value) {
|
|
2733
|
+
this._treeSitterClient = value;
|
|
2734
|
+
this.scheduleUpdate();
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2709
2737
|
scheduleUpdate() {
|
|
2710
2738
|
if (this._pendingUpdate)
|
|
2711
2739
|
return;
|
|
@@ -2720,12 +2748,14 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2720
2748
|
return;
|
|
2721
2749
|
if (!this._filetype) {
|
|
2722
2750
|
this.fallback(content);
|
|
2751
|
+
this._shouldRenderTextBuffer = true;
|
|
2723
2752
|
return;
|
|
2724
2753
|
}
|
|
2725
2754
|
this._currentHighlightId++;
|
|
2726
2755
|
const highlightId = this._currentHighlightId;
|
|
2727
|
-
|
|
2728
|
-
|
|
2756
|
+
this.fallback(content);
|
|
2757
|
+
if (!this._drawUnstyledText) {
|
|
2758
|
+
this._shouldRenderTextBuffer = false;
|
|
2729
2759
|
}
|
|
2730
2760
|
this._isHighlighting = true;
|
|
2731
2761
|
this._pendingRehighlight = false;
|
|
@@ -2739,6 +2769,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2739
2769
|
if (this.isDestroyed)
|
|
2740
2770
|
return;
|
|
2741
2771
|
this.textBuffer.setStyledText(styledText);
|
|
2772
|
+
this._shouldRenderTextBuffer = true;
|
|
2742
2773
|
this.updateTextInfo();
|
|
2743
2774
|
} catch (error) {
|
|
2744
2775
|
if (highlightId !== this._currentHighlightId) {
|
|
@@ -2746,6 +2777,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2746
2777
|
}
|
|
2747
2778
|
console.warn("Code highlighting failed, falling back to plain text:", error);
|
|
2748
2779
|
this.fallback(content);
|
|
2780
|
+
this._shouldRenderTextBuffer = true;
|
|
2749
2781
|
} finally {
|
|
2750
2782
|
if (highlightId === this._currentHighlightId) {
|
|
2751
2783
|
this._isHighlighting = false;
|
|
@@ -2774,6 +2806,11 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2774
2806
|
getLineHighlights(lineIdx) {
|
|
2775
2807
|
return this.textBuffer.getLineHighlights(lineIdx);
|
|
2776
2808
|
}
|
|
2809
|
+
renderSelf(buffer) {
|
|
2810
|
+
if (!this._shouldRenderTextBuffer)
|
|
2811
|
+
return;
|
|
2812
|
+
super.renderSelf(buffer);
|
|
2813
|
+
}
|
|
2777
2814
|
}
|
|
2778
2815
|
// src/renderables/TextNode.ts
|
|
2779
2816
|
var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
|
|
@@ -5523,6 +5560,12 @@ class EditBufferRenderable extends Renderable {
|
|
|
5523
5560
|
this.yogaNode.markDirty();
|
|
5524
5561
|
this.requestRender();
|
|
5525
5562
|
}
|
|
5563
|
+
getTextRange(startOffset, endOffset) {
|
|
5564
|
+
return this.editBuffer.getTextRange(startOffset, endOffset);
|
|
5565
|
+
}
|
|
5566
|
+
getTextRangeByCoords(startRow, startCol, endRow, endCol) {
|
|
5567
|
+
return this.editBuffer.getTextRangeByCoords(startRow, startCol, endRow, endCol);
|
|
5568
|
+
}
|
|
5526
5569
|
}
|
|
5527
5570
|
|
|
5528
5571
|
// src/lib/keymapping.ts
|
|
@@ -6179,5 +6222,5 @@ export {
|
|
|
6179
6222
|
ASCIIFont
|
|
6180
6223
|
};
|
|
6181
6224
|
|
|
6182
|
-
//# debugId=
|
|
6225
|
+
//# debugId=451BE98665FD310764756E2164756E21
|
|
6183
6226
|
//# sourceMappingURL=index.js.map
|