use super::TerminalOutput;
use std::sync::Arc;
#[cfg(windows)]
use kernel::windows_kernel::ansi_support::{try_enable_ansi_support, windows_supportable};
#[cfg(windows)]
use kernel::windows_kernel::terminal::{ exit, terminal_size};
#[cfg(windows)]
use kernel::windows_kernel::cursor::pos;
#[cfg(unix)]
use kernel::unix_kernel::terminal::{exit, pos, terminal_size};
pub fn get_terminal_size() -> (u16, u16) {
return terminal_size();
}
pub fn get_cursor_position(stdout: &Arc<TerminalOutput>) -> (u16, u16) {
#[cfg(unix)]
return pos(stdout);
#[cfg(windows)]
return pos();
}
pub fn exit_terminal() {
exit();
}
#[cfg(windows)]
pub fn get_module<T>(winapi_impl: T, unix_impl: T) -> Option<T> {
let mut term: Option<T> = None;
let mut does_support = true;
if !windows_supportable()
{
does_support = try_enable_ansi_support();
if !does_support {
term = Some(winapi_impl);
}
}
if does_support {
term = Some(unix_impl);
}
term
}