diff options
author | Pierre-Henri Symoneaux <phsym@users.noreply.github.com> | 2017-06-05 11:52:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-05 11:52:22 +0200 |
commit | 14dcf5f9615eeafb8eb7c20732f55d41d1045884 (patch) | |
tree | 163bce32aa54d350507572eeb396eb0c67e9a83c /src/format.rs | |
parent | f155ef2435b4bae5a68235156775c5c9b16d69dc (diff) | |
parent | 6c7212d7417bb595388293a50e43401085a605f4 (diff) |
Merge pull request #57 from hcpl/fix-padding
Fix padding formatting
Diffstat (limited to 'src/format.rs')
-rw-r--r-- | src/format.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/format.rs b/src/format.rs index 0293b67..25f477e 100644 --- a/src/format.rs +++ b/src/format.rs @@ -57,6 +57,7 @@ impl LineSeparator { } /// Print a full line separator to `out`. `col_width` is a slice containing the width of each column + #[deprecated(since = "0.6.7", note = "function will be removed. See [issue #57](https://github.com/phsym/prettytable-rs/pull/57).")] pub fn print<T: Write + ?Sized>(&self, out: &mut T, col_width: &[usize], @@ -64,12 +65,23 @@ impl LineSeparator { lborder: bool, rborder: bool) -> Result<(), Error> { + self._print(out, col_width, (1, 1), colsep, lborder, rborder) + } + + fn _print<T: Write + ?Sized>(&self, + out: &mut T, + col_width: &[usize], + padding: (usize, usize), + colsep: bool, + lborder: bool, + rborder: bool) + -> Result<(), Error> { if lborder { try!(out.write_all(Utf8Char::from(self.ljunc).as_bytes())); } let mut iter = col_width.into_iter().peekable(); while let Some(width) = iter.next() { - for _ in 0..width + 2 { + for _ in 0..width + padding.0 + padding.1 { try!(out.write_all(Utf8Char::from(self.line).as_bytes())); } if colsep && iter.peek().is_some() { @@ -189,11 +201,12 @@ impl TableFormat { -> Result<(), Error> { match *self.get_sep_for_line(pos) {
Some(ref l) => { - l.print(out, - col_width, - self.csep.is_some(), - self.lborder.is_some(), - self.rborder.is_some()) + l._print(out, + col_width, + self.get_padding(), + self.csep.is_some(), + self.lborder.is_some(), + self.rborder.is_some()) }
None => Ok(()),
} |