use std::io; use super::*; use std::rc::Rc; use Context; pub struct TerminalInput { context: Rc, terminal_input: Box, } impl TerminalInput { pub fn new(context: Rc) -> TerminalInput { #[cfg(target_os = "windows")] let input = Box::from(WindowsInput::new(context.clone())); #[cfg(not(target_os = "windows"))] let input = Box::from(UnixInput::new()); TerminalInput { terminal_input: input, context, } } pub fn read_line(&self) -> io::Result { self.terminal_input.read_line() } pub fn read_char(&self) -> io::Result { return self.terminal_input.read_char(); } pub fn read_key(&self) -> io::Result { self.terminal_input.read_pressed_key() } pub fn read_async(&self) -> AsyncReader { self.terminal_input.read_async() } pub fn read_until_async(&self, delimiter: u8) -> AsyncReader { self.terminal_input.read_until_async(delimiter) } } pub fn input(context: &Rc) -> Box { return Box::from(TerminalInput::new(context.clone())); }