hotty conformance vectors
vectors.json is what a host and an SDK must do, as data.
The host sections (vectors, wire) are a host's, and an SDK's test
host's (SDK.md §4.4), which skips what it cannot do (below). A host runs the
keys, keymap and edit sections too, since its fields edit as SPEC
§10.2 has them.
The SDK sections (wire, build, encode, decode, scan, detect,
keys, keymap, edit; SDK.md §5) are an SDK's. An SDK that counts code
points rather than grapheme clusters (SDK.md §4.6) skips the vectors that
require graphemes.
Which hosts and SDKs pass them, the documentation says: Choose a host and Choose an SDK.
A disagreement is either a bug or a line of SPEC.md or SDK.md that says
too little.
Format
{ "version": "0.10",
"vectors": [ { "name": …, "steps": [ step, … ] } ],
"wire": [ { "name": …, "stream": …, "commands": [ … ], "invalid": n } ],
"build": [ … ], "encode": [ … ], "decode": [ … ], "scan": [ … ],
"detect": [ … ] }
Numbers. A number in a body has a type (SPEC §3.3). In this file, a
number written with a fraction or an exponent (720.0) is a float, and
any other an int, so {"w": 720.0} is not matched by an int 720. A host's
runner reads the file keeping the two apart: Python's json does, Go's
with UseNumber, Rust's serde_json (is_f64), and JavaScript's
JSON.parse with a reviver that reads the source text.
Each vector starts on a fresh host, with mod ctrl and the default
edit shortcuts (SPEC §10.2, §10.4), whatever its platform, speaking this
file's version until a query in the vector answers in another. A vector with
"requires" applies only to a host that has what it names, and others skip
it. A list names several, all required:
- a feature (SPEC §4):
"passthrough"(§9.3),"hover"(§9.4),"count"(§9),"menu"(§10.7),"backdrop"(§5.2); "touch", a host that takes touch (SPEC §9.1, §16);"commands", a host with a terminal that takes edit commands (§10.6);"mouse", a host with a terminal that reports the mouse (§9.6), whose runner tells what it reported (Pointer and Touch, below);"middle-paste", a host whose terminal's middle press pastes (SPEC §9, A text field pastes): on Linux, the primary selection, with the host's setting for it on. Its runner sets what the paste reads (Primary, below);"menu-key", a host that reports the menu key ascontextmenu(SPEC §9, The menu key);"control-click", a host whose platform makes Control with the primary button a context click (macOS, SPEC §9);"pinch", a host whose platform reports a touchpad's pinch and turn (SPEC §9.8), whose runner makes one (Pinch, below);"pinch-pan", one whose platform also says how the pinch's fingers move (GTK's does, AppKit's does not);"paste-field", a host whose terminal's paste reaches the text field that has the keyboard (SPEC §11), a middle press's included. A browser host may not (HOST.md §3.2);"undo", a host whose text fields keep a history and cut (§10.2);"pressed", a host that sees the key the user pressed (§10.4): its runner offers a key step's key as pressed, by both its names, and then as the bytes a terminal sends for it, as the host would;"speaks-0.9": a host that speaks 0.9 as well as 0.10 (SPEC §15; HOST.md §5), which answers av=0.9query in 0.9. A host that speaks 0.10 only, and an SDK's test host (SDK.md §4.4) that does, skips these vectors. The vectors without it hold for every 0.10 host:v=0.9,0.10is answered in 0.10, av=0.8query isEVERSION, and anEVERSIONreply is checked for its code, not its detail (the versions the host speaks, SPEC §4), which differs between a host that speaks 0.9 and one that does not;"scroll"(§5.3),"steps","drop"(§9.1),"view"(§9.5) and"layout", whether CSS renders an element (§10.1, focus fixup): what every host of this version does, named so that a host that lays nothing out, an SDK's test host (SDK.md §4.4), skips it. Nor do test hosts keep a history, so they skip"undo".
Its steps come in eight kinds.
Send { "send": {control}, "payload": text?, "payload_b64": str?, "body": value?, "reply": …, "events": … }: the command goes to the host as the
program would send it. It is base64-encoded and chunked as needed.
payload is UTF-8 text; payload_b64 is a payload that is not, its bytes in
base64, sent as they are (a document that is not UTF-8, SPEC §3.3); body
is a msgpack body (a delta's ops, a menu, an a=field's change), as JSON: the runner
writes it as msgpack, its numbers as Numbers (above) say, and sends that.
"reply"absent: replies are not checked."reply": null: the command must produce no reply."reply": {…}: the first reply (a=okora=err) must match. Every key butcode,detail,bodyandtypesis compared with the reply's control, and one whose value isnullmust be absent from it;codeanddetailwith the body of ana=err.bodygives fields the body of ana=okmust have, equal as values (Numbers, above), and one whose value isnullmust be absent from it; fields it does not name are not checked.typesgives the type of each field of the body (SPEC §3.3):"int","float","str","bool",[T]an array of T,{"name": T, …}a map with those fields, and{"*": T}a map of any names to T. The body must decode (SDK.md §3.9) and each field it has be of its type; a field it lacks, or onetypesdoes not name, is not checked."events": the events the command makes the host send, as for a pointer step (below). Some follow the command by a frame or a load (fit, SPEC §5.2), so a runner waits for them, and then a frame or two more to see one too many.
Inspect { "inspect": [surface, id], "expect": … }: the host reports the
element as the program wrote it:
tag;attrs: the attributes, with the program's values (acid:URL stayscid:whatever the host loads);text: the text content;children: the child elements as[tag, id or null, text].
"expect": null means there is no such element. Otherwise every key of
expect must equal the reported value exactly (keys it leaves out are not
checked).
Pointer { "pointer": "move" | "down" | "up" | "leave", "s": surface, "at": …, "keys": [ … ], "events": [ … ] }: a mouse, as the user would move it (SPEC
§9.1, §16).
"move"puts the pointer on surfacesatat: an element's id, for the centre of its box, or[c, r], for the centre of that cell of the surface, counted from its top left cell (§9.1). A cell can lie outside the window, outside the surface, and over another surface. Moving onto another surfaces, with no button down, takes the pointer off the one it was on, as a terminal does: that one is left first (SPEC §9.4)."down"and"up"press and release a button where the pointer is."button"is the button, as the DOM numbers it (0 the primary, 1 the middle, 2 the secondary, 3 back, 4 forward, SPEC §9); 0 when absent. A runner presses it as the host's platform would: GTK's button 3 for the secondary, and 2, 8 and 9 for the middle, back and forward; a browser'spointerdownwith the button, and for the secondary thecontextmenuthat follows, for another button thepointerup,mouseupandauxclickthe browser makes, or real input (HOST.md §3.2). A"down"while another button is down presses a second one. A host that sendscontextmenuat the release, as on Windows (SPEC §9), is checked for a"down"'scontextmenuat the"up"that follows it, with the cell of the pointer at the"up". A browser runner makes a second button as the browser does: Pointer Events send nopointerdownfor it, only apointermovewith itsbutton. With another button than the primary down, a"move"goes along the straight line from where the pointer was, so it passes the host's slop as a touch's does (SPEC §9.1). The vectors assume a slop under a cell's width, as hosts have it (8 px): they move such a pointer two cells or more, and not at all for a release within the slop. The"keys"held apply as for any button, so a secondary press with Shift or Alt is a step too."wheel"turns the wheel where the pointer is, by"by": [c, r], columns and rows of the surface (positive: right and down), a cell's pixels each. It is one gesture: a runner may send it as several wheel events (a browser scrolls no more than a page for one), lets what it scrolls come to rest before the step's events are read, and lets the gesture end before the next step, so each wheel step is a gesture of its own. A"by"with both parts nonzero is sent as events that each move in that ratio, so no event of it moves along one axis alone."by"may also be a list of such moves,[[c, r], …], made in order within that one gesture, each sent as events of its own that move in its direction, with no end of the gesture between them: a swipe that opens across and turns down, or one turned back."precise":truesends it as a device that scrolls by pixels does, a touchpad's,byin a cell's pixels;falseas a notched wheel's lines, a row's height down and a column's width across each (SPEC §9.9), as a browser'sWheelEventinDOM_DELTA_LINE, or what makes those lines on a platform whose notch is several; the host is told which, or guesses from what it is sent as it would from the device. Absent: the runner's choice."leave"takes the pointer out of the terminal's window."keys": the modifier keys held during the step (shift,ctrl,alt,super); none when absent."count", for"down"and"up": the platform's count of this press and its release in a run of clicks, as an OS hands it over with them (macOS'sclickCount, GTK'sn_press, the DOM'sdetail); 1 when absent. A runner gives it to the host as the host's platform would."through":trueif the step passes through the surface (SPEC §9.3), as it passes a backdrop (§5.2),falseif the surface gets it. Absent: not checked."mouse", on a pointer step's"down"and"up", in a vector that requires"mouse": what the terminal reported of the mouse's buttons for the step (SPEC §9, §9.2), each[kind, button](a touch step's"mouse"is[kind, c, r], below),kind"down"or"up"andbuttonthe DOM's number for the button the report names (SGR's 0, 1, 2, 128 and 129 are 0, 1, 2, 3 and 4), its cell and its modifiers not checked;[]for nothing, and absent, not checked."terminal", for a wheel:trueif the gesture went on to the terminal, as over the cells beneath (SPEC §9),falseif it did not (the document scrolled,overscroll-behaviorstopped it, or the host stopped it on the alternate screen, §5.3); for a list of moves,trueif any part of it did. Absent: not checked. Whether the host stops a wheel on the alternate screen does not depend on the terminal's alternate scroll setting, so a runner sets none, and the result is the same whatever it is."events": every event (a=ev) the step makes the host send, in order, and nothing more. Each is compared as a reply is: every key butdetailwith the event's control,nullfor a key it must not have ("t": null: the event names no element, SPEC §9), anddetail, when present, with its body, decoded: equal as values, each of its type (Numbers, above), andnullwhen the event has none. Absent: events are not checked.- Per frame. How many frames a step spans is the runner's, so a run
of
gestureevents of one surface andt, with no other event between them, is compared as its last, and a run ofwheelevents of one surface,t,modsandpreciseas one, itsdxand itsdysummed and the rest its last's. - A wheel's pixels are written in cells, as a wheel step's
byis: a runner compares awheel'sdxwith the vector's times the host'scellcssw, and itsdytimesh(SPEC §4). - Floats in a detail (a gesture's
scaleandangle, a wheel'sdxanddy) match within 1% of the vector's value, or 0.01 of it where it is under 1: a host may round them, and fingers move by device pixels.
- Per frame. How many frames a step spans is the runner's, so a run
of
Touch { "touch": "down" | "move" | "hold" | "up", "finger": n, "s": surface, "at": …, "keys": [ … ], "terminal": …, "mouse": …, "events": [ … ] }: a finger, as the user would touch the terminal (SPEC §9.1, §9.6,
§9.8, §16). "finger" says which, a label of the vector's own, 0 when
absent: a "down" with a label no finger down has touches with another
finger, and the others stay where they are. The host numbers its fingers
itself (SPEC §9.1), which the events show. "down"
touches surface s at at, an element's id or a cell [c, r] as for a
pointer step, or, without s, the cells: the screen's cell [c, r],
counted from 0 at its top left. "move" moves the finger to
at, in moves of a runner's choosing, along the straight line from where
it was, so it passes the host's tap slop in that line's direction, a move
as far across as down staying exactly so (the
vectors end a move that enters an element in the cell where it enters,
so what is reported does not depend on those moves); "up"
lifts it. "hold" keeps the finger down where it is until the host takes
the touch as a long press (SPEC §9.1); the events the long press makes are
its "events". A runner holds for its host's long-press time, or tells the
host the gesture directly if it can. "keys" are the modifier keys held,
as for a pointer step.
"terminal", for a move: true if the touch went on to the terminal as a
scroll (SPEC §9), false if the surface or the program's mouse took it
(§9.6); absent, not checked. "mouse", on a touch step (a pointer step's
is [kind, button], above): what the terminal reported of the
mouse's primary button for the step (§9.6), each [kind, c, r], kind
"down", "move" or "up" on the screen's cell [c, r], counted from
0; [] for nothing, and absent, not checked. How many moves it reports
depends on the runner's moves, so a runner compares the two lists keeping
only the last move of each run of moves in each. "events" as for a
pointer step: what the step makes the host send.
Pinch { "pinch": "begin" | "update" | "end", "scale": n, "angle": n, "by": [c, r], "keys": [ … ], "events": [ … ] }: a touchpad's pinch where
the pointer is, in a vector that requires "pinch" (SPEC §9.8, §16).
"begin" and "end" begin and end it, as the platform's pinch does.
"update" moves its fingers until the transform since the begin is
scale and angle (degrees, clockwise), and, in a vector that requires
"pinch-pan", their centre by columns and rows from where it began,
[0, 0] when absent. A runner gives the host what the platform would: a
magnification and a rotation for AppKit, the scale, the angle and the
deltas of GTK's touchpad pinch. "events" as for a pointer step.
Key { "key": name, "keys": [ … ], "terminal": …, "events": [ … ] }: a
key pressed and released where the keyboard is (SPEC §10): on the surface
that has it, or else on the terminal. name is the key as the DOM's
KeyboardEvent.key has it ("Enter", "Tab", "End", "ArrowDown",
"B"), on a US layout, where its physical key is the one a US keyboard
has it on. "keys" are the modifier keys held, as for a pointer step. The
host names the key as SPEC §10.4 does. A runner that gives the host keys by
name names them so; one that presses keys on a terminal gets them from the
terminal's encoding, which, for the keys the vectors press, names the same
key, but the physical name of a character's key (ctrl+key_w, beside
ctrl+w). "terminal":
true if the key reached the program as terminal input (§10.2), false if
the surface used it; absent, not checked. "events" as for a pointer step.
Primary { "primary": text }: the user selects text in another
application, so that it is what a middle press pastes (SPEC §9, §11): the
platform's primary selection, set as the platform sets it, or the text a
runner gives its host for the paste to read. Only in a vector that
requires "middle-paste". The read is asynchronous on GTK and AppKit, so
a runner lets a middle press's paste land before the next step.
Write { "write": text }: the program writes text to the terminal,
bytes that are not hotty's. The vectors write CSI ? 1002 h and CSI ? 1006 h together, so that the terminal reports the mouse's buttons and
drags in the SGR encoding, CSI ? 1002 l, so that it reports them no
longer, CSI ? 1049 h and CSI ? 1049 l, the alternate screen and
back, and ESC c, a full reset, which ends the program's session (SPEC
§2) and starts another. A runner whose host has no terminal of its own does to the host what
a terminal does on these.
Menu { "menu": "shown" | "pick", "expect": …, "name": str, "events": [ … ] }: the program's menu, in a host that has menu (SPEC §10.7, §16).
"shown": the level the host shows, once any wait it makes before showing one has passed."expect"is its items in order, each{"key", "label", "group", "enabled"}: the item's key and label as the program sent them, whether it is a group, and whether it is enabled;nullwhen none shows."pick": the item named"name"is picked, as from a multiplexer's palette or a command palette the host already has. A host that offers no picks skips the vector."events"as for a pointer step: what the pick makes the host send,[]for nothing.
The documents of pointer steps size their elements in cells
(--hotty-cell-w, --hotty-cell-h, SPEC §8), and point at centres that lie
well inside a cell, so the cell reported is the same on every host. A
vector that needs a move as far across as down sizes its marks in cells'
widths alone, and the rows it reports then hold for a cell between 1.4
and 2.7 times as high as it is wide, as monospace fonts are. A gesture's
values come from where fingers end, in cell centres, so they hold
whatever the cell's shape; a step whose values would not leaves its
"events" out. Wheels
and keys scroll a document to an end, or to the one snap position any step
of theirs comes to rest on (SPEC §5.3), or bring an element into view where
any alignment ends at the same offset, never by a distance: how far a
wheel's notch or an arrow key moves differs between hosts.
A host never compresses what it sends (SPEC §3.3): a runner checks that no
reply or event it reads carries o.
Wire vectors check the envelope alone. The stream (JSON-escaped bytes)
must decode into commands: listed control keys equal, m and o never
present, and the payload is UTF-8 text. It must also report invalid
malformed or interrupted commands.
The vectors check the document, the events and the wire, not pixels (§5.3: pixels may differ between hosts).
The SDK sections
They check an SDK's wire layer (SDK.md §3). Names in them are canonical, in
snake case (SDK.md Appendix A): a runner maps set_text, keep_cursor and
fit_rows to its own. Strings are the UTF-8 of the JSON string. null
means absent: Go's zero value, Python's None. A vector with "requires"
applies to an SDK that implements what it names; a runner declares what it
implements, and skips the rest:
requires |
what it names |
|---|---|
options.unordered |
a q given wins over the q that n implies, whatever their order |
decode.abort-count |
a malformed message that aborts a chunked one counts twice (SPEC §3.7) |
decode.unterminated |
Feed takes a sequence without its terminator |
decode.max |
Decoder.Max: past it a message is malformed, counted once, and its further chunks dropped (SDK.md §3.6) |
scanner.da1 |
the Scanner's da1 segments |
graphemes |
text is split into grapheme clusters (UAX #29), not code points (SDK.md §4.6) |
Build { "build": builder, "args": {…}, "options": {…}?, "out": [ … ] }:
the runner calls the builder with args, and with the reply options n
and q, detached, scroll and late from options, which have no
order. sync takes args.commands, each a { "build", "args", "options" }
of its own. The output, split into raw bytes and hotty sequences, must be
out:
{ "raw": text }: bytes that are not hotty's, such asPlaceAt's cursor moves,Query's DA1 andSync's brackets;{ "cmd": { "control": {…}, "payload": text? } }: one command, decoded. Its control has exactly these keys (mandonever), and its payload is this text, empty when absent, or the bytes of"payload_b64": a delta's or a menu's msgpack, which"body"shows as JSON, as a Decode vector'sbodiesdo (below), and runners ignore.
Encode { "control": [[key, value], …], "payload": text | "payload_b64": …, "bytes"?: text, "chunks"?: [ { "control": text, "len": n } ] }: the
runner calls Encode with the control in that order. With bytes, the
output must be exactly that: these are payloads that cannot be compressed,
under 256 bytes or random. With chunks, it is split into sequences, and
each one's control (between ESC ] 7279 ; and ;) and base64 length must
match. Every case must also decode back to the payload, with the control's
keys in order, but m and o, which are Encode's (SDK.md §3.3).
Decode { "seqs": [ text, … ], "bodies"?: [ … ], "max"?: n, "results": [ … ], "invalid": n, "messages": [ … ] }: each sequence goes to
one Decoder's Feed, in order. max, when present, is the Decoder's Max
(SDK.md §3.6).
results are its results (not_hotty, partial, complete, invalid),
and invalid its count after the last. messages are the complete ones,
in order:
control: exactly these keys and values;reply:Reply's fields (ok,re,n,surface,cols,rows,code,detail,op, andhitwitht,txandty,nullwhere the reply carries none);event:Event's fields and accessors (surface,kind,target,value,checked,rev,selas a list of two,fieldsas a list of[name, value],mods,linkwithhrefandurl,fit_rows,dragwithc,r,x,y,txandty,hoverwithc,randout,area,count,button(0 for a press whose detail has none,nullfor anauxclick's),candrof a press,pointer(""where the event has none),finger,cut,gesturewithc,r,x,y,scale,angleandfingers,wheelwithdx,dy,c,r,x,yandprecise,viewwithareasandat_end,commandwithname,key,textandhas_text);changed: acapsevent'sChanged, withfieldsthe names of exactly the fields it has, as the body names them (cellcss), and those fields ascapschecks them;caps:Caps's fields (cell_csswithwandh,features), and its answers:hasmaps a feature to the answer, andlight.null: the reply carries none, as when its body does not decode.
Only the keys listed are checked, but view's areas, which is compared
whole: the same ids, each with the same area. Numbers compare as
numbers.
A host's body in the sequences is msgpack in base64, which no one reads,
so bodies shows them as JSON (Numbers, above), one for each sequence:
- the body of the message the sequence starts, its maps in their order;
nullwhere the sequence starts no message, or one with no body;{"hex": …}for bytes the script below does not write: a body that is not one msgpack value, one in another of its types' forms than the smallest (an int wider than it needs, a float of 32 bits), or one holding what no host sends (a nil, a key that is not a string, an extension).
Runners ignore it. scripts/bodies.py writes the base64 in seqs from
it, splitting a chunked body where its chunks split it before, and a Build
vector's payload_b64 from its body, and with --check fails when they
differ. The vector about base64 itself
writes its sequences by hand, and has no bodies.
Scan { "stream": text, "segments": [ … ], "held"?: text, "flush"?: [ … ], "invalid"?: n }: the stream goes to a Scanner, which looks for DA1
answers only when the vector requires scanner.da1. The runner feeds it
whole, cut in two at every offset (or, in a long stream, at every offset
near its ends and at a stride between), and a byte at a time; each time,
the segments must be segments (adjacent pass segments merged), what it
holds after the stream held (none when absent), what Flush returns
flush (none when absent), and its count of dropped sequences invalid
(0 when absent). A segment is { "pass": text }, { "osc": text } or { "da1": text }.
Keys checks key names (SPEC §10.4, SDK.md §3.10), in four forms:
{ "input": text, "keys": [ … ] }:DecodeKeys(input)must returnkeys, one entry for each key,nullfor input that is no key;{ "key": text, "canon": text | null }:ParseKey(key)must returncanon,nullwhen the name does not parse. These are myelin key names 0.1'sreadvectors (its conformance/keys.json), as they are;{ "key": text, "mod": "ctrl" | "super", "canon": text | null }:ReadKeyon a Platform whosemodismodmust returncanon,nullwhen the name does not parse. These are myelin key names 0.1'smodvectors that set no other option (strict reading or shifted capitals, which §10.4 does not use), as they are;{ "key": text, "text": text | null }:KeyText(key)must returntext,nullfor none.
Keymap checks keymaps (SPEC §10.2, SDK.md §3.10), each on the
Platform in "platform": { "mod"?, "edit"? }, the zero Platform (ctrl,
the default edit shortcuts) where absent, in two forms:
{ "parse": text, "format": text }:ParseKeymap(platform, parse).Format()must beformat; with"terminal_keys": trueand noparse,TerminalKeysformatted must beformat;{ "reader": "input" | "multiline" | "button" | "select" | "date" | "element" | "selection", "terminal_keys"?: true, "inner"?: [ … ], "own"?: text, … }:Resolve(platform, reader, own, inner…), the keymap its reader reads (SPEC §10.2, Keymaps; SDK.md §3.10).ownis the focused element'sdata-keys, empty when absent, andinnerits ancestors'data-keys-innervalues from the root down, afterTerminalKeyswhenterminal_keysis true. For each check the vector has, the method must return its value for each of the check's keys:"lookup": { key: action | null },Lookup: an action,"insert", ornullwhen the key is not the field's; on a selection's keymap,"copy"ornull;"selects": { key: bool },Selects;"binds": { key: bool },Binds;"program": { key: bool },Program;"prefix": { key: bool },Prefix;"scroll": { key: action | null },Scroll,nullfor none.
Edit { "field": { "value", "caret", "anchor"?, "multiline"?, "password"?, "rows"? }, "steps": [ … ] }: a Field (SDK.md §4.6) made from
field, absent keys false, 1 for rows, and nothing selected when there is
no anchor. Each step is { "do": action }, { "extend": action },
{ "type": text } or { "select": [anchor, caret] }, and after it every
key the step lists must equal the Field's: value, caret and anchor (in
characters; with nothing selected, the anchor is the caret), and changed,
what Do, Extend or Type returned (false for select).
"requires": ["graphemes"] marks the vectors whose text has a character of
more than one code point, other than CR LF.
Detect { "n"?: n, "late"?: true, "steps": [ … ], "caps"?: {…} }: one
Detector, with the query's number n (1 when absent), asking for a late
answer when late is true. Each step happens at time at, in
milliseconds, and is one of start, da1, osc (a sequence, decoded, and
given to Reply; its body shows the body, as a Decode vector's bodies
do, and runners ignore it), tick and end. After each, every key the step lists
must equal the Detector's: took (what DA1 or Reply returned), state
(detecting, native, text), decided, done, and deadline (null
when there is none). caps is checked against the capabilities at the
end; null: there are none, as when the terminal is no host the program
can use.