#![feature(allocator_api)]
#![deny(warnings)]
#![doc(test(attr(deny(warnings))))]
#![doc(test(attr(allow(dead_code))))]
#![doc(test(attr(allow(unused_variables))))]
#![no_std]
extern crate alloc;
use alloc::alloc::Global;
use alloc::boxed::Box;
use core::alloc::Allocator;
pub use tuifw_screen_base::*;
pub unsafe fn init(max_size: Option<(u16, u16)>, error_alloc: Option<&'static dyn Allocator>) -> Result<Box<dyn Screen>, Error> {
init_raw_in(max_size, error_alloc, Global)
}
pub unsafe fn init_in<A: Allocator + Clone + 'static>(
max_size: Option<(u16, u16)>,
error_alloc: Option<&'static dyn Allocator>,
alloc: A
) -> Result<Box<dyn Screen>, Error> {
init_raw_in(max_size, error_alloc, alloc)
}
#[cfg(target_os="dos")]
unsafe fn init_raw_in<A: Allocator + Clone>(
max_size: Option<(u16, u16)>,
error_alloc: Option<&'static dyn Allocator>,
_alloc: A
) -> Result<Box<dyn Screen>, Error> {
if let Some(max_size) = max_size {
assert!(max_size.0 >= 80 && max_size.1 >= 25);
}
Ok(Box::new(tuifw_screen_dos::Screen::new(error_alloc)?))
}
#[cfg(all(not(target_os="dos"), windows))]
unsafe fn init_raw_in<A: Allocator + Clone + 'static>(
max_size: Option<(u16, u16)>,
error_alloc: Option<&'static dyn Allocator>,
alloc: A
) -> Result<Box<dyn Screen>, Error> {
Ok(Box::new(tuifw_screen_winapi::Screen::new_in(max_size, error_alloc, alloc)?))
}
#[cfg(all(not(target_os="dos"), not(windows)))]
unsafe fn init_raw_in<A: Allocator + Clone + 'static>(
max_size: Option<(u16, u16)>,
error_alloc: Option<&'static dyn Allocator>,
alloc: A
) -> Result<Box<dyn Screen>, Error> {
tuifw_screen_ncurses::init_in(max_size, error_alloc, alloc)
}