use {Screen, TerminalOutput};
use super::super::cursor;
use super::super::input;
use super::super::style;
use super::super::terminal;
use std::fmt::Display;
use std::sync::Arc;
pub struct Crossterm {
stdout: Arc<TerminalOutput>
}
impl<'crossterm> Crossterm {
pub fn new(screen: &Screen) -> Crossterm {
Crossterm { stdout: screen.stdout.clone() }
}
pub fn cursor(&self) -> cursor::TerminalCursor {
cursor::TerminalCursor::new(&self.stdout)
}
pub fn input(&self) -> input::TerminalInput {
return input::TerminalInput::new(&self.stdout);
}
pub fn terminal(&self) -> terminal::Terminal {
return terminal::Terminal::new(&self.stdout);
}
pub fn color(&self) -> style::TerminalColor {
return style::TerminalColor::new(&self.stdout);
}
pub fn style<D>(&self, val: D) -> style::StyledObject<D>
where
D: Display, {
style::ObjectStyle::new().apply_to(val)
}
}
impl From<Arc<TerminalOutput>> for Crossterm
{
fn from(stdout: Arc<TerminalOutput>) -> Self {
Crossterm { stdout: stdout }
}
}