@opentui/core 0.0.0-20250918-7ff2578a → 0.0.0-20250919-c2d2d461

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
@@ -13,7 +13,6 @@ import {
13
13
  KeyHandler,
14
14
  LayoutEvents,
15
15
  LogLevel,
16
- MeasureMode,
17
16
  MouseButton,
18
17
  MouseEvent,
19
18
  MouseParser,
@@ -111,7 +110,7 @@ import {
111
110
  white,
112
111
  wrapWithDelegates,
113
112
  yellow
114
- } from "./index-9skjt1d2.js";
113
+ } from "./index-sf59r9br.js";
115
114
  // src/post/filters.ts
116
115
  function applyScanlines(buffer, strength = 0.8, step = 2) {
117
116
  const width = buffer.width;
@@ -1672,9 +1671,11 @@ class TextRenderable extends Renderable {
1672
1671
  _defaultAttributes;
1673
1672
  _selectionBg;
1674
1673
  _selectionFg;
1674
+ _wrap = false;
1675
+ _wrapMode = "word";
1675
1676
  lastLocalSelection = null;
1676
1677
  textBuffer;
1677
- _lineInfo = { lineStarts: [], lineWidths: [] };
1678
+ _lineInfo = { lineStarts: [], lineWidths: [], maxLineWidth: 0 };
1678
1679
  rootTextNode;
1679
1680
  _defaultOptions = {
1680
1681
  content: "",
@@ -1683,7 +1684,9 @@ class TextRenderable extends Renderable {
1683
1684
  selectionBg: undefined,
1684
1685
  selectionFg: undefined,
1685
1686
  selectable: true,
1686
- attributes: 0
1687
+ attributes: 0,
1688
+ wrap: true,
1689
+ wrapMode: "word"
1687
1690
  };
1688
1691
  constructor(ctx, options) {
1689
1692
  super(ctx, options);
@@ -1696,7 +1699,13 @@ class TextRenderable extends Renderable {
1696
1699
  this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : this._defaultOptions.selectionBg;
1697
1700
  this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : this._defaultOptions.selectionFg;
1698
1701
  this.selectable = options.selectable ?? this._defaultOptions.selectable;
1699
- this.textBuffer = TextBuffer.create(64, this._ctx.widthMethod);
1702
+ this._wrap = options.wrap ?? this._defaultOptions.wrap;
1703
+ this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
1704
+ this.textBuffer = TextBuffer.create(this._ctx.widthMethod);
1705
+ this.textBuffer.setWrapMode(this._wrapMode);
1706
+ if (this._wrap) {
1707
+ this.textBuffer.setWrapWidth(this.width > 0 ? this.width : 40);
1708
+ }
1700
1709
  this.textBuffer.setDefaultFg(this._defaultFg);
1701
1710
  this.textBuffer.setDefaultBg(this._defaultBg);
1702
1711
  this.textBuffer.setDefaultAttributes(this._defaultAttributes);
@@ -1803,8 +1812,31 @@ class TextRenderable extends Renderable {
1803
1812
  this.requestRender();
1804
1813
  }
1805
1814
  }
1815
+ get wrap() {
1816
+ return this._wrap;
1817
+ }
1818
+ set wrap(value) {
1819
+ if (this._wrap !== value) {
1820
+ this._wrap = value;
1821
+ this.textBuffer.setWrapWidth(this._wrap ? this.width : null);
1822
+ this.requestRender();
1823
+ }
1824
+ }
1825
+ get wrapMode() {
1826
+ return this._wrapMode;
1827
+ }
1828
+ set wrapMode(value) {
1829
+ if (this._wrapMode !== value) {
1830
+ this._wrapMode = value;
1831
+ this.textBuffer.setWrapMode(this._wrapMode);
1832
+ this.requestRender();
1833
+ }
1834
+ }
1806
1835
  onResize(width, height) {
1807
- if (this.lastLocalSelection) {
1836
+ if (this._wrap) {
1837
+ this.textBuffer.setWrapWidth(width);
1838
+ this.updateTextInfo();
1839
+ } else if (this.lastLocalSelection) {
1808
1840
  const changed = this.updateLocalSelection(this.lastLocalSelection);
1809
1841
  if (changed) {
1810
1842
  this.requestRender();
@@ -1822,6 +1854,7 @@ class TextRenderable extends Renderable {
1822
1854
  const lineInfo = this.textBuffer.lineInfo;
1823
1855
  this._lineInfo.lineStarts = lineInfo.lineStarts;
1824
1856
  this._lineInfo.lineWidths = lineInfo.lineWidths;
1857
+ this._lineInfo.maxLineWidth = lineInfo.maxLineWidth;
1825
1858
  if (this.lastLocalSelection) {
1826
1859
  const changed = this.updateLocalSelection(this.lastLocalSelection);
1827
1860
  if (changed) {
@@ -1833,20 +1866,10 @@ class TextRenderable extends Renderable {
1833
1866
  }
1834
1867
  setupMeasureFunc() {
1835
1868
  const measureFunc = (width, widthMode, height, heightMode) => {
1836
- const maxLineWidth = Math.max(...this._lineInfo.lineWidths, 0);
1837
- const numLines = this._lineInfo.lineStarts.length || 1;
1869
+ const maxLineWidth = this._lineInfo.maxLineWidth;
1870
+ const numLines = this._lineInfo.lineStarts.length;
1838
1871
  let measuredWidth = maxLineWidth;
1839
1872
  let measuredHeight = numLines;
1840
- if (widthMode === MeasureMode.Exactly) {
1841
- measuredWidth = width;
1842
- } else if (widthMode === MeasureMode.AtMost) {
1843
- measuredWidth = Math.min(maxLineWidth, width);
1844
- }
1845
- if (heightMode === MeasureMode.Exactly) {
1846
- measuredHeight = height;
1847
- } else if (heightMode === MeasureMode.AtMost) {
1848
- measuredHeight = Math.min(numLines, height);
1849
- }
1850
1873
  return {
1851
1874
  width: Math.max(1, measuredWidth),
1852
1875
  height: Math.max(1, measuredHeight)
@@ -3733,6 +3756,8 @@ class ScrollBoxRenderable extends BoxRenderable {
3733
3756
  horizontalScrollbarOptions,
3734
3757
  stickyScroll = false,
3735
3758
  stickyStart,
3759
+ scrollX = false,
3760
+ scrollY = true,
3736
3761
  ...options
3737
3762
  }) {
3738
3763
  super(ctx, {
@@ -3767,8 +3792,8 @@ class ScrollBoxRenderable extends BoxRenderable {
3767
3792
  this.wrapper.add(this.viewport);
3768
3793
  this.content = new ContentRenderable(ctx, this.viewport, {
3769
3794
  alignSelf: "flex-start",
3770
- minWidth: "100%",
3771
- minHeight: "100%",
3795
+ ...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
3796
+ ...scrollY ? { minHeight: "100%" } : { minHeight: "100%", maxHeight: "100%" },
3772
3797
  onSizeChange: () => {
3773
3798
  this.recalculateBarProps();
3774
3799
  },
@@ -4270,5 +4295,5 @@ export {
4270
4295
  ASCIIFont
4271
4296
  };
4272
4297
 
4273
- //# debugId=624CE1C61076A58864756E2164756E21
4298
+ //# debugId=9FEF005017B1B5AE64756E2164756E21
4274
4299
  //# sourceMappingURL=index.js.map