Skip to content

Terminal

phroun edited this page Aug 22, 2026 · 3 revisions

Wire name terminal

A full terminal emulator as a trinket, on either surface. It draws a character grid, interprets escape sequences, and reports what the user does at it.

term=new terminal
set term feed="\e[1mhello\e[0m\r\n"

The child process runs on the client

This is the arrangement to understand first, because it is the reverse of what an embedded terminal usually does.

The display service draws the terminal and never spawns anything. The child process belongs to the application, which owns its PTY. So the two directions are:

Direction Carried by
child output → screen the feed property, written by the application
user input → child the input event, delivered to the application
grid size → PTY the resize event

An application therefore holds a real PTY, pumps its output into feed, and writes whatever arrives on input back to it. ptydriver in this repository does exactly that, and is what a Go client would use.

The consequence worth stating: the render server never runs the user's shell. A terminal displayed over a socket, or over TLS from another machine, still runs its child where the application is.

Properties

Property Type Default Meaning
feed stream Append bytes to the terminal display
font string Monday Monospace font family for the grid
font_size int 12 Font point size for the grid

Plus the common properties.

font and font_size pick the monospace face and point size the cell grid derives from on a graphical surface. On a character grid the cells are the terminal's own.

feed is a channel, not state

feed is the one property of kind stream. Every write appends — it is not a value the terminal holds, and it is never read back:

set term feed="\e[1mhello\e[0m\r\n"
set term feed="\x1b[32mgreen\x1b[0m"

Arbitrary bytes travel through the string escapes: \e for ESC, \xNN for any byte. That is what lets a raw PTY stream cross a text protocol intact.

Events

input — The user typed, pasted or moused at the terminal. The bytes are for the child process — under this model the application owns the child, so it is the application that writes them.

Field Type Meaning
trinket uint The terminal's object ID.
data string The bytes to hand the child, verbatim.

resize — The terminal's character grid changed size, so the child needs a new window size.

Field Type Meaning
trinket uint The terminal's object ID.
cols int Columns in the new grid.
rows int Rows in the new grid.

input carries the bytes to write to the PTY — keystrokes, paste, and encoded mouse reports, all already in the form the child expects.

resize fires whenever the grid changes size, and once when the grid first has a size. It also re-fires for a late subscriber: a client cannot subscribe until its build reply has round-tripped, by which time the first resize has usually happened, so subscribing re-emits the current size rather than leaving the PTY at its default and the shell's prompt mis-wrapped.

No children

new terminal children={ new label caption="x" }
  ->  this type does not accept children

The grid is the content.

See also

Editor · ScrollArea · Window · Common Properties

Clone this wiki locally