@opentui/core 0.0.0-20251102-23e7b561 → 0.0.0-20251106-788e97e4

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
@@ -33,6 +33,7 @@ import {
33
33
  StdinBuffer,
34
34
  StyledText,
35
35
  TerminalConsole,
36
+ TerminalPalette,
36
37
  TextAttributes,
37
38
  TextBuffer,
38
39
  TreeSitterClient,
@@ -65,6 +66,7 @@ import {
65
66
  coordinateToCharacterIndex,
66
67
  createCliRenderer,
67
68
  createExtmarksController,
69
+ createTerminalPalette,
68
70
  createTextAttributes,
69
71
  cyan,
70
72
  delegate,
@@ -134,7 +136,7 @@ import {
134
136
  white,
135
137
  wrapWithDelegates,
136
138
  yellow
137
- } from "./index-rzgaxyf4.js";
139
+ } from "./index-pb1pm3hk.js";
138
140
  // src/text-buffer-view.ts
139
141
  class TextBufferView {
140
142
  lib;
@@ -431,6 +433,24 @@ class EditBuffer extends EventEmitter {
431
433
  this.guard();
432
434
  return this.lib.editBufferGetLineStartOffset(this.bufferPtr, row);
433
435
  }
436
+ getTextRange(startOffset, endOffset) {
437
+ this.guard();
438
+ if (startOffset >= endOffset)
439
+ return "";
440
+ const maxSize = 1024 * 1024;
441
+ const textBytes = this.lib.editBufferGetTextRange(this.bufferPtr, startOffset, endOffset, maxSize);
442
+ if (!textBytes)
443
+ return "";
444
+ return this.lib.decoder.decode(textBytes);
445
+ }
446
+ getTextRangeByCoords(startRow, startCol, endRow, endCol) {
447
+ this.guard();
448
+ const maxSize = 1024 * 1024;
449
+ const textBytes = this.lib.editBufferGetTextRangeByCoords(this.bufferPtr, startRow, startCol, endRow, endCol, maxSize);
450
+ if (!textBytes)
451
+ return "";
452
+ return this.lib.decoder.decode(textBytes);
453
+ }
434
454
  debugLogRope() {
435
455
  this.guard();
436
456
  this.lib.editBufferDebugLogRope(this.bufferPtr);
@@ -2552,10 +2572,7 @@ class TextBufferRenderable extends Renderable {
2552
2572
  }
2553
2573
  updateTextInfo() {
2554
2574
  if (this.lastLocalSelection) {
2555
- const changed = this.updateLocalSelection(this.lastLocalSelection);
2556
- if (changed) {
2557
- this.requestRender();
2558
- }
2575
+ this.updateLocalSelection(this.lastLocalSelection);
2559
2576
  }
2560
2577
  this.yogaNode.markDirty();
2561
2578
  this.requestRender();
@@ -2618,6 +2635,9 @@ class TextBufferRenderable extends Renderable {
2618
2635
  this.markClean();
2619
2636
  this._ctx.addToHitGrid(this.x, this.y, this.width, this.height, this.num);
2620
2637
  this.renderSelf(buffer);
2638
+ if (this.buffered && this.frameBuffer) {
2639
+ buffer.drawFrameBuffer(this.x, this.y, this.frameBuffer);
2640
+ }
2621
2641
  }
2622
2642
  renderSelf(buffer) {
2623
2643
  if (this.textBuffer.ptr) {
@@ -2646,10 +2666,15 @@ class CodeRenderable extends TextBufferRenderable {
2646
2666
  _currentHighlightId = 0;
2647
2667
  _conceal;
2648
2668
  _drawUnstyledText;
2669
+ _shouldRenderTextBuffer = true;
2670
+ _streaming;
2671
+ _hadInitialContent = false;
2672
+ _lastHighlights = [];
2649
2673
  _contentDefaultOptions = {
2650
2674
  content: "",
2651
2675
  conceal: true,
2652
- drawUnstyledText: true
2676
+ drawUnstyledText: true,
2677
+ streaming: false
2653
2678
  };
2654
2679
  constructor(ctx, options) {
2655
2680
  super(ctx, options);
@@ -2659,6 +2684,7 @@ class CodeRenderable extends TextBufferRenderable {
2659
2684
  this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient();
2660
2685
  this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
2661
2686
  this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
2687
+ this._streaming = options.streaming ?? this._contentDefaultOptions.streaming;
2662
2688
  this.updateContent(this._content);
2663
2689
  }
2664
2690
  get content() {
@@ -2706,6 +2732,26 @@ class CodeRenderable extends TextBufferRenderable {
2706
2732
  this.scheduleUpdate();
2707
2733
  }
2708
2734
  }
2735
+ get streaming() {
2736
+ return this._streaming;
2737
+ }
2738
+ set streaming(value) {
2739
+ if (this._streaming !== value) {
2740
+ this._streaming = value;
2741
+ this._hadInitialContent = false;
2742
+ this._lastHighlights = [];
2743
+ this.scheduleUpdate();
2744
+ }
2745
+ }
2746
+ get treeSitterClient() {
2747
+ return this._treeSitterClient;
2748
+ }
2749
+ set treeSitterClient(value) {
2750
+ if (this._treeSitterClient !== value) {
2751
+ this._treeSitterClient = value;
2752
+ this.scheduleUpdate();
2753
+ }
2754
+ }
2709
2755
  scheduleUpdate() {
2710
2756
  if (this._pendingUpdate)
2711
2757
  return;
@@ -2720,25 +2766,53 @@ class CodeRenderable extends TextBufferRenderable {
2720
2766
  return;
2721
2767
  if (!this._filetype) {
2722
2768
  this.fallback(content);
2769
+ this._shouldRenderTextBuffer = true;
2723
2770
  return;
2724
2771
  }
2725
2772
  this._currentHighlightId++;
2726
2773
  const highlightId = this._currentHighlightId;
2727
- if (this._drawUnstyledText) {
2728
- this.fallback(content);
2774
+ const isInitialContent = this._streaming && !this._hadInitialContent;
2775
+ if (isInitialContent) {
2776
+ this._hadInitialContent = true;
2777
+ }
2778
+ const shouldDrawUnstyledNow = this._streaming ? isInitialContent && this._drawUnstyledText : this._drawUnstyledText;
2779
+ this.fallback(content);
2780
+ if (!shouldDrawUnstyledNow) {
2781
+ this._shouldRenderTextBuffer = false;
2782
+ }
2783
+ if (this._streaming && !isInitialContent && this._lastHighlights.length > 0) {
2784
+ const chunks = treeSitterToTextChunks(content, this._lastHighlights, this._syntaxStyle, {
2785
+ enabled: this._conceal
2786
+ });
2787
+ const partialStyledText = new StyledText(chunks);
2788
+ if (this.isDestroyed)
2789
+ return;
2790
+ this.textBuffer.setStyledText(partialStyledText);
2791
+ this._shouldRenderTextBuffer = true;
2792
+ this.updateTextInfo();
2729
2793
  }
2730
2794
  this._isHighlighting = true;
2731
2795
  this._pendingRehighlight = false;
2732
2796
  try {
2733
- const styledText = await treeSitterToStyledText(content, this._filetype, this._syntaxStyle, this._treeSitterClient, {
2734
- conceal: { enabled: this._conceal }
2735
- });
2797
+ const result = await this._treeSitterClient.highlightOnce(content, this._filetype);
2736
2798
  if (highlightId !== this._currentHighlightId) {
2737
2799
  return;
2738
2800
  }
2739
2801
  if (this.isDestroyed)
2740
2802
  return;
2741
- this.textBuffer.setStyledText(styledText);
2803
+ if (result.highlights && result.highlights.length > 0) {
2804
+ if (this._streaming) {
2805
+ this._lastHighlights = result.highlights;
2806
+ }
2807
+ const chunks = treeSitterToTextChunks(content, result.highlights, this._syntaxStyle, {
2808
+ enabled: this._conceal
2809
+ });
2810
+ const styledText = new StyledText(chunks);
2811
+ this.textBuffer.setStyledText(styledText);
2812
+ } else {
2813
+ this.fallback(content);
2814
+ }
2815
+ this._shouldRenderTextBuffer = true;
2742
2816
  this.updateTextInfo();
2743
2817
  } catch (error) {
2744
2818
  if (highlightId !== this._currentHighlightId) {
@@ -2746,6 +2820,7 @@ class CodeRenderable extends TextBufferRenderable {
2746
2820
  }
2747
2821
  console.warn("Code highlighting failed, falling back to plain text:", error);
2748
2822
  this.fallback(content);
2823
+ this._shouldRenderTextBuffer = true;
2749
2824
  } finally {
2750
2825
  if (highlightId === this._currentHighlightId) {
2751
2826
  this._isHighlighting = false;
@@ -2774,6 +2849,11 @@ class CodeRenderable extends TextBufferRenderable {
2774
2849
  getLineHighlights(lineIdx) {
2775
2850
  return this.textBuffer.getLineHighlights(lineIdx);
2776
2851
  }
2852
+ renderSelf(buffer) {
2853
+ if (!this._shouldRenderTextBuffer)
2854
+ return;
2855
+ super.renderSelf(buffer);
2856
+ }
2777
2857
  }
2778
2858
  // src/renderables/TextNode.ts
2779
2859
  var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
@@ -3094,6 +3174,7 @@ class InputRenderable extends Renderable {
3094
3174
  _focusedTextColor;
3095
3175
  _placeholderColor;
3096
3176
  _cursorColor;
3177
+ _cursorStyle;
3097
3178
  _maxLength;
3098
3179
  _lastCommittedValue = "";
3099
3180
  _defaultOptions = {
@@ -3104,6 +3185,10 @@ class InputRenderable extends Renderable {
3104
3185
  placeholder: "",
3105
3186
  placeholderColor: "#666666",
3106
3187
  cursorColor: "#FFFFFF",
3188
+ cursorStyle: {
3189
+ style: "block",
3190
+ blinking: true
3191
+ },
3107
3192
  maxLength: 1000,
3108
3193
  value: ""
3109
3194
  };
@@ -3120,6 +3205,7 @@ class InputRenderable extends Renderable {
3120
3205
  this._maxLength = options.maxLength || this._defaultOptions.maxLength;
3121
3206
  this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
3122
3207
  this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
3208
+ this._cursorStyle = options.cursorStyle || this._defaultOptions.cursorStyle;
3123
3209
  }
3124
3210
  updateCursorPosition() {
3125
3211
  if (!this._focused)
@@ -3142,7 +3228,7 @@ class InputRenderable extends Renderable {
3142
3228
  }
3143
3229
  focus() {
3144
3230
  super.focus();
3145
- this._ctx.setCursorStyle("block", true);
3231
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
3146
3232
  this._ctx.setCursorColor(this._cursorColor);
3147
3233
  this.updateCursorPosition();
3148
3234
  }
@@ -3332,7 +3418,21 @@ class InputRenderable extends Renderable {
3332
3418
  const newColor = parseColor(value ?? this._defaultOptions.cursorColor);
3333
3419
  if (this._cursorColor !== newColor) {
3334
3420
  this._cursorColor = newColor;
3335
- this.requestRender();
3421
+ if (this._focused) {
3422
+ this._ctx.requestRender();
3423
+ }
3424
+ }
3425
+ }
3426
+ get cursorStyle() {
3427
+ return this._cursorStyle;
3428
+ }
3429
+ set cursorStyle(style) {
3430
+ const newStyle = style;
3431
+ if (this.cursorStyle.style !== newStyle.style || this.cursorStyle.blinking !== newStyle.blinking) {
3432
+ this._cursorStyle = newStyle;
3433
+ if (this._focused) {
3434
+ this._ctx.requestRender();
3435
+ }
3336
3436
  }
3337
3437
  }
3338
3438
  updateFromLayout() {
@@ -3934,12 +4034,23 @@ class ArrowRenderable extends Renderable {
3934
4034
  // src/renderables/ScrollBox.ts
3935
4035
  class ContentRenderable extends BoxRenderable {
3936
4036
  viewport;
3937
- constructor(ctx, viewport, options) {
4037
+ _viewportCulling;
4038
+ constructor(ctx, viewport, viewportCulling, options) {
3938
4039
  super(ctx, options);
3939
4040
  this.viewport = viewport;
4041
+ this._viewportCulling = viewportCulling;
4042
+ }
4043
+ get viewportCulling() {
4044
+ return this._viewportCulling;
4045
+ }
4046
+ set viewportCulling(value) {
4047
+ this._viewportCulling = value;
3940
4048
  }
3941
4049
  _getChildren() {
3942
- return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis);
4050
+ if (this._viewportCulling) {
4051
+ return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis);
4052
+ }
4053
+ return this.getChildrenSortedByPrimaryAxis();
3943
4054
  }
3944
4055
  }
3945
4056
 
@@ -4071,6 +4182,7 @@ class ScrollBoxRenderable extends BoxRenderable {
4071
4182
  scrollX = false,
4072
4183
  scrollY = true,
4073
4184
  scrollAcceleration,
4185
+ viewportCulling = true,
4074
4186
  ...options
4075
4187
  }) {
4076
4188
  super(ctx, {
@@ -4106,7 +4218,7 @@ class ScrollBoxRenderable extends BoxRenderable {
4106
4218
  id: `scroll-box-viewport-${this.internalId}`
4107
4219
  });
4108
4220
  this.wrapper.add(this.viewport);
4109
- this.content = new ContentRenderable(ctx, this.viewport, {
4221
+ this.content = new ContentRenderable(ctx, this.viewport, viewportCulling, {
4110
4222
  alignSelf: "flex-start",
4111
4223
  flexShrink: 0,
4112
4224
  ...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
@@ -4400,6 +4512,13 @@ class ScrollBoxRenderable extends BoxRenderable {
4400
4512
  set scrollAcceleration(value) {
4401
4513
  this.scrollAccel = value;
4402
4514
  }
4515
+ get viewportCulling() {
4516
+ return this.content.viewportCulling;
4517
+ }
4518
+ set viewportCulling(value) {
4519
+ this.content.viewportCulling = value;
4520
+ this.requestRender();
4521
+ }
4403
4522
  destroySelf() {
4404
4523
  if (this.selectionListener) {
4405
4524
  this._ctx.off("selection", this.selectionListener);
@@ -4418,7 +4537,7 @@ var SelectRenderableEvents;
4418
4537
  class SelectRenderable extends Renderable {
4419
4538
  _focusable = true;
4420
4539
  _options = [];
4421
- selectedIndex = 0;
4540
+ _selectedIndex = 0;
4422
4541
  scrollOffset = 0;
4423
4542
  maxVisibleItems;
4424
4543
  _backgroundColor;
@@ -4444,6 +4563,7 @@ class SelectRenderable extends Renderable {
4444
4563
  focusedTextColor: "#FFFFFF",
4445
4564
  selectedBackgroundColor: "#334455",
4446
4565
  selectedTextColor: "#FFFF00",
4566
+ selectedIndex: 0,
4447
4567
  descriptionColor: "#888888",
4448
4568
  selectedDescriptionColor: "#CCCCCC",
4449
4569
  showScrollIndicator: false,
@@ -4454,11 +4574,13 @@ class SelectRenderable extends Renderable {
4454
4574
  };
4455
4575
  constructor(ctx, options) {
4456
4576
  super(ctx, { ...options, buffered: true });
4577
+ this._options = options.options || [];
4578
+ const requestedIndex = options.selectedIndex ?? this._defaultOptions.selectedIndex;
4579
+ this._selectedIndex = this._options.length > 0 ? Math.min(requestedIndex, this._options.length - 1) : 0;
4457
4580
  this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
4458
4581
  this._textColor = parseColor(options.textColor || this._defaultOptions.textColor);
4459
4582
  this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || this._defaultOptions.focusedBackgroundColor);
4460
4583
  this._focusedTextColor = parseColor(options.focusedTextColor || this._defaultOptions.focusedTextColor);
4461
- this._options = options.options || [];
4462
4584
  this._showScrollIndicator = options.showScrollIndicator ?? this._defaultOptions.showScrollIndicator;
4463
4585
  this._wrapSelection = options.wrapSelection ?? this._defaultOptions.wrapSelection;
4464
4586
  this._showDescription = options.showDescription ?? this._defaultOptions.showDescription;
@@ -4495,7 +4617,7 @@ class SelectRenderable extends Renderable {
4495
4617
  for (let i = 0;i < visibleOptions.length; i++) {
4496
4618
  const actualIndex = this.scrollOffset + i;
4497
4619
  const option = visibleOptions[i];
4498
- const isSelected = actualIndex === this.selectedIndex;
4620
+ const isSelected = actualIndex === this._selectedIndex;
4499
4621
  const itemY = contentY + i * this.linesPerItem;
4500
4622
  if (itemY + this.linesPerItem - 1 >= contentY + contentHeight)
4501
4623
  break;
@@ -4536,7 +4658,7 @@ class SelectRenderable extends Renderable {
4536
4658
  renderScrollIndicatorToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
4537
4659
  if (!this.frameBuffer)
4538
4660
  return;
4539
- const scrollPercent = this.selectedIndex / Math.max(1, this._options.length - 1);
4661
+ const scrollPercent = this._selectedIndex / Math.max(1, this._options.length - 1);
4540
4662
  const indicatorHeight = Math.max(1, contentHeight - 2);
4541
4663
  const indicatorY = contentY + 1 + Math.floor(scrollPercent * indicatorHeight);
4542
4664
  const indicatorX = contentX + contentWidth - 1;
@@ -4547,61 +4669,61 @@ class SelectRenderable extends Renderable {
4547
4669
  }
4548
4670
  set options(options) {
4549
4671
  this._options = options;
4550
- this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, options.length - 1));
4672
+ this._selectedIndex = Math.min(this._selectedIndex, Math.max(0, options.length - 1));
4551
4673
  this.updateScrollOffset();
4552
4674
  this.requestRender();
4553
4675
  }
4554
4676
  getSelectedOption() {
4555
- return this._options[this.selectedIndex] || null;
4677
+ return this._options[this._selectedIndex] || null;
4556
4678
  }
4557
4679
  getSelectedIndex() {
4558
- return this.selectedIndex;
4680
+ return this._selectedIndex;
4559
4681
  }
4560
4682
  moveUp(steps = 1) {
4561
- const newIndex = this.selectedIndex - steps;
4683
+ const newIndex = this._selectedIndex - steps;
4562
4684
  if (newIndex >= 0) {
4563
- this.selectedIndex = newIndex;
4685
+ this._selectedIndex = newIndex;
4564
4686
  } else if (this._wrapSelection && this._options.length > 0) {
4565
- this.selectedIndex = this._options.length - 1;
4687
+ this._selectedIndex = this._options.length - 1;
4566
4688
  } else {
4567
- this.selectedIndex = 0;
4689
+ this._selectedIndex = 0;
4568
4690
  }
4569
4691
  this.updateScrollOffset();
4570
4692
  this.requestRender();
4571
- this.emit("selectionChanged" /* SELECTION_CHANGED */, this.selectedIndex, this.getSelectedOption());
4693
+ this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
4572
4694
  }
4573
4695
  moveDown(steps = 1) {
4574
- const newIndex = this.selectedIndex + steps;
4696
+ const newIndex = this._selectedIndex + steps;
4575
4697
  if (newIndex < this._options.length) {
4576
- this.selectedIndex = newIndex;
4698
+ this._selectedIndex = newIndex;
4577
4699
  } else if (this._wrapSelection && this._options.length > 0) {
4578
- this.selectedIndex = 0;
4700
+ this._selectedIndex = 0;
4579
4701
  } else {
4580
- this.selectedIndex = this._options.length - 1;
4702
+ this._selectedIndex = this._options.length - 1;
4581
4703
  }
4582
4704
  this.updateScrollOffset();
4583
4705
  this.requestRender();
4584
- this.emit("selectionChanged" /* SELECTION_CHANGED */, this.selectedIndex, this.getSelectedOption());
4706
+ this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
4585
4707
  }
4586
4708
  selectCurrent() {
4587
4709
  const selected = this.getSelectedOption();
4588
4710
  if (selected) {
4589
- this.emit("itemSelected" /* ITEM_SELECTED */, this.selectedIndex, selected);
4711
+ this.emit("itemSelected" /* ITEM_SELECTED */, this._selectedIndex, selected);
4590
4712
  }
4591
4713
  }
4592
4714
  setSelectedIndex(index) {
4593
4715
  if (index >= 0 && index < this._options.length) {
4594
- this.selectedIndex = index;
4716
+ this._selectedIndex = index;
4595
4717
  this.updateScrollOffset();
4596
4718
  this.requestRender();
4597
- this.emit("selectionChanged" /* SELECTION_CHANGED */, this.selectedIndex, this.getSelectedOption());
4719
+ this.emit("selectionChanged" /* SELECTION_CHANGED */, this._selectedIndex, this.getSelectedOption());
4598
4720
  }
4599
4721
  }
4600
4722
  updateScrollOffset() {
4601
4723
  if (!this._options)
4602
4724
  return;
4603
4725
  const halfVisible = Math.floor(this.maxVisibleItems / 2);
4604
- const newScrollOffset = Math.max(0, Math.min(this.selectedIndex - halfVisible, this._options.length - this.maxVisibleItems));
4726
+ const newScrollOffset = Math.max(0, Math.min(this._selectedIndex - halfVisible, this._options.length - this.maxVisibleItems));
4605
4727
  if (newScrollOffset !== this.scrollOffset) {
4606
4728
  this.scrollOffset = newScrollOffset;
4607
4729
  this.requestRender();
@@ -4733,6 +4855,15 @@ class SelectRenderable extends Renderable {
4733
4855
  set fastScrollStep(step) {
4734
4856
  this._fastScrollStep = step;
4735
4857
  }
4858
+ set selectedIndex(value) {
4859
+ const newIndex = value ?? this._defaultOptions.selectedIndex;
4860
+ const clampedIndex = this._options.length > 0 ? Math.min(Math.max(0, newIndex), this._options.length - 1) : 0;
4861
+ if (this._selectedIndex !== clampedIndex) {
4862
+ this._selectedIndex = clampedIndex;
4863
+ this.updateScrollOffset();
4864
+ this.requestRender();
4865
+ }
4866
+ }
4736
4867
  }
4737
4868
  // src/renderables/TabSelect.ts
4738
4869
  var TabSelectRenderableEvents;
@@ -5144,6 +5275,7 @@ class EditBufferRenderable extends Renderable {
5144
5275
  _scrollMargin = 0.2;
5145
5276
  _showCursor = true;
5146
5277
  _cursorColor;
5278
+ _cursorStyle;
5147
5279
  lastLocalSelection = null;
5148
5280
  _tabIndicator;
5149
5281
  _tabIndicatorColor;
@@ -5162,6 +5294,10 @@ class EditBufferRenderable extends Renderable {
5162
5294
  scrollMargin: 0.2,
5163
5295
  showCursor: true,
5164
5296
  cursorColor: RGBA.fromValues(1, 1, 1, 1),
5297
+ cursorStyle: {
5298
+ style: "block",
5299
+ blinking: true
5300
+ },
5165
5301
  tabIndicator: undefined,
5166
5302
  tabIndicatorColor: undefined
5167
5303
  };
@@ -5177,6 +5313,7 @@ class EditBufferRenderable extends Renderable {
5177
5313
  this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin;
5178
5314
  this._showCursor = options.showCursor ?? this._defaultOptions.showCursor;
5179
5315
  this._cursorColor = parseColor(options.cursorColor ?? this._defaultOptions.cursorColor);
5316
+ this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle;
5180
5317
  this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
5181
5318
  this._tabIndicatorColor = options.tabIndicatorColor ? parseColor(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
5182
5319
  this.editBuffer = EditBuffer.create(this._ctx.widthMethod);
@@ -5319,7 +5456,21 @@ class EditBufferRenderable extends Renderable {
5319
5456
  const newColor = parseColor(value);
5320
5457
  if (this._cursorColor !== newColor) {
5321
5458
  this._cursorColor = newColor;
5322
- this.requestRender();
5459
+ if (this._focused) {
5460
+ this.requestRender();
5461
+ }
5462
+ }
5463
+ }
5464
+ get cursorStyle() {
5465
+ return this._cursorStyle;
5466
+ }
5467
+ set cursorStyle(style) {
5468
+ const newStyle = style;
5469
+ if (this.cursorStyle.style !== newStyle.style || this.cursorStyle.blinking !== newStyle.blinking) {
5470
+ this._cursorStyle = newStyle;
5471
+ if (this._focused) {
5472
+ this.requestRender();
5473
+ }
5323
5474
  }
5324
5475
  }
5325
5476
  get tabIndicator() {
@@ -5434,11 +5585,11 @@ class EditBufferRenderable extends Renderable {
5434
5585
  const cursorY = this.y + visualCursor.visualRow + 1;
5435
5586
  this._ctx.setCursorPosition(cursorX, cursorY, true);
5436
5587
  this._ctx.setCursorColor(this._cursorColor);
5437
- this._ctx.setCursorStyle("block", true);
5588
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
5438
5589
  }
5439
5590
  focus() {
5440
5591
  super.focus();
5441
- this._ctx.setCursorStyle("block", true);
5592
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
5442
5593
  this._ctx.setCursorColor(this._cursorColor);
5443
5594
  this.requestRender();
5444
5595
  }
@@ -5523,6 +5674,12 @@ class EditBufferRenderable extends Renderable {
5523
5674
  this.yogaNode.markDirty();
5524
5675
  this.requestRender();
5525
5676
  }
5677
+ getTextRange(startOffset, endOffset) {
5678
+ return this.editBuffer.getTextRange(startOffset, endOffset);
5679
+ }
5680
+ getTextRangeByCoords(startRow, startCol, endRow, endCol) {
5681
+ return this.editBuffer.getTextRangeByCoords(startRow, startCol, endRow, endCol);
5682
+ }
5526
5683
  }
5527
5684
 
5528
5685
  // src/lib/keymapping.ts
@@ -6067,6 +6224,7 @@ export {
6067
6224
  cyan,
6068
6225
  createTimeline,
6069
6226
  createTextAttributes,
6227
+ createTerminalPalette,
6070
6228
  createExtmarksController,
6071
6229
  createCliRenderer,
6072
6230
  coordinateToCharacterIndex,
@@ -6117,6 +6275,7 @@ export {
6117
6275
  TextBuffer,
6118
6276
  TextAttributes,
6119
6277
  Text,
6278
+ TerminalPalette,
6120
6279
  TerminalConsole,
6121
6280
  TabSelectRenderableEvents,
6122
6281
  TabSelectRenderable,
@@ -6179,5 +6338,5 @@ export {
6179
6338
  ASCIIFont
6180
6339
  };
6181
6340
 
6182
- //# debugId=52657F382323749F64756E2164756E21
6341
+ //# debugId=027AE54A57A8DE7D64756E2164756E21
6183
6342
  //# sourceMappingURL=index.js.map