@opentui/core 0.1.33 → 0.1.35
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/{index-xqg0a6ka.js → index-n8nbvvhk.js} +50 -7
- package/{index-xqg0a6ka.js.map → index-n8nbvvhk.js.map} +6 -6
- package/index.js +173 -42
- package/index.js.map +8 -8
- package/package.json +7 -7
- package/renderables/Code.d.ts +12 -0
- package/renderables/EditBufferRenderable.d.ts +9 -1
- package/renderables/Input.d.ts +9 -1
- package/renderables/ScrollBox.d.ts +8 -2
- package/renderables/Select.d.ts +4 -1
- package/renderer.d.ts +4 -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/types.d.ts +4 -0
- package/zig.d.ts +2 -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-n8nbvvhk.js";
|
|
138
138
|
// src/text-buffer-view.ts
|
|
139
139
|
class TextBufferView {
|
|
140
140
|
lib;
|
|
@@ -2570,10 +2570,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2570
2570
|
}
|
|
2571
2571
|
updateTextInfo() {
|
|
2572
2572
|
if (this.lastLocalSelection) {
|
|
2573
|
-
|
|
2574
|
-
if (changed) {
|
|
2575
|
-
this.requestRender();
|
|
2576
|
-
}
|
|
2573
|
+
this.updateLocalSelection(this.lastLocalSelection);
|
|
2577
2574
|
}
|
|
2578
2575
|
this.yogaNode.markDirty();
|
|
2579
2576
|
this.requestRender();
|
|
@@ -2636,6 +2633,9 @@ class TextBufferRenderable extends Renderable {
|
|
|
2636
2633
|
this.markClean();
|
|
2637
2634
|
this._ctx.addToHitGrid(this.x, this.y, this.width, this.height, this.num);
|
|
2638
2635
|
this.renderSelf(buffer);
|
|
2636
|
+
if (this.buffered && this.frameBuffer) {
|
|
2637
|
+
buffer.drawFrameBuffer(this.x, this.y, this.frameBuffer);
|
|
2638
|
+
}
|
|
2639
2639
|
}
|
|
2640
2640
|
renderSelf(buffer) {
|
|
2641
2641
|
if (this.textBuffer.ptr) {
|
|
@@ -2664,10 +2664,15 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2664
2664
|
_currentHighlightId = 0;
|
|
2665
2665
|
_conceal;
|
|
2666
2666
|
_drawUnstyledText;
|
|
2667
|
+
_shouldRenderTextBuffer = true;
|
|
2668
|
+
_streaming;
|
|
2669
|
+
_hadInitialContent = false;
|
|
2670
|
+
_lastHighlights = [];
|
|
2667
2671
|
_contentDefaultOptions = {
|
|
2668
2672
|
content: "",
|
|
2669
2673
|
conceal: true,
|
|
2670
|
-
drawUnstyledText: true
|
|
2674
|
+
drawUnstyledText: true,
|
|
2675
|
+
streaming: false
|
|
2671
2676
|
};
|
|
2672
2677
|
constructor(ctx, options) {
|
|
2673
2678
|
super(ctx, options);
|
|
@@ -2677,6 +2682,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2677
2682
|
this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient();
|
|
2678
2683
|
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
2679
2684
|
this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
|
|
2685
|
+
this._streaming = options.streaming ?? this._contentDefaultOptions.streaming;
|
|
2680
2686
|
this.updateContent(this._content);
|
|
2681
2687
|
}
|
|
2682
2688
|
get content() {
|
|
@@ -2724,6 +2730,26 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2724
2730
|
this.scheduleUpdate();
|
|
2725
2731
|
}
|
|
2726
2732
|
}
|
|
2733
|
+
get streaming() {
|
|
2734
|
+
return this._streaming;
|
|
2735
|
+
}
|
|
2736
|
+
set streaming(value) {
|
|
2737
|
+
if (this._streaming !== value) {
|
|
2738
|
+
this._streaming = value;
|
|
2739
|
+
this._hadInitialContent = false;
|
|
2740
|
+
this._lastHighlights = [];
|
|
2741
|
+
this.scheduleUpdate();
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
get treeSitterClient() {
|
|
2745
|
+
return this._treeSitterClient;
|
|
2746
|
+
}
|
|
2747
|
+
set treeSitterClient(value) {
|
|
2748
|
+
if (this._treeSitterClient !== value) {
|
|
2749
|
+
this._treeSitterClient = value;
|
|
2750
|
+
this.scheduleUpdate();
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2727
2753
|
scheduleUpdate() {
|
|
2728
2754
|
if (this._pendingUpdate)
|
|
2729
2755
|
return;
|
|
@@ -2738,25 +2764,53 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2738
2764
|
return;
|
|
2739
2765
|
if (!this._filetype) {
|
|
2740
2766
|
this.fallback(content);
|
|
2767
|
+
this._shouldRenderTextBuffer = true;
|
|
2741
2768
|
return;
|
|
2742
2769
|
}
|
|
2743
2770
|
this._currentHighlightId++;
|
|
2744
2771
|
const highlightId = this._currentHighlightId;
|
|
2745
|
-
|
|
2746
|
-
|
|
2772
|
+
const isInitialContent = this._streaming && !this._hadInitialContent;
|
|
2773
|
+
if (isInitialContent) {
|
|
2774
|
+
this._hadInitialContent = true;
|
|
2775
|
+
}
|
|
2776
|
+
const shouldDrawUnstyledNow = this._streaming ? isInitialContent && this._drawUnstyledText : this._drawUnstyledText;
|
|
2777
|
+
this.fallback(content);
|
|
2778
|
+
if (!shouldDrawUnstyledNow) {
|
|
2779
|
+
this._shouldRenderTextBuffer = false;
|
|
2780
|
+
}
|
|
2781
|
+
if (this._streaming && !isInitialContent && this._lastHighlights.length > 0) {
|
|
2782
|
+
const chunks = treeSitterToTextChunks(content, this._lastHighlights, this._syntaxStyle, {
|
|
2783
|
+
enabled: this._conceal
|
|
2784
|
+
});
|
|
2785
|
+
const partialStyledText = new StyledText(chunks);
|
|
2786
|
+
if (this.isDestroyed)
|
|
2787
|
+
return;
|
|
2788
|
+
this.textBuffer.setStyledText(partialStyledText);
|
|
2789
|
+
this._shouldRenderTextBuffer = true;
|
|
2790
|
+
this.updateTextInfo();
|
|
2747
2791
|
}
|
|
2748
2792
|
this._isHighlighting = true;
|
|
2749
2793
|
this._pendingRehighlight = false;
|
|
2750
2794
|
try {
|
|
2751
|
-
const
|
|
2752
|
-
conceal: { enabled: this._conceal }
|
|
2753
|
-
});
|
|
2795
|
+
const result = await this._treeSitterClient.highlightOnce(content, this._filetype);
|
|
2754
2796
|
if (highlightId !== this._currentHighlightId) {
|
|
2755
2797
|
return;
|
|
2756
2798
|
}
|
|
2757
2799
|
if (this.isDestroyed)
|
|
2758
2800
|
return;
|
|
2759
|
-
|
|
2801
|
+
if (result.highlights && result.highlights.length > 0) {
|
|
2802
|
+
if (this._streaming) {
|
|
2803
|
+
this._lastHighlights = result.highlights;
|
|
2804
|
+
}
|
|
2805
|
+
const chunks = treeSitterToTextChunks(content, result.highlights, this._syntaxStyle, {
|
|
2806
|
+
enabled: this._conceal
|
|
2807
|
+
});
|
|
2808
|
+
const styledText = new StyledText(chunks);
|
|
2809
|
+
this.textBuffer.setStyledText(styledText);
|
|
2810
|
+
} else {
|
|
2811
|
+
this.fallback(content);
|
|
2812
|
+
}
|
|
2813
|
+
this._shouldRenderTextBuffer = true;
|
|
2760
2814
|
this.updateTextInfo();
|
|
2761
2815
|
} catch (error) {
|
|
2762
2816
|
if (highlightId !== this._currentHighlightId) {
|
|
@@ -2764,6 +2818,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2764
2818
|
}
|
|
2765
2819
|
console.warn("Code highlighting failed, falling back to plain text:", error);
|
|
2766
2820
|
this.fallback(content);
|
|
2821
|
+
this._shouldRenderTextBuffer = true;
|
|
2767
2822
|
} finally {
|
|
2768
2823
|
if (highlightId === this._currentHighlightId) {
|
|
2769
2824
|
this._isHighlighting = false;
|
|
@@ -2792,6 +2847,11 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2792
2847
|
getLineHighlights(lineIdx) {
|
|
2793
2848
|
return this.textBuffer.getLineHighlights(lineIdx);
|
|
2794
2849
|
}
|
|
2850
|
+
renderSelf(buffer) {
|
|
2851
|
+
if (!this._shouldRenderTextBuffer)
|
|
2852
|
+
return;
|
|
2853
|
+
super.renderSelf(buffer);
|
|
2854
|
+
}
|
|
2795
2855
|
}
|
|
2796
2856
|
// src/renderables/TextNode.ts
|
|
2797
2857
|
var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
|
|
@@ -3112,6 +3172,7 @@ class InputRenderable extends Renderable {
|
|
|
3112
3172
|
_focusedTextColor;
|
|
3113
3173
|
_placeholderColor;
|
|
3114
3174
|
_cursorColor;
|
|
3175
|
+
_cursorStyle;
|
|
3115
3176
|
_maxLength;
|
|
3116
3177
|
_lastCommittedValue = "";
|
|
3117
3178
|
_defaultOptions = {
|
|
@@ -3122,6 +3183,10 @@ class InputRenderable extends Renderable {
|
|
|
3122
3183
|
placeholder: "",
|
|
3123
3184
|
placeholderColor: "#666666",
|
|
3124
3185
|
cursorColor: "#FFFFFF",
|
|
3186
|
+
cursorStyle: {
|
|
3187
|
+
style: "block",
|
|
3188
|
+
blinking: true
|
|
3189
|
+
},
|
|
3125
3190
|
maxLength: 1000,
|
|
3126
3191
|
value: ""
|
|
3127
3192
|
};
|
|
@@ -3138,6 +3203,7 @@ class InputRenderable extends Renderable {
|
|
|
3138
3203
|
this._maxLength = options.maxLength || this._defaultOptions.maxLength;
|
|
3139
3204
|
this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
|
|
3140
3205
|
this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
|
|
3206
|
+
this._cursorStyle = options.cursorStyle || this._defaultOptions.cursorStyle;
|
|
3141
3207
|
}
|
|
3142
3208
|
updateCursorPosition() {
|
|
3143
3209
|
if (!this._focused)
|
|
@@ -3160,7 +3226,7 @@ class InputRenderable extends Renderable {
|
|
|
3160
3226
|
}
|
|
3161
3227
|
focus() {
|
|
3162
3228
|
super.focus();
|
|
3163
|
-
this._ctx.setCursorStyle(
|
|
3229
|
+
this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
|
|
3164
3230
|
this._ctx.setCursorColor(this._cursorColor);
|
|
3165
3231
|
this.updateCursorPosition();
|
|
3166
3232
|
}
|
|
@@ -3350,7 +3416,21 @@ class InputRenderable extends Renderable {
|
|
|
3350
3416
|
const newColor = parseColor(value ?? this._defaultOptions.cursorColor);
|
|
3351
3417
|
if (this._cursorColor !== newColor) {
|
|
3352
3418
|
this._cursorColor = newColor;
|
|
3353
|
-
this.
|
|
3419
|
+
if (this._focused) {
|
|
3420
|
+
this._ctx.requestRender();
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
get cursorStyle() {
|
|
3425
|
+
return this._cursorStyle;
|
|
3426
|
+
}
|
|
3427
|
+
set cursorStyle(style) {
|
|
3428
|
+
const newStyle = style;
|
|
3429
|
+
if (this.cursorStyle.style !== newStyle.style || this.cursorStyle.blinking !== newStyle.blinking) {
|
|
3430
|
+
this._cursorStyle = newStyle;
|
|
3431
|
+
if (this._focused) {
|
|
3432
|
+
this._ctx.requestRender();
|
|
3433
|
+
}
|
|
3354
3434
|
}
|
|
3355
3435
|
}
|
|
3356
3436
|
updateFromLayout() {
|
|
@@ -3952,12 +4032,23 @@ class ArrowRenderable extends Renderable {
|
|
|
3952
4032
|
// src/renderables/ScrollBox.ts
|
|
3953
4033
|
class ContentRenderable extends BoxRenderable {
|
|
3954
4034
|
viewport;
|
|
3955
|
-
|
|
4035
|
+
_viewportCulling;
|
|
4036
|
+
constructor(ctx, viewport, viewportCulling, options) {
|
|
3956
4037
|
super(ctx, options);
|
|
3957
4038
|
this.viewport = viewport;
|
|
4039
|
+
this._viewportCulling = viewportCulling;
|
|
4040
|
+
}
|
|
4041
|
+
get viewportCulling() {
|
|
4042
|
+
return this._viewportCulling;
|
|
4043
|
+
}
|
|
4044
|
+
set viewportCulling(value) {
|
|
4045
|
+
this._viewportCulling = value;
|
|
3958
4046
|
}
|
|
3959
4047
|
_getChildren() {
|
|
3960
|
-
|
|
4048
|
+
if (this._viewportCulling) {
|
|
4049
|
+
return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis);
|
|
4050
|
+
}
|
|
4051
|
+
return this.getChildrenSortedByPrimaryAxis();
|
|
3961
4052
|
}
|
|
3962
4053
|
}
|
|
3963
4054
|
|
|
@@ -4089,6 +4180,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
4089
4180
|
scrollX = false,
|
|
4090
4181
|
scrollY = true,
|
|
4091
4182
|
scrollAcceleration,
|
|
4183
|
+
viewportCulling = true,
|
|
4092
4184
|
...options
|
|
4093
4185
|
}) {
|
|
4094
4186
|
super(ctx, {
|
|
@@ -4124,7 +4216,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
4124
4216
|
id: `scroll-box-viewport-${this.internalId}`
|
|
4125
4217
|
});
|
|
4126
4218
|
this.wrapper.add(this.viewport);
|
|
4127
|
-
this.content = new ContentRenderable(ctx, this.viewport, {
|
|
4219
|
+
this.content = new ContentRenderable(ctx, this.viewport, viewportCulling, {
|
|
4128
4220
|
alignSelf: "flex-start",
|
|
4129
4221
|
flexShrink: 0,
|
|
4130
4222
|
...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
|
|
@@ -4418,6 +4510,13 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
4418
4510
|
set scrollAcceleration(value) {
|
|
4419
4511
|
this.scrollAccel = value;
|
|
4420
4512
|
}
|
|
4513
|
+
get viewportCulling() {
|
|
4514
|
+
return this.content.viewportCulling;
|
|
4515
|
+
}
|
|
4516
|
+
set viewportCulling(value) {
|
|
4517
|
+
this.content.viewportCulling = value;
|
|
4518
|
+
this.requestRender();
|
|
4519
|
+
}
|
|
4421
4520
|
destroySelf() {
|
|
4422
4521
|
if (this.selectionListener) {
|
|
4423
4522
|
this._ctx.off("selection", this.selectionListener);
|
|
@@ -4436,7 +4535,7 @@ var SelectRenderableEvents;
|
|
|
4436
4535
|
class SelectRenderable extends Renderable {
|
|
4437
4536
|
_focusable = true;
|
|
4438
4537
|
_options = [];
|
|
4439
|
-
|
|
4538
|
+
_selectedIndex = 0;
|
|
4440
4539
|
scrollOffset = 0;
|
|
4441
4540
|
maxVisibleItems;
|
|
4442
4541
|
_backgroundColor;
|
|
@@ -4462,6 +4561,7 @@ class SelectRenderable extends Renderable {
|
|
|
4462
4561
|
focusedTextColor: "#FFFFFF",
|
|
4463
4562
|
selectedBackgroundColor: "#334455",
|
|
4464
4563
|
selectedTextColor: "#FFFF00",
|
|
4564
|
+
selectedIndex: 0,
|
|
4465
4565
|
descriptionColor: "#888888",
|
|
4466
4566
|
selectedDescriptionColor: "#CCCCCC",
|
|
4467
4567
|
showScrollIndicator: false,
|
|
@@ -4472,11 +4572,13 @@ class SelectRenderable extends Renderable {
|
|
|
4472
4572
|
};
|
|
4473
4573
|
constructor(ctx, options) {
|
|
4474
4574
|
super(ctx, { ...options, buffered: true });
|
|
4575
|
+
this._options = options.options || [];
|
|
4576
|
+
const requestedIndex = options.selectedIndex ?? this._defaultOptions.selectedIndex;
|
|
4577
|
+
this._selectedIndex = this._options.length > 0 ? Math.min(requestedIndex, this._options.length - 1) : 0;
|
|
4475
4578
|
this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
|
|
4476
4579
|
this._textColor = parseColor(options.textColor || this._defaultOptions.textColor);
|
|
4477
4580
|
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || this._defaultOptions.focusedBackgroundColor);
|
|
4478
4581
|
this._focusedTextColor = parseColor(options.focusedTextColor || this._defaultOptions.focusedTextColor);
|
|
4479
|
-
this._options = options.options || [];
|
|
4480
4582
|
this._showScrollIndicator = options.showScrollIndicator ?? this._defaultOptions.showScrollIndicator;
|
|
4481
4583
|
this._wrapSelection = options.wrapSelection ?? this._defaultOptions.wrapSelection;
|
|
4482
4584
|
this._showDescription = options.showDescription ?? this._defaultOptions.showDescription;
|
|
@@ -4513,7 +4615,7 @@ class SelectRenderable extends Renderable {
|
|
|
4513
4615
|
for (let i = 0;i < visibleOptions.length; i++) {
|
|
4514
4616
|
const actualIndex = this.scrollOffset + i;
|
|
4515
4617
|
const option = visibleOptions[i];
|
|
4516
|
-
const isSelected = actualIndex === this.
|
|
4618
|
+
const isSelected = actualIndex === this._selectedIndex;
|
|
4517
4619
|
const itemY = contentY + i * this.linesPerItem;
|
|
4518
4620
|
if (itemY + this.linesPerItem - 1 >= contentY + contentHeight)
|
|
4519
4621
|
break;
|
|
@@ -4554,7 +4656,7 @@ class SelectRenderable extends Renderable {
|
|
|
4554
4656
|
renderScrollIndicatorToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
|
|
4555
4657
|
if (!this.frameBuffer)
|
|
4556
4658
|
return;
|
|
4557
|
-
const scrollPercent = this.
|
|
4659
|
+
const scrollPercent = this._selectedIndex / Math.max(1, this._options.length - 1);
|
|
4558
4660
|
const indicatorHeight = Math.max(1, contentHeight - 2);
|
|
4559
4661
|
const indicatorY = contentY + 1 + Math.floor(scrollPercent * indicatorHeight);
|
|
4560
4662
|
const indicatorX = contentX + contentWidth - 1;
|
|
@@ -4565,61 +4667,61 @@ class SelectRenderable extends Renderable {
|
|
|
4565
4667
|
}
|
|
4566
4668
|
set options(options) {
|
|
4567
4669
|
this._options = options;
|
|
4568
|
-
this.
|
|
4670
|
+
this._selectedIndex = Math.min(this._selectedIndex, Math.max(0, options.length - 1));
|
|
4569
4671
|
this.updateScrollOffset();
|
|
4570
4672
|
this.requestRender();
|
|
4571
4673
|
}
|
|
4572
4674
|
getSelectedOption() {
|
|
4573
|
-
return this._options[this.
|
|
4675
|
+
return this._options[this._selectedIndex] || null;
|
|
4574
4676
|
}
|
|
4575
4677
|
getSelectedIndex() {
|
|
4576
|
-
return this.
|
|
4678
|
+
return this._selectedIndex;
|
|
4577
4679
|
}
|
|
4578
4680
|
moveUp(steps = 1) {
|
|
4579
|
-
const newIndex = this.
|
|
4681
|
+
const newIndex = this._selectedIndex - steps;
|
|
4580
4682
|
if (newIndex >= 0) {
|
|
4581
|
-
this.
|
|
4683
|
+
this._selectedIndex = newIndex;
|
|
4582
4684
|
} else if (this._wrapSelection && this._options.length > 0) {
|
|
4583
|
-
this.
|
|
4685
|
+
this._selectedIndex = this._options.length - 1;
|
|
4584
4686
|
} else {
|
|
4585
|
-
this.
|
|
4687
|
+
this._selectedIndex = 0;
|
|
4586
4688
|
}
|
|
4587
4689
|
this.updateScrollOffset();
|
|
4588
4690
|
this.requestRender();
|
|
4589
|
-
this.emit("selectionChanged" /* SELECTION_CHANGED */, this.
|
|
4691
|
+
this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
|
|
4590
4692
|
}
|
|
4591
4693
|
moveDown(steps = 1) {
|
|
4592
|
-
const newIndex = this.
|
|
4694
|
+
const newIndex = this._selectedIndex + steps;
|
|
4593
4695
|
if (newIndex < this._options.length) {
|
|
4594
|
-
this.
|
|
4696
|
+
this._selectedIndex = newIndex;
|
|
4595
4697
|
} else if (this._wrapSelection && this._options.length > 0) {
|
|
4596
|
-
this.
|
|
4698
|
+
this._selectedIndex = 0;
|
|
4597
4699
|
} else {
|
|
4598
|
-
this.
|
|
4700
|
+
this._selectedIndex = this._options.length - 1;
|
|
4599
4701
|
}
|
|
4600
4702
|
this.updateScrollOffset();
|
|
4601
4703
|
this.requestRender();
|
|
4602
|
-
this.emit("selectionChanged" /* SELECTION_CHANGED */, this.
|
|
4704
|
+
this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
|
|
4603
4705
|
}
|
|
4604
4706
|
selectCurrent() {
|
|
4605
4707
|
const selected = this.getSelectedOption();
|
|
4606
4708
|
if (selected) {
|
|
4607
|
-
this.emit("itemSelected" /* ITEM_SELECTED */, this.
|
|
4709
|
+
this.emit("itemSelected" /* ITEM_SELECTED */, this._selectedIndex, selected);
|
|
4608
4710
|
}
|
|
4609
4711
|
}
|
|
4610
4712
|
setSelectedIndex(index) {
|
|
4611
4713
|
if (index >= 0 && index < this._options.length) {
|
|
4612
|
-
this.
|
|
4714
|
+
this._selectedIndex = index;
|
|
4613
4715
|
this.updateScrollOffset();
|
|
4614
4716
|
this.requestRender();
|
|
4615
|
-
this.emit("selectionChanged" /* SELECTION_CHANGED */, this.
|
|
4717
|
+
this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
|
|
4616
4718
|
}
|
|
4617
4719
|
}
|
|
4618
4720
|
updateScrollOffset() {
|
|
4619
4721
|
if (!this._options)
|
|
4620
4722
|
return;
|
|
4621
4723
|
const halfVisible = Math.floor(this.maxVisibleItems / 2);
|
|
4622
|
-
const newScrollOffset = Math.max(0, Math.min(this.
|
|
4724
|
+
const newScrollOffset = Math.max(0, Math.min(this._selectedIndex - halfVisible, this._options.length - this.maxVisibleItems));
|
|
4623
4725
|
if (newScrollOffset !== this.scrollOffset) {
|
|
4624
4726
|
this.scrollOffset = newScrollOffset;
|
|
4625
4727
|
this.requestRender();
|
|
@@ -4751,6 +4853,15 @@ class SelectRenderable extends Renderable {
|
|
|
4751
4853
|
set fastScrollStep(step) {
|
|
4752
4854
|
this._fastScrollStep = step;
|
|
4753
4855
|
}
|
|
4856
|
+
set selectedIndex(value) {
|
|
4857
|
+
const newIndex = value ?? this._defaultOptions.selectedIndex;
|
|
4858
|
+
const clampedIndex = this._options.length > 0 ? Math.min(Math.max(0, newIndex), this._options.length - 1) : 0;
|
|
4859
|
+
if (this._selectedIndex !== clampedIndex) {
|
|
4860
|
+
this._selectedIndex = clampedIndex;
|
|
4861
|
+
this.updateScrollOffset();
|
|
4862
|
+
this.requestRender();
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4754
4865
|
}
|
|
4755
4866
|
// src/renderables/TabSelect.ts
|
|
4756
4867
|
var TabSelectRenderableEvents;
|
|
@@ -5162,6 +5273,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5162
5273
|
_scrollMargin = 0.2;
|
|
5163
5274
|
_showCursor = true;
|
|
5164
5275
|
_cursorColor;
|
|
5276
|
+
_cursorStyle;
|
|
5165
5277
|
lastLocalSelection = null;
|
|
5166
5278
|
_tabIndicator;
|
|
5167
5279
|
_tabIndicatorColor;
|
|
@@ -5180,6 +5292,10 @@ class EditBufferRenderable extends Renderable {
|
|
|
5180
5292
|
scrollMargin: 0.2,
|
|
5181
5293
|
showCursor: true,
|
|
5182
5294
|
cursorColor: RGBA.fromValues(1, 1, 1, 1),
|
|
5295
|
+
cursorStyle: {
|
|
5296
|
+
style: "block",
|
|
5297
|
+
blinking: true
|
|
5298
|
+
},
|
|
5183
5299
|
tabIndicator: undefined,
|
|
5184
5300
|
tabIndicatorColor: undefined
|
|
5185
5301
|
};
|
|
@@ -5195,6 +5311,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5195
5311
|
this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin;
|
|
5196
5312
|
this._showCursor = options.showCursor ?? this._defaultOptions.showCursor;
|
|
5197
5313
|
this._cursorColor = parseColor(options.cursorColor ?? this._defaultOptions.cursorColor);
|
|
5314
|
+
this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle;
|
|
5198
5315
|
this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
|
|
5199
5316
|
this._tabIndicatorColor = options.tabIndicatorColor ? parseColor(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
|
|
5200
5317
|
this.editBuffer = EditBuffer.create(this._ctx.widthMethod);
|
|
@@ -5337,7 +5454,21 @@ class EditBufferRenderable extends Renderable {
|
|
|
5337
5454
|
const newColor = parseColor(value);
|
|
5338
5455
|
if (this._cursorColor !== newColor) {
|
|
5339
5456
|
this._cursorColor = newColor;
|
|
5340
|
-
this.
|
|
5457
|
+
if (this._focused) {
|
|
5458
|
+
this.requestRender();
|
|
5459
|
+
}
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
get cursorStyle() {
|
|
5463
|
+
return this._cursorStyle;
|
|
5464
|
+
}
|
|
5465
|
+
set cursorStyle(style) {
|
|
5466
|
+
const newStyle = style;
|
|
5467
|
+
if (this.cursorStyle.style !== newStyle.style || this.cursorStyle.blinking !== newStyle.blinking) {
|
|
5468
|
+
this._cursorStyle = newStyle;
|
|
5469
|
+
if (this._focused) {
|
|
5470
|
+
this.requestRender();
|
|
5471
|
+
}
|
|
5341
5472
|
}
|
|
5342
5473
|
}
|
|
5343
5474
|
get tabIndicator() {
|
|
@@ -5452,11 +5583,11 @@ class EditBufferRenderable extends Renderable {
|
|
|
5452
5583
|
const cursorY = this.y + visualCursor.visualRow + 1;
|
|
5453
5584
|
this._ctx.setCursorPosition(cursorX, cursorY, true);
|
|
5454
5585
|
this._ctx.setCursorColor(this._cursorColor);
|
|
5455
|
-
this._ctx.setCursorStyle(
|
|
5586
|
+
this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
|
|
5456
5587
|
}
|
|
5457
5588
|
focus() {
|
|
5458
5589
|
super.focus();
|
|
5459
|
-
this._ctx.setCursorStyle(
|
|
5590
|
+
this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
|
|
5460
5591
|
this._ctx.setCursorColor(this._cursorColor);
|
|
5461
5592
|
this.requestRender();
|
|
5462
5593
|
}
|
|
@@ -6203,5 +6334,5 @@ export {
|
|
|
6203
6334
|
ASCIIFont
|
|
6204
6335
|
};
|
|
6205
6336
|
|
|
6206
|
-
//# debugId=
|
|
6337
|
+
//# debugId=44707EEC392262B964756E2164756E21
|
|
6207
6338
|
//# sourceMappingURL=index.js.map
|