use std::io::{self, Write};
pub const RESET_PROGRESS_BAR: &[u8] = b"\x1b]9;4;0\x07";
pub const SET_INDETERMINATE_PROGRESS_BAR: &[u8] = b"\x1b]9;4;3\x07";
fn clamp_percentage(p: i32) -> u8 {
p.clamp(0, 100) as u8
}
pub fn write_set_progress_bar<W: Write>(w: &mut W, percentage: i32) -> io::Result<()> {
write!(w, "\x1b]9;4;1;{}\x07", clamp_percentage(percentage))
}
pub fn write_set_error_progress_bar<W: Write>(w: &mut W, percentage: i32) -> io::Result<()> {
write!(w, "\x1b]9;4;2;{}\x07", clamp_percentage(percentage))
}
pub fn write_set_warning_progress_bar<W: Write>(w: &mut W, percentage: i32) -> io::Result<()> {
write!(w, "\x1b]9;4;4;{}\x07", clamp_percentage(percentage))
}