@opentui/core 0.0.0-20251031-fc297165 → 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/index.js CHANGED
@@ -30,6 +30,7 @@ import {
30
30
  RendererControlState,
31
31
  RootRenderable,
32
32
  Selection,
33
+ StdinBuffer,
33
34
  StyledText,
34
35
  TerminalConsole,
35
36
  TextAttributes,
@@ -133,7 +134,7 @@ import {
133
134
  white,
134
135
  wrapWithDelegates,
135
136
  yellow
136
- } from "./index-vr8t68wb.js";
137
+ } from "./index-n8nbvvhk.js";
137
138
  // src/text-buffer-view.ts
138
139
  class TextBufferView {
139
140
  lib;
@@ -430,6 +431,24 @@ class EditBuffer extends EventEmitter {
430
431
  this.guard();
431
432
  return this.lib.editBufferGetLineStartOffset(this.bufferPtr, row);
432
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
+ }
433
452
  debugLogRope() {
434
453
  this.guard();
435
454
  this.lib.editBufferDebugLogRope(this.bufferPtr);
@@ -2202,6 +2221,13 @@ class BoxRenderable extends Renderable {
2202
2221
  this.applyYogaGap(options);
2203
2222
  }
2204
2223
  }
2224
+ initializeBorder() {
2225
+ if (this._border === false) {
2226
+ this._border = true;
2227
+ this.borderSides = getBorderSides(this._border);
2228
+ this.applyYogaBorders();
2229
+ }
2230
+ }
2205
2231
  get customBorderChars() {
2206
2232
  return this._customBorderCharsObj;
2207
2233
  }
@@ -2236,9 +2262,10 @@ class BoxRenderable extends Renderable {
2236
2262
  }
2237
2263
  set borderStyle(value) {
2238
2264
  let _value = value ?? this._defaultOptions.borderStyle;
2239
- if (this._borderStyle !== _value) {
2265
+ if (this._borderStyle !== _value || !this._border) {
2240
2266
  this._borderStyle = _value;
2241
2267
  this._customBorderChars = undefined;
2268
+ this.initializeBorder();
2242
2269
  this.requestRender();
2243
2270
  }
2244
2271
  }
@@ -2249,6 +2276,7 @@ class BoxRenderable extends Renderable {
2249
2276
  const newColor = parseColor(value ?? this._defaultOptions.borderColor);
2250
2277
  if (this._borderColor !== newColor) {
2251
2278
  this._borderColor = newColor;
2279
+ this.initializeBorder();
2252
2280
  this.requestRender();
2253
2281
  }
2254
2282
  }
@@ -2259,6 +2287,7 @@ class BoxRenderable extends Renderable {
2259
2287
  const newColor = parseColor(value ?? this._defaultOptions.focusedBorderColor);
2260
2288
  if (this._focusedBorderColor !== newColor) {
2261
2289
  this._focusedBorderColor = newColor;
2290
+ this.initializeBorder();
2262
2291
  if (this._focused) {
2263
2292
  this.requestRender();
2264
2293
  }
@@ -2541,10 +2570,7 @@ class TextBufferRenderable extends Renderable {
2541
2570
  }
2542
2571
  updateTextInfo() {
2543
2572
  if (this.lastLocalSelection) {
2544
- const changed = this.updateLocalSelection(this.lastLocalSelection);
2545
- if (changed) {
2546
- this.requestRender();
2547
- }
2573
+ this.updateLocalSelection(this.lastLocalSelection);
2548
2574
  }
2549
2575
  this.yogaNode.markDirty();
2550
2576
  this.requestRender();
@@ -2607,6 +2633,9 @@ class TextBufferRenderable extends Renderable {
2607
2633
  this.markClean();
2608
2634
  this._ctx.addToHitGrid(this.x, this.y, this.width, this.height, this.num);
2609
2635
  this.renderSelf(buffer);
2636
+ if (this.buffered && this.frameBuffer) {
2637
+ buffer.drawFrameBuffer(this.x, this.y, this.frameBuffer);
2638
+ }
2610
2639
  }
2611
2640
  renderSelf(buffer) {
2612
2641
  if (this.textBuffer.ptr) {
@@ -2635,10 +2664,15 @@ class CodeRenderable extends TextBufferRenderable {
2635
2664
  _currentHighlightId = 0;
2636
2665
  _conceal;
2637
2666
  _drawUnstyledText;
2667
+ _shouldRenderTextBuffer = true;
2668
+ _streaming;
2669
+ _hadInitialContent = false;
2670
+ _lastHighlights = [];
2638
2671
  _contentDefaultOptions = {
2639
2672
  content: "",
2640
2673
  conceal: true,
2641
- drawUnstyledText: true
2674
+ drawUnstyledText: true,
2675
+ streaming: false
2642
2676
  };
2643
2677
  constructor(ctx, options) {
2644
2678
  super(ctx, options);
@@ -2648,6 +2682,7 @@ class CodeRenderable extends TextBufferRenderable {
2648
2682
  this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient();
2649
2683
  this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
2650
2684
  this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
2685
+ this._streaming = options.streaming ?? this._contentDefaultOptions.streaming;
2651
2686
  this.updateContent(this._content);
2652
2687
  }
2653
2688
  get content() {
@@ -2695,6 +2730,26 @@ class CodeRenderable extends TextBufferRenderable {
2695
2730
  this.scheduleUpdate();
2696
2731
  }
2697
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
+ }
2698
2753
  scheduleUpdate() {
2699
2754
  if (this._pendingUpdate)
2700
2755
  return;
@@ -2709,25 +2764,53 @@ class CodeRenderable extends TextBufferRenderable {
2709
2764
  return;
2710
2765
  if (!this._filetype) {
2711
2766
  this.fallback(content);
2767
+ this._shouldRenderTextBuffer = true;
2712
2768
  return;
2713
2769
  }
2714
2770
  this._currentHighlightId++;
2715
2771
  const highlightId = this._currentHighlightId;
2716
- if (this._drawUnstyledText) {
2717
- this.fallback(content);
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();
2718
2791
  }
2719
2792
  this._isHighlighting = true;
2720
2793
  this._pendingRehighlight = false;
2721
2794
  try {
2722
- const styledText = await treeSitterToStyledText(content, this._filetype, this._syntaxStyle, this._treeSitterClient, {
2723
- conceal: { enabled: this._conceal }
2724
- });
2795
+ const result = await this._treeSitterClient.highlightOnce(content, this._filetype);
2725
2796
  if (highlightId !== this._currentHighlightId) {
2726
2797
  return;
2727
2798
  }
2728
2799
  if (this.isDestroyed)
2729
2800
  return;
2730
- this.textBuffer.setStyledText(styledText);
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;
2731
2814
  this.updateTextInfo();
2732
2815
  } catch (error) {
2733
2816
  if (highlightId !== this._currentHighlightId) {
@@ -2735,6 +2818,7 @@ class CodeRenderable extends TextBufferRenderable {
2735
2818
  }
2736
2819
  console.warn("Code highlighting failed, falling back to plain text:", error);
2737
2820
  this.fallback(content);
2821
+ this._shouldRenderTextBuffer = true;
2738
2822
  } finally {
2739
2823
  if (highlightId === this._currentHighlightId) {
2740
2824
  this._isHighlighting = false;
@@ -2763,6 +2847,11 @@ class CodeRenderable extends TextBufferRenderable {
2763
2847
  getLineHighlights(lineIdx) {
2764
2848
  return this.textBuffer.getLineHighlights(lineIdx);
2765
2849
  }
2850
+ renderSelf(buffer) {
2851
+ if (!this._shouldRenderTextBuffer)
2852
+ return;
2853
+ super.renderSelf(buffer);
2854
+ }
2766
2855
  }
2767
2856
  // src/renderables/TextNode.ts
2768
2857
  var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
@@ -3083,6 +3172,7 @@ class InputRenderable extends Renderable {
3083
3172
  _focusedTextColor;
3084
3173
  _placeholderColor;
3085
3174
  _cursorColor;
3175
+ _cursorStyle;
3086
3176
  _maxLength;
3087
3177
  _lastCommittedValue = "";
3088
3178
  _defaultOptions = {
@@ -3093,6 +3183,10 @@ class InputRenderable extends Renderable {
3093
3183
  placeholder: "",
3094
3184
  placeholderColor: "#666666",
3095
3185
  cursorColor: "#FFFFFF",
3186
+ cursorStyle: {
3187
+ style: "block",
3188
+ blinking: true
3189
+ },
3096
3190
  maxLength: 1000,
3097
3191
  value: ""
3098
3192
  };
@@ -3109,6 +3203,7 @@ class InputRenderable extends Renderable {
3109
3203
  this._maxLength = options.maxLength || this._defaultOptions.maxLength;
3110
3204
  this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
3111
3205
  this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
3206
+ this._cursorStyle = options.cursorStyle || this._defaultOptions.cursorStyle;
3112
3207
  }
3113
3208
  updateCursorPosition() {
3114
3209
  if (!this._focused)
@@ -3131,7 +3226,7 @@ class InputRenderable extends Renderable {
3131
3226
  }
3132
3227
  focus() {
3133
3228
  super.focus();
3134
- this._ctx.setCursorStyle("block", true);
3229
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
3135
3230
  this._ctx.setCursorColor(this._cursorColor);
3136
3231
  this.updateCursorPosition();
3137
3232
  }
@@ -3321,7 +3416,21 @@ class InputRenderable extends Renderable {
3321
3416
  const newColor = parseColor(value ?? this._defaultOptions.cursorColor);
3322
3417
  if (this._cursorColor !== newColor) {
3323
3418
  this._cursorColor = newColor;
3324
- this.requestRender();
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
+ }
3325
3434
  }
3326
3435
  }
3327
3436
  updateFromLayout() {
@@ -3923,12 +4032,23 @@ class ArrowRenderable extends Renderable {
3923
4032
  // src/renderables/ScrollBox.ts
3924
4033
  class ContentRenderable extends BoxRenderable {
3925
4034
  viewport;
3926
- constructor(ctx, viewport, options) {
4035
+ _viewportCulling;
4036
+ constructor(ctx, viewport, viewportCulling, options) {
3927
4037
  super(ctx, options);
3928
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;
3929
4046
  }
3930
4047
  _getChildren() {
3931
- return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis);
4048
+ if (this._viewportCulling) {
4049
+ return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis);
4050
+ }
4051
+ return this.getChildrenSortedByPrimaryAxis();
3932
4052
  }
3933
4053
  }
3934
4054
 
@@ -4060,6 +4180,7 @@ class ScrollBoxRenderable extends BoxRenderable {
4060
4180
  scrollX = false,
4061
4181
  scrollY = true,
4062
4182
  scrollAcceleration,
4183
+ viewportCulling = true,
4063
4184
  ...options
4064
4185
  }) {
4065
4186
  super(ctx, {
@@ -4095,7 +4216,7 @@ class ScrollBoxRenderable extends BoxRenderable {
4095
4216
  id: `scroll-box-viewport-${this.internalId}`
4096
4217
  });
4097
4218
  this.wrapper.add(this.viewport);
4098
- this.content = new ContentRenderable(ctx, this.viewport, {
4219
+ this.content = new ContentRenderable(ctx, this.viewport, viewportCulling, {
4099
4220
  alignSelf: "flex-start",
4100
4221
  flexShrink: 0,
4101
4222
  ...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
@@ -4389,6 +4510,13 @@ class ScrollBoxRenderable extends BoxRenderable {
4389
4510
  set scrollAcceleration(value) {
4390
4511
  this.scrollAccel = value;
4391
4512
  }
4513
+ get viewportCulling() {
4514
+ return this.content.viewportCulling;
4515
+ }
4516
+ set viewportCulling(value) {
4517
+ this.content.viewportCulling = value;
4518
+ this.requestRender();
4519
+ }
4392
4520
  destroySelf() {
4393
4521
  if (this.selectionListener) {
4394
4522
  this._ctx.off("selection", this.selectionListener);
@@ -4407,7 +4535,7 @@ var SelectRenderableEvents;
4407
4535
  class SelectRenderable extends Renderable {
4408
4536
  _focusable = true;
4409
4537
  _options = [];
4410
- selectedIndex = 0;
4538
+ _selectedIndex = 0;
4411
4539
  scrollOffset = 0;
4412
4540
  maxVisibleItems;
4413
4541
  _backgroundColor;
@@ -4433,6 +4561,7 @@ class SelectRenderable extends Renderable {
4433
4561
  focusedTextColor: "#FFFFFF",
4434
4562
  selectedBackgroundColor: "#334455",
4435
4563
  selectedTextColor: "#FFFF00",
4564
+ selectedIndex: 0,
4436
4565
  descriptionColor: "#888888",
4437
4566
  selectedDescriptionColor: "#CCCCCC",
4438
4567
  showScrollIndicator: false,
@@ -4443,11 +4572,13 @@ class SelectRenderable extends Renderable {
4443
4572
  };
4444
4573
  constructor(ctx, options) {
4445
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;
4446
4578
  this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
4447
4579
  this._textColor = parseColor(options.textColor || this._defaultOptions.textColor);
4448
4580
  this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || this._defaultOptions.focusedBackgroundColor);
4449
4581
  this._focusedTextColor = parseColor(options.focusedTextColor || this._defaultOptions.focusedTextColor);
4450
- this._options = options.options || [];
4451
4582
  this._showScrollIndicator = options.showScrollIndicator ?? this._defaultOptions.showScrollIndicator;
4452
4583
  this._wrapSelection = options.wrapSelection ?? this._defaultOptions.wrapSelection;
4453
4584
  this._showDescription = options.showDescription ?? this._defaultOptions.showDescription;
@@ -4484,7 +4615,7 @@ class SelectRenderable extends Renderable {
4484
4615
  for (let i = 0;i < visibleOptions.length; i++) {
4485
4616
  const actualIndex = this.scrollOffset + i;
4486
4617
  const option = visibleOptions[i];
4487
- const isSelected = actualIndex === this.selectedIndex;
4618
+ const isSelected = actualIndex === this._selectedIndex;
4488
4619
  const itemY = contentY + i * this.linesPerItem;
4489
4620
  if (itemY + this.linesPerItem - 1 >= contentY + contentHeight)
4490
4621
  break;
@@ -4525,7 +4656,7 @@ class SelectRenderable extends Renderable {
4525
4656
  renderScrollIndicatorToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
4526
4657
  if (!this.frameBuffer)
4527
4658
  return;
4528
- const scrollPercent = this.selectedIndex / Math.max(1, this._options.length - 1);
4659
+ const scrollPercent = this._selectedIndex / Math.max(1, this._options.length - 1);
4529
4660
  const indicatorHeight = Math.max(1, contentHeight - 2);
4530
4661
  const indicatorY = contentY + 1 + Math.floor(scrollPercent * indicatorHeight);
4531
4662
  const indicatorX = contentX + contentWidth - 1;
@@ -4536,61 +4667,61 @@ class SelectRenderable extends Renderable {
4536
4667
  }
4537
4668
  set options(options) {
4538
4669
  this._options = options;
4539
- this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, options.length - 1));
4670
+ this._selectedIndex = Math.min(this._selectedIndex, Math.max(0, options.length - 1));
4540
4671
  this.updateScrollOffset();
4541
4672
  this.requestRender();
4542
4673
  }
4543
4674
  getSelectedOption() {
4544
- return this._options[this.selectedIndex] || null;
4675
+ return this._options[this._selectedIndex] || null;
4545
4676
  }
4546
4677
  getSelectedIndex() {
4547
- return this.selectedIndex;
4678
+ return this._selectedIndex;
4548
4679
  }
4549
4680
  moveUp(steps = 1) {
4550
- const newIndex = this.selectedIndex - steps;
4681
+ const newIndex = this._selectedIndex - steps;
4551
4682
  if (newIndex >= 0) {
4552
- this.selectedIndex = newIndex;
4683
+ this._selectedIndex = newIndex;
4553
4684
  } else if (this._wrapSelection && this._options.length > 0) {
4554
- this.selectedIndex = this._options.length - 1;
4685
+ this._selectedIndex = this._options.length - 1;
4555
4686
  } else {
4556
- this.selectedIndex = 0;
4687
+ this._selectedIndex = 0;
4557
4688
  }
4558
4689
  this.updateScrollOffset();
4559
4690
  this.requestRender();
4560
- this.emit("selectionChanged" /* SELECTION_CHANGED */, this.selectedIndex, this.getSelectedOption());
4691
+ this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
4561
4692
  }
4562
4693
  moveDown(steps = 1) {
4563
- const newIndex = this.selectedIndex + steps;
4694
+ const newIndex = this._selectedIndex + steps;
4564
4695
  if (newIndex < this._options.length) {
4565
- this.selectedIndex = newIndex;
4696
+ this._selectedIndex = newIndex;
4566
4697
  } else if (this._wrapSelection && this._options.length > 0) {
4567
- this.selectedIndex = 0;
4698
+ this._selectedIndex = 0;
4568
4699
  } else {
4569
- this.selectedIndex = this._options.length - 1;
4700
+ this._selectedIndex = this._options.length - 1;
4570
4701
  }
4571
4702
  this.updateScrollOffset();
4572
4703
  this.requestRender();
4573
- this.emit("selectionChanged" /* SELECTION_CHANGED */, this.selectedIndex, this.getSelectedOption());
4704
+ this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
4574
4705
  }
4575
4706
  selectCurrent() {
4576
4707
  const selected = this.getSelectedOption();
4577
4708
  if (selected) {
4578
- this.emit("itemSelected" /* ITEM_SELECTED */, this.selectedIndex, selected);
4709
+ this.emit("itemSelected" /* ITEM_SELECTED */, this._selectedIndex, selected);
4579
4710
  }
4580
4711
  }
4581
4712
  setSelectedIndex(index) {
4582
4713
  if (index >= 0 && index < this._options.length) {
4583
- this.selectedIndex = index;
4714
+ this._selectedIndex = index;
4584
4715
  this.updateScrollOffset();
4585
4716
  this.requestRender();
4586
- this.emit("selectionChanged" /* SELECTION_CHANGED */, this.selectedIndex, this.getSelectedOption());
4717
+ this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
4587
4718
  }
4588
4719
  }
4589
4720
  updateScrollOffset() {
4590
4721
  if (!this._options)
4591
4722
  return;
4592
4723
  const halfVisible = Math.floor(this.maxVisibleItems / 2);
4593
- const newScrollOffset = Math.max(0, Math.min(this.selectedIndex - halfVisible, this._options.length - this.maxVisibleItems));
4724
+ const newScrollOffset = Math.max(0, Math.min(this._selectedIndex - halfVisible, this._options.length - this.maxVisibleItems));
4594
4725
  if (newScrollOffset !== this.scrollOffset) {
4595
4726
  this.scrollOffset = newScrollOffset;
4596
4727
  this.requestRender();
@@ -4722,6 +4853,15 @@ class SelectRenderable extends Renderable {
4722
4853
  set fastScrollStep(step) {
4723
4854
  this._fastScrollStep = step;
4724
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
+ }
4725
4865
  }
4726
4866
  // src/renderables/TabSelect.ts
4727
4867
  var TabSelectRenderableEvents;
@@ -5133,6 +5273,7 @@ class EditBufferRenderable extends Renderable {
5133
5273
  _scrollMargin = 0.2;
5134
5274
  _showCursor = true;
5135
5275
  _cursorColor;
5276
+ _cursorStyle;
5136
5277
  lastLocalSelection = null;
5137
5278
  _tabIndicator;
5138
5279
  _tabIndicatorColor;
@@ -5151,6 +5292,10 @@ class EditBufferRenderable extends Renderable {
5151
5292
  scrollMargin: 0.2,
5152
5293
  showCursor: true,
5153
5294
  cursorColor: RGBA.fromValues(1, 1, 1, 1),
5295
+ cursorStyle: {
5296
+ style: "block",
5297
+ blinking: true
5298
+ },
5154
5299
  tabIndicator: undefined,
5155
5300
  tabIndicatorColor: undefined
5156
5301
  };
@@ -5166,6 +5311,7 @@ class EditBufferRenderable extends Renderable {
5166
5311
  this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin;
5167
5312
  this._showCursor = options.showCursor ?? this._defaultOptions.showCursor;
5168
5313
  this._cursorColor = parseColor(options.cursorColor ?? this._defaultOptions.cursorColor);
5314
+ this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle;
5169
5315
  this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
5170
5316
  this._tabIndicatorColor = options.tabIndicatorColor ? parseColor(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
5171
5317
  this.editBuffer = EditBuffer.create(this._ctx.widthMethod);
@@ -5308,7 +5454,21 @@ class EditBufferRenderable extends Renderable {
5308
5454
  const newColor = parseColor(value);
5309
5455
  if (this._cursorColor !== newColor) {
5310
5456
  this._cursorColor = newColor;
5311
- this.requestRender();
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
+ }
5312
5472
  }
5313
5473
  }
5314
5474
  get tabIndicator() {
@@ -5423,11 +5583,11 @@ class EditBufferRenderable extends Renderable {
5423
5583
  const cursorY = this.y + visualCursor.visualRow + 1;
5424
5584
  this._ctx.setCursorPosition(cursorX, cursorY, true);
5425
5585
  this._ctx.setCursorColor(this._cursorColor);
5426
- this._ctx.setCursorStyle("block", true);
5586
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
5427
5587
  }
5428
5588
  focus() {
5429
5589
  super.focus();
5430
- this._ctx.setCursorStyle("block", true);
5590
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
5431
5591
  this._ctx.setCursorColor(this._cursorColor);
5432
5592
  this.requestRender();
5433
5593
  }
@@ -5512,6 +5672,12 @@ class EditBufferRenderable extends Renderable {
5512
5672
  this.yogaNode.markDirty();
5513
5673
  this.requestRender();
5514
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
+ }
5515
5681
  }
5516
5682
 
5517
5683
  // src/lib/keymapping.ts
@@ -6112,6 +6278,7 @@ export {
6112
6278
  TabSelect,
6113
6279
  SyntaxStyle,
6114
6280
  StyledText,
6281
+ StdinBuffer,
6115
6282
  SliderRenderable,
6116
6283
  Selection,
6117
6284
  SelectRenderableEvents,
@@ -6167,5 +6334,5 @@ export {
6167
6334
  ASCIIFont
6168
6335
  };
6169
6336
 
6170
- //# debugId=FA34F12A6B07201B64756E2164756E21
6337
+ //# debugId=44707EEC392262B964756E2164756E21
6171
6338
  //# sourceMappingURL=index.js.map