2016-07-01 06:38:01 +00:00
|
|
|
use event;
|
|
|
|
use theme;
|
|
|
|
|
|
|
|
// Module is not named `ncurses` to avoir naming conflict
|
|
|
|
mod curses;
|
2016-10-08 23:47:15 +00:00
|
|
|
mod termion;
|
2016-07-01 06:38:01 +00:00
|
|
|
|
|
|
|
pub use self::curses::NcursesBackend;
|
2016-10-08 23:47:15 +00:00
|
|
|
pub use self::termion::TermionBackend;
|
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?
|
2016-09-24 23:51:42 +00:00
|
|
|
fn finish(&mut self);
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-10-09 22:47:06 +00:00
|
|
|
fn clear(&self);
|
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;
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-09-24 23:51:42 +00:00
|
|
|
fn init_color_style(&mut self, style: theme::ColorStyle,
|
|
|
|
foreground: &theme::Color, background: &theme::Color);
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-09-24 23:51:42 +00:00
|
|
|
fn print_at(&self, (usize, usize), &str);
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-09-24 23:51:42 +00:00
|
|
|
fn poll_event(&self) -> event::Event;
|
|
|
|
fn set_refresh_rate(&mut self, fps: u32);
|
|
|
|
fn screen_size(&self) -> (usize, usize);
|
2016-07-01 06:38:01 +00:00
|
|
|
|
2016-10-08 23:47:15 +00:00
|
|
|
// TODO: unify those into a single method?
|
2016-09-24 23:51:42 +00:00
|
|
|
fn with_color<F: FnOnce()>(&self, color: theme::ColorStyle, f: F);
|
|
|
|
fn with_effect<F: FnOnce()>(&self, effect: theme::Effect, f: F);
|
2016-07-01 06:38:01 +00:00
|
|
|
}
|