[Fork] A Text User Interface library for the Rust programming language
Go to file
2020-12-18 14:08:09 -08:00
.github/workflows Update CI config 2020-05-26 13:22:56 -07:00
cursive Fix clippy lints 2020-10-09 15:59:41 -07:00
cursive-core Add Margins::zeroes 2020-12-18 14:08:09 -08:00
doc Really minor fix (#520) 2020-10-28 19:56:43 -07:00
examples Re-organize imports 2020-12-05 23:45:29 -08:00
.gitignore Add newline at end of gitignore file 2019-04-17 12:09:37 -07:00
.travis.yml Split non-backend code into cursive-core 2020-04-23 13:46:00 -07:00
appveyor.yml Fix size confusion in LinearLayout::Child 2020-06-08 19:57:55 -07:00
Cargo.toml Move examples to its own member 2020-04-23 17:17:30 -07:00
CHANGELOG.md Rename SpannedString::shrink_to_fit -> trim 2020-10-15 17:38:13 -07:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2018-01-08 13:01:21 +01:00
CONTRIBUTING.md Update CONTRIBUTING.md 2017-06-14 23:55:11 -07:00
ISSUE_TEMPLATE.md Create ISSUE_TEMPLATE.md 2018-01-08 13:09:18 +01:00
LICENSE Add license 2015-05-22 00:25:59 -07:00
Readme.md Added mythra Project to showcases (#527) 2020-12-09 10:35:04 -08:00
rustfmt.toml Update rustfmt config 2020-12-18 14:07:47 -08:00
shell.nix add shell.nix file for Nix users 2017-01-31 19:38:38 +01:00

Cursive

crates.io Build Status (travis) Build status (appveyor) MIT licensed Gitter chat

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.15"

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();
}

Cursive dialog example

Check out the other examples to get these results, and more:

edit.rs example lorem.rs example menubar.rs example select.rs example mines example theme.rs example

(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:

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.