@opentui/core 0.5.11 → 0.5.13

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.
@@ -41,7 +41,7 @@ import {
41
41
  NativeMeasureTargetKind2,
42
42
  resolveRenderLib2,
43
43
  yoga_default
44
- } from "./chunk-node-70eg2nhg.js";
44
+ } from "./chunk-node-80p7e6t6.js";
45
45
 
46
46
  // src/syntax-style.ts
47
47
  function convertThemeToStyles2(theme) {
@@ -1110,8 +1110,8 @@ class Renderable2 extends BaseRenderable2 {
1110
1110
  const parentScreenY = this.parent ? this.parent._screenY : 0;
1111
1111
  this._screenX = parentScreenX + this._x + this._translateX;
1112
1112
  this._screenY = parentScreenY + this._y + this._translateY;
1113
- const newWidth = Math.max(layout.width, 1);
1114
- const newHeight = Math.max(layout.height, 1);
1113
+ const newWidth = Number.isNaN(layout.width) ? oldWidth : Math.max(layout.width, 1);
1114
+ const newHeight = Number.isNaN(layout.height) ? oldHeight : Math.max(layout.height, 1);
1115
1115
  const sizeChanged = oldWidth !== newWidth || oldHeight !== newHeight;
1116
1116
  this._widthValue = newWidth;
1117
1117
  this._heightValue = newHeight;
@@ -1843,6 +1843,7 @@ class TextBufferView2 {
1843
1843
  viewPtr;
1844
1844
  textBuffer;
1845
1845
  _destroyed = false;
1846
+ selectionClear = true;
1846
1847
  constructor(lib, ptr, textBuffer) {
1847
1848
  this.lib = lib;
1848
1849
  this.viewPtr = ptr;
@@ -1863,15 +1864,20 @@ class TextBufferView2 {
1863
1864
  }
1864
1865
  setSelection(start, end, bgColor, fgColor) {
1865
1866
  this.guard();
1867
+ this.selectionClear = false;
1866
1868
  this.lib.textBufferViewSetSelection(this.viewPtr, start, end, bgColor || null, fgColor || null);
1867
1869
  }
1868
1870
  updateSelection(end, bgColor, fgColor) {
1869
1871
  this.guard();
1872
+ this.selectionClear = false;
1870
1873
  this.lib.textBufferViewUpdateSelection(this.viewPtr, end, bgColor || null, fgColor || null);
1871
1874
  }
1872
1875
  resetSelection() {
1873
1876
  this.guard();
1877
+ if (this.selectionClear)
1878
+ return;
1874
1879
  this.lib.textBufferViewResetSelection(this.viewPtr);
1880
+ this.selectionClear = true;
1875
1881
  }
1876
1882
  getSelection() {
1877
1883
  this.guard();
@@ -1883,15 +1889,20 @@ class TextBufferView2 {
1883
1889
  }
1884
1890
  setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior = "cell") {
1885
1891
  this.guard();
1892
+ this.selectionClear = false;
1886
1893
  return this.lib.textBufferViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, behavior);
1887
1894
  }
1888
1895
  updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior = "cell") {
1889
1896
  this.guard();
1897
+ this.selectionClear = false;
1890
1898
  return this.lib.textBufferViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, behavior);
1891
1899
  }
1892
1900
  resetLocalSelection() {
1893
1901
  this.guard();
1902
+ if (this.selectionClear)
1903
+ return;
1894
1904
  this.lib.textBufferViewResetLocalSelection(this.viewPtr);
1905
+ this.selectionClear = true;
1895
1906
  }
1896
1907
  setSelectionOccupancy(occupancy) {
1897
1908
  this.guard();
@@ -1909,6 +1920,10 @@ class TextBufferView2 {
1909
1920
  this.guard();
1910
1921
  this.lib.textBufferViewSetWrapMode(this.viewPtr, mode);
1911
1922
  }
1923
+ setTextAlign(alignment) {
1924
+ this.guard();
1925
+ this.lib.textBufferViewSetTextAlign(this.viewPtr, alignment);
1926
+ }
1912
1927
  setFirstLineOffset(offset) {
1913
1928
  this.guard();
1914
1929
  this.lib.textBufferViewSetFirstLineOffset(this.viewPtr, offset);
@@ -2321,6 +2336,9 @@ class EditorView2 {
2321
2336
  const viewPtr = lib.createEditorView(editBuffer.ptr, viewportWidth, viewportHeight);
2322
2337
  return new EditorView2(lib, viewPtr, editBuffer);
2323
2338
  }
2339
+ get isDestroyed() {
2340
+ return this._destroyed;
2341
+ }
2324
2342
  guard() {
2325
2343
  if (this._destroyed)
2326
2344
  throw new Error("EditorView is destroyed");
@@ -2793,6 +2811,7 @@ class TextBufferRenderable2 extends Renderable2 {
2793
2811
  _selectionBg;
2794
2812
  _selectionFg;
2795
2813
  _wrapMode = "word";
2814
+ _textAlign = "left";
2796
2815
  lastLocalSelection = null;
2797
2816
  _tabIndicator;
2798
2817
  _tabIndicatorColor;
@@ -2812,6 +2831,7 @@ class TextBufferRenderable2 extends Renderable2 {
2812
2831
  selectable: true,
2813
2832
  attributes: 0,
2814
2833
  wrapMode: "word",
2834
+ textAlign: "left",
2815
2835
  tabIndicator: undefined,
2816
2836
  tabIndicatorColor: undefined,
2817
2837
  truncate: false
@@ -2825,6 +2845,7 @@ class TextBufferRenderable2 extends Renderable2 {
2825
2845
  this._selectionFg = options.selectionFg ? parseColor2(options.selectionFg) : this._defaultOptions.selectionFg;
2826
2846
  this.selectable = options.selectable ?? this._defaultOptions.selectable;
2827
2847
  this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
2848
+ this._textAlign = options.textAlign ?? this._defaultOptions.textAlign;
2828
2849
  this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
2829
2850
  this._tabIndicatorColor = options.tabIndicatorColor ? parseColor2(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
2830
2851
  this._truncate = options.truncate ?? this._defaultOptions.truncate;
@@ -2834,6 +2855,7 @@ class TextBufferRenderable2 extends Renderable2 {
2834
2855
  this._textBufferSyntaxStyle = SyntaxStyle2.create();
2835
2856
  this.textBuffer.setSyntaxStyle(this._textBufferSyntaxStyle);
2836
2857
  this.textBufferView.setWrapMode(this._wrapMode);
2858
+ this.textBufferView.setTextAlign(this._textAlign);
2837
2859
  this.textBufferView.setFirstLineOffset(this._firstLineOffset);
2838
2860
  this.setupNativeRenderable();
2839
2861
  this.textBuffer.setDefaultFg(this._defaultFg);
@@ -3024,6 +3046,16 @@ class TextBufferRenderable2 extends Renderable2 {
3024
3046
  this.requestRender();
3025
3047
  }
3026
3048
  }
3049
+ get textAlign() {
3050
+ return this._textAlign;
3051
+ }
3052
+ set textAlign(value) {
3053
+ if (this._textAlign !== value) {
3054
+ this._textAlign = value;
3055
+ this.textBufferView.setTextAlign(this._textAlign);
3056
+ this.requestRender();
3057
+ }
3058
+ }
3027
3059
  get tabIndicator() {
3028
3060
  return this._tabIndicator;
3029
3061
  }
@@ -5532,6 +5564,13 @@ class TerminalConsole2 extends EventEmitter4 {
5532
5564
 
5533
5565
  // src/renderables/EditBufferRenderable.ts
5534
5566
  var BrandedEditBufferRenderable = Symbol.for("@opentui/core/EditBufferRenderable");
5567
+ var emptyVisualCursor = Object.freeze({
5568
+ visualRow: 0,
5569
+ visualCol: 0,
5570
+ logicalRow: 0,
5571
+ logicalCol: 0,
5572
+ offset: 0
5573
+ });
5535
5574
  var EditBufferRenderableEvents2;
5536
5575
  ((EditBufferRenderableEvents) => {
5537
5576
  EditBufferRenderableEvents["TRAITS_CHANGED"] = "traits-changed";
@@ -5676,10 +5715,12 @@ class EditBufferRenderable2 extends Renderable2 {
5676
5715
  return this.editBuffer.getCursorPosition();
5677
5716
  }
5678
5717
  get visualCursor() {
5718
+ if (this.editorView.isDestroyed)
5719
+ return emptyVisualCursor;
5679
5720
  return this.editorView.getVisualCursor();
5680
5721
  }
5681
5722
  get cursorOffset() {
5682
- return this.editorView.getVisualCursor().offset;
5723
+ return this.visualCursor.offset;
5683
5724
  }
5684
5725
  set cursorOffset(offset) {
5685
5726
  this.clearSelection();
@@ -6314,7 +6355,7 @@ class EditBufferRenderable2 extends Renderable2 {
6314
6355
  renderCursor(buffer) {
6315
6356
  if (!this._showCursor || !this._focused)
6316
6357
  return;
6317
- const visualCursor = this.editorView.getVisualCursor();
6358
+ const visualCursor = this.visualCursor;
6318
6359
  const screenX = this._screenX;
6319
6360
  const screenY = this._screenY;
6320
6361
  const cursorX = screenX + visualCursor.visualCol + 1;
@@ -9507,7 +9548,7 @@ Captured external output:
9507
9548
  if (splitFooterActive) {
9508
9549
  let clearStart = null;
9509
9550
  if (width < prevWidth && visiblePreviousSplitHeight > 0) {
9510
- clearStart = Math.max(previousTerminalHeight - visiblePreviousSplitHeight * 2, 1);
9551
+ clearStart = Math.min(this.renderOffset + 1, Math.max(previousTerminalHeight - visiblePreviousSplitHeight * 2, 1));
9511
9552
  }
9512
9553
  if (pendingSplitFooterTransition !== null) {
9513
9554
  clearStart = clearStart === null ? pendingSplitFooterTransition.sourceTopLine : Math.min(clearStart, pendingSplitFooterTransition.sourceTopLine);
@@ -10472,5 +10513,5 @@ Captured external output:
10472
10513
 
10473
10514
  export { convertThemeToStyles2, SyntaxStyle2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBufferView2, EditBuffer2, EditorView2, ANSI, BoxRenderable2, TextBufferRenderable2, CodeRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSpanFeed2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, getObjectsInViewport, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
10474
10515
 
10475
- //# debugId=EDE4817CFEF779F464756E2164756E21
10476
- //# sourceMappingURL=chunk-node-54dhb2fr.js.map
10516
+ //# debugId=1E9C4A614B22FBD464756E2164756E21
10517
+ //# sourceMappingURL=chunk-node-fz19wge8.js.map