mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 19:00:46 +00:00
Switch backend with cargo features
Use `termion` feature and disable default features to use the termion backend.
This commit is contained in:
parent
df4397a174
commit
ad7606ca55
@ -16,7 +16,7 @@ skeptic = "0.6"
|
||||
|
||||
[dependencies]
|
||||
odds = "0.2"
|
||||
termion = "1.1.1"
|
||||
termion = {version="1.1.1", optional=true}
|
||||
toml = "0.2"
|
||||
unicode-segmentation = "0.1"
|
||||
unicode-width = "0.1"
|
||||
@ -24,6 +24,7 @@ unicode-width = "0.1"
|
||||
[dependencies.ncurses]
|
||||
features = ["wide"]
|
||||
version = "5.82.0"
|
||||
optional=true
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.3"
|
||||
@ -31,3 +32,6 @@ skeptic = "0.6"
|
||||
|
||||
[lib]
|
||||
name = "cursive"
|
||||
|
||||
[features]
|
||||
default = ["ncurses"]
|
||||
|
@ -2,11 +2,10 @@ use event;
|
||||
use theme;
|
||||
|
||||
// Module is not named `ncurses` to avoir naming conflict
|
||||
mod curses;
|
||||
mod termion;
|
||||
|
||||
pub use self::curses::NcursesBackend;
|
||||
pub use self::termion::TermionBackend;
|
||||
#[cfg(feature = "ncurses")]
|
||||
pub mod curses;
|
||||
#[cfg(feature = "termion")]
|
||||
pub mod termion;
|
||||
|
||||
pub trait Backend {
|
||||
fn init() -> Self;
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -56,12 +56,15 @@
|
||||
//! and log to it instead of stdout.
|
||||
#![deny(missing_docs)]
|
||||
|
||||
#[cfg(feature = "ncurses")]
|
||||
extern crate ncurses;
|
||||
#[cfg(feature = "termion")]
|
||||
extern crate termion;
|
||||
|
||||
extern crate toml;
|
||||
extern crate unicode_segmentation;
|
||||
extern crate unicode_width;
|
||||
extern crate odds;
|
||||
extern crate termion;
|
||||
|
||||
macro_rules! println_stderr(
|
||||
($($arg:tt)*) => { {
|
||||
@ -155,8 +158,13 @@ new_default!(Cursive);
|
||||
|
||||
// Use the Ncurses backend.
|
||||
// TODO: make this feature-driven
|
||||
#[cfg(feature = "termion")]
|
||||
#[doc(hidden)]
|
||||
pub type B = backend::TermionBackend;
|
||||
pub type B = backend::termion::TermionBackend;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "ncurses")]
|
||||
pub type B = backend::curses::NcursesBackend;
|
||||
|
||||
impl Cursive {
|
||||
/// Creates a new Cursive root, and initialize ncurses.
|
||||
|
Loading…
Reference in New Issue
Block a user