An imperative retained-mode TUI framework powered by Vaxis.
Cooper is heavily influenced by OpenTUI. A lot of TUI libraries are immediate mode or use heavy functional paradigms, and I wanted a retained mode library that provided a similar imperative API to the DOM because that is intuitive to me, when building UIs. Also, I just wanted to build TUIs with my programming language, Ard.
ard add github.com/akonwi/cooper@latestuse cooper
use cooper/ui
fn main() {
let application = cooper::app().expect("could not create app")
defer application.destroy()
let field = ui::input(
application.context,
placeholder: "Type here, then press Ctrl+C to quit",
styles: ui::style(
width: ui::percent(100.0),
height: ui::cells(1),
),
)
application.root.add(field)
field.focus()
application.run().expect("run Cooper")
}
cooper is the application namespace for App, Runtime, and events. cooper/ui
is the view-construction namespace for controls, layout, colors, geometry,
selection, and rich text.
- Controls — Box, Text, Image, Input, TextArea, ScrollBox, Scrollbar, Select, TabSelect. See the controls list and examples.
- Structural dividers — A
ui::divideroccupies one normal layout row; its borderedBoxparent paints the connected├──┤,╠══╣, or┣━━┫junctions. This avoids fragile overdraw and inset-rule gaps in framed dialogs;cui::divider()provides the declarative form. - Animation — Runtime-owned timelines and springs with easing, looping, and momentum-preserving retargeting. See ADR 0014, ADR 0021, and the spring lab example.
- Terminal screen modes< 66E3 /strong> — Alternate screen, main buffer, inline, and split-footer configurations. See ADR 0023 and the screen modes example.
- Declarative components — Opt-in
cooper/cuilayer with persistent component structs, keyed reconciliation, and lifecycle hooks. (Feels like the good days of Backbone.js or React class components). See the framework guide. - Keymaps — Typed commands, scoped bindings, control remapping, and discoverable shortcut labels. See the keymap guide.
- Clipboard, notifications, progress, program status, title — Runtime-exposed terminal services. See ADR 0006, ADR 0009, ADR 0010, ADR 0012, ADR 0027.
The runnable examples exercise the public application and control APIs.
See examples/README.md for the full gallery,
behavior descriptions, and PTY smoke tests.
- Design decisions — Architecture Decision Records in
docs/adrs/; seedocs/README.mdfor the index - Declarative framework —
docs/declarative.md - Keymaps and commands —
docs/keymaps.md - Examples and behavior —
examples/README.md - Benchmarks and performance —
benchmarks/README.md,docs/performance-optimization.md