turbodesk
Write terminal applications as functions of their state.
An open source Python library
Terminal interfaces are hard to test.
Most Python terminal libraries keep a tree of widget objects alive between frames. The state of the screen is spread across them. To check one screen, a test builds the tree, drives it, and queries it back.
Your application is a function.
It runs again when something changes, and returns a picture of the screen.
- Immutable views, placed beside, above or over each other
- State in hooks matched by call order, as in React
- Around twenty widgets, each one a function
A test calls the function.
Drawing has no side effect, so a test renders at any size and reads the text.
- Tests need no pilot or async harness
- 2,909 tests in about seventy seconds
- Every code sample in the documentation is checked
Two programs run on it.
Turbo Python and TurboVI are on PyPI. Both shaped the library.
- An IDE with windows, menus, a debugger and a language server
- A vi clone that draws every cell without widgets
- Two Textual applications ported, 47% and 21% smaller
You can read all of it in an afternoon.
Open source
Apache 2.0. Install it from PyPI as turbodesk.
One dependency
Rich measures glyph widths. Pygments is optional, for syntax colouring.
Python 3.12 and later
It runs in Linux, macOS and FreeBSD terminals.
A stable core
Views, hooks and widget signatures freeze at 1.0.
Documentation and a guide: turbodesk.lab.abilian.com