Fix padding, add --wrap argument, disable wrap for non-tty.

Now bat(1) can be used like cat(1) again!
This commit is contained in:
eth-p 2018-05-12 13:23:33 -07:00
parent f95a23f948
commit cd26d403a3
No known key found for this signature in database
GPG Key ID: 1F8DF8091CD46FBC
1 changed files with 44 additions and 52 deletions

View File

@ -117,16 +117,6 @@ impl<'a> Printer<'a> {
let border = if gutter_width > 0 && self.config.output_components.grid() {
self.gen_border()
} else {
PrintSegment {
size: 0,
text: "".to_owned(),
}
};
cursor_max -= border.size;
write!(self.handle, "{} ", border.text)?;
// Line contents.
for &(style, text) in regions.iter() {
let mut chars = text.chars().filter(|c| *c != '\n');
let mut remaining = text.chars().filter(|c| *c != '\n').count();
@ -176,8 +166,10 @@ impl<'a> Printer<'a> {
}
}
// Finished.
write!(self.handle, "\n")?;
}
// Finished.
Ok(())
}
@ -231,7 +223,7 @@ impl<'a> Printer<'a> {
fn gen_border(&self) -> PrintSegment {
return PrintSegment {
text: self.colors.grid.paint("").to_string(),
size: 1,
size: 2,
};
}