@opentui/core 0.1.64 → 0.1.66
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/index.js +60 -33
- package/index.js.map +4 -4
- package/package.json +7 -7
- package/renderables/Code.d.ts +1 -0
- package/renderables/Diff.d.ts +5 -8
package/index.js
CHANGED
|
@@ -2840,9 +2840,10 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2840
2840
|
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
2841
2841
|
this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
|
|
2842
2842
|
this._streaming = options.streaming ?? this._contentDefaultOptions.streaming;
|
|
2843
|
-
if (this._content.length > 0
|
|
2843
|
+
if (this._content.length > 0) {
|
|
2844
2844
|
this.textBuffer.setText(this._content);
|
|
2845
2845
|
this.updateTextInfo();
|
|
2846
|
+
this._shouldRenderTextBuffer = this._drawUnstyledText || !this._filetype;
|
|
2846
2847
|
}
|
|
2847
2848
|
this._highlightsDirty = this._content.length > 0;
|
|
2848
2849
|
}
|
|
@@ -2853,10 +2854,9 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2853
2854
|
if (this._content !== value) {
|
|
2854
2855
|
this._content = value;
|
|
2855
2856
|
this._highlightsDirty = true;
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
}
|
|
2857
|
+
this._highlightSnapshotId++;
|
|
2858
|
+
this.textBuffer.setText(value);
|
|
2859
|
+
this.updateTextInfo();
|
|
2860
2860
|
}
|
|
2861
2861
|
}
|
|
2862
2862
|
get filetype() {
|
|
@@ -2915,14 +2915,15 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2915
2915
|
this._highlightsDirty = true;
|
|
2916
2916
|
}
|
|
2917
2917
|
}
|
|
2918
|
+
get isHighlighting() {
|
|
2919
|
+
return this._isHighlighting;
|
|
2920
|
+
}
|
|
2918
2921
|
ensureVisibleTextBeforeHighlight() {
|
|
2922
|
+
if (this.isDestroyed)
|
|
2923
|
+
return;
|
|
2919
2924
|
const content = this._content;
|
|
2920
2925
|
if (!this._filetype) {
|
|
2921
|
-
if (this.isDestroyed)
|
|
2922
|
-
return;
|
|
2923
|
-
this.textBuffer.setText(content);
|
|
2924
2926
|
this._shouldRenderTextBuffer = true;
|
|
2925
|
-
this.updateTextInfo();
|
|
2926
2927
|
return;
|
|
2927
2928
|
}
|
|
2928
2929
|
const isInitialContent = this._streaming && !this._hadInitialContent;
|
|
@@ -2933,29 +2934,17 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2933
2934
|
enabled: this._conceal
|
|
2934
2935
|
});
|
|
2935
2936
|
const partialStyledText = new StyledText(chunks);
|
|
2936
|
-
if (this.isDestroyed)
|
|
2937
|
-
return;
|
|
2938
2937
|
this.textBuffer.setStyledText(partialStyledText);
|
|
2939
2938
|
this._shouldRenderTextBuffer = true;
|
|
2940
2939
|
this.updateTextInfo();
|
|
2941
2940
|
} else {
|
|
2942
|
-
if (this.isDestroyed)
|
|
2943
|
-
return;
|
|
2944
|
-
this.textBuffer.setText(content);
|
|
2945
2941
|
this._shouldRenderTextBuffer = true;
|
|
2946
|
-
this.updateTextInfo();
|
|
2947
2942
|
}
|
|
2948
2943
|
} else if (shouldDrawUnstyledNow) {
|
|
2949
|
-
if (this.isDestroyed)
|
|
2950
|
-
return;
|
|
2951
2944
|
this.textBuffer.setText(content);
|
|
2952
2945
|
this._shouldRenderTextBuffer = true;
|
|
2953
|
-
this.updateTextInfo();
|
|
2954
2946
|
} else {
|
|
2955
|
-
if (this.isDestroyed)
|
|
2956
|
-
return;
|
|
2957
2947
|
this._shouldRenderTextBuffer = false;
|
|
2958
|
-
this.updateTextInfo();
|
|
2959
2948
|
}
|
|
2960
2949
|
}
|
|
2961
2950
|
async startHighlight() {
|
|
@@ -2989,9 +2978,9 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2989
2978
|
this.textBuffer.setText(content);
|
|
2990
2979
|
}
|
|
2991
2980
|
this._shouldRenderTextBuffer = true;
|
|
2992
|
-
this.updateTextInfo();
|
|
2993
2981
|
this._isHighlighting = false;
|
|
2994
2982
|
this._highlightsDirty = false;
|
|
2983
|
+
this.updateTextInfo();
|
|
2995
2984
|
this.requestRender();
|
|
2996
2985
|
} catch (error) {
|
|
2997
2986
|
if (snapshotId !== this._highlightSnapshotId) {
|
|
@@ -3002,9 +2991,9 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3002
2991
|
return;
|
|
3003
2992
|
this.textBuffer.setText(content);
|
|
3004
2993
|
this._shouldRenderTextBuffer = true;
|
|
3005
|
-
this.updateTextInfo();
|
|
3006
2994
|
this._isHighlighting = false;
|
|
3007
2995
|
this._highlightsDirty = false;
|
|
2996
|
+
this.updateTextInfo();
|
|
3008
2997
|
this.requestRender();
|
|
3009
2998
|
}
|
|
3010
2999
|
}
|
|
@@ -3013,20 +3002,14 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3013
3002
|
}
|
|
3014
3003
|
renderSelf(buffer) {
|
|
3015
3004
|
if (this._highlightsDirty) {
|
|
3005
|
+
if (this.isDestroyed)
|
|
3006
|
+
return;
|
|
3016
3007
|
if (this._content.length === 0) {
|
|
3017
|
-
if (this.isDestroyed)
|
|
3018
|
-
return;
|
|
3019
|
-
this.textBuffer.setText("");
|
|
3020
3008
|
this._shouldRenderTextBuffer = false;
|
|
3021
3009
|
this._highlightsDirty = false;
|
|
3022
|
-
this.updateTextInfo();
|
|
3023
3010
|
} else if (!this._filetype) {
|
|
3024
|
-
if (this.isDestroyed)
|
|
3025
|
-
return;
|
|
3026
|
-
this.textBuffer.setText(this._content);
|
|
3027
3011
|
this._shouldRenderTextBuffer = true;
|
|
3028
3012
|
this._highlightsDirty = false;
|
|
3029
|
-
this.updateTextInfo();
|
|
3030
3013
|
} else {
|
|
3031
3014
|
this.ensureVisibleTextBeforeHighlight();
|
|
3032
3015
|
this._highlightsDirty = false;
|
|
@@ -4673,6 +4656,8 @@ class DiffRenderable extends Renderable {
|
|
|
4673
4656
|
_lastWidth = 0;
|
|
4674
4657
|
errorTextRenderable = null;
|
|
4675
4658
|
errorCodeRenderable = null;
|
|
4659
|
+
_waitingForHighlight = false;
|
|
4660
|
+
_lineInfoChangeHandler = null;
|
|
4676
4661
|
constructor(ctx, options) {
|
|
4677
4662
|
super(ctx, {
|
|
4678
4663
|
...options,
|
|
@@ -4769,7 +4754,40 @@ class DiffRenderable extends Renderable {
|
|
|
4769
4754
|
this.buildView();
|
|
4770
4755
|
}
|
|
4771
4756
|
}
|
|
4757
|
+
handleLineInfoChange = () => {
|
|
4758
|
+
if (!this._waitingForHighlight)
|
|
4759
|
+
return;
|
|
4760
|
+
if (!this.leftCodeRenderable || !this.rightCodeRenderable)
|
|
4761
|
+
return;
|
|
4762
|
+
const leftIsHighlighting = this.leftCodeRenderable.isHighlighting;
|
|
4763
|
+
const rightIsHighlighting = this.rightCodeRenderable.isHighlighting;
|
|
4764
|
+
if (!leftIsHighlighting && !rightIsHighlighting) {
|
|
4765
|
+
this._waitingForHighlight = false;
|
|
4766
|
+
this.requestRebuild();
|
|
4767
|
+
}
|
|
4768
|
+
};
|
|
4769
|
+
attachLineInfoListeners() {
|
|
4770
|
+
if (this._lineInfoChangeHandler)
|
|
4771
|
+
return;
|
|
4772
|
+
if (!this.leftCodeRenderable || !this.rightCodeRenderable)
|
|
4773
|
+
return;
|
|
4774
|
+
this._lineInfoChangeHandler = this.handleLineInfoChange;
|
|
4775
|
+
this.leftCodeRenderable.on("line-info-change", this._lineInfoChangeHandler);
|
|
4776
|
+
this.rightCodeRenderable.on("line-info-change", this._lineInfoChangeHandler);
|
|
4777
|
+
}
|
|
4778
|
+
detachLineInfoListeners() {
|
|
4779
|
+
if (!this._lineInfoChangeHandler)
|
|
4780
|
+
return;
|
|
4781
|
+
if (this.leftCodeRenderable) {
|
|
4782
|
+
this.leftCodeRenderable.off("line-info-change", this._lineInfoChangeHandler);
|
|
4783
|
+
}
|
|
4784
|
+
if (this.rightCodeRenderable) {
|
|
4785
|
+
this.rightCodeRenderable.off("line-info-change", this._lineInfoChangeHandler);
|
|
4786
|
+
}
|
|
4787
|
+
this._lineInfoChangeHandler = null;
|
|
4788
|
+
}
|
|
4772
4789
|
destroyRecursively() {
|
|
4790
|
+
this.detachLineInfoListeners();
|
|
4773
4791
|
this.pendingRebuild = false;
|
|
4774
4792
|
this.leftSideAdded = false;
|
|
4775
4793
|
this.rightSideAdded = false;
|
|
@@ -5127,7 +5145,15 @@ class DiffRenderable extends Renderable {
|
|
|
5127
5145
|
const rightCodeRenderable = this.createOrUpdateCodeRenderable("right", preRightContent, this._wrapMode, drawUnstyledText);
|
|
5128
5146
|
let finalLeftLines;
|
|
5129
5147
|
let finalRightLines;
|
|
5130
|
-
|
|
5148
|
+
const leftIsHighlighting = leftCodeRenderable.isHighlighting;
|
|
5149
|
+
const rightIsHighlighting = rightCodeRenderable.isHighlighting;
|
|
5150
|
+
const highlightingInProgress = needsConsistentConcealing && (leftIsHighlighting || rightIsHighlighting);
|
|
5151
|
+
if (highlightingInProgress) {
|
|
5152
|
+
this._waitingForHighlight = true;
|
|
5153
|
+
this.attachLineInfoListeners();
|
|
5154
|
+
}
|
|
5155
|
+
const shouldDoAlignment = canDoWrapAlignment && !highlightingInProgress;
|
|
5156
|
+
if (shouldDoAlignment) {
|
|
5131
5157
|
const leftLineInfo = leftCodeRenderable.lineInfo;
|
|
5132
5158
|
const rightLineInfo = rightCodeRenderable.lineInfo;
|
|
5133
5159
|
const leftSources = leftLineInfo.lineSources || [];
|
|
@@ -5269,6 +5295,7 @@ class DiffRenderable extends Renderable {
|
|
|
5269
5295
|
set diff(value) {
|
|
5270
5296
|
if (this._diff !== value) {
|
|
5271
5297
|
this._diff = value;
|
|
5298
|
+
this._waitingForHighlight = false;
|
|
5272
5299
|
this.parseDiff();
|
|
5273
5300
|
this.rebuildView();
|
|
5274
5301
|
}
|
|
@@ -8962,5 +8989,5 @@ export {
|
|
|
8962
8989
|
ASCIIFont
|
|
8963
8990
|
};
|
|
8964
8991
|
|
|
8965
|
-
//# debugId=
|
|
8992
|
+
//# debugId=5E4CDD3395AC328364756E2164756E21
|
|
8966
8993
|
//# sourceMappingURL=index.js.map
|