@opentui/core 0.1.53 → 0.1.54

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
@@ -137,7 +137,7 @@ import {
137
137
  white,
138
138
  wrapWithDelegates,
139
139
  yellow
140
- } from "./index-vhxgbbed.js";
140
+ } from "./index-aedd54rx.js";
141
141
  // src/text-buffer-view.ts
142
142
  class TextBufferView {
143
143
  lib;
@@ -243,6 +243,10 @@ class TextBufferView {
243
243
  this.guard();
244
244
  return this.lib.textBufferViewMeasureForDimensions(this.viewPtr, width, height);
245
245
  }
246
+ getVirtualLineCount() {
247
+ this.guard();
248
+ return this.lib.textBufferViewGetVirtualLineCount(this.viewPtr);
249
+ }
246
250
  destroy() {
247
251
  if (this._destroyed)
248
252
  return;
@@ -2501,6 +2505,9 @@ class TextBufferRenderable extends Renderable {
2501
2505
  get lineCount() {
2502
2506
  return this.textBuffer.getLineCount();
2503
2507
  }
2508
+ get virtualLineCount() {
2509
+ return this.textBufferView.getVirtualLineCount();
2510
+ }
2504
2511
  get scrollY() {
2505
2512
  return this._scrollY;
2506
2513
  }
@@ -2650,6 +2657,7 @@ class TextBufferRenderable extends Renderable {
2650
2657
  }
2651
2658
  onResize(width, height) {
2652
2659
  this.textBufferView.setViewport(this._scrollX, this._scrollY, width, height);
2660
+ this.updateTextInfo();
2653
2661
  if (this.lastLocalSelection) {
2654
2662
  const changed = this.updateLocalSelection(this.lastLocalSelection);
2655
2663
  if (changed) {
@@ -3318,12 +3326,12 @@ class GutterRenderable extends Renderable {
3318
3326
  this._lineNumberOffset = options.lineNumberOffset;
3319
3327
  this._hideLineNumbers = options.hideLineNumbers;
3320
3328
  this._lineNumbers = options.lineNumbers ?? new Map;
3321
- this._lastKnownLineCount = this.target.lineCount;
3329
+ this._lastKnownLineCount = this.target.virtualLineCount;
3322
3330
  this._lastKnownScrollY = this.target.scrollY;
3323
3331
  this.calculateSignWidths();
3324
3332
  this.setupMeasureFunc();
3325
3333
  this.onLifecyclePass = () => {
3326
- const currentLineCount = this.target.lineCount;
3334
+ const currentLineCount = this.target.virtualLineCount;
3327
3335
  if (currentLineCount !== this._lastKnownLineCount) {
3328
3336
  this._lastKnownLineCount = currentLineCount;
3329
3337
  this.yogaNode.markDirty();
@@ -3334,7 +3342,7 @@ class GutterRenderable extends Renderable {
3334
3342
  setupMeasureFunc() {
3335
3343
  const measureFunc = (width, widthMode, height, heightMode) => {
3336
3344
  const gutterWidth = this.calculateWidth();
3337
- const gutterHeight = this.target.lineCount;
3345
+ const gutterHeight = this.target.virtualLineCount;
3338
3346
  return {
3339
3347
  width: gutterWidth,
3340
3348
  height: gutterHeight
@@ -3377,7 +3385,7 @@ class GutterRenderable extends Renderable {
3377
3385
  }
3378
3386
  }
3379
3387
  calculateWidth() {
3380
- const totalLines = this.target.lineCount;
3388
+ const totalLines = this.target.virtualLineCount;
3381
3389
  let maxLineNumber = totalLines + this._lineNumberOffset;
3382
3390
  if (this._lineNumbers.size > 0) {
3383
3391
  for (const customLineNum of this._lineNumbers.values()) {
@@ -3581,7 +3589,7 @@ class LineNumberRenderable extends Renderable {
3581
3589
  super.add(this.target);
3582
3590
  }
3583
3591
  add(child) {
3584
- if (!this.target && "lineInfo" in child && "lineCount" in child && "scrollY" in child) {
3592
+ if (!this.target && "lineInfo" in child && "lineCount" in child && "virtualLineCount" in child && "scrollY" in child) {
3585
3593
  this.setTarget(child);
3586
3594
  return this.getChildrenCount() - 1;
3587
3595
  }
@@ -4571,6 +4579,7 @@ class DiffRenderable extends Renderable {
4571
4579
  _conceal;
4572
4580
  _selectionBg;
4573
4581
  _selectionFg;
4582
+ _treeSitterClient;
4574
4583
  _showLineNumbers;
4575
4584
  _lineNumberFg;
4576
4585
  _lineNumberBg;
@@ -4591,6 +4600,7 @@ class DiffRenderable extends Renderable {
4591
4600
  leftCodeRenderable = null;
4592
4601
  rightCodeRenderable = null;
4593
4602
  pendingRebuild = false;
4603
+ _lastWidth = 0;
4594
4604
  errorTextRenderable = null;
4595
4605
  errorCodeRenderable = null;
4596
4606
  constructor(ctx, options) {
@@ -4603,9 +4613,10 @@ class DiffRenderable extends Renderable {
4603
4613
  this._filetype = options.filetype;
4604
4614
  this._syntaxStyle = options.syntaxStyle;
4605
4615
  this._wrapMode = options.wrapMode;
4606
- this._conceal = options.conceal ?? true;
4616
+ this._conceal = options.conceal ?? false;
4607
4617
  this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : undefined;
4608
4618
  this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : undefined;
4619
+ this._treeSitterClient = options.treeSitterClient;
4609
4620
  this._showLineNumbers = options.showLineNumbers ?? true;
4610
4621
  this._lineNumberFg = parseColor(options.lineNumberFg ?? "#888888");
4611
4622
  this._lineNumberBg = parseColor(options.lineNumberBg ?? "transparent");
@@ -4661,7 +4672,10 @@ class DiffRenderable extends Renderable {
4661
4672
  onResize(width, height) {
4662
4673
  super.onResize(width, height);
4663
4674
  if (this._view === "split" && this._wrapMode !== "none" && this._wrapMode !== undefined) {
4664
- this.requestRebuild();
4675
+ if (this._lastWidth !== width) {
4676
+ this._lastWidth = width;
4677
+ this.requestRebuild();
4678
+ }
4665
4679
  }
4666
4680
  }
4667
4681
  requestRebuild() {
@@ -4728,7 +4742,8 @@ class DiffRenderable extends Renderable {
4728
4742
  conceal: this._conceal,
4729
4743
  width: "100%",
4730
4744
  flexGrow: 1,
4731
- flexShrink: 1
4745
+ flexShrink: 1,
4746
+ ...this._treeSitterClient !== undefined && { treeSitterClient: this._treeSitterClient }
4732
4747
  });
4733
4748
  super.add(this.errorCodeRenderable);
4734
4749
  } else {
@@ -4757,7 +4772,8 @@ class DiffRenderable extends Renderable {
4757
4772
  height: "100%",
4758
4773
  ...drawUnstyledText !== undefined && { drawUnstyledText },
4759
4774
  ...this._selectionBg !== undefined && { selectionBg: this._selectionBg },
4760
- ...this._selectionFg !== undefined && { selectionFg: this._selectionFg }
4775
+ ...this._selectionFg !== undefined && { selectionFg: this._selectionFg },
4776
+ ...this._treeSitterClient !== undefined && { treeSitterClient: this._treeSitterClient }
4761
4777
  };
4762
4778
  const newRenderable = new CodeRenderable(this.ctx, codeOptions);
4763
4779
  if (side === "left") {
@@ -4769,6 +4785,7 @@ class DiffRenderable extends Renderable {
4769
4785
  } else {
4770
4786
  existingRenderable.content = content;
4771
4787
  existingRenderable.wrapMode = wrapMode ?? "none";
4788
+ existingRenderable.conceal = this._conceal;
4772
4789
  if (drawUnstyledText !== undefined) {
4773
4790
  existingRenderable.drawUnstyledText = drawUnstyledText;
4774
4791
  }
@@ -5029,9 +5046,10 @@ class DiffRenderable extends Renderable {
5029
5046
  `);
5030
5047
  const preRightContent = rightLogicalLines.map((l) => l.content).join(`
5031
5048
  `);
5032
- const effectiveWrapMode = canDoWrapAlignment ? this._wrapMode : "none";
5033
- const leftCodeRenderable = this.createOrUpdateCodeRenderable("left", preLeftContent, effectiveWrapMode, true);
5034
- const rightCodeRenderable = this.createOrUpdateCodeRenderable("right", preRightContent, effectiveWrapMode, true);
5049
+ const needsConsistentConcealing = (this._wrapMode === "word" || this._wrapMode === "char") && this._conceal && this._filetype;
5050
+ const drawUnstyledText = !needsConsistentConcealing;
5051
+ const leftCodeRenderable = this.createOrUpdateCodeRenderable("left", preLeftContent, this._wrapMode, drawUnstyledText);
5052
+ const rightCodeRenderable = this.createOrUpdateCodeRenderable("right", preRightContent, this._wrapMode, drawUnstyledText);
5035
5053
  let finalLeftLines;
5036
5054
  let finalRightLines;
5037
5055
  if (canDoWrapAlignment) {
@@ -5385,6 +5403,15 @@ class DiffRenderable extends Renderable {
5385
5403
  }
5386
5404
  }
5387
5405
  }
5406
+ get conceal() {
5407
+ return this._conceal;
5408
+ }
5409
+ set conceal(value) {
5410
+ if (this._conceal !== value) {
5411
+ this._conceal = value;
5412
+ this.rebuildView();
5413
+ }
5414
+ }
5388
5415
  }
5389
5416
  // src/renderables/Input.ts
5390
5417
  var InputRenderableEvents;
@@ -7231,10 +7258,12 @@ class TabSelectRenderable extends Renderable {
7231
7258
  }
7232
7259
  }
7233
7260
  refreshFrameBuffer() {
7234
- if (!this.frameBuffer || this._options.length === 0)
7261
+ if (!this.frameBuffer)
7235
7262
  return;
7236
7263
  const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
7237
7264
  this.frameBuffer.clear(bgColor);
7265
+ if (this._options.length === 0)
7266
+ return;
7238
7267
  const contentX = 0;
7239
7268
  const contentY = 0;
7240
7269
  const contentWidth = this.width;
@@ -7570,6 +7599,9 @@ class EditBufferRenderable extends Renderable {
7570
7599
  get lineCount() {
7571
7600
  return this.editBuffer.getLineCount();
7572
7601
  }
7602
+ get virtualLineCount() {
7603
+ return this.editorView.getVirtualLineCount();
7604
+ }
7573
7605
  get scrollY() {
7574
7606
  return this.editorView.getViewport().offsetY;
7575
7607
  }
@@ -7828,12 +7860,15 @@ class EditBufferRenderable extends Renderable {
7828
7860
  }
7829
7861
  }
7830
7862
  destroy() {
7863
+ if (this.isDestroyed)
7864
+ return;
7831
7865
  if (this._focused) {
7832
7866
  this._ctx.setCursorPosition(0, 0, false);
7867
+ this.blur();
7833
7868
  }
7834
- super.destroy();
7835
7869
  this.editorView.destroy();
7836
7870
  this.editBuffer.destroy();
7871
+ super.destroy();
7837
7872
  }
7838
7873
  set onCursorChange(handler) {
7839
7874
  this._cursorChangeListener = handler;
@@ -8360,7 +8395,9 @@ class TextareaRenderable extends EditBufferRenderable {
8360
8395
  }
8361
8396
  blur() {
8362
8397
  super.blur();
8363
- this.updateColors();
8398
+ if (!this.isDestroyed) {
8399
+ this.updateColors();
8400
+ }
8364
8401
  }
8365
8402
  get placeholder() {
8366
8403
  return this._placeholder;
@@ -8619,5 +8656,5 @@ export {
8619
8656
  ASCIIFont
8620
8657
  };
8621
8658
 
8622
- //# debugId=3CC45F188E274E3E64756E2164756E21
8659
+ //# debugId=04B0510AE1DAC91C64756E2164756E21
8623
8660
  //# sourceMappingURL=index.js.map