Crate cursive [−] [src]
Cursive
Cursive is a TUI library built on top of ncurses-rs. It allows to easily build layouts for text-based applications.
Getting started
- Every application should start with a
Cursiveobject. It is the main entry-point to the library. - A declarative phase then describes the structure of the UI by adding views and configuring their behaviours.
- Finally, the event loop is started by calling
Cursive::run(&mut self).
Views
Views are the main components of a cursive interface.
The view module contains many views to use in your
application; if you don't find what you need, you may also implement the
View trait and build your own.
Callbacks
Cursive is a reactive UI: it reacts to events generated by user input.
During the declarative phase, callbacks are set to trigger on specific
events. These functions usually take a &mut Cursive argument, allowing
them to modify the view tree at will.
Examples
extern crate cursive; use cursive::prelude::*; fn main() { let mut siv = Cursive::new(); siv.add_layer(TextView::new("Hello World!\nPress q to quit.")); siv.add_global_callback('q', |s| s.quit()); siv.run(); }
Modules
| align |
Tools to control view alignment |
| direction |
Direction-related structures. |
| event |
User-input events and their effects. |
| menu |
Build menu trees. |
| prelude |
Commonly used imports, conveniently grouped. |
| theme |
Handle colors and themes in the UI. |
| utils |
Toolbox to make text layout easier. |
| vec |
Points on the 2D character grid. |
| view |
Base elements required to build views. |
| views |
Various views to use when creating the layout. |
Macros
| wrap_impl! |
Convenient macro to implement the ViewWrapper trait. |
Structs
| Cursive |
Central part of the cursive library. |
| Printer |
Convenient interface to draw on a subset of the screen. |
| XY |
A generic structure with a value for each axis. |
Traits
| With |
Generic trait to enable chainable API |
Type Definitions
| ScreenId |
Identifies a screen in the cursive ROOT. |