OpenTUI 0.9.5
With conceal on, Markdown draws the box of a task item as ☐ or ☑. Before this release, an app could not get ASCII boxes and still conceal the rest of the document. Core apps had to patch the item’s Text renderables, and Rust apps could not change the box at all. Now both bindings let you set the box text:
const markdown = new MarkdownRenderable(renderer, {
content: "- [ ] write tests\n- [x] fix the bug",
syntaxStyle,
taskMarkers: { unchecked: "[ ]", checked: "[x]" },
})
In Rust, call task_markers("[ ]", "[x]") on a Markdown. The box is part of the item’s marker. With [ ], the wrapped text of an item therefore continues at column 6, under its first word. When you change the option, the items already on screen update, also while the document streams. Without conceal, the option has no effect, and items show the source’s [ ] or [x].
A Rust app that streams Markdown into the split-mode scrollback could already get the number of final top-level blocks from committed_block_count. It could not find which rows those blocks use. block_rows() now returns one Range<u32> for each top-level block in the latest frame. These are the same rows that ScrollbackSurface::commit_rows takes. Blocks are one row apart. To commit blocks from..to, each with the gap above it, start at rows[from - 1].end, or at rows[0].start for the first block, and end at rows[to - 1].end. Core apps read the same rows from the y and height of each child in MarkdownRenderable.getChildren(). A shared test checks that Core and Rust put the blocks of a streamed document on the same rows.
Starting with this release, the release workflow publishes the Rust crates to crates.io. cargo add anomalyco-opentui --rename opentui now gets the version of the newest release. Link the native archive from that same release. Prereleases are published too, but Cargo selects a prerelease only when you ask for one.
Added
- core:
MarkdownOptions.taskMarkersandMarkdownRenderable.taskMarkersset the text of the unchecked and checked task boxes whenconcealis on. The defaults are ☐ and ☑. See Markdown. (#2173) - native: Rust
Markdown::task_markers(unchecked, checked)sets the task boxes when conceal is on, as Core’staskMarkersdoes. See Code, Markdown, and highlighting. (#2173) - native: Rust
Markdown::block_rowsreturns the rows of each top-level block in the latest frame, in the rows thatScrollbackSurface::commit_rowstakes. See Time, animation, and the split footer. (#2174) - native: Each release publishes the Rust crates
anomalyco-opentui-sys,anomalyco-opentui, andopentui-sshto crates.io at the release version. See Install, link, and ship. (#2170)
API changes#
@opentui/core#
Added
interface MarkdownTaskMarkersproperty MarkdownOptions.taskMarkers?: MarkdownTaskMarkersproperty MarkdownRenderable.taskMarkers: MarkdownTaskMarkers
Changed
protected property MarkdownRenderable._contentDefaultOptions: { content: string; conceal: true; concealCode: false; streaming: false; }protected property MarkdownRenderable._contentDefaultOptions: { content: string; conceal: true; concealCode: false; taskMarkers: { unchecked: string; checked: string; }; streaming: false; }