@opentui/core 0.1.41 → 0.1.43

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-kj9k00yt.js";
139
+ } from "./index-23t1sg60.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
  }
@@ -4699,8 +4705,8 @@ class SelectRenderable extends Renderable {
4699
4705
  text: option.name,
4700
4706
  x: contentX + 1 + indicatorWidth,
4701
4707
  y: itemY,
4702
- fg: nameColor,
4703
- bg: isSelected ? this._selectedBackgroundColor : bgColor,
4708
+ color: nameColor,
4709
+ backgroundColor: isSelected ? this._selectedBackgroundColor : bgColor,
4704
4710
  font: this._font
4705
4711
  });
4706
4712
  descX = contentX + 1 + indicatorWidth;
@@ -6417,5 +6423,5 @@ export {
6417
6423
  ASCIIFont
6418
6424
  };
6419
6425
 
6420
- //# debugId=1245366BCDEC541D64756E2164756E21
6426
+ //# debugId=B9B7175D268B0B9C64756E2164756E21
6421
6427
  //# sourceMappingURL=index.js.map