-
Notifications
You must be signed in to change notification settings - Fork 0
Terminal
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"
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.
| 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 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.
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.
new terminal children={ new label caption="x" }
-> this type does not accept children
The grid is the content.
KittyTK — image/tty Trinket Kit · MIT licensed · alpha, 0.1.x
Repository · Issues · Support on ko-fi
Sibling projects: PurfecTerm (terminal emulator) · mew (text editor) · PawScript (language)
Getting Started
Installation Building from Source Running a Display Host Your First Application Examples
Protocol
Protocol Overview Object Model Properties and Values Events Templates and Aliases Common Properties Introspection Transports and Security
Clients
Go Client Python Client C Client
Application Objects
Application · MenuBar · Window · MessageBox
Output Trinkets
Label · ProgressBar · StatusBar
Input Trinkets
TextInput · Editor · Terminal
Button · CheckBox · RadioButton
ListView · ComboBox · TreeView
Layout Trinkets
TabTrinket · Panel
ScrollArea · MDIPane
Separator · Spacer · Splitter
Other Trinkets
Layout Helpers