OpenTUI 0.9.8

npmGitHub release

Without selection colors, a selection inverts its cells. On a cell with no opaque background, inverting forces the text to black. opencode keeps the renderer background transparent and paints its own background, so on a light theme every selection showed black text on a near-black background. Until now, the only fix was to set selectionBg and selectionFg on every text renderable in the app. Now you can set them once, on the renderer:

const renderer = await createCliRenderer({ selectionBg: "#d3ddf8", selectionFg: "#101010" })
renderer.setSelectionColors("#23344b", "#ffffff") // for example, when the app's theme changes
renderer.setSelectionColors(undefined, undefined) // back to inverted cells

Each color falls back separately. A Textarea that sets only its own selectionBg keeps that background and uses the renderer’s selectionFg. The selectionBg and selectionFg getters on a renderable still return only the values set on that renderable. An app that sets no renderer colors sees no change. ASCIIFont does not use the renderer colors, and the Rust crates do not have renderer selection colors yet.

A box with width: 10, a border, and padding: 1 has 6 columns for its content. The default, "border-box", counts the border and padding as part of the width. With boxSizing: "content-box", the width is the size of the content:

const box = new BoxRenderable(renderer, {
  width: 10,
  height: 3,
  border: true,
  padding: 1,
  boxSizing: "content-box",
})

This box is 14 columns by 7 rows, and its content is 10 by 3. Use it when the content needs an exact size and the frame around it can grow. The default is still "border-box", which is not the CSS initial value, so existing layouts do not change. To restore the default, assign null or undefined.

@opentui/solid no longer installs babel-plugin-module-resolver. Its own Solid transform now rewrites module specifiers with a small Babel plugin. The earlier Node instructions used the resolver to send solid-js to its client runtime. To move to the new setup, remove the resolver from your Babel config and start Node with the browser condition:

node --conditions=browser --experimental-ffi app.js

If your Babel config still imports the resolver, add babel-plugin-module-resolver to your own dependencies. @opentui/solid no longer installs it for you.

Breaking changes

  • solid: @opentui/solid no longer depends on babel-plugin-module-resolver, so npm audit --omit=dev no longer reports GHSA-3g3m-2fjr-6pw4 and GHSA-g3hv-75wg-m249. List the resolver in your own dependencies if your Babel config imports it, or run Node with --conditions=browser instead. See Solid bindings. (#2182)

Added

  • core: createCliRenderer() accepts selectionBg and selectionFg, and renderer.setSelectionColors(bg, fg) changes them and repaints an active selection. Text, Code, Markdown, Diff, Textarea, Input, and TextTable use these colors when they have no selection color of their own. See Interaction, focus, and selection. (#2196)
  • core: The boxSizing layout option accepts "content-box", which adds padding and borders to the size and its limits. getBoxSizing() returns the value, and React and Solid props also accept it. See Layout. (#2183)
  • core: flexBasis accepts a percentage, such as "50%". Before, Core discarded a percentage value without an error. See Layout. (#2183)
  • native: The Rust Widget trait has box_sizing and aspect_ratio layout methods. See Widgets and layout. (#2183)

Changed

  • native: syntax_theme on Rust Markdown, Code, Diff, and Textarea accepts impl Into<Arc<SyntaxTheme>>, so views that get clones of one Arc share one theme. Passing a SyntaxTheme still compiles, and a new Diff view now makes 74 allocations instead of 607. See Code, Markdown, and highlighting. (#2190)

Fixed

  • core: After Ctrl+Z and fg, the renderer resumes at the current terminal size, also in the Rust Host. Before, a terminal that changed size during the suspend got a frame at the old size. See Renderer. (#2181)
  • native: A percentage flexBasis or percentage padding now updates when its parent resizes, unless the parent takes its size from its content. Before, a 50% child of a row that grew from 20 to 30 cells stayed at 10 cells. See Layout. (#2192)
  • native: Text that you type after zero-width text, such as a combining mark or ZWJ, at a line start or after a tab now goes after that zero-width text, in Core and Rust. An insert that adds a line break at a line start goes before the zero-width text, so the line keeps it. See Editing buffers and views. (#2193, #2185)
  • native: A Rust ScrollBox that becomes sticky after layout now follows new rows only from the edge, as in Core. A program scroll on a box with zero rows no longer jumps to the last items when the content grows. See Widgets and layout. (#2185)

API changes#

@opentui/core#

Added

  • method CliRenderer.setSelectionColors(bg: ColorInput | undefined, fg: ColorInput | undefined): void
  • method Renderable.getBoxSizing(): BoxSizing
  • readonly property CliRenderer.selectionBg: RGBA | undefined
  • readonly property CliRenderer.selectionFg: RGBA | undefined
  • property CliRendererConfig.selectionBg?: ColorInput
  • property CliRendererConfig.selectionFg?: ColorInput
  • property LayoutOptions.boxSizing?: BoxSizingString
  • readonly property RenderContext.selectionBg?: RGBA
  • readonly property RenderContext.selectionFg?: RGBA
  • property Renderable.boxSizing: BoxSizingString | null | undefined

Changed

  • function parseBoxSizing(value: string): BoxSizingfunction parseBoxSizing(value: string | null | undefined): BoxSizing
  • property LayoutOptions.flexBasis?: number | "auto" | undefinedproperty LayoutOptions.flexBasis?: number | "auto" | `${number}%` | undefined
  • property Renderable.flexBasis: number | "auto" | null | undefinedproperty Renderable.flexBasis: number | "auto" | `${number}%` | null | undefined