Cursive

crates.io Build Status MIT licensed

Cursive is a TUI (Text User Interface) library for rust. It is currently based on jeaye's ncurses-rs.

It allows you to build rich user interfaces for terminal applications.

Documentation

It is designed to be safe and easy to use:

toml [dependencies] cursive = "0.3"

Or to use the latest git version:

toml [dependencies] cursive = { git = "https://github.com/gyscos/Cursive" }

(You will also need ncurses installed - if it isn't already, check in your package manager. Make sure you install the ncursesw version if available, for UTF-8 support.)

```rust,no_run extern crate cursive;

use cursive::Cursive; use cursive::views::{Dialog, TextView};

fn main() { // Creates the cursive root - required for every application. let mut siv = Cursive::new();

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

<code>edit</code> example <code>lorem</code> example <code>menubar</code> example <code>select</code> example <code>list_view</code> example <code>theme</code> example

(Colors may depend on your terminal configuration.)

Tutorials

These tutorials may help you get started with cursive:

Goals

Non-goals

Compatibility

First off, terminals are messy. A small set of features is standard, but beyond that, almost every terminal has its own implementation.

Output

Input

Here is the support table for input keys. Tested terminals are mostly Gnome terminal and Linux TTY, xterm, and a few others now and then.

| | Key | Shift+Key | Ctrl+Key | Shift+Ctrl+Key | |--------------------------|:----:|:----------------------:|:--------------------------:|:---------------:| | Letters | All | All | All (except c,z,q,s,i,h,m) | None | | Numbers | All | All | None (can crash the app) | None | | Punctuation | All | All | None (can crash the app) | None | | Enter, Esc | All | None | None | None | | Left, Right arrow keys | All | VTE+Xterm | VTE+Xterm | VTE+Xterm | | Up, Down arrow keys | All | Xterm | VTE+Xterm | Xterm | | Ins | All | None (paste clipboard) | Xterm | None | | Del | All | VTE+Xterm | VTE+Xterm | VTE+Xterm | | Home, End | All | Xterm | Xterm | Xterm | | PageUp, PageDown | All | All | All | None | | Fn keys: F1-F4 | All | All except Konsole | Gnome+XTerm | Gnome+Xterm | | Fn keys: F5-F8 | All | All | All except TTY | All except TTY | | Fn keys: F9-F12 | All | All except TTY | All except TTY | All except TTY | | PrtScn, ScrollLock | None | None | None | None | | Window, Menu | None | None | None | None | | Ctrl, Shift, Alt (by themselves) | None | None | None | None |

Contribute & Feedback

You want to help? Thank you so much! Here are some ideas of things you could do: