06d64be0a0
* Allow taking the content of a dialog without destroying it by replacing it with another view. * Add getters for all three ways of mutating padding (`Margins` struct, LRTB tuple, and individual fields) * Allow setting focus * Add a getter for the title of the dialog * Add getter for title position * Add immutable button iterator for `Dialog` * Rename `buttons_mut` to fit with `iter_buttons_mut`. * Add getter for horizontal alignment property * Remove `replace_content` and replace it with just having `set_content` return the previous view. * Actually clamp dialog focus rather than forcibly unclamping it * Use the existing convention for button iterators rather than the `iter`/`iter_mut` convention * Remove extraneous padding getters * Remove import of `std::mem::replace` |
||
---|---|---|
.github/workflows | ||
cursive | ||
cursive-core | ||
doc | ||
examples | ||
.gitignore | ||
.travis.yml | ||
appveyor.yml | ||
Cargo.toml | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
ISSUE_TEMPLATE.md | ||
LICENSE | ||
Readme.md | ||
rustfmt.toml | ||
shell.nix |
Cursive
Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available.
It allows you to build rich user interfaces for terminal applications.
Documentation
It is designed to be safe and easy to use:
[dependencies]
cursive = "0.16"
Or to use the latest git version:
[dependencies]
cursive = { git = "https://github.com/gyscos/cursive" }
(You will also need ncurses installed.)
use cursive::views::{Dialog, TextView};
fn main() {
// Creates the cursive root - required for every application.
let mut siv = cursive::default();
// Creates a dialog with a single "Quit" button
siv.add_layer(Dialog::around(TextView::new("Hello Dialog!"))
.title("Cursive")
.button("Quit", |s| s.quit()));
// Starts the event loop.
siv.run();
}
Check out the other examples to get these results, and more:
(Colors may depend on your terminal configuration.)
Tutorials
These tutorials may help you get started with cursive:
Third-party views
Here are a few crates implementing new views for you to use:
- cursive-aligned-view: A view wrapper for gyscos/cursive views which aligns child views.
- cursive-async-view: A loading-screen wrapper.
- cursive-flexi-logger-view: An alternative debug view using
emabee/flexi_logger
. - cursive-markup: A view that renders HTML or other markup.
- cursive-multiplex: A tmux like multiplexer.
- cursive-tabs: Tabs.
- cursive_calendar_view: A basic calendar view implementation.
- cursive_hexview: A simple hexview.
- cursive_table_view: A basic table view component.
- cursive_tree_view: A tree view implementation.
Showcases
Here are some cool applications using cursive:
- ncspot: Cross-platform ncurses Spotify client.
- so: A terminal interface for Stack Overflow.
- RustyChat: Chat client made using Rust and Cursive.
- fui: Add CLI & form interface to your program.
- grin-tui: Minimal implementation of the MimbleWimble protocol.
- ripasso: A simple password manager written in Rust.
- clock-cli: A clock with stopwatch and countdown timer functionalities
- sudoku-tui: Play sudoku on the command line.
- rusty-man: Browse rustdoc documentation
- mythra: CLI to search for music
Goals
- Ease of use. Simple apps should be simple. Complex apps should be manageable.
- Linux TTY Compatibility. Colors may suffer, and UTF-8 may be too much, but most features must work properly on a Linux TTY.
- Flexibility. This library should be able to handle simple UI scripts, complex real-time applications, or even games.
- In particular, it tries to have enough features to recreate these kind of tools:
Compatibility
First off, terminals are messy. A small set of features is standard, but beyond that, almost every terminal has its own implementation.
Output
- Colors: the basic 8-colors palette should be broadly supported. User-defined colors is not supported in the raw linux TTY, but should work in most terminals, although it's still kinda experimental.
- UTF-8: Currently Cursive really expects a UTF-8 locale. It may eventually get patched to support window borders on other locales, but it's not a priority. There is initial support for wide characters. RTL support is planned, but still very early.
Input
- The
key_codes
example can be a useful tool to see how the library reacts to various key presses. - Keep in mind that if the terminal has shortcuts registered, they probably won't be transmitted to the app.
- UTF-8 input should work fine in a unicode-enabled terminal emulator, but raw linux TTY may be more capricious.
Contributing
Alternatives
See also tui-rs - and a small comparison page.