tui-rs README

The project's README from github.com/fdehau/tui-rs. As one markdown file: README.md.

tui-rs

⚠️ August 2023: This crate is no longer maintained. See https://github.com/ratatui-org/ratatui for an actively maintained fork. ⚠️

Build Status Crate Status Docs Status

Demo cast under Linux Termite with Inconsolata font 12pt

tui-rs is a Rust library to build rich terminal user interfaces and dashboards. It is heavily inspired by the Javascript library blessed-contrib and the Go library termui.

The library supports multiple backends:

The library is based on the principle of immediate rendering with intermediate 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 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.

I'm actively looking for help maintaining this crate. See this issue

Rust version requirements

Since version 0.17.0, tui requires rustc version 1.56.1 or greater.

Documentation

Demo

The demo shown in the gif can be run with all available backends.

# crossterm
cargo run --example demo --release -- --tick-rate 200
# termion
cargo run --example demo --no-default-features --features=termion --release -- --tick-rate 200

where tick-rate is the UI refresh rate in ms.

The UI code is in examples/demo/ui.rs while the application state is in examples/demo/app.rs.

If the user interface contains glyphs that are not displayed correctly by your terminal, you may want to run the demo without those symbols:

cargo run --example demo --release -- --tick-rate 200 --enhanced-graphics false

Widgets

The library comes with the following list of widgets:

Click on each item to see the source of the example. Run the examples with with cargo (e.g. to run the gauge example cargo run --example gauge), and quit by pressing q.

You can run all examples by running cargo make run-examples (require cargo-make that can be installed with cargo install cargo-make).

Third-party widgets

Apps using tui

Alternatives

You might want to checkout Cursive for an alternative solution to build text user interfaces in Rust.

License

MIT

tui-rs (fdehau/tui-rs)

Searching Database…

10.9K ·GitHub
archived
这是什么?tui-rs 是一个 Rust 库,用于构建丰富的终端用户界面和仪表盘,灵感来自 JavaScript 库 blessed-contrib 和 Go 库 termui。
这是一个我能直接运行的应用,还是用来开发的库?是库,不是应用:你把它加入 Rust 项目,然后自己编写界面——每一帧都要重新构建所有需要显示在屏幕上的小组件,tui-rs 负责把它们绘制到终端里。
我怎么试用它?用 cargo 运行自带的示例,例如 'cargo run --example gauge'(按 q 退出)。要运行全部示例,先用 'cargo install cargo-make' 安装 cargo-make,然后执行 'cargo make run-examples'。
我需要特定的 Rust 版本吗?只需要一个较新的 Rust 工具链:从 0.17.0 版本起,这个 crate 要求 rustc 1.56.1 或更高版本。
这个项目还在维护吗?不在了——这个 crate 自 2023 年 8 月起已停止维护。README 指向了一个仍在积极维护的分支,并推荐 Cursive 作为在 Rust 中构建 TUI 的替代方案。
不管我用什么操作系统,它在我的终端里都能用吗?它通过可插拔的后端来渲染——默认是 crossterm,也可以换用 termion——所以它面向的是终端本身,而不针对特定操作系统。
内置了哪些小组件?有 Block、Gauge、Sparkline、Chart、BarChart、List、Table、Paragraph、Tabs,还有一个能绘制线条、点云和地图的 Canvas——每个都在仓库里有可运行的示例。
它怎么处理键盘输入?它不处理:tui-rs 不带任何输入处理和事件系统。你需要通过渲染所用的同一个后端自己实现,通常是 crossterm 或 termion。
它的渲染在底层是怎么工作的?采用即时渲染加中间缓冲区:每一帧都重新构建组成界面的所有小组件。这个 crate 尽量减少 ANSI 转义序列来降低重绘开销,实际剩下的开销更多来自终端模拟器而不是库本身。
有哪些实际应用在用它?一大串终端工具都在用,包括 spotify-tui、bandwhich、bottom、zenith、gping、gitui、diskonaut、tickrs、termchat、xplr 和 tokio-console。
What are similar projects?ratatui, FTXUI, hqtui, blessed-contrib, lipgloss, gocui, blessed, tokscale
Creator
fdehau
Size
3.8 MB
Stars
10.9K
Age
9y
Commits · 90 Days