Skip to content

feat(tui): add a toolkit for full-screen terminal applications - #23

Merged
dgrieser merged 2 commits into
mainfrom
feat/tui
Nov 25, 2026
Merged

dgrieser merged 2 commits into
mainfrom
feat/tui

Conversation

@dgrieser

Copy link
Copy Markdown
Collaborator

Summary

New package tui: building blocks for full-screen terminal applications (the kind lazygit, k9s or htop are), with no new dependency.

  • App: raw mode, alternate screen, bracketed paste, optional mouse, cell-diff redraws; terminal restored on quit, panic and signals; SIGWINCH resizes; Ctrl-Z suspend; App.Go/Busy/Notify for blocking work.
  • Keys: per-widget keymaps, focused widget first, text fields get characters first; Tab/Shift-Tab focus, Esc closes layers, ?/F1 help; decoder for modifiers, F-keys, CSI-u, SGR mouse, paste (fuzzed).
  • Widgets: VBox/HBox, Panel, Pages, Tabs, Pad, Keyed; Label, Viewport (scroll, search); List[T] (list or table, filter, marks, paging); Input (readline keys, undo, suggestions, secret); TextArea; Toggle (checkbox/switch), RadioGroup, CheckList, Select, Button, Form; Dialog, Confirm, Prompt, Choose, Menu, EditText; Legend, StatusBar.
  • Headless driver so applications can test their screens.
  • term.Controls: a terminal acting on escape sequences regardless of color mode (refuses TERM=dumb, enables VT on Windows).
  • internal/ttyin: wakeable terminal read (same approach as pick's).
  • Demo: make demo ARGS=tui — a ticket tool on made-up tickets.

Test plan

  • make check (vet, lint, race, locale, cross-compile, tidy)
  • Widget tests through Headless, Example tests, FuzzDecode
  • Demo driven in a real pty: keys, resize, SIGTERM restore, quit restore
  • Ctrl-Z suspend in an interactive shell
  • Windows console

🤖 Generated with Claude Code

dgrieser and others added 2 commits November 25, 2026 23:55
Controls reports whether a stream is a terminal that acts on escape
sequences, independent of the color mode: TERM=dumb is refused, and on
Windows virtual terminal processing is switched on even with
--color=never or NO_COLOR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Package tui builds full-screen applications from widgets: lists and
tables that filter as you type and mark rows, a one-line input with
readline keys, undo and suggestions, a multi-line editor, switches,
checkboxes, radio groups, check lists, selects, buttons and forms,
dialogs, menus and prompts, panels, boxes, pages and tabs, a scrolling
and searchable viewport, a key legend, a help screen and a status bar.

The App takes the terminal over (raw mode, alternate screen, bracketed
paste, optional mouse), redraws only the cells that changed, and puts
the terminal back on quit, panic and signals; it suspends on request
and picks resizes up through SIGWINCH. Keys go from the focused widget
up the tree to the application's keymap, and a widget that takes text
gets characters first. Work that blocks runs through App.Go, with
App.Busy and App.Notify for the status bar. Headless runs an
application without a terminal, for tests.

internal/ttyin holds the wakeable terminal read the app loop uses. The
demo gains a tui command: a ticket tool on made-up tickets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dgrieser
dgrieser merged commit 3b45e11 into main Nov 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant