cursive/src/lib.rs

119 lines
2.8 KiB
Rust
Raw Normal View History

2015-05-15 19:16:58 +00:00
//! # Cursive
//!
//! [Cursive](https://github.com/gyscos/Cursive) is a TUI library built on top
//! of ncurses-rs.
2015-05-15 19:16:58 +00:00
//! It allows to easily build layouts for text-based applications.
//!
//! ## 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
//!
//! 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
//!
2015-06-04 18:40:35 +00:00
//! ```no_run
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() {
//! let mut siv = Cursive::new();
//!
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.
#![deny(missing_docs)]
#[macro_use]
extern crate enumset;
#[macro_use]
extern crate log;
2017-12-30 22:03:42 +00:00
#[macro_use]
extern crate maplit;
extern crate num;
extern crate owning_ref;
2015-05-22 06:29:49 +00:00
extern crate toml;
extern crate unicode_segmentation;
2016-07-02 08:01:09 +00:00
extern crate unicode_width;
extern crate xi_unicode;
2015-05-09 19:18:25 +00:00
#[cfg(feature = "termion")]
#[macro_use]
extern crate chan;
2016-07-17 00:28:42 +00:00
macro_rules! new_default(
($c:ty) => {
2016-07-17 00:28:42 +00:00
impl Default for $c {
fn default() -> Self {
Self::new()
}
}
}
);
2016-07-17 00:28:42 +00:00
pub mod traits;
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
pub mod views;
pub mod vec;
pub mod theme;
pub mod align;
pub mod menu;
pub mod direction;
2016-07-29 06:05:08 +00:00
pub mod utils;
// This probably doesn't need to be public?
2017-10-12 23:33:24 +00:00
mod cursive;
mod printer;
2016-07-13 04:01:11 +00:00
mod xy;
mod with;
2015-05-09 19:18:25 +00:00
mod div;
mod utf8;
2015-05-09 19:18:25 +00:00
2016-10-10 20:02:07 +00:00
#[doc(hidden)]
pub mod backend;
2017-10-12 23:38:55 +00:00
pub use cursive::{Cursive, ScreenId};
2016-10-02 22:22:29 +00:00
pub use printer::Printer;
pub use with::With;
pub use xy::XY;