R3BL TUI library & suite of apps focused on developer productivity
We are working on building command line apps in Rust which have rich text user interfaces (TUI). We want to lean into the terminal as a place of productivity, and build all kinds of awesome apps for it.
🔮 Instead of just building one app, we are building a library to enable any kind of rich TUI development w/ a twist: taking concepts that work really well for the frontend mobile and web development world and re-imagining them for TUI & Rust.
🌎 We are building apps to enhance developer productivity & workflows.
This crate is related to the first thing that's described above. It provides lots of useful functionality to help you build TUI (text user interface) apps, along w/ general niceties & ergonomics that all Rustaceans 🦀 can enjoy 🎉:
All the procedural macros are organized in 3 crates using an internal or core crate: the public crate, an internal or core crate, and the proc macro crate.
Here's an example of the style!
macro:
rust
style! {
id: "my_style", /* Optional. */
attrib: [dim, bold] /* Optional. */
padding: 10, /* Optional. */
color_fg: TuiColor::Blue, /* Optional. */
color_bg: TuiColor::Red, /* Optional. */
}
color_fg
and color_bg
can take any of the following:
This derive macro makes it easy to generate builders when annotating a struct
or enum
. It
generates It has full support for generics. It can be used like this.
```rust
struct Point
let mypt: Point
asserteq!(mypt.x, 1); asserteq!(mypt.y, 2); ```
This function like macro (with custom syntax) makes it easy to manage shareability and interior mutability of a struct. We call this pattern the "manager" of "things").
🪄 You can read all about it here.
RwLock
for thread safety.Arc
so we can share it across threads.where
clause.Here's a very simple usage:
rust
make_struct_safe_to_share_and_mutate! {
named MyMapManager<K, V>
where K: Default + Send + Sync + 'static, V: Default + Send + Sync + 'static
containing my_map
of_type std::collections::HashMap<K, V>
}
Here's an async example.
```rust
async fn testcustomsyntaxnowhereclause() {
makestructsafetoshareandmutate! {
named StringMap
let mymanager: StringMap
This function like macro (with custom syntax) makes it easy to share functions and lambdas that are async. They should be safe to share between threads and they should support either being invoked or spawned.
🪄 You can read all about how to write proc macros here.
Arc<RwLock<>>
for thread
safety and interior mutability.get()
method is generated which makes it possible to share this struct across threads.from()
method is generated which makes it easy to create this struct from a function or
lambda.spawn()
method is generated which makes it possible to spawn the enclosed function or lambda
asynchronously using Tokio.invoke()
method is generated which makes it possible to invoke the enclosed function or
lambda synchronously.Here's an example of how to use this macro.
```rust use r3blrsutils::makesafeasyncfnwrapper;
makesafeasyncfnwrapper! { named SafeMiddlewareFnWrapper containing fnmut oftype FnMut(A) -> Option } ```
Here's another example.
```rust use r3blrsutils::makesafeasyncfnwrapper;
makesafeasyncfnwrapper! {
named SafeSubscriberFnWrapper
containing fnmut
oftype FnMut(S) -> ()
}
```
This crate is a dependency of r3bl_rs_utils
crate (the
"main" library).
Please report any issues to the issue tracker. And if you have any feature requests, feel free to add them there too 👍.