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 cellsEach 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.jsIf 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/solidno longer depends onbabel-plugin-module-resolver, sonpm audit --omit=devno 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=browserinstead. See Solid bindings. (#2182)
Added
- core:
createCliRenderer()acceptsselectionBgandselectionFg, andrenderer.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
boxSizinglayout 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:
flexBasisaccepts a percentage, such as"50%". Before, Core discarded a percentage value without an error. See Layout. (#2183) - native: The Rust
Widgettrait hasbox_sizingandaspect_ratiolayout methods. See Widgets and layout. (#2183)
Changed
- native:
syntax_themeon RustMarkdown,Code,Diff, andTextareaacceptsimpl Into<Arc<SyntaxTheme>>, so views that get clones of oneArcshare one theme. Passing aSyntaxThemestill compiles, and a newDiffview 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 RustHost. Before, a terminal that changed size during the suspend got a frame at the old size. See Renderer. (#2181) - native: A percentage
flexBasisor 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
ScrollBoxthat 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 and documentation: https://opentui.com/docs/releases/0.9.8
What's Changed
- core: resume at the terminal size set while suspended by @simonklee in #2181
- solid: drop babel-plugin-module-resolver by @simonklee in #2182
- core: expose boxSizing and percentage flexBasis by @simonklee in #2183
- web: update OpenMono to the final 1.000 build by @iamdavidhill in #2186
- rust, native: align scroll follow and zero-width edits with Core by @simonklee in #2185
- rust: share one syntax theme across widgets by @simonklee in #2190
- native: recompute a percentage flex basis when its parent resizes by @simonklee in #2192
- core: let the renderer set default selection colours by @neriousy in #2196
- native: insert after zero-width text at a line start by @simonklee in #2193
- agents: keep bug-fix regression checks to the smallest test by @simonklee in #2197
Full Changelog: v0.9.7...v0.9.8