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