Skip to main content

Module wire

Module wire 

Source
Expand description

Layer 1: the wire. Constants, the messages a program sends and receives, the encoder (framing, chunking, blobs) and the decoder of replies and events.

Every message is one APC string, ESC _ tsp;<verb>[;k=v]*;<body> ESC \. A body over the negotiated apc limit is cut by chunks exactly as Tern’s own tsp_chunks cuts it, and each piece is sent with c=<id> (and m=1 on all but the last).

Modules§

feature
Feature names of the hello query (program) and reply (terminal).
kind
Node kinds, as the k of a node and the kinds of the hello reply.

Structs§

Ack
ack: the highest frame applied and drawn.
Action
action: a pointer action with a custom name.
Blob
A b message: binary data named by its SHA-256.
BlobsReply
The blobs reply: which of the asked blobs Tern holds.
Cell
A cell size in pixels.
Change
change: an el control flipped, or a prefs row changed.
Close
An x message: close a surface.
Edit
edit: native editing replaced UTF-16 [from, to) with text.
Encoder
Encodes messages under the session’s apc limit, numbering chunk sequences with a base-36 counter.
ErrorEvent
error: a rejected op, message, stylesheet or element.
Focus
focus: a click asked for the keys in a field.
Frame
An f message: an atomic batch of ops on one surface.
Gone
gone: nodes or a surface Tern dropped.
Hello
The hello reply: what the terminal draws and supports.
Motion
motion: Reduce Motion was toggled.
Open
An o message: open a surface.
Palette
A t message: the program palette, token → #rrggbb per variant.
PaletteNames
The names of a palette’s two variants.
Resize
resize: the pane’s width or cell size changed.
Select
select or activate: an item was picked or opened.
SendText
send: submit text through a composer.
Sheet
An s message: install, replace or (without css) remove a stylesheet.
Theme
theme: the appearance switched.
Toggle
toggle: a collapsible node was folded or unfolded.
Undo
undo: undo the last change to a field.
Visible
visible: the pane was hidden or shown.
WireNode
A node with its id, as an add op carries it.

Enums§

Event
An e message: an event.
Message
Any program → terminal message.
Mode
A surface mode.
Op
One frame op.
Query
A q query.
Reply
An r message: the reply to a query.
RevealAt
Where a reveal op scrolls a node.
ScrollBy
How far a scroll op moves.
TextMode
How a text op changes primary text.

Constants§

APC_LIMIT
The largest body sent in one message unless the hello reply says otherwise.
CREDITS
How many frames may be unacknowledged unless the hello reply says otherwise.
MAX_BLOB
The largest blob Tern takes, in decoded bytes.
VERSION
The protocol version this SDK speaks.

Functions§

blob_id
The id of a blob: the lowercase hex SHA-256 of its bytes.
chunks
Splits a body into chunk bodies exactly as Tern’s tsp_chunks does.
encode
Encodes one message of verb with params and an already serialized body, chunked under limit with chunk id chunk when it is longer.