@opentui/core 0.0.0-20251102-23e7b561 → 0.0.0-20251106-dd34dace
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-rzgaxyf4.js → index-n8nbvvhk.js} +115 -10
- package/{index-rzgaxyf4.js.map → index-n8nbvvhk.js.map} +8 -8
- package/index.js +197 -42
- package/index.js.map +9 -9
- package/package.json +7 -7
- package/renderables/Code.d.ts +12 -0
- package/renderables/EditBufferRenderable.d.ts +11 -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/text-buffer.d.ts +1 -0
- package/types.d.ts +4 -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-n8nbvvhk.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);
|
|
@@ -2552,10 +2570,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2552
2570
|
}
|
|
2553
2571
|
updateTextInfo() {
|
|
2554
2572
|
if (this.lastLocalSelection) {
|
|
2555
|
-
|
|
2556
|
-
if (changed) {
|
|
2557
|
-
this.requestRender();
|
|
2558
|
-
}
|
|
2573
|
+
this.updateLocalSelection(this.lastLocalSelection);
|
|
2559
2574
|
}
|
|
2560
2575
|
this.yogaNode.markDirty();
|
|
2561
2576
|
this.requestRender();
|
|
@@ -2618,6 +2633,9 @@ class TextBufferRenderable extends Renderable {
|
|
|
2618
2633
|
this.markClean();
|
|
2619
2634
|
this._ctx.addToHitGrid(this.x, this.y, this.width, this.height, this.num);
|
|
2620
2635
|
this.renderSelf(buffer);
|
|
2636
|
+
if (this.buffered && this.frameBuffer) {
|
|
2637
|
+
buffer.drawFrameBuffer(this.x, this.y, this.frameBuffer);
|
|
2638
|
+
}
|
|
2621
2639
|
}
|
|
2622
2640
|
renderSelf(buffer) {
|
|
2623
2641
|
if (this.textBuffer.ptr) {
|
|
@@ -2646,10 +2664,15 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2646
2664
|
_currentHighlightId = 0;
|
|
2647
2665
|
_conceal;
|
|
2648
2666
|
_drawUnstyledText;
|
|
2667
|
+
_shouldRenderTextBuffer = true;
|
|
2668
|
+
_streaming;
|
|
2669
|
+
_hadInitialContent = false;
|
|
2670
|
+
_lastHighlights = [];
|
|
2649
2671
|
_contentDefaultOptions = {
|
|
2650
2672
|
content: "",
|
|
2651
2673
|
conceal: true,
|
|
2652
|
-
drawUnstyledText: true
|
|
2674
|
+
drawUnstyledText: true,
|
|
2675
|
+
streaming: false
|
|
2653
2676
|
};
|
|
2654
2677
|
constructor(ctx, options) {
|
|
2655
2678
|
super(ctx, options);
|
|
@@ -2659,6 +2682,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2659
2682
|
this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient();
|
|
2660
2683
|
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
2661
2684
|
this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
|
|
2685
|
+
this._streaming = options.streaming ?? this._contentDefaultOptions.streaming;
|
|
2662
2686
|
this.updateContent(this._content);
|
|
2663
2687
|
}
|
|
2664
2688
|
get content() {
|
|
@@ -2706,6 +2730,26 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2706
2730
|
this.scheduleUpdate();
|
|
2707
2731
|
}
|
|
2708
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
|
+
}
|
|
2709
2753
|
scheduleUpdate() {
|
|
2710
2754
|
if (this._pendingUpdate)
|
|
2711
2755
|
return;
|
|
@@ -2720,25 +2764,53 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2720
2764
|
return;
|
|
2721
2765
|
if (!this._filetype) {
|
|
2722
2766
|
this.fallback(content);
|
|
2767
|
+
this._shouldRenderTextBuffer = true;
|
|
2723
2768
|
return;
|
|
2724
2769
|
}
|
|
2725
2770
|
this._currentHighlightId++;
|
|
2726
2771
|
const highlightId = this._currentHighlightId;
|
|
2727
|
-
|
|
2728
|
-
|
|
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();
|
|
2729
2791
|
}
|
|
2730
2792
|
this._isHighlighting = true;
|
|
2731
2793
|
this._pendingRehighlight = false;
|
|
2732
2794
|
try {
|
|
2733
|
-
const
|
|
2734
|
-
conceal: { enabled: this._conceal }
|
|
2735
|
-
});
|
|
2795
|
+
const result = await this._treeSitterClient.highlightOnce(content, this._filetype);
|
|
2736
2796
|
if (highlightId !== this._currentHighlightId) {
|
|
2737
2797
|
return;
|
|
2738
2798
|
}
|
|
2739
2799
|
if (this.isDestroyed)
|
|
2740
2800
|
return;
|
|
2741
|
-
|
|
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;
|
|
2742
2814
|
this.updateTextInfo();
|
|
2743
2815
|
} catch (error) {
|
|
2744
2816
|
if (highlightId !== this._currentHighlightId) {
|
|
@@ -2746,6 +2818,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2746
2818
|
}
|
|
2747
2819
|
console.warn("Code highlighting failed, falling back to plain text:", error);
|
|
2748
2820
|
this.fallback(content);
|
|
2821
|
+
this._shouldRenderTextBuffer = true;
|
|
2749
2822
|
} finally {
|
|
2750
2823
|
if (highlightId === this._currentHighlightId) {
|
|
2751
2824
|
this._isHighlighting = false;
|
|
@@ -2774,6 +2847,11 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2774
2847
|
getLineHighlights(lineIdx) {
|
|
2775
2848
|
return this.textBuffer.getLineHighlights(lineIdx);
|
|
2776
2849
|
}
|
|
2850
|
+
renderSelf(buffer) {
|
|
2851
|
+
if (!this._shouldRenderTextBuffer)
|
|
2852
|
+
return;
|
|
2853
|
+
super.renderSelf(buffer);
|
|
2854
|
+
}
|
|
2777
2855
|
}
|
|
2778
2856
|
// src/renderables/TextNode.ts
|
|
2779
2857
|
var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
|
|
@@ -3094,6 +3172,7 @@ class InputRenderable extends Renderable {
|
|
|
3094
3172
|
_focusedTextColor;
|
|
3095
3173
|
_placeholderColor;
|
|
3096
3174
|
_cursorColor;
|
|
3175
|
+
_cursorStyle;
|
|
3097
3176
|
_maxLength;
|
|
3098
3177
|
_lastCommittedValue = "";
|
|
3099
3178
|
_defaultOptions = {
|
|
@@ -3104,6 +3183,10 @@ class InputRenderable extends Renderable {
|
|
|
3104
3183
|
placeholder: "",
|
|
3105
3184
|
placeholderColor: "#666666",
|
|
3106
3185
|
cursorColor: "#FFFFFF",
|
|
3186
|
+
cursorStyle: {
|
|
3187
|
+
style: "block",
|
|
3188
|
+
blinking: true
|
|
3189
|
+
},
|
|
3107
3190
|
maxLength: 1000,
|
|
3108
3191
|
value: ""
|
|
3109
3192
|
};
|
|
@@ -3120,6 +3203,7 @@ class InputRenderable extends Renderable {
|
|
|
3120
3203
|
this._maxLength = options.maxLength || this._defaultOptions.maxLength;
|
|
3121
3204
|
this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
|
|
3122
3205
|
this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
|
|
3206
|
+
this._cursorStyle = options.cursorStyle || this._defaultOptions.cursorStyle;
|
|
3123
3207
|
}
|
|
3124
3208
|
updateCursorPosition() {
|
|
3125
3209
|
if (!this._focused)
|
|
@@ -3142,7 +3226,7 @@ class InputRenderable extends Renderable {
|
|
|
3142
3226
|
}
|
|
3143
3227
|
focus() {
|
|
3144
3228
|
super.focus();
|
|
3145
|
-
this._ctx.setCursorStyle(
|
|
3229
|
+
this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
|
|
3146
3230
|
this._ctx.setCursorColor(this._cursorColor);
|
|
3147
3231
|
this.updateCursorPosition();
|
|
3148
3232
|
}
|
|
@@ -3332,7 +3416,21 @@ class InputRenderable extends Renderable {
|
|
|
3332
3416
|
const newColor = parseColor(value ?? this._defaultOptions.cursorColor);
|
|
3333
3417
|
if (this._cursorColor !== newColor) {
|
|
3334
3418
|
this._cursorColor = newColor;
|
|
3335
|
-
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
|
+
}
|
|
3336
3434
|
}
|
|
3337
3435
|
}
|
|
3338
3436
|
updateFromLayout() {
|
|
@@ -3934,12 +4032,23 @@ class ArrowRenderable extends Renderable {
|
|
|
3934
4032
|
// src/renderables/ScrollBox.ts
|
|
3935
4033
|
class ContentRenderable extends BoxRenderable {
|
|
3936
4034
|
viewport;
|
|
3937
|
-
|
|
4035
|
+
_viewportCulling;
|
|
4036
|
+
constructor(ctx, viewport, viewportCulling, options) {
|
|
3938
4037
|
super(ctx, options);
|
|
3939
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;
|
|
3940
4046
|
}
|
|
3941
4047
|
_getChildren() {
|
|
3942
|
-
|
|
4048
|
+
if (this._viewportCulling) {
|
|
4049
|
+
return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis);
|
|
4050
|
+
}
|
|
4051
|
+
return this.getChildrenSortedByPrimaryAxis();
|
|
3943
4052
|
}
|
|
3944
4053
|
}
|
|
3945
4054
|
|
|
@@ -4071,6 +4180,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
4071
4180
|
scrollX = false,
|
|
4072
4181
|
scrollY = true,
|
|
4073
4182
|
scrollAcceleration,
|
|
4183
|
+
viewportCulling = true,
|
|
4074
4184
|
...options
|
|
4075
4185
|
}) {
|
|
4076
4186
|
super(ctx, {
|
|
@@ -4106,7 +4216,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
4106
4216
|
id: `scroll-box-viewport-${this.internalId}`
|
|
4107
4217
|
});
|
|
4108
4218
|
this.wrapper.add(this.viewport);
|
|
4109
|
-
this.content = new ContentRenderable(ctx, this.viewport, {
|
|
4219
|
+
this.content = new ContentRenderable(ctx, this.viewport, viewportCulling, {
|
|
4110
4220
|
alignSelf: "flex-start",
|
|
4111
4221
|
flexShrink: 0,
|
|
4112
4222
|
...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
|
|
@@ -4400,6 +4510,13 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
4400
4510
|
set scrollAcceleration(value) {
|
|
4401
4511
|
this.scrollAccel = value;
|
|
4402
4512
|
}
|
|
4513
|
+
get viewportCulling() {
|
|
4514
|
+
return this.content.viewportCulling;
|
|
4515
|
+
}
|
|
4516
|
+
set viewportCulling(value) {
|
|
4517
|
+
this.content.viewportCulling = value;
|
|
4518
|
+
this.requestRender();
|
|
4519
|
+
}
|
|
4403
4520
|
destroySelf() {
|
|
4404
4521
|
if (this.selectionListener) {
|
|
4405
4522
|
this._ctx.off("selection", this.selectionListener);
|
|
@@ -4418,7 +4535,7 @@ var SelectRenderableEvents;
|
|
|
4418
4535
|
class SelectRenderable extends Renderable {
|
|
4419
4536
|
_focusable = true;
|
|
4420
4537
|
_options = [];
|
|
4421
|
-
|
|
4538
|
+
_selectedIndex = 0;
|
|
4422
4539
|
scrollOffset = 0;
|
|
4423
4540
|
maxVisibleItems;
|
|
4424
4541
|
_backgroundColor;
|
|
@@ -4444,6 +4561,7 @@ class SelectRenderable extends Renderable {
|
|
|
4444
4561
|
focusedTextColor: "#FFFFFF",
|
|
4445
4562
|
selectedBackgroundColor: "#334455",
|
|
4446
4563
|
selectedTextColor: "#FFFF00",
|
|
4564
|
+
selectedIndex: 0,
|
|
4447
4565
|
descriptionColor: "#888888",
|
|
4448
4566
|
selectedDescriptionColor: "#CCCCCC",
|
|
4449
4567
|
showScrollIndicator: false,
|
|
@@ -4454,11 +4572,13 @@ class SelectRenderable extends Renderable {
|
|
|
4454
4572
|
};
|
|
4455
4573
|
constructor(ctx, options) {
|
|
4456
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;
|
|
4457
4578
|
this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
|
|
4458
4579
|
this._textColor = parseColor(options.textColor || this._defaultOptions.textColor);
|
|
4459
4580
|
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || this._defaultOptions.focusedBackgroundColor);
|
|
4460
4581
|
this._focusedTextColor = parseColor(options.focusedTextColor || this._defaultOptions.focusedTextColor);
|
|
4461
|
-
this._options = options.options || [];
|
|
4462
4582
|
this._showScrollIndicator = options.showScrollIndicator ?? this._defaultOptions.showScrollIndicator;
|
|
4463
4583
|
this._wrapSelection = options.wrapSelection ?? this._defaultOptions.wrapSelection;
|
|
4464
4584
|
this._showDescription = options.showDescription ?? this._defaultOptions.showDescription;
|
|
@@ -4495,7 +4615,7 @@ class SelectRenderable extends Renderable {
|
|
|
4495
4615
|
for (let i = 0;i < visibleOptions.length; i++) {
|
|
4496
4616
|
const actualIndex = this.scrollOffset + i;
|
|
4497
4617
|
const option = visibleOptions[i];
|
|
4498
|
-
const isSelected = actualIndex === this.
|
|
4618
|
+
const isSelected = actualIndex === this._selectedIndex;
|
|
4499
4619
|
const itemY = contentY + i * this.linesPerItem;
|
|
4500
4620
|
if (itemY + this.linesPerItem - 1 >= contentY + contentHeight)
|
|
4501
4621
|
break;
|
|
@@ -4536,7 +4656,7 @@ class SelectRenderable extends Renderable {
|
|
|
4536
4656
|
renderScrollIndicatorToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
|
|
4537
4657
|
if (!this.frameBuffer)
|
|
4538
4658
|
return;
|
|
4539
|
-
const scrollPercent = this.
|
|
4659
|
+
const scrollPercent = this._selectedIndex / Math.max(1, this._options.length - 1);
|
|
4540
4660
|
const indicatorHeight = Math.max(1, contentHeight - 2);
|
|
4541
4661
|
const indicatorY = contentY + 1 + Math.floor(scrollPercent * indicatorHeight);
|
|
4542
4662
|
const indicatorX = contentX + contentWidth - 1;
|
|
@@ -4547,61 +4667,61 @@ class SelectRenderable extends Renderable {
|
|
|
4547
4667
|
}
|
|
4548
4668
|
set options(options) {
|
|
4549
4669
|
this._options = options;
|
|
4550
|
-
this.
|
|
4670
|
+
this._selectedIndex = Math.min(this._selectedIndex, Math.max(0, options.length - 1));
|
|
4551
4671
|
this.updateScrollOffset();
|
|
4552
4672
|
this.requestRender();
|
|
4553
4673
|
}
|
|
4554
4674
|
getSelectedOption() {
|
|
4555
|
-
return this._options[this.
|
|
4675
|
+
return this._options[this._selectedIndex] || null;
|
|
4556
4676
|
}
|
|
4557
4677
|
getSelectedIndex() {
|
|
4558
|
-
return this.
|
|
4678
|
+
return this._selectedIndex;
|
|
4559
4679
|
}
|
|
4560
4680
|
moveUp(steps = 1) {
|
|
4561
|
-
const newIndex = this.
|
|
4681
|
+
const newIndex = this._selectedIndex - steps;
|
|
4562
4682
|
if (newIndex >= 0) {
|
|
4563
|
-
this.
|
|
4683
|
+
this._selectedIndex = newIndex;
|
|
4564
4684
|
} else if (this._wrapSelection && this._options.length > 0) {
|
|
4565
|
-
this.
|
|
4685
|
+
this._selectedIndex = this._options.length - 1;
|
|
4566
4686
|
} else {
|
|
4567
|
-
this.
|
|
4687
|
+
this._selectedIndex = 0;
|
|
4568
4688
|
}
|
|
4569
4689
|
this.updateScrollOffset();
|
|
4570
4690
|
this.requestRender();
|
|
4571
|
-
this.emit("selectionChanged" /* SELECTION_CHANGED */, this.
|
|
4691
|
+
this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
|
|
4572
4692
|
}
|
|
4573
4693
|
moveDown(steps = 1) {
|
|
4574
|
-
const newIndex = this.
|
|
4694
|
+
const newIndex = this._selectedIndex + steps;
|
|
4575
4695
|
if (newIndex < this._options.length) {
|
|
4576
|
-
this.
|
|
4696
|
+
this._selectedIndex = newIndex;
|
|
4577
4697
|
} else if (this._wrapSelection && this._options.length > 0) {
|
|
4578
|
-
this.
|
|
4698
|
+
this._selectedIndex = 0;
|
|
4579
4699
|
} else {
|
|
4580
|
-
this.
|
|
4700
|
+
this._selectedIndex = this._options.length - 1;
|
|
4581
4701
|
}
|
|
4582
4702
|
this.updateScrollOffset();
|
|
4583
4703
|
this.requestRender();
|
|
4584
|
-
this.emit("selectionChanged" /* SELECTION_CHANGED */, this.
|
|
4704
|
+
this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
|
|
4585
4705
|
}
|
|
4586
4706
|
selectCurrent() {
|
|
4587
4707
|
const selected = this.getSelectedOption();
|
|
4588
4708
|
if (selected) {
|
|
4589
|
-
this.emit("itemSelected" /* ITEM_SELECTED */, this.
|
|
4709
|
+
this.emit("itemSelected" /* ITEM_SELECTED */, this._selectedIndex, selected);
|
|
4590
4710
|
}
|
|
4591
4711
|
}
|
|
4592
4712
|
setSelectedIndex(index) {
|
|
4593
4713
|
if (index >= 0 && index < this._options.length) {
|
|
4594
|
-
this.
|
|
4714
|
+
this._selectedIndex = index;
|
|
4595
4715
|
this.updateScrollOffset();
|
|
4596
4716
|
this.requestRender();
|
|
4597
|
-
this.emit("selectionChanged" /* SELECTION_CHANGED */, this.
|
|
4717
|
+
this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
|
|
4598
4718
|
}
|
|
4599
4719
|
}
|
|
4600
4720
|
updateScrollOffset() {
|
|
4601
4721
|
if (!this._options)
|
|
4602
4722
|
return;
|
|
4603
4723
|
const halfVisible = Math.floor(this.maxVisibleItems / 2);
|
|
4604
|
-
const newScrollOffset = Math.max(0, Math.min(this.
|
|
4724
|
+
const newScrollOffset = Math.max(0, Math.min(this._selectedIndex - halfVisible, this._options.length - this.maxVisibleItems));
|
|
4605
4725
|
if (newScrollOffset !== this.scrollOffset) {
|
|
4606
4726
|
this.scrollOffset = newScrollOffset;
|
|
4607
4727
|
this.requestRender();
|
|
@@ -4733,6 +4853,15 @@ class SelectRenderable extends Renderable {
|
|
|
4733
4853
|
set fastScrollStep(step) {
|
|
4734
4854
|
this._fastScrollStep = step;
|
|
4735
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
|
+
}
|
|
4736
4865
|
}
|
|
4737
4866
|
// src/renderables/TabSelect.ts
|
|
4738
4867
|
var TabSelectRenderableEvents;
|
|
@@ -5144,6 +5273,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5144
5273
|
_scrollMargin = 0.2;
|
|
5145
5274
|
_showCursor = true;
|
|
5146
5275
|
_cursorColor;
|
|
5276
|
+
_cursorStyle;
|
|
5147
5277
|
lastLocalSelection = null;
|
|
5148
5278
|
_tabIndicator;
|
|
5149
5279
|
_tabIndicatorColor;
|
|
@@ -5162,6 +5292,10 @@ class EditBufferRenderable extends Renderable {
|
|
|
5162
5292
|
scrollMargin: 0.2,
|
|
5163
5293
|
showCursor: true,
|
|
5164
5294
|
cursorColor: RGBA.fromValues(1, 1, 1, 1),
|
|
5295
|
+
cursorStyle: {
|
|
5296
|
+
style: "block",
|
|
5297
|
+
blinking: true
|
|
5298
|
+
},
|
|
5165
5299
|
tabIndicator: undefined,
|
|
5166
5300
|
tabIndicatorColor: undefined
|
|
5167
5301
|
};
|
|
@@ -5177,6 +5311,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5177
5311
|
this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin;
|
|
5178
5312
|
this._showCursor = options.showCursor ?? this._defaultOptions.showCursor;
|
|
5179
5313
|
this._cursorColor = parseColor(options.cursorColor ?? this._defaultOptions.cursorColor);
|
|
5314
|
+
this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle;
|
|
5180
5315
|
this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
|
|
5181
5316
|
this._tabIndicatorColor = options.tabIndicatorColor ? parseColor(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
|
|
5182
5317
|
this.editBuffer = EditBuffer.create(this._ctx.widthMethod);
|
|
@@ -5319,7 +5454,21 @@ class EditBufferRenderable extends Renderable {
|
|
|
5319
5454
|
const newColor = parseColor(value);
|
|
5320
5455
|
if (this._cursorColor !== newColor) {
|
|
5321
5456
|
this._cursorColor = newColor;
|
|
5322
|
-
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
|
+
}
|
|
5323
5472
|
}
|
|
5324
5473
|
}
|
|
5325
5474
|
get tabIndicator() {
|
|
@@ -5434,11 +5583,11 @@ class EditBufferRenderable extends Renderable {
|
|
|
5434
5583
|
const cursorY = this.y + visualCursor.visualRow + 1;
|
|
5435
5584
|
this._ctx.setCursorPosition(cursorX, cursorY, true);
|
|
5436
5585
|
this._ctx.setCursorColor(this._cursorColor);
|
|
5437
|
-
this._ctx.setCursorStyle(
|
|
5586
|
+
this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
|
|
5438
5587
|
}
|
|
5439
5588
|
focus() {
|
|
5440
5589
|
super.focus();
|
|
5441
|
-
this._ctx.setCursorStyle(
|
|
5590
|
+
this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
|
|
5442
5591
|
this._ctx.setCursorColor(this._cursorColor);
|
|
5443
5592
|
this.requestRender();
|
|
5444
5593
|
}
|
|
@@ -5523,6 +5672,12 @@ class EditBufferRenderable extends Renderable {
|
|
|
5523
5672
|
this.yogaNode.markDirty();
|
|
5524
5673
|
this.requestRender();
|
|
5525
5674
|
}
|
|
5675
|
+
getTextRange(startOffset, endOffset) {
|
|
5676
|
+
return this.editBuffer.getTextRange(startOffset, endOffset);
|
|
5677
|
+
}
|
|
5678
|
+
getTextRangeByCoords(startRow, startCol, endRow, endCol) {
|
|
5679
|
+
return this.editBuffer.getTextRangeByCoords(startRow, startCol, endRow, endCol);
|
|
5680
|
+
}
|
|
5526
5681
|
}
|
|
5527
5682
|
|
|
5528
5683
|
// src/lib/keymapping.ts
|
|
@@ -6179,5 +6334,5 @@ export {
|
|
|
6179
6334
|
ASCIIFont
|
|
6180
6335
|
};
|
|
6181
6336
|
|
|
6182
|
-
//# debugId=
|
|
6337
|
+
//# debugId=44707EEC392262B964756E2164756E21
|
|
6183
6338
|
//# sourceMappingURL=index.js.map
|