#![allow(clippy::await_holding_refcell_ref)]
#![allow(clippy::collapsible_else_if)]
#![warn(anonymous_parameters, bad_style, missing_docs)]
#![warn(unused, unused_extern_crates, unused_import_braces, unused_qualifications)]
#![warn(unsafe_code)]
use async_channel::Sender;
use endbasic_core::exec::Signal;
use endbasic_std::console::Console;
use std::cell::RefCell;
use std::io;
use std::rc::Rc;
mod console;
mod font;
mod host;
mod spec;
fn string_error_to_io_error(e: String) -> io::Error {
io::Error::new(io::ErrorKind::Other, e)
}
pub fn setup(spec: &str, signals_tx: Sender<Signal>) -> io::Result<Rc<RefCell<dyn Console>>> {
let spec = spec::parse_graphics_spec(spec)?;
let console = match spec.1 {
None => {
let default_font = spec::TempFont::default_font()?;
console::SdlConsole::new(spec.0, default_font.path(), spec.2, signals_tx)?
}
Some(font_path) => {
console::SdlConsole::new(spec.0, font_path.to_owned(), spec.2, signals_tx)?
}
};
Ok(Rc::from(RefCell::from(console)))
}