2016-07-01 06:38:01 +00:00
|
|
|
use event;
|
|
|
|
use theme;
|
|
|
|
|
2016-10-09 23:42:55 +00:00
|
|
|
#[cfg(feature = "termion")]
|
2016-10-09 22:48:51 +00:00
|
|
|
mod termion;
|
2016-10-11 23:23:08 +00:00
|
|
|
#[cfg(feature = "bear-lib-terminal")]
|
|
|
|
mod blt;
|
2016-10-12 07:47:20 +00:00
|
|
|
#[cfg(any(feature = "ncurses", feature = "pancurses"))]
|
2016-10-09 22:48:51 +00:00
|
|
|
mod curses;
|
|
|
|
|
2017-02-07 02:18:17 +00:00
|
|
|
#[cfg(feature = "bear-lib-terminal")]
|
|
|
|
pub use self::blt::*;
|
2016-10-12 07:47:20 +00:00
|
|
|
#[cfg(any(feature = "ncurses", feature = "pancurses"))]
|
2016-10-09 22:48:51 +00:00
|
|
|
pub use self::curses::*;
|
2016-10-09 23:42:55 +00:00
|
|
|
#[cfg(feature = "termion")]
|
2016-10-09 22:48:51 +00:00
|
|
|
pub use self::termion::*;
|
2016-07-01 06:38:01 +00:00
|
|
|
|
|
|
|
pub trait Backend {
|
2016-09-24 23:51:42 +00:00
|
|
|
fn init() -> Self;
|
2016-10-08 23:47:15 +00:00
|
|
|
// TODO: take `self` by value?
|
2017-06-13 06:29:26 +00:00
|
|
|
// Or implement Drop?
|
2016-09-24 23:51:42 +00:00
|
|
|
fn finish(&mut self);
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-10-08 23:47:15 +00:00
|
|
|
fn refresh(&mut self);
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-09-24 23:51:42 +00:00
|
|
|
fn has_colors(&self) -> bool;
|
2017-06-13 06:29:26 +00:00
|
|
|
fn screen_size(&self) -> (usize, usize);
|
|
|
|
|
|
|
|
/// Main input method
|
2017-10-08 23:02:43 +00:00
|
|
|
fn poll_event(&mut self) -> event::Event;
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2017-06-13 06:29:26 +00:00
|
|
|
/// Main method used for printing
|
2016-09-24 23:51:42 +00:00
|
|
|
fn print_at(&self, (usize, usize), &str);
|
2017-06-13 06:29:26 +00:00
|
|
|
fn clear(&self, color: theme::Color);
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-09-24 23:51:42 +00:00
|
|
|
fn set_refresh_rate(&mut self, fps: u32);
|
2016-10-08 23:47:15 +00:00
|
|
|
// TODO: unify those into a single method?
|
2017-06-12 18:59:33 +00:00
|
|
|
fn with_color<F: FnOnce()>(&self, colors: theme::ColorPair, f: F);
|
2016-09-24 23:51:42 +00:00
|
|
|
fn with_effect<F: FnOnce()>(&self, effect: theme::Effect, f: F);
|
2016-07-01 06:38:01 +00:00
|
|
|
}
|