2015-05-15 19:16:58 +00:00
|
|
|
//! # Cursive
|
|
|
|
//!
|
2018-01-25 02:19:19 +00:00
|
|
|
//! [Cursive] is a [TUI] library - it lets you easily build rich interfaces
|
|
|
|
//! for use in a terminal.
|
|
|
|
//!
|
|
|
|
//! [Cursive]: https://github.com/gyscos/Cursive
|
|
|
|
//! [TUI]: https://en.wikipedia.org/wiki/Text-based_user_interface
|
2015-05-15 19:16:58 +00:00
|
|
|
//!
|
2016-07-14 06:18:59 +00:00
|
|
|
//! ## Getting started
|
|
|
|
//!
|
|
|
|
//! * Every application should start with a [`Cursive`](struct.Cursive.html)
|
|
|
|
//! 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(&mut self)`](struct.Cursive.html#method.run).
|
|
|
|
//!
|
2016-07-15 06:25:32 +00:00
|
|
|
//! ## Views
|
|
|
|
//!
|
|
|
|
//! Views are the main components of a cursive interface.
|
2016-12-12 18:19:41 +00:00
|
|
|
//! The [`views`](./views/index.html) module contains many views to use in your
|
2016-07-15 06:25:32 +00:00
|
|
|
//! application; if you don't find what you need, you may also implement the
|
|
|
|
//! [`View`](view/trait.View.html) trait and build your own.
|
|
|
|
//!
|
|
|
|
//! ## Callbacks
|
|
|
|
//!
|
2018-10-23 02:30:05 +00:00
|
|
|
//! Cursive is callback-driven: it reacts to events generated by user input.
|
2016-07-15 06:25:32 +00:00
|
|
|
//!
|
|
|
|
//! 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
|
|
|
|
//!
|
2018-04-01 23:39:03 +00:00
|
|
|
//! ```rust
|
2015-05-15 19:16:58 +00:00
|
|
|
//! extern crate cursive;
|
|
|
|
//!
|
2016-12-12 18:19:41 +00:00
|
|
|
//! use cursive::Cursive;
|
|
|
|
//! use cursive::views::TextView;
|
2015-05-15 19:16:58 +00:00
|
|
|
//!
|
|
|
|
//! fn main() {
|
2018-04-01 23:39:03 +00:00
|
|
|
//! let mut siv = Cursive::dummy();
|
2015-05-15 19:16:58 +00:00
|
|
|
//!
|
2016-12-12 18:19:41 +00:00
|
|
|
//! siv.add_layer(TextView::new("Hello World!\nPress q to quit."));
|
2015-05-15 19:16:58 +00:00
|
|
|
//!
|
2015-06-04 18:40:35 +00:00
|
|
|
//! siv.add_global_callback('q', |s| s.quit());
|
2015-05-15 19:16:58 +00:00
|
|
|
//!
|
|
|
|
//! siv.run();
|
|
|
|
//! }
|
|
|
|
//! ```
|
2016-09-25 00:19:09 +00:00
|
|
|
//!
|
|
|
|
//! ## Debugging
|
|
|
|
//!
|
|
|
|
//! The `Cursive` root initializes the terminal on creation, and do 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.
|
2016-12-12 18:19:41 +00:00
|
|
|
//!
|
|
|
|
//! Or you can use gdb as usual.
|
2016-07-12 03:26:33 +00:00
|
|
|
#![deny(missing_docs)]
|
2016-07-11 00:41:49 +00:00
|
|
|
|
2018-01-22 19:55:56 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate enum_map;
|
2018-01-08 14:44:27 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate enumset;
|
2017-08-23 14:49:09 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2018-05-20 16:59:35 +00:00
|
|
|
#[macro_use]
|
2018-07-08 19:48:37 +00:00
|
|
|
extern crate crossbeam_channel;
|
2019-02-22 20:38:16 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
2018-02-20 22:50:13 +00:00
|
|
|
|
2018-02-20 23:44:07 +00:00
|
|
|
#[cfg(any(feature = "ncurses", feature = "pancurses"))]
|
2017-12-30 22:03:42 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate maplit;
|
2018-01-17 17:35:57 +00:00
|
|
|
|
2018-06-18 23:50:09 +00:00
|
|
|
// We use chan_signal to detect SIGWINCH.
|
|
|
|
// It's not how windows work, so no need to use that.
|
|
|
|
#[cfg(unix)]
|
2018-07-08 19:48:37 +00:00
|
|
|
extern crate signal_hook;
|
2018-06-18 23:50:09 +00:00
|
|
|
|
2019-02-22 21:55:07 +00:00
|
|
|
extern crate chrono;
|
2018-04-06 00:36:58 +00:00
|
|
|
extern crate libc;
|
2018-06-11 06:29:10 +00:00
|
|
|
extern crate num;
|
2017-08-23 14:49:09 +00:00
|
|
|
extern crate owning_ref;
|
2015-05-22 06:29:49 +00:00
|
|
|
extern crate toml;
|
2016-06-26 22:03:12 +00:00
|
|
|
extern crate unicode_segmentation;
|
2016-07-02 08:01:09 +00:00
|
|
|
extern crate unicode_width;
|
2018-01-08 14:44:27 +00:00
|
|
|
extern crate xi_unicode;
|
2015-05-09 19:18:25 +00:00
|
|
|
|
2016-07-17 00:28:42 +00:00
|
|
|
macro_rules! new_default(
|
2016-09-25 00:06:33 +00:00
|
|
|
($c:ty) => {
|
2016-07-17 00:28:42 +00:00
|
|
|
impl Default for $c {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-26 06:54:33 +00:00
|
|
|
);
|
2016-07-17 00:28:42 +00:00
|
|
|
|
2016-09-29 05:45:27 +00:00
|
|
|
pub mod traits;
|
2016-07-10 01:23:58 +00:00
|
|
|
|
2015-05-15 00:41:17 +00:00
|
|
|
pub mod event;
|
2016-07-28 23:36:01 +00:00
|
|
|
#[macro_use]
|
2015-05-09 19:18:25 +00:00
|
|
|
pub mod view;
|
2016-07-28 23:36:01 +00:00
|
|
|
|
2018-09-24 20:43:19 +00:00
|
|
|
#[macro_use]
|
|
|
|
pub mod utils;
|
|
|
|
|
2015-06-02 00:48:29 +00:00
|
|
|
pub mod align;
|
2016-07-15 03:27:15 +00:00
|
|
|
pub mod direction;
|
2019-02-22 20:38:16 +00:00
|
|
|
pub mod logger;
|
2018-06-11 06:29:10 +00:00
|
|
|
pub mod menu;
|
|
|
|
pub mod rect;
|
|
|
|
pub mod theme;
|
|
|
|
pub mod vec;
|
|
|
|
pub mod views;
|
2016-06-28 04:59:42 +00:00
|
|
|
|
|
|
|
// This probably doesn't need to be public?
|
2017-10-12 23:33:24 +00:00
|
|
|
mod cursive;
|
2016-07-14 06:18:59 +00:00
|
|
|
mod printer;
|
2016-07-16 20:25:21 +00:00
|
|
|
mod with;
|
2018-06-11 06:29:10 +00:00
|
|
|
mod xy;
|
2015-05-09 19:18:25 +00:00
|
|
|
|
2015-05-15 00:41:17 +00:00
|
|
|
mod div;
|
2015-05-28 05:13:51 +00:00
|
|
|
mod utf8;
|
2015-05-09 19:18:25 +00:00
|
|
|
|
2016-10-10 20:02:07 +00:00
|
|
|
pub mod backend;
|
2016-06-30 00:36:20 +00:00
|
|
|
|
2019-02-28 01:07:55 +00:00
|
|
|
pub use cursive::{CbFunc, CbSink, Cursive, ScreenId};
|
2016-10-02 22:22:29 +00:00
|
|
|
pub use printer::Printer;
|
2018-06-20 18:44:09 +00:00
|
|
|
pub use vec::Vec2;
|
2016-10-02 22:22:29 +00:00
|
|
|
pub use with::With;
|
|
|
|
pub use xy::XY;
|