use papergrid::records::Records;
use crate::{style::Offset, CellOption, Table};
#[derive(Debug)]
pub struct BorderChar {
c: char,
offset: Offset,
horizontal: bool,
}
impl BorderChar {
pub fn horizontal(c: char, offset: Offset) -> Self {
Self {
c,
offset,
horizontal: true,
}
}
pub fn vertical(c: char, offset: Offset) -> Self {
Self {
c,
offset,
horizontal: false,
}
}
}
impl<R> CellOption<R> for BorderChar
where
R: Records,
{
fn change_cell(&mut self, table: &mut Table<R>, entity: papergrid::Entity) {
let offset = self.offset.into();
for pos in entity.iter(table.count_rows(), table.count_rows()) {
match self.horizontal {
true => {
table
.get_config_mut()
.override_horizontal_border(pos, self.c, offset);
}
false => {
table
.get_config_mut()
.override_vertical_border(pos, self.c, offset);
}
}
}
}
}