use crate::{loading_element::LoadingElement, terminal_helper::V2Usz};
pub enum Position {
TOP,BOTTOM
}
pub trait LoadingColorScheme {
fn get_char_block_color(&self, l_elem: &LoadingElement) -> Box<str>; }
pub struct RedGreenScheme {}
impl LoadingColorScheme for RedGreenScheme {
fn get_char_block_color(&self, l_elem: &LoadingElement) -> Box<str> {
let ratio = if l_elem.get_max() > 0 {255 * l_elem.get_progress() / l_elem.get_max()} else {0}; return Box::from(format!("\x1b[38;2;{r};{g};{b}m", r=255-ratio, g=ratio, b=0)) }
}
pub struct BlueScheme {}
impl LoadingColorScheme for BlueScheme {
fn get_char_block_color(&self, _l_elem: &LoadingElement) -> Box<str> {
Box::from(format!("\x1b[38;2;{r};{g};{b}m", r=0, g=0, b=255)) }
}
pub fn set_terminal_pos(pos: V2Usz) {
print!("\x1B[{line};{column}H", column = pos.x as usize, line = pos.y as usize);
}
pub fn print_splitter_line(terminal_size: &V2Usz, offset_height: usize) {
set_terminal_pos(V2Usz { x: 0, y: offset_height }); print!("{end:\u{2500}>times$}", end="", times=terminal_size.x as usize); }