Skip to content

feat(tui): blitz-tui, a Blitz document painted into a terminal's cells - #12

Merged
adammharris merged 4 commits into
leaffrom
tui
Oct 22, 2026
Merged

adammharris merged 4 commits into
leaffrom
tui

Conversation

@adammharris

Copy link
Copy Markdown
Member

A new package, packages/blitz-tui, beside blitz-paint and blitz-shell. Blitz's DOM, Stylo and taffy work exactly as they do for a window. Only the last step changes: the laid-out tree is walked into character cells instead of pixels.

  • Painter (paint). Text comes from each inline root's parley layout, one cell per cluster. A background fills the cells whose centres it covers. A border is drawn in box-drawing characters. An app's own caret box, named by class, becomes the terminal's cursor.
  • Terminal. Built on ratatui. Pictures use the graphics protocol through ratatui-image: kitty, iTerm2 or sixel, with half-blocks as the fallback. Their pixels come from Blitz's loaded image data, an SVG data: URL, or a decoder the host supplies.
  • Input. crossterm keys and mouse events become Blitz's events. A typed character carries its text.
  • run. Drives any blitz_dom::Document.
  • TermWindow (behind the winit feature), for apps that ask their window for its size and theme.

examples/tui_counter is the Dioxus counter running through it. Its tests click the buttons and send keys to a focused element, all headlessly.

The package was moved from leaf's terminal editor prototype (diaryx-org/leaf#20), which now depends on this branch.

The package's README lists what it does not draw yet: <input> text, ::marker, outlines, shadows, gradients, transforms and scrollbars.

Checked locally on macOS:

  • cargo fmt --all --check
  • cargo clippy --workspace -- -D warnings
  • clippy -D warnings on the new packages with all their targets
  • tests for both new packages
  • cargo doc -p blitz-tui
  • cargo check for aarch64-apple-ios

Not run locally: Windows, Linux and Android. The tests expect a monospace system font.

…cells

A sibling of blitz-paint and blitz-shell: Blitz's DOM, Stylo and taffy as
they are, and the laid-out tree walked into cells instead of pixels. Text is
read off each inline root's parley layout, a cell to a cluster; backgrounds
fill the cells their centres cover; borders are box-drawing characters; an
img is drawn through the terminal's graphics protocol (ratatui-image),
from the image data Blitz loaded, an SVG data URL, or a host's decoder.
input turns crossterm's keys and mouse into Blitz's events, and run drives
any Document with them.

Moved from leaf's terminal editor prototype (apps/leaf-dioxus-tui), with its
leaf-specific parts made options: caret boxes by class, a click's sideways
shift, a picture decoder. A horizontal border now takes the row boundary
nearest it, so a box whose bottom edge falls just into a row still gets its
bottom side.
@adammharris
adammharris marked this pull request as ready for review October 22, 2026 02:56
@adammharris
adammharris merged commit d681fa8 into leaf Oct 22, 2026
10 of 14 checks passed
adammharris added a commit to diaryx-org/leaf that referenced this pull request Oct 22, 2026
…tui has merged

diaryx-org/blitz#12 merged the tui branch into leaf, so the prototype takes every Blitz crate from leaf, as apps/leaf-dioxus does. The proposal marks decision 6 as settled, apart from offering blitz-tui upstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant