| 1 |
|
| 2 |
|
| 3 |
use std::io; |
| 4 |
|
| 5 |
use crate::{buffer::Cell, terminal::Config}; |
| 6 |
|
| 7 |
use helix_view::{ |
| 8 |
graphics::{CursorKind, Rect}, |
| 9 |
theme::Color, |
| 10 |
}; |
| 11 |
|
| 12 |
#[cfg(all(feature = "termina", not(windows)))] |
| 13 |
mod termina; |
| 14 |
#[cfg(all(feature = "termina", not(windows)))] |
| 15 |
pub use self::termina::TerminaBackend; |
| 16 |
|
| 17 |
#[cfg(all(feature = "termina", windows))] |
| 18 |
mod crossterm; |
| 19 |
#[cfg(all(feature = "termina", windows))] |
| 20 |
pub use self::crossterm::CrosstermBackend; |
| 21 |
|
| 22 |
mod test; |
| 23 |
pub use self::test::TestBackend; |
| 24 |
|
| 25 |
|
| 26 |
pub trait Backend { |
| 27 |
|
| 28 |
fn claim(&mut self) -> Result<(), io::Error>; |
| 29 |
|
| 30 |
fn reconfigure(&mut self, config: Config) -> Result<(), io::Error>; |
| 31 |
|
| 32 |
fn restore(&mut self) -> Result<(), io::Error>; |
| 33 |
|
| 34 |
fn draw<'a, I>(&mut self, content: I) -> Result<(), io::Error> |
| 35 |
where |
| 36 |
I: Iterator<Item = (u16, u16, &'a Cell)>; |
| 37 |
|
| 38 |
fn hide_cursor(&mut self) -> Result<(), io::Error>; |
| 39 |
|
| 40 |
fn show_cursor(&mut self, kind: CursorKind) -> Result<(), io::Error>; |
| 41 |
|
| 42 |
fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), io::Error>; |
| 43 |
|
| 44 |
fn clear(&mut self) -> Result<(), io::Error>; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
fn start_sync(&mut self) -> Result<(), io::Error>; |
| 49 |
|
| 50 |
fn end_sync(&mut self) -> Result<(), io::Error>; |
| 51 |
|
| 52 |
fn size(&self) -> Result<Rect, io::Error>; |
| 53 |
|
| 54 |
fn flush(&mut self) -> Result<(), io::Error>; |
| 55 |
fn supports_true_color(&self) -> bool; |
| 56 |
fn get_theme_mode(&self) -> Option<helix_view::theme::Mode>; |
| 57 |
fn set_background_color(&mut self, color: Option<Color>) -> io::Result<()>; |
| 58 |
} |