radicle-cli
radicle-cli copied to clipboard
terminal-tui: library w/ tui-realm
Description
This PR introduces a thin layer on top of tui-realm and provides some common components that can be re-used across multiple TUI applications in the Radicle project.
It's meant to be an alternative implementation of https://github.com/radicle-dev/radicle-cli/pull/151, providing the same functionality, but being based on an exising library instead of an own solution / library.
Motivation
After building a few smaller prototypes (e.g. https://github.com/radicle-dev/radicle-cli/pull/147) based on https://github.com/radicle-dev/radicle-cli/pull/151, it turned out to have some shortcomings:
- input handling is global which leads to large(r) state machines updating application state
- components / widgets hard to re-use / compose because of application state's global nature and little separation of concerns:
- property-store can be accessed from everywhere, making it hard to enforce a certain design of components (API only defined by string-based properties instead of e.g. traits)
- do not separate properties used while drawing / and properties reflecting application state
- no focus system, global state needs to be queried in order to select target component of user input
Some research on how to solve these shortcomings led to the discovery of tui-realm
. Since tui-realm
makes use of some concepts that were also considered (or even partially used) while developing the initial TUI library (input subscriptions), it seemed to make sense to use tui-realm
instead in order to save the effort of implementing and maintaining our own library.
tui-realm
The library follows an Elm / React inspired design approach that solves the shortcomings mentioned above:
- input-handling is local to components and can be composed using the built-in messaging system
- separation of concerns in components: properties for drawing, states (w/ update traits) for input handling
- focus system for components (w/ subscriptions)
- standard library that implements tui-realm components for almost every tui-rs component
- interesting components such as radio buttons / checkboxes
- very good documentation
What should be added next?
- Themes
- Support for user-defined key-bindings
Nice, makes sense!