A friendly tour of how T-Strip is put together. T-Strip is about 6,800 lines of Go with just a handful of external dependencies (creack/pty, BurntSushi/toml, golang.org/x/term).
πΈ Screenshot coming here: A diagram of client and server talking over a unix socket. π¬ Video coming here: A visual walkthrough of the packages and how data flows.
Attached (default): a thin client inside your terminal talks to a background server over a unix socket.
ββββββββββββββββββββββ unix socket, framed messages βββββββββββββββββββββββ
β T-Strip client β <βββββββββββββββββββββββββββββββ>β T-Strip server β
β relays keystrokes β MsgInput -> <- MsgOutput β owns every PTY, β
β draws frames β MsgResize -> <- MsgSetup β mux, and emulator β
ββββββββββββββββββββββ <- MsgEnded βββββββββββββββββββββββ
Local (tst local): one process does everything in your terminal. Nothing survives when the terminal closes.
| Package | What it does |
|---|---|
cmd/tst |
Command-line entry: flags, new/attach/ls/kill/local/init |
internal/session |
Persistent sessions: the unix-socket protocol, the daemon, the attaching client |
internal/app |
βLocalβ mode: a raw input loop around the mux |
internal/config |
TOML loading, keymap compilation, action table, themes |
internal/input |
Turns raw terminal bytes into named key/mouse chords |
internal/screen |
Cell grid and diffing renderer (no tears mid-frame) |
internal/vt |
Terminal emulator with scrollback (vendored vt10x fork) |
internal/pane |
One PTY, one emulator, one reader goroutine |
internal/mux |
The multiplexer β all user-visible behaviour |
internal/stats |
/proc and /sys sampling plus custom command widgets |
internal/clipboard |
OSC 52 packing plus native clipboard tool drivers |
internal/width |
Display width of text (CJK / emoji take 2 cells) |
The mux sub-packages, in a good reading order for new contributors:
mux.go β layout.go β actions.go β keyboard.go β mouse.go β render.go β
bar.go β help.go β selection.go β copymode.go β scrollback.go β
wallpaper.go β control.go
Mux.Loop owns all mutable layout and selection state. It waits on:
keys β decoded key and mouse batchespost β closures other goroutines run here (attach, resize, stats)dirty β nudges (I/O in a pane, a stat change)exits β dead panes to removefpsA render frame is emitted only when something changed or an animation is still running. If nothing looks different, the tick costs almost nothing.
Everything that changes layout or selection lives on the loop goroutine. The only mutex of note guards each paneβs VT state while the PTY reader parses chunks and the render briefly reads it. The session server hands state changes in through post, never by writing fields directly.
Every frame is 1 byte type + uint32 BE length + payload (16 MiB payload limit):
| Type | Direction | Meaning |
|---|---|---|
H |
client β server | Hello: JSON {Cols, Rows} |
I |
client β server | Raw terminal bytes |
R |
client β server | Resize: JSON size |
K |
client β server | Kill session |
P / p |
both | Info request / response (used by tst ls) |
S |
server β client | Setup: escape sequences to paint and tear down |
O |
server β client | Bytes to paint on screen |
X |
server β client | βYou were detachedβ (payload = reason) |
Q |
server β client | Session ended |
Attach sequence: H β S β (input/output loop) β X or Q. One client per session; a second attach displaces the first.
internal/vt)A vendored fork of vt10x (MIT) β a Go port of suckless stβs state table β with glyph grids, attributes, cursor management, DEC private modes, and OSC/D scanners. On top:
pushHistory β records scroll-up of the primary screenSetScrollbackLimit, ScrollbackLen, Row, ClearScrollback β the ring used by the muxinternal/screen)A double-buffered cell grid. Each frame is composed into cur, diffed against prev, and only changed cells are written with absolute cursor positioning plus attribute runs. Frames are bounded by synchronized-update markers (CSI ? 2026 h/l) and blinking-cursor suppression, so no tearing appears mid-frame.
ActionInfo (config/actions.go), add a case in run (mux/actions.go), bind it in default.toml. The help overlay picks it up automatically.case in bar.go:widget and name it in left/center/right β or just point a custom widget at a shell command (see Status Bar).internal/input/keys.go is where raw terminal bytes become named chords.make test # go test ./...
make vet # go vet ./...
Test coverage is thin today, focused on: key parsing (input), config normalisation, the session protocol round-trip, detach keeping panes alive, and the vt scrollback ring.
π¬ Video coming here: Adding a new action from start to finish.