use std::fmt::Write;

use crate::color::Color;

/// writes a move-to escape seq to a string buffer. NOTE: row and col are *ZERO*-based
pub fn write_move_to(str: &mut String, col: usize, row: usize) {
    let _ = write!(str, "\x1b[{};{}H", row + 1, col + 1);
}

pub fn write_fg_color(str: &mut String, color: Color) {
    color.write_fg(str);
}

pub fn write_bg_color(str: &mut String, color: Color) {
    color.write_bg(str);
}

pub fn write_fg_reset(str: &mut String) {
    let _ = write!(str, "\x1b[39m",);
}

pub fn write_bg_reset(str: &mut String) {
    let _ = write!(str, "\x1b[49m",);
}
