use retroglyph_core::Backend;
use retroglyph_core::Rect;
use retroglyph_core::Style;
use retroglyph_core::Terminal;
#[allow(clippy::redundant_pub_crate)]
pub(crate) const TL: char = '┌'; #[allow(clippy::redundant_pub_crate)]
pub(crate) const TR: char = '┐'; #[allow(clippy::redundant_pub_crate)]
pub(crate) const BL: char = '└'; #[allow(clippy::redundant_pub_crate)]
pub(crate) const BR: char = '┘'; #[allow(clippy::redundant_pub_crate)]
pub(crate) const H: char = '─'; #[allow(clippy::redundant_pub_crate)]
pub(crate) const V: char = '│';
pub fn fill_rect<B: Backend>(term: &mut Terminal<B>, rect: Rect, ch: char, style: Style) {
term.reset_style()
.fg(style.foreground())
.bg(style.background());
for y in rect.top()..rect.bottom() {
for x in rect.left()..rect.right() {
term.put(x, y, ch);
}
}
term.reset_style();
}
#[cfg(test)]
mod tests {
use retroglyph_core::Headless;
use super::*;
#[test]
fn fill_rect_overwrites_the_whole_rectangle() {
let area = Rect::new(1, 1, 4, 2);
let mut term = Terminal::new(Headless::new(6, 4));
fill_rect(&mut term, area, '#', Style::new());
for y in 1..3 {
for x in 1..5 {
assert_eq!(term.grid().get(x, y).glyph(), '#');
}
}
assert_eq!(term.grid().get(0, 0).glyph(), ' ');
}
}