@opentui/core 0.0.0-20251026-63abf532 → 0.0.0-20251028-c5b3c52c

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-g5xctwrm.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([
@@ -5514,8 +5519,8 @@ class TextareaRenderable extends EditBufferRenderable {
5514
5519
  ["submit", () => this.submit()]
5515
5520
  ]);
5516
5521
  }
5517
- handlePaste(text) {
5518
- this.insertText(text);
5522
+ handlePaste(event) {
5523
+ this.insertText(event.text);
5519
5524
  }
5520
5525
  handleKeyPress(key) {
5521
5526
  const keyName = typeof key === "string" ? key : key.name;
@@ -5523,6 +5528,7 @@ class TextareaRenderable extends EditBufferRenderable {
5523
5528
  const keyCtrl = typeof key === "string" ? false : key.ctrl;
5524
5529
  const keyShift = typeof key === "string" ? false : key.shift;
5525
5530
  const keyMeta = typeof key === "string" ? false : key.meta;
5531
+ console.log("handleKeyPress", key);
5526
5532
  const bindingKey = getKeyBindingKey({
5527
5533
  name: keyName,
5528
5534
  ctrl: keyCtrl,
@@ -5532,6 +5538,7 @@ class TextareaRenderable extends EditBufferRenderable {
5532
5538
  });
5533
5539
  const action = this._keyBindingsMap.get(bindingKey);
5534
5540
  if (action) {
5541
+ console.log("action", action);
5535
5542
  const handler = this._actionHandlers.get(action);
5536
5543
  if (handler) {
5537
5544
  return handler();
@@ -5771,7 +5778,7 @@ class TextareaRenderable extends EditBufferRenderable {
5771
5778
  set placeholder(value) {
5772
5779
  if (this._placeholder !== value) {
5773
5780
  this._placeholder = value;
5774
- this.editBuffer.setPlaceholder(value);
5781
+ this.applyPlaceholder(value);
5775
5782
  this.requestRender();
5776
5783
  }
5777
5784
  }
@@ -5809,14 +5816,6 @@ class TextareaRenderable extends EditBufferRenderable {
5809
5816
  this.updateColors();
5810
5817
  }
5811
5818
  }
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
5819
  set initialValue(value) {
5821
5820
  if (!this._initialValueSet) {
5822
5821
  this.setText(value);
@@ -6025,5 +6024,5 @@ export {
6025
6024
  ASCIIFont
6026
6025
  };
6027
6026
 
6028
- //# debugId=6D1D4813A8D6270C64756E2164756E21
6027
+ //# debugId=2D492194646FCB1E64756E2164756E21
6029
6028
  //# sourceMappingURL=index.js.map