2016-11-07 00:07:53 +00:00
# tui-rs
2019-11-05 07:24:14 +00:00
[![Build Status ](https://github.com/fdehau/tui-rs/workflows/CI/badge.svg )](https://github.com/fdehau/tui-rs/actions?query=workflow%3ACI+)
2017-05-21 12:21:29 +00:00
[![Crate Status ](https://img.shields.io/crates/v/tui.svg )](https://crates.io/crates/tui)
[![Docs Status ](https://docs.rs/tui/badge.svg )](https://docs.rs/crate/tui/)
2018-09-09 06:55:51 +00:00
< img src = "./assets/demo.gif" alt = "Demo cast under Linux Termite with Inconsolata font 12pt" >
2016-11-07 00:07:53 +00:00
2023-02-14 09:22:07 +00:00
# What is this fork?
2023-02-13 15:10:08 +00:00
2023-02-14 09:22:07 +00:00
This fork was created to continue maintenance on the original TUI project. The original maintainer had created an [issue ](https://github.com/fdehau/tui-rs/issues/654 ) explaining how he couldn't find time to continue development, which led to us creating this fork. From here, we hope to continue developing the TUI crate.
2023-02-13 15:10:08 +00:00
2023-02-14 09:22:07 +00:00
In order to organize ourselves, we have created a **temporary** [discord server ](https://discord.gg/pMCEU9hNEj ). We have not yet determined with the community what will be our definitive communication medium.
2023-02-13 15:10:08 +00:00
Please make sure you read the updated contributing guidelines, especially if you are interested in working on a PR or issue opened in the previous repository.
# Introduction
2016-11-07 00:07:53 +00:00
`tui-rs` is a [Rust ](https://www.rust-lang.org ) library to build rich terminal
user interfaces and dashboards. It is heavily inspired by the `Javascript`
library [blessed-contrib ](https://github.com/yaronn/blessed-contrib ) and the
`Go` library [termui ](https://github.com/gizak/termui ).
2021-11-11 14:56:37 +00:00
The library supports multiple backends:
2023-02-15 12:55:44 +00:00
- [crossterm ](https://github.com/crossterm-rs/crossterm ) [default]
- [termion ](https://github.com/ticki/termion )
2016-11-07 23:35:46 +00:00
The library is based on the principle of immediate rendering with intermediate
2016-11-08 10:20:59 +00:00
buffers. This means that at each new frame you should build all widgets that are
supposed to be part of the UI. While providing a great flexibility for rich and
interactive UI, this may introduce overhead for highly dynamic content. So, the
implementation try to minimize the number of ansi escapes sequences generated to
draw the updated UI. In practice, given the speed of `Rust` the overhead rather
2016-11-07 23:35:46 +00:00
comes from the terminal emulator than the library itself.
Moreover, the library does not provide any input handling nor any event system and
you may rely on the previously cited libraries to achieve such features.
2016-11-07 00:07:53 +00:00
2023-02-13 15:10:08 +00:00
## Rust version requirements
2020-08-02 14:17:57 +00:00
2023-02-15 12:59:50 +00:00
Since version 0.17.0, `tui` requires **rustc version 1.59.0 or greater** .
2020-08-02 14:17:57 +00:00
2023-02-13 15:10:08 +00:00
# Documentation
The documentation can be found on [docs.rs. ](https://docs.rs/tui )
2016-11-07 23:35:46 +00:00
2023-02-13 15:10:08 +00:00
# Demo
2018-06-09 09:31:02 +00:00
2021-11-11 14:56:37 +00:00
The demo shown in the gif can be run with all available backends.
2019-02-10 21:35:44 +00:00
```
2021-11-11 14:56:37 +00:00
# crossterm
cargo run --example demo --release -- --tick-rate 200
# termion
cargo run --example demo --no-default-features --features=termion --release -- --tick-rate 200
2019-02-10 21:35:44 +00:00
```
2019-12-13 19:19:59 +00:00
where `tick-rate` is the UI refresh rate in ms.
2022-08-14 13:27:06 +00:00
The UI code is in [examples/demo/ui.rs ](https://github.com/fdehau/tui-rs/blob/v0.19.0/examples/demo/ui.rs ) while the
application state is in [examples/demo/app.rs ](https://github.com/fdehau/tui-rs/blob/v0.19.0/examples/demo/app.rs ).
2018-06-09 09:31:02 +00:00
2020-04-13 23:10:01 +00:00
If the user interface contains glyphs that are not displayed correctly by your terminal, you may want to run
the demo without those symbols:
```
2021-11-11 14:56:37 +00:00
cargo run --example demo --release -- --tick-rate 200 --enhanced-graphics false
2020-04-13 23:10:01 +00:00
```
2023-02-13 15:10:08 +00:00
# Widgets
## Built in
2016-11-07 23:35:46 +00:00
The library comes with the following list of widgets:
2023-02-15 12:55:44 +00:00
- [Block ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/block.rs )
- [Gauge ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/gauge.rs )
- [Sparkline ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/sparkline.rs )
- [Chart ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/chart.rs )
- [BarChart ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/barchart.rs )
- [List ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/list.rs )
- [Table ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/table.rs )
- [Paragraph ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/paragraph.rs )
- [Canvas (with line, point cloud, map) ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/canvas.rs )
- [Tabs ](https://github.com/fdehau/tui-rs/blob/v0.16.0/examples/tabs.rs )
Click on each item to see the source of the example. Run the examples with with
2021-11-11 14:56:37 +00:00
cargo (e.g. to run the gauge example `cargo run --example gauge` ), and quit by pressing `q` .
2016-11-07 23:35:46 +00:00
2021-11-11 14:56:37 +00:00
You can run all examples by running `cargo make run-examples` (require
`cargo-make` that can be installed with `cargo install cargo-make` ).
2019-02-10 21:35:44 +00:00
2023-02-15 12:55:44 +00:00
### Third-party libraries, bootstrapping templates and widgets
- [ansi-to-tui ](https://github.com/uttarayan21/ansi-to-tui ) — Convert ansi colored text to `tui::text::Text`
- [color-to-tui ](https://github.com/uttarayan21/color-to-tui ) — Parse hex colors to `tui::style::Color`
- [rust-tui-template ](https://github.com/orhun/rust-tui-template ) — A template for bootstrapping a Rust TUI application with Tui-rs & crossterm
- [simple-tui-rs ](https://github.com/pmsanford/simple-tui-rs ) — A simple example tui-rs app
- [tui-builder ](https://github.com/jkelleyrtp/tui-builder ) — Batteries-included MVC framework for Tui-rs + Crossterm apps
- [tui-clap ](https://github.com/kegesch/tui-clap-rs ) — Use clap-rs together with Tui-rs
- [tui-log ](https://github.com/kegesch/tui-log-rs ) — Example of how to use logging with Tui-rs
- [tui-logger ](https://github.com/gin66/tui-logger ) — Logger and Widget for Tui-rs
- [tui-realm ](https://github.com/veeso/tui-realm ) — Tui-rs framework to build stateful applications with a React/Elm inspired approach
- [tui-realm-treeview ](https://github.com/veeso/tui-realm-treeview ) — Treeview component for Tui-realm
- [tui tree widget ](https://github.com/EdJoPaTo/tui-rs-tree-widget ) — Tree Widget for Tui-rs
- [tui-windows ](https://github.com/markatk/tui-windows-rs ) — Tui-rs abstraction to handle multiple windows and their rendering
2023-02-17 12:01:16 +00:00
- [tui-textarea ](https://github.com/rhysd/tui-textarea ): Simple yet powerful multi-line text editor widget supporting several key shortcuts, undo/redo, text search, etc.
- [tui-rs-tree-widgets ](https://github.com/EdJoPaTo/tui-rs-tree-widget ): Widget for tree data structures.
- [tui-input ](https://github.com/sayanarijit/tui-input ): TUI input library supporting multiple backends and tui-rs.
2016-11-07 23:35:46 +00:00
2023-03-19 00:30:47 +00:00
# Apps
Check out the list of [close to 40 apps ](./APPS.md ) using `ratatui` !
# Alternatives
2016-11-07 00:07:53 +00:00
2018-06-09 09:31:02 +00:00
You might want to checkout [Cursive ](https://github.com/gyscos/Cursive ) for an
alternative solution to build text user interfaces in Rust.
2016-11-07 00:07:53 +00:00
2023-02-13 15:10:08 +00:00
# License
2016-11-07 00:07:53 +00:00
2018-06-09 09:31:02 +00:00
[MIT ](LICENSE )