@opentuah/core 0.1.95 → 0.1.96

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
@@ -155,7 +155,7 @@ import {
155
155
  white,
156
156
  wrapWithDelegates,
157
157
  yellow
158
- } from "./index-2fr3e57d.js";
158
+ } from "./index-yc0yx782.js";
159
159
  // src/text-buffer-view.ts
160
160
  class TextBufferView {
161
161
  lib;
@@ -4162,6 +4162,23 @@ class LineNumberRenderable extends Renderable {
4162
4162
  this._inlineHighlights.clear();
4163
4163
  this.requestRender();
4164
4164
  }
4165
+ highlightLines(startLine, endLine, color) {
4166
+ for (let i = startLine;i <= endLine; i++) {
4167
+ this.parseLineColor(i, color);
4168
+ }
4169
+ if (this.gutter) {
4170
+ this.gutter.setLineColors(this._lineColorsGutter, this._lineColorsContent);
4171
+ }
4172
+ }
4173
+ clearHighlightLines(startLine, endLine) {
4174
+ for (let i = startLine;i <= endLine; i++) {
4175
+ this._lineColorsGutter.delete(i);
4176
+ this._lineColorsContent.delete(i);
4177
+ }
4178
+ if (this.gutter) {
4179
+ this.gutter.setLineColors(this._lineColorsGutter, this._lineColorsContent);
4180
+ }
4181
+ }
4165
4182
  }
4166
4183
 
4167
4184
  // ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/base.js
@@ -6119,6 +6136,30 @@ class DiffRenderable extends Renderable {
6119
6136
  this.rebuildView();
6120
6137
  }
6121
6138
  }
6139
+ setLineColor(line, color) {
6140
+ this.leftSide?.setLineColor(line, color);
6141
+ this.rightSide?.setLineColor(line, color);
6142
+ }
6143
+ clearLineColor(line) {
6144
+ this.leftSide?.clearLineColor(line);
6145
+ this.rightSide?.clearLineColor(line);
6146
+ }
6147
+ setLineColors(lineColors) {
6148
+ this.leftSide?.setLineColors(lineColors);
6149
+ this.rightSide?.setLineColors(lineColors);
6150
+ }
6151
+ clearAllLineColors() {
6152
+ this.leftSide?.clearAllLineColors();
6153
+ this.rightSide?.clearAllLineColors();
6154
+ }
6155
+ highlightLines(startLine, endLine, color) {
6156
+ this.leftSide?.highlightLines(startLine, endLine, color);
6157
+ this.rightSide?.highlightLines(startLine, endLine, color);
6158
+ }
6159
+ clearHighlightLines(startLine, endLine) {
6160
+ this.leftSide?.clearHighlightLines(startLine, endLine);
6161
+ this.rightSide?.clearHighlightLines(startLine, endLine);
6162
+ }
6122
6163
  }
6123
6164
  // src/renderables/EditBufferRenderable.ts
6124
6165
  class EditBufferRenderable extends Renderable {
@@ -6550,13 +6591,11 @@ class EditBufferRenderable extends Renderable {
6550
6591
  const cursorX = this.x + visualCursor.visualCol + 1;
6551
6592
  const cursorY = this.y + visualCursor.visualRow + 1;
6552
6593
  this._ctx.setCursorPosition(cursorX, cursorY, true);
6553
- this._ctx.setCursorColor(this._cursorColor);
6554
- this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
6594
+ this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor });
6555
6595
  }
6556
6596
  focus() {
6557
6597
  super.focus();
6558
- this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
6559
- this._ctx.setCursorColor(this._cursorColor);
6598
+ this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor });
6560
6599
  this.requestRender();
6561
6600
  }
6562
6601
  blur() {
@@ -7147,9 +7186,10 @@ class TextareaRenderable extends EditBufferRenderable {
7147
7186
  return this._placeholder;
7148
7187
  }
7149
7188
  set placeholder(value) {
7150
- if (this._placeholder !== value) {
7151
- this._placeholder = value;
7152
- this.applyPlaceholder(value);
7189
+ const normalizedValue = value ?? null;
7190
+ if (this._placeholder !== normalizedValue) {
7191
+ this._placeholder = normalizedValue;
7192
+ this.applyPlaceholder(normalizedValue);
7153
7193
  this.requestRender();
7154
7194
  }
7155
7195
  }
@@ -8765,8 +8805,7 @@ class MarkdownRenderable extends Renderable {
8765
8805
  set streaming(value) {
8766
8806
  if (this._streaming !== value) {
8767
8807
  this._streaming = value;
8768
- this.updateBlocks();
8769
- this.requestRender();
8808
+ this.clearCache();
8770
8809
  }
8771
8810
  }
8772
8811
  getStyle(group) {
@@ -10199,13 +10238,13 @@ class ScrollBoxRenderable extends BoxRenderable {
10199
10238
  if (this.scrollTop <= 0) {
10200
10239
  this._stickyScrollTop = true;
10201
10240
  this._stickyScrollBottom = false;
10202
- if (this._stickyStart === "top" || this._stickyStart === "bottom" && maxScrollTop === 0) {
10241
+ if (!this._isApplyingStickyScroll && (this._stickyStart === "top" || this._stickyStart === "bottom" && maxScrollTop === 0)) {
10203
10242
  this._hasManualScroll = false;
10204
10243
  }
10205
10244
  } else if (this.scrollTop >= maxScrollTop) {
10206
10245
  this._stickyScrollTop = false;
10207
10246
  this._stickyScrollBottom = true;
10208
- if (this._stickyStart === "bottom") {
10247
+ if (!this._isApplyingStickyScroll && this._stickyStart === "bottom") {
10209
10248
  this._hasManualScroll = false;
10210
10249
  }
10211
10250
  } else {
@@ -10215,13 +10254,13 @@ class ScrollBoxRenderable extends BoxRenderable {
10215
10254
  if (this.scrollLeft <= 0) {
10216
10255
  this._stickyScrollLeft = true;
10217
10256
  this._stickyScrollRight = false;
10218
- if (this._stickyStart === "left" || this._stickyStart === "right" && maxScrollLeft === 0) {
10257
+ if (!this._isApplyingStickyScroll && (this._stickyStart === "left" || this._stickyStart === "right" && maxScrollLeft === 0)) {
10219
10258
  this._hasManualScroll = false;
10220
10259
  }
10221
10260
  } else if (this.scrollLeft >= maxScrollLeft) {
10222
10261
  this._stickyScrollLeft = false;
10223
10262
  this._stickyScrollRight = true;
10224
- if (this._stickyStart === "right") {
10263
+ if (!this._isApplyingStickyScroll && this._stickyStart === "right") {
10225
10264
  this._hasManualScroll = false;
10226
10265
  }
10227
10266
  } else {
@@ -10230,30 +10269,34 @@ class ScrollBoxRenderable extends BoxRenderable {
10230
10269
  }
10231
10270
  }
10232
10271
  applyStickyStart(stickyStart) {
10272
+ const wasApplyingStickyScroll = this._isApplyingStickyScroll;
10233
10273
  this._isApplyingStickyScroll = true;
10234
- switch (stickyStart) {
10235
- case "top":
10236
- this._stickyScrollTop = true;
10237
- this._stickyScrollBottom = false;
10238
- this.verticalScrollBar.scrollPosition = 0;
10239
- break;
10240
- case "bottom":
10241
- this._stickyScrollTop = false;
10242
- this._stickyScrollBottom = true;
10243
- this.verticalScrollBar.scrollPosition = Math.max(0, this.scrollHeight - this.viewport.height);
10244
- break;
10245
- case "left":
10246
- this._stickyScrollLeft = true;
10247
- this._stickyScrollRight = false;
10248
- this.horizontalScrollBar.scrollPosition = 0;
10249
- break;
10250
- case "right":
10251
- this._stickyScrollLeft = false;
10252
- this._stickyScrollRight = true;
10253
- this.horizontalScrollBar.scrollPosition = Math.max(0, this.scrollWidth - this.viewport.width);
10254
- break;
10274
+ try {
10275
+ switch (stickyStart) {
10276
+ case "top":
10277
+ this._stickyScrollTop = true;
10278
+ this._stickyScrollBottom = false;
10279
+ this.verticalScrollBar.scrollPosition = 0;
10280
+ break;
10281
+ case "bottom":
10282
+ this._stickyScrollTop = false;
10283
+ this._stickyScrollBottom = true;
10284
+ this.verticalScrollBar.scrollPosition = Math.max(0, this.scrollHeight - this.viewport.height);
10285
+ break;
10286
+ case "left":
10287
+ this._stickyScrollLeft = true;
10288
+ this._stickyScrollRight = false;
10289
+ this.horizontalScrollBar.scrollPosition = 0;
10290
+ break;
10291
+ case "right":
10292
+ this._stickyScrollLeft = false;
10293
+ this._stickyScrollRight = true;
10294
+ this.horizontalScrollBar.scrollPosition = Math.max(0, this.scrollWidth - this.viewport.width);
10295
+ break;
10296
+ }
10297
+ } finally {
10298
+ this._isApplyingStickyScroll = wasApplyingStickyScroll;
10255
10299
  }
10256
- this._isApplyingStickyScroll = false;
10257
10300
  }
10258
10301
  constructor(ctx, {
10259
10302
  wrapperOptions,
@@ -10593,29 +10636,32 @@ class ScrollBoxRenderable extends BoxRenderable {
10593
10636
  recalculateBarProps() {
10594
10637
  const wasApplyingStickyScroll = this._isApplyingStickyScroll;
10595
10638
  this._isApplyingStickyScroll = true;
10596
- this.verticalScrollBar.scrollSize = this.content.height;
10597
- this.verticalScrollBar.viewportSize = this.viewport.height;
10598
- this.horizontalScrollBar.scrollSize = this.content.width;
10599
- this.horizontalScrollBar.viewportSize = this.viewport.width;
10600
- if (this._stickyScroll) {
10601
- const newMaxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
10602
- const newMaxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
10603
- if (this._stickyStart && !this._hasManualScroll) {
10604
- this.applyStickyStart(this._stickyStart);
10605
- } else {
10606
- if (this._stickyScrollTop) {
10607
- this.scrollTop = 0;
10608
- } else if (this._stickyScrollBottom && newMaxScrollTop > 0) {
10609
- this.scrollTop = newMaxScrollTop;
10610
- }
10611
- if (this._stickyScrollLeft) {
10612
- this.scrollLeft = 0;
10613
- } else if (this._stickyScrollRight && newMaxScrollLeft > 0) {
10614
- this.scrollLeft = newMaxScrollLeft;
10639
+ try {
10640
+ this.verticalScrollBar.scrollSize = this.content.height;
10641
+ this.verticalScrollBar.viewportSize = this.viewport.height;
10642
+ this.horizontalScrollBar.scrollSize = this.content.width;
10643
+ this.horizontalScrollBar.viewportSize = this.viewport.width;
10644
+ if (this._stickyScroll) {
10645
+ const newMaxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
10646
+ const newMaxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
10647
+ if (this._stickyStart && !this._hasManualScroll) {
10648
+ this.applyStickyStart(this._stickyStart);
10649
+ } else {
10650
+ if (this._stickyScrollTop) {
10651
+ this.scrollTop = 0;
10652
+ } else if (this._stickyScrollBottom && newMaxScrollTop > 0) {
10653
+ this.scrollTop = newMaxScrollTop;
10654
+ }
10655
+ if (this._stickyScrollLeft) {
10656
+ this.scrollLeft = 0;
10657
+ } else if (this._stickyScrollRight && newMaxScrollLeft > 0) {
10658
+ this.scrollLeft = newMaxScrollLeft;
10659
+ }
10615
10660
  }
10616
10661
  }
10662
+ } finally {
10663
+ this._isApplyingStickyScroll = wasApplyingStickyScroll;
10617
10664
  }
10618
- this._isApplyingStickyScroll = wasApplyingStickyScroll;
10619
10665
  process.nextTick(() => {
10620
10666
  this.requestRender();
10621
10667
  });
@@ -11046,6 +11092,839 @@ class SelectRenderable extends Renderable {
11046
11092
  }
11047
11093
  }
11048
11094
  }
11095
+ // src/renderables/TextTable.ts
11096
+ var MEASURE_HEIGHT = 1e4;
11097
+
11098
+ class TextTableRenderable extends Renderable {
11099
+ _content;
11100
+ _wrapMode;
11101
+ _columnWidthMode;
11102
+ _cellPadding;
11103
+ _showBorders;
11104
+ _border;
11105
+ _outerBorder;
11106
+ _hasExplicitOuterBorder;
11107
+ _borderStyle;
11108
+ _borderColor;
11109
+ _borderBackgroundColor;
11110
+ _backgroundColor;
11111
+ _defaultFg;
11112
+ _defaultBg;
11113
+ _defaultAttributes;
11114
+ _selectionBg;
11115
+ _selectionFg;
11116
+ _lastLocalSelection = null;
11117
+ _cells = [];
11118
+ _prevCellContent = [];
11119
+ _rowCount = 0;
11120
+ _columnCount = 0;
11121
+ _layout = this.createEmptyLayout();
11122
+ _layoutDirty = true;
11123
+ _rasterDirty = true;
11124
+ _cachedMeasureLayout = null;
11125
+ _cachedMeasureWidth = undefined;
11126
+ _defaultOptions = {
11127
+ content: [],
11128
+ wrapMode: "none",
11129
+ columnWidthMode: "content",
11130
+ cellPadding: 0,
11131
+ showBorders: true,
11132
+ border: true,
11133
+ outerBorder: true,
11134
+ selectable: true,
11135
+ selectionBg: undefined,
11136
+ selectionFg: undefined,
11137
+ borderStyle: "single",
11138
+ borderColor: "#FFFFFF",
11139
+ borderBackgroundColor: "transparent",
11140
+ backgroundColor: "transparent",
11141
+ fg: "#FFFFFF",
11142
+ bg: "transparent",
11143
+ attributes: 0
11144
+ };
11145
+ constructor(ctx, options = {}) {
11146
+ super(ctx, { ...options, buffered: true });
11147
+ this._content = options.content ?? this._defaultOptions.content;
11148
+ this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
11149
+ this._columnWidthMode = options.columnWidthMode ?? this._defaultOptions.columnWidthMode;
11150
+ this._cellPadding = this.resolveCellPadding(options.cellPadding);
11151
+ this._showBorders = options.showBorders ?? this._defaultOptions.showBorders;
11152
+ this._border = options.border ?? this._defaultOptions.border;
11153
+ this._hasExplicitOuterBorder = options.outerBorder !== undefined;
11154
+ this._outerBorder = options.outerBorder ?? this._border;
11155
+ this.selectable = options.selectable ?? this._defaultOptions.selectable;
11156
+ this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : undefined;
11157
+ this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : undefined;
11158
+ this._borderStyle = parseBorderStyle(options.borderStyle, this._defaultOptions.borderStyle);
11159
+ this._borderColor = parseColor(options.borderColor ?? this._defaultOptions.borderColor);
11160
+ this._borderBackgroundColor = parseColor(options.borderBackgroundColor ?? this._defaultOptions.borderBackgroundColor);
11161
+ this._backgroundColor = parseColor(options.backgroundColor ?? this._defaultOptions.backgroundColor);
11162
+ this._defaultFg = parseColor(options.fg ?? this._defaultOptions.fg);
11163
+ this._defaultBg = parseColor(options.bg ?? this._defaultOptions.bg);
11164
+ this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
11165
+ this.setupMeasureFunc();
11166
+ this.rebuildCells();
11167
+ }
11168
+ get content() {
11169
+ return this._content;
11170
+ }
11171
+ set content(value) {
11172
+ this._content = value ?? [];
11173
+ this.rebuildCells();
11174
+ }
11175
+ get wrapMode() {
11176
+ return this._wrapMode;
11177
+ }
11178
+ set wrapMode(value) {
11179
+ if (this._wrapMode === value)
11180
+ return;
11181
+ this._wrapMode = value;
11182
+ for (const row of this._cells) {
11183
+ for (const cell of row) {
11184
+ cell.textBufferView.setWrapMode(value);
11185
+ }
11186
+ }
11187
+ this.invalidateLayoutAndRaster();
11188
+ }
11189
+ get columnWidthMode() {
11190
+ return this._columnWidthMode;
11191
+ }
11192
+ set columnWidthMode(value) {
11193
+ if (this._columnWidthMode === value)
11194
+ return;
11195
+ this._columnWidthMode = value;
11196
+ this.invalidateLayoutAndRaster();
11197
+ }
11198
+ get cellPadding() {
11199
+ return this._cellPadding;
11200
+ }
11201
+ set cellPadding(value) {
11202
+ const next = this.resolveCellPadding(value);
11203
+ if (this._cellPadding === next)
11204
+ return;
11205
+ this._cellPadding = next;
11206
+ this.invalidateLayoutAndRaster();
11207
+ }
11208
+ get showBorders() {
11209
+ return this._showBorders;
11210
+ }
11211
+ set showBorders(value) {
11212
+ if (this._showBorders === value)
11213
+ return;
11214
+ this._showBorders = value;
11215
+ this.invalidateRasterOnly();
11216
+ }
11217
+ get outerBorder() {
11218
+ return this._outerBorder;
11219
+ }
11220
+ set outerBorder(value) {
11221
+ if (this._outerBorder === value)
11222
+ return;
11223
+ this._hasExplicitOuterBorder = true;
11224
+ this._outerBorder = value;
11225
+ this.invalidateLayoutAndRaster();
11226
+ }
11227
+ get border() {
11228
+ return this._border;
11229
+ }
11230
+ set border(value) {
11231
+ if (this._border === value)
11232
+ return;
11233
+ this._border = value;
11234
+ if (!this._hasExplicitOuterBorder) {
11235
+ this._outerBorder = value;
11236
+ }
11237
+ this.invalidateLayoutAndRaster();
11238
+ }
11239
+ get borderStyle() {
11240
+ return this._borderStyle;
11241
+ }
11242
+ set borderStyle(value) {
11243
+ const next = parseBorderStyle(value, this._defaultOptions.borderStyle);
11244
+ if (this._borderStyle === next)
11245
+ return;
11246
+ this._borderStyle = next;
11247
+ this.invalidateRasterOnly();
11248
+ }
11249
+ get borderColor() {
11250
+ return this._borderColor;
11251
+ }
11252
+ set borderColor(value) {
11253
+ const next = parseColor(value);
11254
+ if (this._borderColor === next)
11255
+ return;
11256
+ this._borderColor = next;
11257
+ this.invalidateRasterOnly();
11258
+ }
11259
+ shouldStartSelection(x2, y2) {
11260
+ if (!this.selectable)
11261
+ return false;
11262
+ this.ensureLayoutReady();
11263
+ const localX = x2 - this.x;
11264
+ const localY = y2 - this.y;
11265
+ return this.getCellAtLocalPosition(localX, localY) !== null;
11266
+ }
11267
+ onSelectionChanged(selection) {
11268
+ this.ensureLayoutReady();
11269
+ const previousLocalSelection = this._lastLocalSelection;
11270
+ const localSelection = convertGlobalToLocalSelection(selection, this.x, this.y);
11271
+ this._lastLocalSelection = localSelection;
11272
+ const dirtyRows = this.getDirtySelectionRowRange(previousLocalSelection, localSelection);
11273
+ if (!localSelection?.isActive) {
11274
+ this.resetCellSelections();
11275
+ } else {
11276
+ this.applySelectionToCells(localSelection, selection?.isStart ?? false);
11277
+ }
11278
+ if (dirtyRows !== null) {
11279
+ this.redrawSelectionRows(dirtyRows.firstRow, dirtyRows.lastRow);
11280
+ }
11281
+ return this.hasSelection();
11282
+ }
11283
+ hasSelection() {
11284
+ for (const row of this._cells) {
11285
+ for (const cell of row) {
11286
+ if (cell.textBufferView.hasSelection()) {
11287
+ return true;
11288
+ }
11289
+ }
11290
+ }
11291
+ return false;
11292
+ }
11293
+ getSelection() {
11294
+ for (const row of this._cells) {
11295
+ for (const cell of row) {
11296
+ const selection = cell.textBufferView.getSelection();
11297
+ if (selection) {
11298
+ return selection;
11299
+ }
11300
+ }
11301
+ }
11302
+ return null;
11303
+ }
11304
+ getSelectedText() {
11305
+ const selectedRows = [];
11306
+ for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
11307
+ const rowSelections = [];
11308
+ for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11309
+ const cell = this._cells[rowIdx]?.[colIdx];
11310
+ if (!cell || !cell.textBufferView.hasSelection())
11311
+ continue;
11312
+ const selectedText = cell.textBufferView.getSelectedText();
11313
+ if (selectedText.length > 0) {
11314
+ rowSelections.push(selectedText);
11315
+ }
11316
+ }
11317
+ if (rowSelections.length > 0) {
11318
+ selectedRows.push(rowSelections.join("\t"));
11319
+ }
11320
+ }
11321
+ return selectedRows.join(`
11322
+ `);
11323
+ }
11324
+ onResize(width, height) {
11325
+ this.invalidateLayoutAndRaster(false);
11326
+ super.onResize(width, height);
11327
+ }
11328
+ renderSelf(buffer) {
11329
+ if (!this.visible || this.isDestroyed)
11330
+ return;
11331
+ if (this._layoutDirty) {
11332
+ this.rebuildLayoutForCurrentWidth();
11333
+ }
11334
+ if (!this._rasterDirty)
11335
+ return;
11336
+ buffer.clear(this._backgroundColor);
11337
+ if (this._rowCount === 0 || this._columnCount === 0) {
11338
+ this._rasterDirty = false;
11339
+ return;
11340
+ }
11341
+ this.drawBorders(buffer);
11342
+ this.drawCells(buffer);
11343
+ this._rasterDirty = false;
11344
+ }
11345
+ destroySelf() {
11346
+ this.destroyCells();
11347
+ super.destroySelf();
11348
+ }
11349
+ setupMeasureFunc() {
11350
+ const measureFunc = (width, widthMode, height, heightMode) => {
11351
+ const hasWidthConstraint = widthMode !== MeasureMode.Undefined && Number.isFinite(width);
11352
+ const rawWidthConstraint = hasWidthConstraint ? Math.max(1, Math.floor(width)) : undefined;
11353
+ const widthConstraint = this.resolveLayoutWidthConstraint(rawWidthConstraint);
11354
+ const measuredLayout = this.computeLayout(widthConstraint);
11355
+ this._cachedMeasureLayout = measuredLayout;
11356
+ this._cachedMeasureWidth = widthConstraint;
11357
+ let measuredWidth = measuredLayout.tableWidth > 0 ? measuredLayout.tableWidth : 1;
11358
+ let measuredHeight = measuredLayout.tableHeight > 0 ? measuredLayout.tableHeight : 1;
11359
+ if (widthMode === MeasureMode.AtMost && rawWidthConstraint !== undefined && this._positionType !== "absolute") {
11360
+ measuredWidth = Math.min(rawWidthConstraint, measuredWidth);
11361
+ }
11362
+ if (heightMode === MeasureMode.AtMost && Number.isFinite(height) && this._positionType !== "absolute") {
11363
+ measuredHeight = Math.min(Math.max(1, Math.floor(height)), measuredHeight);
11364
+ }
11365
+ return {
11366
+ width: measuredWidth,
11367
+ height: measuredHeight
11368
+ };
11369
+ };
11370
+ this.yogaNode.setMeasureFunc(measureFunc);
11371
+ }
11372
+ rebuildCells() {
11373
+ const newRowCount = this._content.length;
11374
+ const newColumnCount = this._content.reduce((max, row) => Math.max(max, row.length), 0);
11375
+ if (this._cells.length === 0) {
11376
+ this._rowCount = newRowCount;
11377
+ this._columnCount = newColumnCount;
11378
+ this._cells = [];
11379
+ this._prevCellContent = [];
11380
+ for (let rowIdx = 0;rowIdx < newRowCount; rowIdx++) {
11381
+ const row = this._content[rowIdx] ?? [];
11382
+ const rowCells = [];
11383
+ const rowRefs = [];
11384
+ for (let colIdx = 0;colIdx < newColumnCount; colIdx++) {
11385
+ const cellContent = row[colIdx];
11386
+ rowCells.push(this.createCell(cellContent));
11387
+ rowRefs.push(cellContent);
11388
+ }
11389
+ this._cells.push(rowCells);
11390
+ this._prevCellContent.push(rowRefs);
11391
+ }
11392
+ this.invalidateLayoutAndRaster();
11393
+ return;
11394
+ }
11395
+ this.updateCellsDiff(newRowCount, newColumnCount);
11396
+ this.invalidateLayoutAndRaster();
11397
+ }
11398
+ updateCellsDiff(newRowCount, newColumnCount) {
11399
+ const oldRowCount = this._rowCount;
11400
+ const oldColumnCount = this._columnCount;
11401
+ const keepRows = Math.min(oldRowCount, newRowCount);
11402
+ const keepCols = Math.min(oldColumnCount, newColumnCount);
11403
+ for (let rowIdx = 0;rowIdx < keepRows; rowIdx++) {
11404
+ const newRow = this._content[rowIdx] ?? [];
11405
+ const cellRow = this._cells[rowIdx];
11406
+ const refRow = this._prevCellContent[rowIdx];
11407
+ for (let colIdx = 0;colIdx < keepCols; colIdx++) {
11408
+ const cellContent = newRow[colIdx];
11409
+ if (cellContent === refRow[colIdx])
11410
+ continue;
11411
+ const oldCell = cellRow[colIdx];
11412
+ oldCell.textBufferView.destroy();
11413
+ oldCell.textBuffer.destroy();
11414
+ oldCell.syntaxStyle.destroy();
11415
+ cellRow[colIdx] = this.createCell(cellContent);
11416
+ refRow[colIdx] = cellContent;
11417
+ }
11418
+ if (newColumnCount > oldColumnCount) {
11419
+ for (let colIdx = oldColumnCount;colIdx < newColumnCount; colIdx++) {
11420
+ const cellContent = newRow[colIdx];
11421
+ cellRow.push(this.createCell(cellContent));
11422
+ refRow.push(cellContent);
11423
+ }
11424
+ } else if (newColumnCount < oldColumnCount) {
11425
+ for (let colIdx = newColumnCount;colIdx < oldColumnCount; colIdx++) {
11426
+ const cell = cellRow[colIdx];
11427
+ cell.textBufferView.destroy();
11428
+ cell.textBuffer.destroy();
11429
+ cell.syntaxStyle.destroy();
11430
+ }
11431
+ cellRow.length = newColumnCount;
11432
+ refRow.length = newColumnCount;
11433
+ }
11434
+ }
11435
+ if (newRowCount > oldRowCount) {
11436
+ for (let rowIdx = oldRowCount;rowIdx < newRowCount; rowIdx++) {
11437
+ const newRow = this._content[rowIdx] ?? [];
11438
+ const rowCells = [];
11439
+ const rowRefs = [];
11440
+ for (let colIdx = 0;colIdx < newColumnCount; colIdx++) {
11441
+ const cellContent = newRow[colIdx];
11442
+ rowCells.push(this.createCell(cellContent));
11443
+ rowRefs.push(cellContent);
11444
+ }
11445
+ this._cells.push(rowCells);
11446
+ this._prevCellContent.push(rowRefs);
11447
+ }
11448
+ } else if (newRowCount < oldRowCount) {
11449
+ for (let rowIdx = newRowCount;rowIdx < oldRowCount; rowIdx++) {
11450
+ const row = this._cells[rowIdx];
11451
+ for (const cell of row) {
11452
+ cell.textBufferView.destroy();
11453
+ cell.textBuffer.destroy();
11454
+ cell.syntaxStyle.destroy();
11455
+ }
11456
+ }
11457
+ this._cells.length = newRowCount;
11458
+ this._prevCellContent.length = newRowCount;
11459
+ }
11460
+ this._rowCount = newRowCount;
11461
+ this._columnCount = newColumnCount;
11462
+ }
11463
+ createCell(content) {
11464
+ const styledText = this.toStyledText(content);
11465
+ const textBuffer = TextBuffer.create(this._ctx.widthMethod);
11466
+ const syntaxStyle = SyntaxStyle.create();
11467
+ textBuffer.setDefaultFg(this._defaultFg);
11468
+ textBuffer.setDefaultBg(this._defaultBg);
11469
+ textBuffer.setDefaultAttributes(this._defaultAttributes);
11470
+ textBuffer.setSyntaxStyle(syntaxStyle);
11471
+ textBuffer.setStyledText(styledText);
11472
+ const textBufferView = TextBufferView.create(textBuffer);
11473
+ textBufferView.setWrapMode(this._wrapMode);
11474
+ return { textBuffer, textBufferView, syntaxStyle };
11475
+ }
11476
+ toStyledText(content) {
11477
+ if (Array.isArray(content)) {
11478
+ return new StyledText(content);
11479
+ }
11480
+ if (content === null || content === undefined) {
11481
+ return stringToStyledText("");
11482
+ }
11483
+ return stringToStyledText(String(content));
11484
+ }
11485
+ destroyCells() {
11486
+ for (const row of this._cells) {
11487
+ for (const cell of row) {
11488
+ cell.textBufferView.destroy();
11489
+ cell.textBuffer.destroy();
11490
+ cell.syntaxStyle.destroy();
11491
+ }
11492
+ }
11493
+ this._cells = [];
11494
+ this._prevCellContent = [];
11495
+ this._rowCount = 0;
11496
+ this._columnCount = 0;
11497
+ this._layout = this.createEmptyLayout();
11498
+ }
11499
+ rebuildLayoutForCurrentWidth() {
11500
+ const maxTableWidth = this.resolveLayoutWidthConstraint(this.width);
11501
+ let layout;
11502
+ if (this._cachedMeasureLayout !== null && this._cachedMeasureWidth === maxTableWidth) {
11503
+ layout = this._cachedMeasureLayout;
11504
+ } else {
11505
+ layout = this.computeLayout(maxTableWidth);
11506
+ }
11507
+ this._cachedMeasureLayout = null;
11508
+ this._cachedMeasureWidth = undefined;
11509
+ this._layout = layout;
11510
+ this.applyLayoutToViews(layout);
11511
+ this._layoutDirty = false;
11512
+ if (this._lastLocalSelection?.isActive) {
11513
+ this.applySelectionToCells(this._lastLocalSelection, true);
11514
+ }
11515
+ }
11516
+ computeLayout(maxTableWidth) {
11517
+ if (this._rowCount === 0 || this._columnCount === 0) {
11518
+ return this.createEmptyLayout();
11519
+ }
11520
+ const borderLayout = this.resolveBorderLayout();
11521
+ const columnWidths = this.computeColumnWidths(maxTableWidth, borderLayout);
11522
+ const rowHeights = this.computeRowHeights(columnWidths);
11523
+ const columnOffsets = this.computeOffsets(columnWidths, borderLayout.left, borderLayout.right, borderLayout.innerVertical);
11524
+ const rowOffsets = this.computeOffsets(rowHeights, borderLayout.top, borderLayout.bottom, borderLayout.innerHorizontal);
11525
+ return {
11526
+ columnWidths,
11527
+ rowHeights,
11528
+ columnOffsets,
11529
+ rowOffsets,
11530
+ columnOffsetsI32: new Int32Array(columnOffsets),
11531
+ rowOffsetsI32: new Int32Array(rowOffsets),
11532
+ tableWidth: (columnOffsets[columnOffsets.length - 1] ?? 0) + 1,
11533
+ tableHeight: (rowOffsets[rowOffsets.length - 1] ?? 0) + 1
11534
+ };
11535
+ }
11536
+ computeColumnWidths(maxTableWidth, borderLayout) {
11537
+ const horizontalPadding = this.getHorizontalCellPadding();
11538
+ const intrinsicWidths = new Array(this._columnCount).fill(1 + horizontalPadding);
11539
+ for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
11540
+ for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11541
+ const cell = this._cells[rowIdx]?.[colIdx];
11542
+ if (!cell)
11543
+ continue;
11544
+ const measure = cell.textBufferView.measureForDimensions(0, MEASURE_HEIGHT);
11545
+ const measuredWidth = Math.max(1, measure?.maxWidth ?? 0) + horizontalPadding;
11546
+ intrinsicWidths[colIdx] = Math.max(intrinsicWidths[colIdx], measuredWidth);
11547
+ }
11548
+ }
11549
+ if (maxTableWidth === undefined || !Number.isFinite(maxTableWidth) || maxTableWidth <= 0) {
11550
+ return intrinsicWidths;
11551
+ }
11552
+ const maxContentWidth = Math.max(1, Math.floor(maxTableWidth) - this.getVerticalBorderCount(borderLayout));
11553
+ const currentWidth = intrinsicWidths.reduce((sum, width) => sum + width, 0);
11554
+ if (currentWidth === maxContentWidth) {
11555
+ return intrinsicWidths;
11556
+ }
11557
+ if (currentWidth < maxContentWidth) {
11558
+ if (this._columnWidthMode === "fill") {
11559
+ return this.expandColumnWidths(intrinsicWidths, maxContentWidth);
11560
+ }
11561
+ return intrinsicWidths;
11562
+ }
11563
+ if (this._wrapMode === "none") {
11564
+ return intrinsicWidths;
11565
+ }
11566
+ return this.fitColumnWidths(intrinsicWidths, maxContentWidth);
11567
+ }
11568
+ expandColumnWidths(widths, targetContentWidth) {
11569
+ const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
11570
+ const totalBaseWidth = baseWidths.reduce((sum, width) => sum + width, 0);
11571
+ if (totalBaseWidth >= targetContentWidth) {
11572
+ return baseWidths;
11573
+ }
11574
+ const expanded = [...baseWidths];
11575
+ const columns = expanded.length;
11576
+ const extraWidth = targetContentWidth - totalBaseWidth;
11577
+ const sharedWidth = Math.floor(extraWidth / columns);
11578
+ const remainder = extraWidth % columns;
11579
+ for (let idx = 0;idx < columns; idx++) {
11580
+ expanded[idx] += sharedWidth;
11581
+ if (idx < remainder) {
11582
+ expanded[idx] += 1;
11583
+ }
11584
+ }
11585
+ return expanded;
11586
+ }
11587
+ fitColumnWidths(widths, targetContentWidth) {
11588
+ const minWidth = 1 + this.getHorizontalCellPadding();
11589
+ const hardMinWidths = new Array(widths.length).fill(minWidth);
11590
+ const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
11591
+ const preferredMinWidths = baseWidths.map((width) => Math.min(width, minWidth + 1));
11592
+ const preferredMinTotal = preferredMinWidths.reduce((sum, width) => sum + width, 0);
11593
+ const floorWidths = preferredMinTotal <= targetContentWidth ? preferredMinWidths : hardMinWidths;
11594
+ const floorTotal = floorWidths.reduce((sum, width) => sum + width, 0);
11595
+ const clampedTarget = Math.max(floorTotal, targetContentWidth);
11596
+ const totalBaseWidth = baseWidths.reduce((sum, width) => sum + width, 0);
11597
+ if (totalBaseWidth <= clampedTarget) {
11598
+ return baseWidths;
11599
+ }
11600
+ const shrinkable = baseWidths.map((width, idx) => width - floorWidths[idx]);
11601
+ const totalShrinkable = shrinkable.reduce((sum, value) => sum + value, 0);
11602
+ if (totalShrinkable <= 0) {
11603
+ return [...floorWidths];
11604
+ }
11605
+ const targetShrink = totalBaseWidth - clampedTarget;
11606
+ const integerShrink = new Array(baseWidths.length).fill(0);
11607
+ const fractions = new Array(baseWidths.length).fill(0);
11608
+ let usedShrink = 0;
11609
+ for (let idx = 0;idx < baseWidths.length; idx++) {
11610
+ if (shrinkable[idx] <= 0)
11611
+ continue;
11612
+ const exact = shrinkable[idx] / totalShrinkable * targetShrink;
11613
+ const whole = Math.min(shrinkable[idx], Math.floor(exact));
11614
+ integerShrink[idx] = whole;
11615
+ fractions[idx] = exact - whole;
11616
+ usedShrink += whole;
11617
+ }
11618
+ let remainingShrink = targetShrink - usedShrink;
11619
+ while (remainingShrink > 0) {
11620
+ let bestIdx = -1;
11621
+ let bestFraction = -1;
11622
+ for (let idx = 0;idx < baseWidths.length; idx++) {
11623
+ if (shrinkable[idx] - integerShrink[idx] <= 0)
11624
+ continue;
11625
+ if (fractions[idx] > bestFraction) {
11626
+ bestFraction = fractions[idx];
11627
+ bestIdx = idx;
11628
+ }
11629
+ }
11630
+ if (bestIdx === -1)
11631
+ break;
11632
+ integerShrink[bestIdx] += 1;
11633
+ fractions[bestIdx] = 0;
11634
+ remainingShrink -= 1;
11635
+ }
11636
+ return baseWidths.map((width, idx) => Math.max(floorWidths[idx], width - integerShrink[idx]));
11637
+ }
11638
+ computeRowHeights(columnWidths) {
11639
+ const horizontalPadding = this.getHorizontalCellPadding();
11640
+ const verticalPadding = this.getVerticalCellPadding();
11641
+ const rowHeights = new Array(this._rowCount).fill(1 + verticalPadding);
11642
+ for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
11643
+ for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11644
+ const cell = this._cells[rowIdx]?.[colIdx];
11645
+ if (!cell)
11646
+ continue;
11647
+ const width = Math.max(1, (columnWidths[colIdx] ?? 1) - horizontalPadding);
11648
+ const measure = cell.textBufferView.measureForDimensions(width, MEASURE_HEIGHT);
11649
+ const lineCount = Math.max(1, measure?.lineCount ?? 1);
11650
+ rowHeights[rowIdx] = Math.max(rowHeights[rowIdx], lineCount + verticalPadding);
11651
+ }
11652
+ }
11653
+ return rowHeights;
11654
+ }
11655
+ computeOffsets(parts, startBoundary, endBoundary, includeInnerBoundaries) {
11656
+ const offsets = [startBoundary ? 0 : -1];
11657
+ let cursor = offsets[0] ?? 0;
11658
+ for (let idx = 0;idx < parts.length; idx++) {
11659
+ const size = parts[idx] ?? 1;
11660
+ const hasBoundaryAfter = idx < parts.length - 1 ? includeInnerBoundaries : endBoundary;
11661
+ cursor += size + (hasBoundaryAfter ? 1 : 0);
11662
+ offsets.push(cursor);
11663
+ }
11664
+ return offsets;
11665
+ }
11666
+ applyLayoutToViews(layout) {
11667
+ const horizontalPadding = this.getHorizontalCellPadding();
11668
+ const verticalPadding = this.getVerticalCellPadding();
11669
+ for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
11670
+ for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11671
+ const cell = this._cells[rowIdx]?.[colIdx];
11672
+ if (!cell)
11673
+ continue;
11674
+ const colWidth = layout.columnWidths[colIdx] ?? 1;
11675
+ const rowHeight = layout.rowHeights[rowIdx] ?? 1;
11676
+ const contentWidth = Math.max(1, colWidth - horizontalPadding);
11677
+ const contentHeight = Math.max(1, rowHeight - verticalPadding);
11678
+ if (this._wrapMode === "none") {
11679
+ cell.textBufferView.setWrapWidth(null);
11680
+ } else {
11681
+ cell.textBufferView.setWrapWidth(contentWidth);
11682
+ }
11683
+ cell.textBufferView.setViewport(0, 0, contentWidth, contentHeight);
11684
+ }
11685
+ }
11686
+ }
11687
+ resolveBorderLayout() {
11688
+ return {
11689
+ left: this._outerBorder,
11690
+ right: this._outerBorder,
11691
+ top: this._outerBorder,
11692
+ bottom: this._outerBorder,
11693
+ innerVertical: this._border && this._columnCount > 1,
11694
+ innerHorizontal: this._border && this._rowCount > 1
11695
+ };
11696
+ }
11697
+ getVerticalBorderCount(borderLayout) {
11698
+ return (borderLayout.left ? 1 : 0) + (borderLayout.right ? 1 : 0) + (borderLayout.innerVertical ? Math.max(0, this._columnCount - 1) : 0);
11699
+ }
11700
+ getHorizontalBorderCount(borderLayout) {
11701
+ return (borderLayout.top ? 1 : 0) + (borderLayout.bottom ? 1 : 0) + (borderLayout.innerHorizontal ? Math.max(0, this._rowCount - 1) : 0);
11702
+ }
11703
+ drawBorders(buffer) {
11704
+ if (!this._showBorders) {
11705
+ return;
11706
+ }
11707
+ const borderLayout = this.resolveBorderLayout();
11708
+ if (this.getVerticalBorderCount(borderLayout) === 0 && this.getHorizontalBorderCount(borderLayout) === 0) {
11709
+ return;
11710
+ }
11711
+ buffer.drawGrid({
11712
+ borderChars: BorderCharArrays[this._borderStyle],
11713
+ borderFg: this._borderColor,
11714
+ borderBg: this._borderBackgroundColor,
11715
+ columnOffsets: this._layout.columnOffsetsI32,
11716
+ rowOffsets: this._layout.rowOffsetsI32,
11717
+ drawInner: this._border,
11718
+ drawOuter: this._outerBorder
11719
+ });
11720
+ }
11721
+ drawCells(buffer) {
11722
+ this.drawCellRange(buffer, 0, this._rowCount - 1);
11723
+ }
11724
+ drawCellRange(buffer, firstRow, lastRow) {
11725
+ const colOffsets = this._layout.columnOffsets;
11726
+ const rowOffsets = this._layout.rowOffsets;
11727
+ const cellPadding = this._cellPadding;
11728
+ for (let rowIdx = firstRow;rowIdx <= lastRow; rowIdx++) {
11729
+ const cellY = (rowOffsets[rowIdx] ?? 0) + 1 + cellPadding;
11730
+ for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11731
+ const cell = this._cells[rowIdx]?.[colIdx];
11732
+ if (!cell)
11733
+ continue;
11734
+ buffer.drawTextBuffer(cell.textBufferView, (colOffsets[colIdx] ?? 0) + 1 + cellPadding, cellY);
11735
+ }
11736
+ }
11737
+ }
11738
+ redrawSelectionRows(firstRow, lastRow) {
11739
+ if (firstRow > lastRow)
11740
+ return;
11741
+ if (this._backgroundColor.a < 1) {
11742
+ this.invalidateRasterOnly();
11743
+ return;
11744
+ }
11745
+ const buffer = this.frameBuffer;
11746
+ if (!buffer)
11747
+ return;
11748
+ this.clearCellRange(buffer, firstRow, lastRow);
11749
+ this.drawCellRange(buffer, firstRow, lastRow);
11750
+ this.requestRender();
11751
+ }
11752
+ clearCellRange(buffer, firstRow, lastRow) {
11753
+ const colWidths = this._layout.columnWidths;
11754
+ const rowHeights = this._layout.rowHeights;
11755
+ const colOffsets = this._layout.columnOffsets;
11756
+ const rowOffsets = this._layout.rowOffsets;
11757
+ for (let rowIdx = firstRow;rowIdx <= lastRow; rowIdx++) {
11758
+ const cellY = (rowOffsets[rowIdx] ?? 0) + 1;
11759
+ const rowHeight = rowHeights[rowIdx] ?? 1;
11760
+ for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11761
+ const cellX = (colOffsets[colIdx] ?? 0) + 1;
11762
+ const colWidth = colWidths[colIdx] ?? 1;
11763
+ buffer.fillRect(cellX, cellY, colWidth, rowHeight, this._backgroundColor);
11764
+ }
11765
+ }
11766
+ }
11767
+ ensureLayoutReady() {
11768
+ if (!this._layoutDirty)
11769
+ return;
11770
+ this.rebuildLayoutForCurrentWidth();
11771
+ }
11772
+ getCellAtLocalPosition(localX, localY) {
11773
+ if (this._rowCount === 0 || this._columnCount === 0)
11774
+ return null;
11775
+ if (localX < 0 || localY < 0 || localX >= this._layout.tableWidth || localY >= this._layout.tableHeight) {
11776
+ return null;
11777
+ }
11778
+ let rowIdx = -1;
11779
+ for (let idx = 0;idx < this._rowCount; idx++) {
11780
+ const top = (this._layout.rowOffsets[idx] ?? 0) + 1;
11781
+ const bottom = top + (this._layout.rowHeights[idx] ?? 1) - 1;
11782
+ if (localY >= top && localY <= bottom) {
11783
+ rowIdx = idx;
11784
+ break;
11785
+ }
11786
+ }
11787
+ if (rowIdx < 0)
11788
+ return null;
11789
+ let colIdx = -1;
11790
+ for (let idx = 0;idx < this._columnCount; idx++) {
11791
+ const left = (this._layout.columnOffsets[idx] ?? 0) + 1;
11792
+ const right = left + (this._layout.columnWidths[idx] ?? 1) - 1;
11793
+ if (localX >= left && localX <= right) {
11794
+ colIdx = idx;
11795
+ break;
11796
+ }
11797
+ }
11798
+ if (colIdx < 0)
11799
+ return null;
11800
+ return { rowIdx, colIdx };
11801
+ }
11802
+ applySelectionToCells(localSelection, isStart) {
11803
+ const minSelY = Math.min(localSelection.anchorY, localSelection.focusY);
11804
+ const maxSelY = Math.max(localSelection.anchorY, localSelection.focusY);
11805
+ const firstRow = this.findRowForLocalY(minSelY);
11806
+ const lastRow = this.findRowForLocalY(maxSelY);
11807
+ for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
11808
+ if (rowIdx < firstRow || rowIdx > lastRow) {
11809
+ this.resetRowSelection(rowIdx);
11810
+ continue;
11811
+ }
11812
+ const cellTop = (this._layout.rowOffsets[rowIdx] ?? 0) + 1 + this._cellPadding;
11813
+ for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11814
+ const cell = this._cells[rowIdx]?.[colIdx];
11815
+ if (!cell)
11816
+ continue;
11817
+ const cellLeft = (this._layout.columnOffsets[colIdx] ?? 0) + 1 + this._cellPadding;
11818
+ const anchorX = localSelection.anchorX - cellLeft;
11819
+ const anchorY = localSelection.anchorY - cellTop;
11820
+ const focusX = localSelection.focusX - cellLeft;
11821
+ const focusY = localSelection.focusY - cellTop;
11822
+ if (isStart) {
11823
+ cell.textBufferView.setLocalSelection(anchorX, anchorY, focusX, focusY, this._selectionBg, this._selectionFg);
11824
+ } else {
11825
+ cell.textBufferView.updateLocalSelection(anchorX, anchorY, focusX, focusY, this._selectionBg, this._selectionFg);
11826
+ }
11827
+ }
11828
+ }
11829
+ }
11830
+ findRowForLocalY(localY) {
11831
+ if (this._rowCount === 0)
11832
+ return 0;
11833
+ if (localY < 0)
11834
+ return 0;
11835
+ for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
11836
+ const rowStart = (this._layout.rowOffsets[rowIdx] ?? 0) + 1;
11837
+ const rowEnd = rowStart + (this._layout.rowHeights[rowIdx] ?? 1) - 1;
11838
+ if (localY <= rowEnd)
11839
+ return rowIdx;
11840
+ }
11841
+ return this._rowCount - 1;
11842
+ }
11843
+ getSelectionRowRange(selection) {
11844
+ if (!selection?.isActive || this._rowCount === 0)
11845
+ return null;
11846
+ const minSelY = Math.min(selection.anchorY, selection.focusY);
11847
+ const maxSelY = Math.max(selection.anchorY, selection.focusY);
11848
+ return {
11849
+ firstRow: this.findRowForLocalY(minSelY),
11850
+ lastRow: this.findRowForLocalY(maxSelY)
11851
+ };
11852
+ }
11853
+ getDirtySelectionRowRange(previousSelection, currentSelection) {
11854
+ const previousRange = this.getSelectionRowRange(previousSelection);
11855
+ const currentRange = this.getSelectionRowRange(currentSelection);
11856
+ if (previousRange === null)
11857
+ return currentRange;
11858
+ if (currentRange === null)
11859
+ return previousRange;
11860
+ return {
11861
+ firstRow: Math.min(previousRange.firstRow, currentRange.firstRow),
11862
+ lastRow: Math.max(previousRange.lastRow, currentRange.lastRow)
11863
+ };
11864
+ }
11865
+ resetRowSelection(rowIdx) {
11866
+ const row = this._cells[rowIdx];
11867
+ if (!row)
11868
+ return;
11869
+ for (const cell of row) {
11870
+ if (!cell.textBufferView.hasSelection())
11871
+ continue;
11872
+ cell.textBufferView.resetLocalSelection();
11873
+ }
11874
+ }
11875
+ resetCellSelections() {
11876
+ for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
11877
+ this.resetRowSelection(rowIdx);
11878
+ }
11879
+ }
11880
+ createEmptyLayout() {
11881
+ return {
11882
+ columnWidths: [],
11883
+ rowHeights: [],
11884
+ columnOffsets: [0],
11885
+ rowOffsets: [0],
11886
+ columnOffsetsI32: new Int32Array([0]),
11887
+ rowOffsetsI32: new Int32Array([0]),
11888
+ tableWidth: 0,
11889
+ tableHeight: 0
11890
+ };
11891
+ }
11892
+ resolveLayoutWidthConstraint(width) {
11893
+ if (width === undefined || !Number.isFinite(width) || width <= 0) {
11894
+ return;
11895
+ }
11896
+ if (this._wrapMode !== "none" || this._columnWidthMode === "fill") {
11897
+ return Math.max(1, Math.floor(width));
11898
+ }
11899
+ return;
11900
+ }
11901
+ getHorizontalCellPadding() {
11902
+ return this._cellPadding * 2;
11903
+ }
11904
+ getVerticalCellPadding() {
11905
+ return this._cellPadding * 2;
11906
+ }
11907
+ resolveCellPadding(value) {
11908
+ if (value === undefined || !Number.isFinite(value)) {
11909
+ return this._defaultOptions.cellPadding;
11910
+ }
11911
+ return Math.max(0, Math.floor(value));
11912
+ }
11913
+ invalidateLayoutAndRaster(markYogaDirty = true) {
11914
+ this._layoutDirty = true;
11915
+ this._rasterDirty = true;
11916
+ this._cachedMeasureLayout = null;
11917
+ this._cachedMeasureWidth = undefined;
11918
+ if (markYogaDirty) {
11919
+ this.yogaNode.markDirty();
11920
+ }
11921
+ this.requestRender();
11922
+ }
11923
+ invalidateRasterOnly() {
11924
+ this._rasterDirty = true;
11925
+ this.requestRender();
11926
+ }
11927
+ }
11049
11928
  // src/renderables/TabSelect.ts
11050
11929
  var defaultTabSelectKeybindings = [
11051
11930
  { name: "left", action: "move-left" },
@@ -11615,6 +12494,7 @@ export {
11615
12494
  TreeSitterClient,
11616
12495
  Timeline,
11617
12496
  TextareaRenderable,
12497
+ TextTableRenderable,
11618
12498
  TextRenderable,
11619
12499
  TextNodeRenderable,
11620
12500
  TextBufferView,
@@ -11695,5 +12575,5 @@ export {
11695
12575
  ASCIIFont
11696
12576
  };
11697
12577
 
11698
- //# debugId=BB0EDE58447BBE9564756E2164756E21
12578
+ //# debugId=FEAD097E3158A1E664756E2164756E21
11699
12579
  //# sourceMappingURL=index.js.map