@opentui/core 0.0.0-20251027-327d7e76 → 0.0.0-20251028-8f761bab

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
@@ -133,7 +133,7 @@ import {
133
133
  white,
134
134
  wrapWithDelegates,
135
135
  yellow
136
- } from "./index-bsb3x2r3.js";
136
+ } from "./index-nmrjz1q1.js";
137
137
  // src/text-buffer-view.ts
138
138
  class TextBufferView {
139
139
  lib;
@@ -469,14 +469,6 @@ class EditBuffer extends EventEmitter {
469
469
  this.guard();
470
470
  this.lib.textBufferResetDefaults(this.textBufferPtr);
471
471
  }
472
- setPlaceholder(text) {
473
- this.guard();
474
- this.lib.editBufferSetPlaceholder(this.bufferPtr, text);
475
- }
476
- setPlaceholderColor(color) {
477
- this.guard();
478
- this.lib.editBufferSetPlaceholderColor(this.bufferPtr, color);
479
- }
480
472
  setSyntaxStyle(style) {
481
473
  this.guard();
482
474
  this._syntaxStyle = style ?? undefined;
@@ -649,13 +641,11 @@ class EditorView {
649
641
  }
650
642
  getLineInfo() {
651
643
  this.guard();
652
- const textBufferViewPtr = this.lib.editorViewGetTextBufferView(this.viewPtr);
653
- return this.lib.textBufferViewGetLineInfo(textBufferViewPtr);
644
+ return this.lib.editorViewGetLineInfo(this.viewPtr);
654
645
  }
655
646
  getLogicalLineInfo() {
656
647
  this.guard();
657
- const textBufferViewPtr = this.lib.editorViewGetTextBufferView(this.viewPtr);
658
- return this.lib.textBufferViewGetLogicalLineInfo(textBufferViewPtr);
648
+ return this.lib.editorViewGetLogicalLineInfo(this.viewPtr);
659
649
  }
660
650
  get extmarks() {
661
651
  if (!this._extmarksController) {
@@ -663,6 +653,10 @@ class EditorView {
663
653
  }
664
654
  return this._extmarksController;
665
655
  }
656
+ setPlaceholderStyledText(chunks) {
657
+ this.guard();
658
+ this.lib.editorViewSetPlaceholderStyledText(this.viewPtr, chunks);
659
+ }
666
660
  destroy() {
667
661
  if (this._destroyed)
668
662
  return;
@@ -2504,8 +2498,9 @@ class TextBufferRenderable extends Renderable {
2504
2498
  }
2505
2499
  setupMeasureFunc() {
2506
2500
  const measureFunc = (width, widthMode, height, heightMode) => {
2507
- if (this._wrapMode !== "none" && this.width !== width) {
2508
- this.updateWrapWidth(width);
2501
+ const effectiveWidth = isNaN(width) ? 1 : width;
2502
+ if (this._wrapMode !== "none" && this.width !== effectiveWidth) {
2503
+ this.updateWrapWidth(effectiveWidth);
2509
2504
  } else {
2510
2505
  this.updateLineInfo();
2511
2506
  }
@@ -3156,7 +3151,7 @@ class InputRenderable extends Renderable {
3156
3151
  this.deleteCharacter("forward");
3157
3152
  return true;
3158
3153
  case "return":
3159
- case "enter":
3154
+ case "linefeed":
3160
3155
  if (this._value !== this._lastCommittedValue) {
3161
3156
  this._lastCommittedValue = this._value;
3162
3157
  this.emit("change" /* CHANGE */, this._value);
@@ -4511,7 +4506,7 @@ class SelectRenderable extends Renderable {
4511
4506
  this.moveDown(isShift ? this._fastScrollStep : 1);
4512
4507
  return true;
4513
4508
  case "return":
4514
- case "enter":
4509
+ case "linefeed":
4515
4510
  this.selectCurrent();
4516
4511
  return true;
4517
4512
  }
@@ -4830,7 +4825,7 @@ class TabSelectRenderable extends Renderable {
4830
4825
  this.moveRight();
4831
4826
  return true;
4832
4827
  case "return":
4833
- case "enter":
4828
+ case "linefeed":
4834
4829
  this.selectCurrent();
4835
4830
  return true;
4836
4831
  }
@@ -5245,10 +5240,12 @@ class EditBufferRenderable extends Renderable {
5245
5240
  }
5246
5241
  setupMeasureFunc() {
5247
5242
  const measureFunc = (width, widthMode, height, heightMode) => {
5248
- if (this._wrapMode !== "none" && this.width !== width) {
5249
- this.editorView.setViewportSize(width, height);
5243
+ const effectiveHeight = isNaN(height) ? 1 : height;
5244
+ const effectiveWidth = isNaN(width) ? 1 : width;
5245
+ if (this._wrapMode !== "none" && this.width !== effectiveWidth) {
5246
+ this.editorView.setViewportSize(effectiveWidth, effectiveHeight);
5250
5247
  } else {
5251
- this.editorView.setViewportSize(width, height);
5248
+ this.editorView.setViewportSize(effectiveWidth, effectiveHeight);
5252
5249
  }
5253
5250
  const lineInfo = this.editorView.getLogicalLineInfo();
5254
5251
  const measuredWidth = lineInfo.maxLineWidth;
@@ -5418,9 +5415,8 @@ var defaultTextareaKeybindings = [
5418
5415
  { name: "backspace", action: "backspace" },
5419
5416
  { name: "delete", action: "delete" },
5420
5417
  { name: "return", action: "newline" },
5421
- { name: "enter", action: "newline" },
5418
+ { name: "linefeed", action: "newline" },
5422
5419
  { name: "return", meta: true, action: "submit" },
5423
- { name: "enter", meta: true, action: "submit" },
5424
5420
  { name: "z", ctrl: true, action: "undo" },
5425
5421
  { name: "Z", ctrl: true, shift: true, action: "redo" },
5426
5422
  { name: "y", ctrl: true, action: "redo" },
@@ -5443,7 +5439,6 @@ class TextareaRenderable extends EditBufferRenderable {
5443
5439
  _unfocusedTextColor;
5444
5440
  _focusedBackgroundColor;
5445
5441
  _focusedTextColor;
5446
- _placeholderColor;
5447
5442
  _keyBindingsMap;
5448
5443
  _actionHandlers;
5449
5444
  _initialValueSet = false;
@@ -5453,8 +5448,7 @@ class TextareaRenderable extends EditBufferRenderable {
5453
5448
  textColor: "#FFFFFF",
5454
5449
  focusedBackgroundColor: "transparent",
5455
5450
  focusedTextColor: "#FFFFFF",
5456
- placeholder: null,
5457
- placeholderColor: "#666666"
5451
+ placeholder: null
5458
5452
  };
5459
5453
  constructor(ctx, options) {
5460
5454
  const defaults = TextareaRenderable.defaults;
@@ -5469,7 +5463,6 @@ class TextareaRenderable extends EditBufferRenderable {
5469
5463
  this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor || defaults.focusedBackgroundColor);
5470
5464
  this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || defaults.focusedTextColor);
5471
5465
  this._placeholder = options.placeholder ?? defaults.placeholder;
5472
- this._placeholderColor = parseColor(options.placeholderColor || defaults.placeholderColor);
5473
5466
  const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, options.keyBindings || []);
5474
5467
  this._keyBindingsMap = buildKeyBindingsMap(mergedBindings);
5475
5468
  this._actionHandlers = this.buildActionHandlers();
@@ -5479,8 +5472,20 @@ class TextareaRenderable extends EditBufferRenderable {
5479
5472
  this._initialValueSet = true;
5480
5473
  }
5481
5474
  this.updateColors();
5482
- this.editBuffer.setPlaceholder(this._placeholder);
5483
- this.editBuffer.setPlaceholderColor(this._placeholderColor);
5475
+ this.applyPlaceholder(this._placeholder);
5476
+ }
5477
+ applyPlaceholder(placeholder) {
5478
+ if (placeholder === null) {
5479
+ this.editorView.setPlaceholderStyledText([]);
5480
+ return;
5481
+ }
5482
+ if (typeof placeholder === "string") {
5483
+ const defaultGray = fg("#666666");
5484
+ const chunks = [defaultGray(placeholder)];
5485
+ this.editorView.setPlaceholderStyledText(chunks);
5486
+ } else {
5487
+ this.editorView.setPlaceholderStyledText(placeholder.chunks);
5488
+ }
5484
5489
  }
5485
5490
  buildActionHandlers() {
5486
5491
  return new Map([
@@ -5771,7 +5776,7 @@ class TextareaRenderable extends EditBufferRenderable {
5771
5776
  set placeholder(value) {
5772
5777
  if (this._placeholder !== value) {
5773
5778
  this._placeholder = value;
5774
- this.editBuffer.setPlaceholder(value);
5779
+ this.applyPlaceholder(value);
5775
5780
  this.requestRender();
5776
5781
  }
5777
5782
  }
@@ -5809,14 +5814,6 @@ class TextareaRenderable extends EditBufferRenderable {
5809
5814
  this.updateColors();
5810
5815
  }
5811
5816
  }
5812
- set placeholderColor(value) {
5813
- const newColor = parseColor(value ?? TextareaRenderable.defaults.placeholderColor);
5814
- if (this._placeholderColor !== newColor) {
5815
- this._placeholderColor = newColor;
5816
- this.editBuffer.setPlaceholderColor(newColor);
5817
- this.requestRender();
5818
- }
5819
- }
5820
5817
  set initialValue(value) {
5821
5818
  if (!this._initialValueSet) {
5822
5819
  this.setText(value);
@@ -6025,5 +6022,5 @@ export {
6025
6022
  ASCIIFont
6026
6023
  };
6027
6024
 
6028
- //# debugId=36B0ACD96C2FA6A664756E2164756E21
6025
+ //# debugId=6DE3AAD23AD1DB9564756E2164756E21
6029
6026
  //# sourceMappingURL=index.js.map