# tui-realm
<p align="center">
<img src="docs/images/tui-realm.svg" width="256" height="256" />
</p>
<p align="center">~ A tui-rs framework inspired by Elm and React ~</p>
<p align="center">
<a href="/docs/get-started.md" target="_blank">Get started</a>
ยท
<a href="https://github.com/veeso/tui-realm-stdlib" target="_blank">Standard Library</a>
ยท
<a href="https://docs.rs/tuirealm" target="_blank">Documentation</a>
</p>
<p align="center">Developed by <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
<p align="center">Current version: 1.2.0 (25/11/2021)</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT"
><img
src="https://img.shields.io/badge/License-MIT-teal.svg"
alt="License-MIT"
/></a>
<a href="https://github.com/veeso/tui-realm/stargazers"
><img
src="https://img.shields.io/github/stars/veeso/tui-realm.svg"
alt="Repo stars"
/></a>
<a href="https://crates.io/crates/tuirealm"
><img
src="https://img.shields.io/crates/d/tuirealm.svg"
alt="Downloads counter"
/></a>
<a href="https://crates.io/crates/tuirealm"
><img
src="https://img.shields.io/crates/v/tuirealm.svg"
alt="Latest version"
/></a>
<a href="https://www.buymeacoffee.com/veeso">
<img
src="https://img.shields.io/badge/Donate-BuyMeACoffee-yellow.svg"
alt="Buy me a coffee"
/></a>
</p>
<p align="center">
<a href="https://github.com/veeso/tui-realm/actions"
><img
src="https://github.com/veeso/tui-realm/workflows/Crossterm/badge.svg"
alt="Crossterm CI"
/></a>
<a href="https://github.com/veeso/tui-realm/actions"
><img
src="https://github.com/veeso/tui-realm/workflows/Crossterm%20%28Windows%29/badge.svg"
alt="Crossterm CI (Windows)"
/></a>
<a href="https://github.com/veeso/tui-realm/actions"
><img
src="https://github.com/veeso/tui-realm/workflows/Termion/badge.svg"
alt="Termion CI"
/></a>
<a href="https://coveralls.io/github/veeso/tui-realm"
><img
src="https://coveralls.io/repos/github/veeso/tui-realm/badge.svg"
alt="Coveralls"
/></a>
<a href="https://docs.rs/tuirealm"
><img
src="https://docs.rs/tuirealm/badge.svg"
alt="Docs"
/></a>
</p>
---
- [tui-realm](#tui-realm)
- [About tui-realm ๐](#about-tui-realm-)
- [Features ๐](#features-)
- [Get started ๐](#get-started-)
- [Add tui-realm to your Cargo.toml ๐ฆ](#add-tui-realm-to-your-cargotoml-)
- [Create a tui-realm application ๐ช](#create-a-tui-realm-application-)
- [Run examples ๐](#run-examples-)
- [Standard components library ๐จ](#standard-components-library-)
- [Community components ๐๏ธ](#community-components-๏ธ)
- [Guides ๐](#guides-)
- [Documentation ๐](#documentation-)
- [Apps using tui-realm ๐](#apps-using-tui-realm-)
- [Legacy API ๐](#legacy-api-)
- [Support the developer โ](#support-the-developer-)
- [Contributing and issues ๐ค๐ป](#contributing-and-issues-)
- [Changelog โณ](#changelog-)
- [License ๐](#license-)
---
## About tui-realm ๐
tui-realm is a **framework** for [tui](https://github.com/fdehau/tui-rs) 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.
And that's also explains the reason of the name: Realm stands for React and Elm.
tui-realm also comes with a standard library of components, which can be added to your dependencies, that you may find very useful. Don't worry, they are optional if you don't want to use them ๐, just follow the guide in [get started](#get-started-).

See tui-realm in action in the [Example](#run-examples) or if you want to read more about tui-realm start reading the official guide [HERE](docs/en/get-started.md).
## Features ๐
- โจ๏ธ **Event-driven**
- โ๏ธ Based on **React** and **Elm**
- ๐ฒ **Boilerplate** code
- ๐ Quick-setup
- ๐ฏ Single **focus** and **states** management
- ๐ Easy to learn
- ๐ค Adaptable to any use case
---
## Get started ๐
> โ ๏ธ Warning: currently tui-realm supports these backends: crossterm, termion
### Add tui-realm to your Cargo.toml ๐ฆ
If you want the default features, just add tuirealm 1.x version:
```toml
tuirealm = "^1.2.0"
```
otherwise you can specify the features you want to add:
```toml
tuirealm = { version = "^1.2.0", default-features = false, features = [ "derive", "with-termion" ] }
```
Supported features are:
- `derive` (*default*): add the `#[derive(MockComponent)]` proc macro to automatically implement `MockComponent` for `Component`. [Read more](https://github.com/veeso/tuirealm_derive).
- `with-crossterm` (*default*): use [crossterm](https://github.com/crossterm-rs/crossterm) as backend for tui.
- `with-termion`: use [termion](https://github.com/redox-os/termion) as backend for tui.
> โ ๏ธ You can enable only one backend at the time and at least one must be enabled in order to build.
> โ You don't need tui as a dependency, since you can access to tui types via `use tuirealm::tui::`
### Create a tui-realm application ๐ช
View how to implement a tui-realm application in the [related guide](/docs/en/get-started.md).
### Run examples ๐
Still confused about how tui-realm works? Don't worry, try with the examples:
- [demo](/examples/demo.rs): a simple application which shows how tui-realm works
```sh
cargo run --example demo
```
---
## Standard components library ๐จ
Tui-realm comes with an optional standard library of components I thought would have been useful for most of the applications.
If you want to use it, just add the [tui-realm-stdlib](https://github.com/veeso/tui-realm-stdlib) to your `Cargo.toml` dependencies.
## Community components ๐๏ธ
These components are not included in tui-realm, but have been developed by other users. I like advertising other's contents, so here you can find a list of components you may find useful for your next tui-realm project ๐.
- [tui-realm-treeview](https://github.com/veeso/tui-realm-treeview) A treeview component developed by [@veeso](https://github.com/veeso)
Want to add yours? Open an issue using the `New app/component` template ๐
---
## Guides ๐
- [Get Started Guide](/docs/en/get-started.md)
- [Advanced concepts](/docs/en/advanced.md)
- [Migrating from tui-realm 0.x to 1.x](/docs/en/migrating-legacy.md)
---
## Documentation ๐
The developer documentation can be found on Rust Docs at <https://docs.rs/tuirealm>
---
## Apps using tui-realm ๐
- [termusic](https://github.com/tramhao/termusic)
- [termscp](https://github.com/veeso/termscp)
- [tuifeed](https://github.com/veeso/tuifeed)
Want to add yours? Open an issue using the `New app/component` template ๐
## Legacy API ๐
Looking for the old ugly tui-realm API? You can find it [here](https://github.com/veeso/tui-realm/tree/legacy)
---
## Support the developer โ
If you like tui-realm and you're grateful for the work I've done, please consider a little donation ๐ฅณ
You can make a donation with one of these platforms:
[](https://www.buymeacoffee.com/veeso)
[](https://www.paypal.me/chrisintin)
---
## Contributing and issues ๐ค๐ป
Contributions, bug reports, new features and questions are welcome! ๐
If you have any question or concern, or you want to suggest a new feature, or you want just want to improve tui-realm, feel free to open an issue or a PR.
Please follow [our contributing guidelines](CONTRIBUTING.md)
---
## Changelog โณ
View tui-realm's changelog [HERE](CHANGELOG.md)
---
## License ๐
tui-realm is licensed under the MIT license.
You can read the entire license [HERE](LICENSE)