Cursive
Cursive is a TUI library - it lets you easily build rich interfaces for use in a terminal.
Getting started
- Every application should start with a [
Cursive
] object. 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
].
Examples
use ;
use TextView;
let mut siv = new;
siv.add_layer;
siv.add_global_callback;
siv.run;
Views
Views are the main components of a cursive interface.
The [views
] 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 callback-driven: it reacts to events generated by user input.
During the declarative phase, callbacks are set to trigger on specific
events. These functions usually take an &mut Cursive
argument, allowing
them to modify the view tree at will.
Debugging
The Cursive
root initializes the terminal on creation, and does cleanups
on drop. While it is alive, printing to the terminal will not work
as expected, making debugging a bit harder.
One solution is to redirect stderr to a file when running the application, and log to it instead of stdout.
Or you can use gdb as usual.
Themes
Cursive supports configuring the feels and looks of your application with
custom themes and colors. For details see documentation of the
cursive::theme
module.