@opentui/core 0.0.0-20251108-0c7899b1 → 0.0.0-20251112-613689c1

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
@@ -136,7 +136,7 @@ import {
136
136
  white,
137
137
  wrapWithDelegates,
138
138
  yellow
139
- } from "./index-z5bb2h2z.js";
139
+ } from "./index-y49e47t2.js";
140
140
  // src/text-buffer-view.ts
141
141
  class TextBufferView {
142
142
  lib;
@@ -2022,17 +2022,27 @@ class FrameBufferRenderable extends Renderable {
2022
2022
  // src/renderables/ASCIIFont.ts
2023
2023
  class ASCIIFontRenderable extends FrameBufferRenderable {
2024
2024
  selectable = true;
2025
+ static _defaultOptions = {
2026
+ text: "",
2027
+ font: "tiny",
2028
+ color: "#FFFFFF",
2029
+ backgroundColor: "transparent",
2030
+ selectionBg: undefined,
2031
+ selectionFg: undefined,
2032
+ selectable: true
2033
+ };
2025
2034
  _text;
2026
2035
  _font;
2027
- _fg;
2028
- _bg;
2036
+ _color;
2037
+ _backgroundColor;
2029
2038
  _selectionBg;
2030
2039
  _selectionFg;
2031
2040
  lastLocalSelection = null;
2032
2041
  selectionHelper;
2033
2042
  constructor(ctx, options) {
2034
- const font = options.font || "tiny";
2035
- const text = options.text || "";
2043
+ const defaultOptions = ASCIIFontRenderable._defaultOptions;
2044
+ const font = options.font || defaultOptions.font;
2045
+ const text = options.text || defaultOptions.text;
2036
2046
  const measurements = measureText({ text, font });
2037
2047
  super(ctx, {
2038
2048
  flexShrink: 0,
@@ -2043,8 +2053,8 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
2043
2053
  });
2044
2054
  this._text = text;
2045
2055
  this._font = font;
2046
- this._fg = Array.isArray(options.fg) ? options.fg : [options.fg || RGBA.fromInts(255, 255, 255, 255)];
2047
- this._bg = options.bg || RGBA.fromValues(0, 0, 0, 0);
2056
+ this._color = options.color || defaultOptions.color;
2057
+ this._backgroundColor = options.backgroundColor || defaultOptions.backgroundColor;
2048
2058
  this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : undefined;
2049
2059
  this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : undefined;
2050
2060
  this.selectable = options.selectable ?? true;
@@ -2075,23 +2085,19 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
2075
2085
  this.renderFontToBuffer();
2076
2086
  this.requestRender();
2077
2087
  }
2078
- get fg() {
2079
- return this._fg;
2088
+ get color() {
2089
+ return this._color;
2080
2090
  }
2081
- set fg(value) {
2082
- if (Array.isArray(value)) {
2083
- this._fg = value.map((color) => typeof color === "string" ? parseColor(color) : color);
2084
- } else {
2085
- this._fg = [typeof value === "string" ? parseColor(value) : value];
2086
- }
2091
+ set color(value) {
2092
+ this._color = value;
2087
2093
  this.renderFontToBuffer();
2088
2094
  this.requestRender();
2089
2095
  }
2090
- get bg() {
2091
- return this._bg;
2096
+ get backgroundColor() {
2097
+ return this._backgroundColor;
2092
2098
  }
2093
- set bg(value) {
2094
- this._bg = typeof value === "string" ? parseColor(value) : value;
2099
+ set backgroundColor(value) {
2100
+ this._backgroundColor = value;
2095
2101
  this.renderFontToBuffer();
2096
2102
  this.requestRender();
2097
2103
  }
@@ -2131,13 +2137,13 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
2131
2137
  renderFontToBuffer() {
2132
2138
  if (this.isDestroyed)
2133
2139
  return;
2134
- this.frameBuffer.clear(this._bg);
2140
+ this.frameBuffer.clear(parseColor(this._backgroundColor));
2135
2141
  renderFontToFrameBuffer(this.frameBuffer, {
2136
2142
  text: this._text,
2137
2143
  x: 0,
2138
2144
  y: 0,
2139
- fg: this._fg,
2140
- bg: this._bg,
2145
+ color: this.color,
2146
+ backgroundColor: this._backgroundColor,
2141
2147
  font: this._font
2142
2148
  });
2143
2149
  const selection = this.selectionHelper.getSelection();
@@ -2155,15 +2161,15 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
2155
2161
  const startX = positions[selection.start] || 0;
2156
2162
  const endX = selection.end < positions.length ? positions[selection.end] : measureText({ text: this._text, font: this._font }).width;
2157
2163
  if (this._selectionBg) {
2158
- this.frameBuffer.fillRect(startX, 0, endX - startX, this.height, this._selectionBg);
2164
+ this.frameBuffer.fillRect(startX, 0, endX - startX, this.height, parseColor(this._selectionBg));
2159
2165
  }
2160
2166
  if (this._selectionFg || this._selectionBg) {
2161
2167
  renderFontToFrameBuffer(this.frameBuffer, {
2162
2168
  text: selectedText,
2163
2169
  x: startX,
2164
2170
  y: 0,
2165
- fg: this._selectionFg ? [this._selectionFg] : this._fg,
2166
- bg: this._selectionBg || this._bg,
2171
+ color: this._selectionFg ? this._selectionFg : this._color,
2172
+ backgroundColor: this._selectionBg ? this._selectionBg : this._backgroundColor,
2167
2173
  font: this._font
2168
2174
  });
2169
2175
  }
@@ -4226,12 +4232,7 @@ class ScrollBoxRenderable extends BoxRenderable {
4226
4232
  this.internalId = ScrollBoxRenderable.idCounter++;
4227
4233
  this._stickyScroll = stickyScroll;
4228
4234
  this._stickyStart = stickyStart;
4229
- if (scrollAcceleration) {
4230
- this.scrollAccel = scrollAcceleration;
4231
- } else if (process.platform === "darwin") {
4232
- this.scrollAccel = new MacOSScrollAccel;
4233
- }
4234
- this.scrollAccel ??= new LinearScrollAccel;
4235
+ this.scrollAccel = scrollAcceleration ?? new LinearScrollAccel;
4235
4236
  this.wrapper = new BoxRenderable(ctx, {
4236
4237
  flexDirection: "column",
4237
4238
  flexGrow: 1,
@@ -4704,8 +4705,8 @@ class SelectRenderable extends Renderable {
4704
4705
  text: option.name,
4705
4706
  x: contentX + 1 + indicatorWidth,
4706
4707
  y: itemY,
4707
- fg: nameColor,
4708
- bg: isSelected ? this._selectedBackgroundColor : bgColor,
4708
+ color: nameColor,
4709
+ backgroundColor: isSelected ? this._selectedBackgroundColor : bgColor,
4709
4710
  font: this._font
4710
4711
  });
4711
4712
  descX = contentX + 1 + indicatorWidth;
@@ -5763,7 +5764,7 @@ function mergeKeyBindings(defaults, custom) {
5763
5764
  return Array.from(map.values());
5764
5765
  }
5765
5766
  function getKeyBindingKey(binding) {
5766
- return `${binding.name}:${!!binding.ctrl}:${!!binding.shift}:${!!binding.meta}`;
5767
+ return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
5767
5768
  }
5768
5769
  function buildKeyBindingsMap(bindings) {
5769
5770
  const map = new Map;
@@ -5790,27 +5791,33 @@ var defaultTextareaKeybindings = [
5790
5791
  { name: "end", shift: true, action: "select-line-end" },
5791
5792
  { name: "a", ctrl: true, action: "buffer-home" },
5792
5793
  { name: "e", ctrl: true, action: "buffer-end" },
5793
- { name: "d", ctrl: true, action: "delete-line" },
5794
+ { name: "f", ctrl: true, action: "move-right" },
5795
+ { name: "b", ctrl: true, action: "move-left" },
5796
+ { name: "d", ctrl: true, action: "delete-word-forward" },
5797
+ { name: "w", ctrl: true, action: "delete-word-backward" },
5794
5798
  { name: "k", ctrl: true, action: "delete-to-line-end" },
5799
+ { name: "u", ctrl: true, action: "delete-to-line-start" },
5795
5800
  { name: "backspace", action: "backspace" },
5801
+ { name: "backspace", shift: true, action: "backspace" },
5796
5802
  { name: "delete", action: "delete" },
5803
+ { name: "delete", shift: true, action: "delete" },
5797
5804
  { name: "return", action: "newline" },
5798
5805
  { name: "linefeed", action: "newline" },
5799
5806
  { name: "return", meta: true, action: "submit" },
5800
- { name: "z", ctrl: true, action: "undo" },
5801
- { name: "Z", ctrl: true, shift: true, action: "redo" },
5802
- { name: "y", ctrl: true, action: "redo" },
5807
+ { name: "-", ctrl: true, action: "undo" },
5808
+ { name: ".", ctrl: true, action: "redo" },
5809
+ { name: "z", super: true, action: "undo" },
5810
+ { name: "z", super: true, shift: true, action: "redo" },
5803
5811
  { name: "f", meta: true, action: "word-forward" },
5804
5812
  { name: "b", meta: true, action: "word-backward" },
5805
5813
  { name: "right", meta: true, action: "word-forward" },
5806
5814
  { name: "left", meta: true, action: "word-backward" },
5807
- { name: "F", meta: true, shift: true, action: "select-word-forward" },
5808
- { name: "B", meta: true, shift: true, action: "select-word-backward" },
5815
+ { name: "f", meta: true, shift: true, action: "select-word-forward" },
5816
+ { name: "b", meta: true, shift: true, action: "select-word-backward" },
5809
5817
  { name: "right", meta: true, shift: true, action: "select-word-forward" },
5810
5818
  { name: "left", meta: true, shift: true, action: "select-word-backward" },
5811
- { name: "d", meta: true, action: "delete-word-forward" },
5812
- { name: "backspace", meta: true, action: "delete-word-backward" },
5813
- { name: "w", ctrl: true, action: "delete-word-backward" }
5819
+ { name: "d", meta: true, action: "delete-line" },
5820
+ { name: "backspace", meta: true, action: "delete-word-backward" }
5814
5821
  ];
5815
5822
 
5816
5823
  class TextareaRenderable extends EditBufferRenderable {
@@ -5885,6 +5892,7 @@ class TextareaRenderable extends EditBufferRenderable {
5885
5892
  ["buffer-end", () => this.gotoBufferEnd()],
5886
5893
  ["delete-line", () => this.deleteLine()],
5887
5894
  ["delete-to-line-end", () => this.deleteToLineEnd()],
5895
+ ["delete-to-line-start", () => this.deleteToLineStart()],
5888
5896
  ["backspace", () => this.deleteCharBackward()],
5889
5897
  ["delete", () => this.deleteChar()],
5890
5898
  ["newline", () => this.newLine()],
@@ -5908,11 +5916,13 @@ class TextareaRenderable extends EditBufferRenderable {
5908
5916
  const keyCtrl = typeof key === "string" ? false : key.ctrl;
5909
5917
  const keyShift = typeof key === "string" ? false : key.shift;
5910
5918
  const keyMeta = typeof key === "string" ? false : key.meta;
5919
+ const keySuper = typeof key === "string" ? false : key.super;
5911
5920
  const bindingKey = getKeyBindingKey({
5912
5921
  name: keyName,
5913
5922
  ctrl: keyCtrl,
5914
5923
  shift: keyShift,
5915
5924
  meta: keyMeta,
5925
+ super: keySuper,
5916
5926
  action: "move-left"
5917
5927
  });
5918
5928
  const action = this._keyBindingsMap.get(bindingKey);
@@ -6065,6 +6075,14 @@ class TextareaRenderable extends EditBufferRenderable {
6065
6075
  this.requestRender();
6066
6076
  return true;
6067
6077
  }
6078
+ deleteToLineStart() {
6079
+ const cursor = this.editorView.getCursor();
6080
+ if (cursor.col > 0) {
6081
+ this.editBuffer.deleteRange(cursor.row, 0, cursor.row, cursor.col);
6082
+ }
6083
+ this.requestRender();
6084
+ return true;
6085
+ }
6068
6086
  undo() {
6069
6087
  this._ctx.clearSelection();
6070
6088
  this.editBuffer.undo();
@@ -6405,5 +6423,5 @@ export {
6405
6423
  ASCIIFont
6406
6424
  };
6407
6425
 
6408
- //# debugId=33D29679C10495BA64756E2164756E21
6426
+ //# debugId=B9B7175D268B0B9C64756E2164756E21
6409
6427
  //# sourceMappingURL=index.js.map