1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#[cfg(unix)]
mod resize;
pub mod blt;
pub mod crossterm;
pub mod curses;
pub mod puppet;
pub mod termion;
#[allow(dead_code)]
fn boxed(e: impl std::error::Error + 'static) -> Box<dyn std::error::Error> {
Box::new(e)
}
pub fn try_default(
) -> Result<Box<dyn cursive_core::backend::Backend>, Box<dyn std::error::Error>>
{
cfg_if::cfg_if! {
if #[cfg(feature = "blt-backend")] {
Ok(blt::Backend::init())
} else if #[cfg(feature = "termion-backend")] {
termion::Backend::init().map_err(boxed)
} else if #[cfg(feature = "crossterm-backend")] {
crossterm::Backend::init().map_err(boxed)
} else if #[cfg(feature = "pancurses-backend")] {
curses::pan::Backend::init().map_err(boxed)
} else if #[cfg(feature = "ncurses-backend")] {
curses::n::Backend::init().map_err(boxed)
} else {
log::warn!("No built-it backend, falling back to Dummy backend.");
Ok(cursive_core::backend::Dummy::init())
}
}
}