use std::io::{self, Write};
#[derive(Debug)]
pub struct Terminal;
impl Terminal {
pub fn clear_screen() -> io::Result<()> {
let stdout = io::stdout();
let mut handle = stdout.lock();
handle.write_all(b"\x1b[2J")?;
handle.flush()
}
pub fn move_cursor(row: u16, col: u16) -> io::Result<()> {
let stdout = io::stdout();
let mut handle = stdout.lock();
write!(handle, "\x1b[{};{}H", row, col)?;
handle.flush()
}
pub fn size() -> Option<(u16, u16)> {
crate::os::get_terminal_size()
}
pub fn print_at(row: u16, col: u16, text: &str) -> io::Result<()> {
Self::move_cursor(row, col)?;
let stdout = io::stdout();
let mut handle = stdout.lock();
handle.write_all(text.as_bytes())?;
handle.flush()
}
}