1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::CellOption;
use papergrid::{Entity, Grid, Settings};

/// Indent is responsilbe for a left/right/top/bottom indent.
///
/// ```rust,no_run
///   # use tabled::{Style, Indent, Row, Table, Modify};
///   # let data: Vec<&'static str> = Vec::new();
///     let table = Table::new(&data).with(Modify::new(Row(..1)).with(Indent::new(0, 0, 1, 1)));
/// ```
#[derive(Debug)]
pub struct Indent(usize, usize, usize, usize);

impl Indent {
    pub fn new(left: usize, right: usize, top: usize, bottom: usize) -> Self {
        Self(left, right, top, bottom)
    }
}

impl CellOption for Indent {
    fn change_cell(&self, grid: &mut Grid, row: usize, column: usize) {
        grid.set(
            Entity::Cell(row, column),
            Settings::new().indent(self.0, self.1, self.2, self.3),
        )
    }
}