Skip to main content

Crate tuirealm

Crate tuirealm 

Source
Expand description

tui-realm is a framework for ratatui to simplify the implementation of terminal user interfaces adding the possibility to work with re-usable components with properties and states, as you’d do in React. But that’s not all: the components communicate with the ui engine via a system based on Messages and Events, providing you with the possibility to implement update routines as happens in Elm.

In addition, the components are organized inside the View, which manages mounting/umounting, focus and event forwarding for you.

tui-realm also comes with a standard library of components, that you may find very useful. The stdlib can be found in tui-realm-stdlib

§Get started 🏁

Β§Add tui-realm to your Cargo.toml πŸ¦€

If you want the default features:

tuirealm = "4"

Alternatively you can specify the features you want to add:

tuirealm = { version = "4", default-features = false, features = [ "derive", "serialize", "crossterm" ] }

Supported features are:

  • derive (default): add the #[derive(Component)] proc macro to automatically implement Component for AppComponent. Read more.
  • async-ports: add support for async ports
  • serialize: add the serialize/deserialize trait implementation for KeyEvent and Key.
  • crossterm (default): enable the crossterm terminal backend
  • termion: enable the termion terminal backend
  • termwiz: enable the termwiz terminal backend

Β§Create a tui-realm application πŸͺ‚

You can read the Get Started guide guide on github.

Β§Run examples πŸ”

Still confused about how tui-realm works? Don’t worry, try with the examples:

  • demo: a simple example that shows basic tui-realm usage
  • user-events: showcase using custom events
  • inline-display: showcase how tui-realm can be used without requiring a alternate screen
  • async-ports: showcase usage of async ports
  • arbitrary-data: showcase usage of PropPayload::Any to send custom data across query and attr

ModulesΒ§

application
This module exposes the Application, the core of tui-realm and its directly related types.
command
This module exposes the Cmd type, which must be used when sending commands to the Component from the AppComponent after an Event.
component
This module exposes the component traits
event
events contains all the types related to Event.
injector
properties injector
listener
This module exposes everything required to run the event listener which handles Input and custom events in a tui-realm application.
props
The props module exposes the Properties supported by the components and all the values they can get.
ratatui
ratatui just exposes ratatui itself, so that users of tui-realm dont have to install ratatui on their own and potentially have confliciting versions.
state
This module exposes the state type and values
subscription
This module defines the model for the Subscriptions
terminal
All render and input backends
testing
Utilities for snapshot and rendering tests.
utils
This module exposes utilities
view
This module exposes the View structure, which is the wrapper for all the components in an application.

MacrosΒ§

subclause_and
A macro to generate a chain of crate::subscription::SubClause::AndMany from a list of Ids with the case crate::subscription::SubClause::IsMounted for every id.
subclause_and_not
A macro to generate a chain of crate::subscription::SubClause::And from a list of Ids with the case crate::subscription::SubClause::Not containing crate::subscription::SubClause::IsMounted for every id.
subclause_or
A macro to generate a chain of crate::subscription::SubClause::OrMany from a list of Ids with the case crate::subscription::SubClause::IsMounted for every id.

Attribute MacrosΒ§

async_traitasync-ports