mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-08 22:11:16 +01:00
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:
parent
f95a23f948
commit
cd26d403a3
@ -117,16 +117,6 @@ impl<'a> Printer<'a> {
|
|||||||
let border = if gutter_width > 0 && self.config.output_components.grid() {
|
let border = if gutter_width > 0 && self.config.output_components.grid() {
|
||||||
self.gen_border()
|
self.gen_border()
|
||||||
} else {
|
} else {
|
||||||
PrintSegment {
|
|
||||||
size: 0,
|
|
||||||
text: "".to_owned(),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
cursor_max -= border.size;
|
|
||||||
write!(self.handle, "{} ", border.text)?;
|
|
||||||
|
|
||||||
// Line contents.
|
|
||||||
for &(style, text) in regions.iter() {
|
for &(style, text) in regions.iter() {
|
||||||
let mut chars = text.chars().filter(|c| *c != '\n');
|
let mut chars = text.chars().filter(|c| *c != '\n');
|
||||||
let mut remaining = text.chars().filter(|c| *c != '\n').count();
|
let mut remaining = text.chars().filter(|c| *c != '\n').count();
|
||||||
@ -160,7 +150,7 @@ impl<'a> Printer<'a> {
|
|||||||
|
|
||||||
write!(
|
write!(
|
||||||
self.handle,
|
self.handle,
|
||||||
"{}\n{}{} ",
|
"{}\n{}{}",
|
||||||
as_terminal_escaped(
|
as_terminal_escaped(
|
||||||
style,
|
style,
|
||||||
&*text,
|
&*text,
|
||||||
@ -176,8 +166,10 @@ impl<'a> Printer<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finished.
|
|
||||||
write!(self.handle, "\n")?;
|
write!(self.handle, "\n")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finished.
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,8 +222,8 @@ impl<'a> Printer<'a> {
|
|||||||
/// Generates the vertical grid border.
|
/// Generates the vertical grid border.
|
||||||
fn gen_border(&self) -> PrintSegment {
|
fn gen_border(&self) -> PrintSegment {
|
||||||
return PrintSegment {
|
return PrintSegment {
|
||||||
text: self.colors.grid.paint("│").to_string(),
|
text: self.colors.grid.paint("│ ").to_string(),
|
||||||
size: 1,
|
size: 2,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user