hottyHTML over the TTY

☰ Contents · Reference › hotty-blitz

hotty-blitz

hotty on Blitz. Blitz assembles Firefox's style engine (Stylo), html5ever, Taffy for layout and Parley for text, and renders on the CPU. This repository holds the following; the protocol itself, the envelope a program's output is split by, a program's commands read and checked, and the replies and events written, is the hotty crate of hotty-rs, which every Rust host and program shares:

crate what
crates/hotty-blitz the host of hotty 0.10 (and 0.9): surfaces, deltas and morph, cid: resources and the network policy (animated GIF, APNG and WebP play, and CSS animations and transitions run; an infinite one, once seen through its period, plays from memory with nothing restyled or painted, and one whose period shows nothing at all asks for no frames), damage-proportional rendering into a caller's buffer, input and events (their bodies msgpack), and a C ABI (include/hotty_blitz.h) for terminals to link
crates/hotty the hotty CLI (package hotty-cli): render and show a page, run (the kitty graphics polyfill), send, dump, replay, bench, css
mods/ our patches on Blitz, parley (its text layout), vello_cpu (its renderer), glifo (vello_cpu's glyph renderer) and Stylo (its style engine), one set each, every patch with a page on what it changes, why we carry it and whether upstream might want it (gov P-7; neuroplast.io/modding lists them)

The host speaks hotty 0.10, and 0.9 as well (SPEC §15, HOST.md §5). It answers a query listing either (a=q:n=1:v=0.9,0.10, SPEC §4) in the highest version the two share, and speaks that version until the session ends. Other queries, one with no v too, get EVERSION, its detail 0.9,0.10. A 0.9 session hears what 0.9 sends: no pointer, finger or cut, no wheel or gestures, and a second finger ends a drag. The media features of §8 follow the device in either.

0.10.x speaks hotty 0.10 and 0.9; the patch number is this repository's own. The capabilities name it: "host": "hotty-blitz", "version": "0.10.0".

A program can scroll with a scroll delta op, by the steps a bound key would take from its target, or from the root without one. a=hit asks what a drag would name at the centre of a surface cell, with a drop target's steps, without changing hover or focus. A text field can give Tab to the program with tab=program; key=default gives a key back to the host. Reset ends the session and drops its resources. The terminal passes the system's reduced-motion setting to hotty_host_set_reduced_motion, and the refresh rate of the display its window is on to hotty_host_set_refresh_rate. It tells hotty_host_set_seen when a placement scrolls out of view or its window is hidden, so that what plays there stops asking for frames. It passes the alternate-screen and mouse tracking modes to hotty_host_set_scroll_modes for scroll chaining.

Try it

Needs mise and a checkout of neuroplastio/hotty next to this repository (or HOTTY_DIR) with the 0.10 conformance vectors.

mise install && make release       # also patches Blitz at ../blitz, parley at ../parley, vello_cpu at ../vello_cpu, glifo at ../glifo and Stylo at ../stylo
./target/release/hotty run -- python3 ../hotty/examples/dash.py
./target/release/hotty render ../hotty/corpus/01-card.html -o card.png
./target/release/hotty dump capture.bin     # the hotty messages in a captured stream

hotty run works in any terminal with kitty graphics (kitty, Ghostty, and others). It sits on the pty, passes everything through except hotty, and shows surfaces as images (SPEC §14). It also works across SSH: hotty run -- ssh host program.

A terminal can instead link libhotty_blitz through the C ABI and render surfaces natively: sharp at any zoom, no pixels on the wire, and local interaction. hottyterm does exactly that; install it with brew install --cask neuroplastio/tap/hottyterm (macOS on Apple silicon) or the AUR's hottyterm-bin (Arch on x86_64).

Reading the wire

A host's replies and events carry msgpack bodies (SPEC §3.3), in base64, which no one reads off a terminal. hotty dump [FILE] reads a captured stream from FILE or stdin, a program's output or what its terminal gave it to read (util-linux's script -I in.bin -O out.bin), and prints one line for each hotty message, its chunks joined and o=z inflated: its control, then its body as JSON with each value's type in sight, or what a program sent as its text.

a=ok:n=1:re=q  {"v": "0.10", "cellcss": {"w": 10.0, "h": 21.0}, "scale": 2.0, …}
a=delta:s=form:q=2  {"ops": [{"op": "text", "t": "status", "v": "saved ✓"}]}
a=ev:s=form:e=fit  {"r": 3}
  • A float always has a fraction or an exponent (2.0, 1e-7), and an int never. Bytes are h'…' in hex, a timestamp (extension −1) t'…' in RFC 3339, another extension ext(<type>, h'…').
  • A body that is not one msgpack map says why after !: not a map, bytes after it, nested deeper than 32 levels, or not msgpack. So does one that holds, anywhere in it, what no host sends (SPEC §3.3), which fails the whole body for its reader: a nil, a key that is not a string, a key given twice in one map (a fixstr and a str 8 of one name are one key), a string that is not UTF-8, an int further than 2^53 − 1 from zero, or a timestamp of another size, with a second's nanoseconds or more, or past 2^53 − 1 seconds. Each kind is said once, at the byte it is first at ( !a nil at byte 13, and 2 more), and the body is shown all the same.
  • In text, \ and control characters are escaped (\n, \e); a resource that is not text shows its size and first bytes.
  • --all prints the bytes between messages too, as (bytes) lines; a sequence that does not decode is an (invalid) line.

The network

A surface fetches nothing from the network unless its user allows it (SPEC §7.2). The terminal's half of the policy is CSP's syntax: hotty run --net 'img-src https:', hotty_host_set_network through the C ABI. The capabilities report it as net. A document asks with <meta name="hotty-network" content="img-src https://example.com">, and a URL is fetched only when a source in both halves matches it, for its directive: img-src for images (<img>, CSS backgrounds and masks), style-src for stylesheets and @import, font-src for @font-face.

  • Only http and https, never a document (<iframe>), never a file, and nothing under the default base https://hotty.invalid/. Relative URLs resolve against the document's <base>.
  • No referrer, cookies or credentials. A redirect is followed only where the policy allows its target too.
  • At most 8 MiB and 10 seconds per fetch, its redirects included; past either, it fails as a missing resource does.
  • Four threads fetch for the whole process, off every terminal's render thread, into one cache (64 MiB, least recently used out): a URL shown in several surfaces or terminals is fetched once while it is cached. What arrives wakes the terminal (hotty_host_set_waker), and the surface is drawn again; a placement made with f=1 hears fit if its height changed (SPEC §5.2). Animated GIFs from the network play.
  • srcset, sizes and <picture> choose the source, with cid: too: the candidate for the display's density, the first <source> whose type and media match. They choose again when the display changes (another scale, a zoom, a light or dark theme, a new width for sizes).
  • An inline SVG's <image href> is an image like any other: cid:, or fetched under img-src. An SVG that is itself an image (<img>, CSS) loads only data: URLs inside it, as in a browser.

Scrolling

A document scrolls only along the axes it asks for (a=doc with scroll=1, 2 or 3, SPEC §5.3), as a page does: its root and its overflow: auto and scroll boxes, with overlay scrollbars that take pixels, never cells, and fade. Along an axis it did not ask for nothing moves, whatever its CSS, and nothing shows a scrollbar.

  • A terminal hands every wheel, touchpad scroll and touch pan (below) to hotty_host_scroll first. It returns whether the surface took it; one it did not take is the terminal's, as over the cells. A gesture goes where its first wheel went, as in a browser: the innermost box that can still move that way, then the root, then the terminal, unless overscroll-behavior stops it.
  • While a surface has the keyboard, the keys a browser scrolls with scroll it (those its focused control does not use), and focus scrolls an element into view.
  • hotty run does the same with the wheel reports it reads: one report is a row. Its pointer is always a mouse: the terminal under it reports no touch, pen or pinch, so a program there hears no fingers and no gestures, and an element's wheel comes in notches (precise false).
  • hotty-blitz neither bounces at an edge nor coasts after a fling, which SPEC §5.3 leaves to the host: a scroll stops where it can go no further. A trackpad's momentum on macOS scrolls on as AppKit sends it (HOTTY_SCROLL_MOMENTUM).
  • reveal (SPEC §6.1) scrolls an element into view for the program: its top to the top of each box that holds it (start), its bottom to the bottom (end), or as little as it takes; across, as little as it takes. It scrolls only the root and overflow: auto and scroll boxes, never one that is hidden, and moves no focus.
  • view (SPEC §9.5) tells the program which elements with data-on~=view and an id are in view, each with its area, and whether the root shows its end, from the frame that draws them: shown in the window and clipped by no box on the element's chain of containing blocks, as CSS clips. A wheel's gesture or a dragged thumb holds it back until the scroll comes to rest: a gesture rests at its end phase (HOTTY_SCROLL_END) or 150 ms after its last wheel, which hotty_host_next_frame counts as a deadline.

Input

The 0.10 C ABI has one call for each kind of input from a pointing device, and replaces every input call before it (hotty_host_pointer, hotty_host_button, hotty_host_wheel, hotty_host_end_gesture, hotty_host_touch, hotty_host_cells_touch):

  • hotty_host_input (Host::input): a mouse's, a pen's or a touchpad's pointer and buttons, and each finger on a touchscreen by its id, with its kind, phase, position, button (the DOM's number), keys, the platform's click count and flags (the context gesture; for a finger on the cells, whether the program reads the mouse and whether the screen shows). It returns whose the input is: the terminal's (0), undecided (1: hold a finger's moves) or the surface's (2).
  • hotty_host_scroll (Host::scroll): a wheel, a touchpad's scroll or a finger's pan, in CSS pixels, lines or pages, with whether the device is precise and the platform's phase (begin, update, end, momentum).
  • hotty_host_pinch (Host::pinch): a touchpad's pinch and rotation, scale and angle since its begin, and how its centre moved where the platform says (GTK), not where it doesn't (AppKit).
  • hotty_host_set_pointers (Host::set_pointers): the pointers of the device, for pointer, any-pointer, hover and any-hover (SPEC §8) in every session (Blitz mod 0113).

The session's version decides what the program hears: a 0.9 session hears what 0.9 sends, with no pointer, finger, cut, gestures or wheel, and a second finger ends a touch there.

A 0.10 session hears pointer (SPEC §9) when the user presses, touches or scrolls with another kind of pointer than it last heard of, or for the first time since its query, before anything that input makes; a press, a click, a contextmenu, a dragstart, a gesturestart and a wheel carry their kind. Nothing is sent for a detached surface.

Pointer buttons

Pass the primary button's presses and releases, and pointer moves, to hotty_host_input, and other buttons by their DOM numbers (SPEC §9). It returns whether the surface took the button. While it holds a press, feed it moves and releases even outside its window. Pass presses over the cells with a null surface so the host can track which side owns the chord.

contextmenu requests the platform's menu gesture, aux takes other buttons, and rightbutton takes the secondary button for an auxiliary click or drag. Configure release-time menus with hotty_host_set_context_menu_on_release. A terminal can offer ContextMenu and Shift+F10 with hotty_host_menu_key after normal key routing.

Where the terminal's middle button pastes, enable it with hotty_host_set_middle_paste. A press on a field can call the effects' paste callback to request what the middle button pastes. Deliver that text with hotty_host_paste.

Touch

A terminal passes every phase of each finger that touches a surface (where hotty_host_takes_pointer is true) to hotty_host_input, taps included: down, move, up, cancel (the platform cancelled it) and hold (the terminal took it for a long press). hotty-blitz decides whose each finger is (SPEC §9.1, §9.8) and says so on every phase.

  • A finger drags an element with drag in its data-on and an id when the touch-action of the element touched allows no pan along its first move past the tap slop, 8 CSS px (TAP_SLOP, GTK's drag threshold and the addon's): the larger of the move's two deltas; a tie pans where either pan is allowed, and drags otherwise (in 0.9, a tie pans). The value is Pointer Events': the touched element's and its ancestors' up to the nearest element that scrolls, so none, pinch-zoom and a pan-x or pan-y across the move drag; auto and manipulation pan. Stylo parses no pan-left, pan-right, pan-up or pan-down.
  • A drag is a press when it is decided: press and dragstart at the cell where the touch began, what the press causes (focus), and a drag at once if the finger is already over another element. Then drags as for a mouse, and its lift ends it as a mouse drag ends (dragend, and a click if it lifts over the element it began on).
  • Each finger drags on its own, with finger, the lowest number no other finger down holds, from 0. A finger that would pan beside a drag does nothing; once one pans, the others are the terminal's. A tap among other fingers is a click where it lifted.
  • Two fingers on an element with gesture in its data-on are a gesture once one goes past the slop since the second touched: a drag under way ends with dragend and cut (a pan stops), then gesturestart, gesture at most once a frame, and gestureend when fewer than two are left. A touchpad's pinch over it is the same gesture, its pointer "mouse".
  • A cancel ends the finger's drag with dragend, no target and cut; a placement going away or a new document ends every finger's.
  • A pan is the terminal's: it scrolls with it, hotty_host_scroll first, from where the touch began, and the pan presses nothing. Touches with Alt held at touch-down, on no drag element, on a detached surface or after a long press never drag. A tap, a touch that never went past the slop, is a click where the finger lifted: a press there, never a drag.
  • A long press over or inside an element with contextmenu in its data-on, with neither Shift nor Alt, sends contextmenu at the finger's cell (SPEC §9.1). Hold returns the surface's (2), and the lift makes no click.
  • A touch hovers nothing.

A finger that touches the cells, outside every surface or where one lets the pointer through, goes to hotty_host_input with a null surface, every phase of it, with whether the program reads the mouse and whether the terminal shows the screen rather than its scrollback. The areas a program names with a=touch (SPEC §9.6) are kept per screen, as its menu is: leaving the alternate screen (hotty_host_set_screen) drops its areas, and a full reset (hotty_host_reset) drops both. In an area, while the program reads the mouse on the screen and without Alt, the first finger is decided as on a surface: the way the area drags makes it the program's mouse (2), and hotty-blitz hands back the reports to make, in the program's mode and encoding: the primary button pressed where the touch began, moved with the finger wherever it goes, and released where it lifts, or on the last cell at a cancel or a second finger, with the keys held but one the terminal keeps a press for (Shift, where Shift and a press select). The other way is a pan (0), and a tap there is a press and a release where it lifted. Anywhere else the touch is the terminal's (0).

The wheel

An element with wheel in its data-on and an id takes the wheel and the touchpad's scroll over it in a 0.10 session (SPEC §9.9): nothing scrolls, hotty_host_scroll returns true, and the program hears wheel at most once a frame with the CSS pixels summed, the pointer's cell and step, precise, and the kind "mouse". A gesture that began over it stays its own to its end.

Text fields

A focused text field types and edits only as its program's keymap says (SPEC §10.2). The host resolves the default keymap, each ancestor's data-keys-inner from the root down, and the field's own data-keys. Each reader takes the bindings it can use. A printable key a field types can be given to the program through its own data-keys. With nothing focused, use the root's and body's inner maps and the body's own map. Document selection copy reads those same maps over the defaults. Words, lines and a password field are the spec's (crates/hotty-blitz/src/edit.rs); moves by rows and pages follow the field's layout. A terminal offers a key twice at most (SPEC §10.4), its keys named as myelin key names 0.1 names them: first as the user pressed it, named from the key event with its physical key and the character it types (ctrl+key_w, ctrl+w), before its own shortcuts and translations (hotty_host_key_pressed), so Command+Left is super+arrow_left and not the ctrl+a a macOS terminal sends for it, and the physical name is looked up first; then, if the surface did not use it, as the bytes its key encoding or a binding would write (hotty_host_key_bytes), named by what the program would read (hotty::keys), so a remapped key is the key it sends. The keys a field does not use go on to the terminal's edit-command lookup (SPEC §10.6) and then to the program as input where it took no matching command. When sending an edit command instead of the pressed key's bytes, call hotty_host_command_key_sent so a prefix bound to the key starts. Any other focused element's data-keys gives keys to the program, or, in a document that scrolls, scrolls with them (scroll-down, scroll-end, …), after the keys the element uses itself; a field leaves those scroll actions out.

A program changes a control as the user would with a=field (SPEC §6.4), only while the user has not changed it since: each control counts the user's edits, undos, toggles, checks and picks as its rev (a radio group, one name in one form, counts together), and input and change carry it. Positions are bytes of the UTF-8 value, a textarea's CR LF and lone CR made LF first, and a selection's ends snap to the start of a grapheme cluster. An a=field sends nothing, is one edit of the field's history and ends a run of typing; a field that only a=field changed sends no change when focus leaves it. A field's caret starts at the end of its value (mods/blitz/caret-at-end.md), and it keeps its selection while not focused. A field with data-on~=caret hears caret when the user moves its selection, at most one a frame (a second in one frame waits for the next), and its input carries the selection. This host has no input method yet, so a field never composes.

Performance

Measured 2026-09-29, release build:

  • A one-cell delta costs about 0.1 ms per frame at any size of nested document (64 to 262,144 cells), because the Blitz patch makes construction, layout and rounding stop where the change stops.
  • Paint covers only the damage: the old and new boxes of what changed.
  • Bub-n-Bros (../hotty/examples/bubbros.py) sends deltas to 7 of its ~380 sprites a frame.

Flat lists still cost linear time in their length: every pass, Stylo's included, scans the children of the node that changed.

Not done yet:

  • Occlusion. A placement wholly under others (SPEC §5.2, z) is still laid out and painted, and its deltas still cost a render. Overlap detection over the placements would let the host skip the paint of what cannot show, and defer its deltas until it shows again.

Fonts

A host ships three families (in crates/hotty-blitz/fonts/), so a document looks the same on every system.

AdwaitaMono Nerd Font Propo (Regular, Bold, Italic and Bold Italic) is there for the terminal's own text and its Nerd Font icons, which then draw without an installed font. Italic is the font's own, as in hottyterm's cells, not Regular slanted. It is the first monospace font. In every other generic family it comes second: after the system's choice for that family and before the fonts fontconfig lists after it. So a symbol or icon the system's font lacks draws from it, at its own width.

IBM Plex Sans (Regular, Medium and SemiBold: 400, 500 and 600) is there because hotty-surf's kit draws its Compact and Roomy densities in it. Without it a surface falls to whatever sans the system has, with other metrics. It answers only to its own name, "IBM Plex Sans", and is in no generic family. The bundled faces win over an installed Plex of the same name, so a surface draws alike on a machine that has Plex and one that does not. The files are IBM's v6.4.0 release, byte for byte (the name "Plex" is reserved, so they are never subsetted or re-encoded).

Noto Color Emoji v2.051 (Google's CBDT build, byte for byte the file Ghostty embeds) draws every emoji, whatever font the document asks for, rather than whichever emoji font the system has. It is the first emoji font. In every other generic family it comes just before the system's colour emoji font (fontconfig lists Noto Color Emoji under monospace and sans-serif), so an emoji cluster, which takes the first colour font of its stack, takes ours, and text draws as before. A document that names "Noto Color Emoji" gets ours too, whatever copy the system has. hottyterm draws its cells' emoji from the same file.

The faces are decompressed on a thread of their own when a host starts (tens of milliseconds).

The spec names none of these fonts: a document can't count on them on another host.

Fidelity

docs/fidelity/ has the corpus rendered here next to Chromium. The known gaps:

  • forms (type=password shows its text);
  • tables (captions, colspan);
  • text-overflow on right-to-left lines (they clip);
  • container queries;
  • 3D transforms.

make oracle rebuilds the sheets.

Environment

variable effect
HOTTY_LOG=<file> log what hotty run does
HOTTY_FRAME_LOG=<file> one line of timings per rendered frame (in hotty run and any terminal linking the library)
HOTTY_STATS=1 a summary when hotty run exits
HOTTY_SCALE=<s> device pixels per CSS pixel, overriding the guess

Licence

Apache-2.0 (LICENSE).

  • Blitz is MIT OR Apache-2.0, parley Apache-2.0 OR MIT, vello_cpu and glifo Apache-2.0 OR MIT, and Stylo MPL-2.0. Our patches on each, in mods/, are offered under that upstream's licence, the one its mod.md names (gov P-7).
  • AdwaitaMono, IBM Plex Sans and Noto Color Emoji in crates/hotty-blitz/fonts/ are OFL-1.1: AdwaitaMono's in OFL.txt, IBM Plex Sans's (Reserved Font Name "Plex") in IBM-Plex-OFL.txt, Noto Color Emoji's in NotoColorEmoji-OFL.txt. AdwaitaMono's Nerd Fonts icon sets keep their own licences, listed with their texts in NOTICE.txt, which also records where Plex's and Noto Color Emoji's files came from. A program that ships the library ships all four files.

Loading hotty-demo…