use papergrid::Indent;
use crate::{Table, TableOption};
#[derive(Debug, Clone)]
pub struct Margin(papergrid::Margin);
impl Margin {
pub fn new(left: usize, right: usize, top: usize, bottom: usize) -> Self {
Self(papergrid::Margin {
top: Indent::spaced(top),
bottom: Indent::spaced(bottom),
left: Indent::spaced(left),
right: Indent::spaced(right),
})
}
pub fn set_fill(mut self, left: char, right: char, top: char, bottom: char) -> Self {
self.0.left.fill = left;
self.0.right.fill = right;
self.0.top.fill = top;
self.0.bottom.fill = bottom;
self
}
}
impl<R> TableOption<R> for Margin {
fn change(&mut self, table: &mut Table<R>) {
table.get_config_mut().set_margin(self.0);
}
}