1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-14 17:22:25 +01:00

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

I'm not quite sure what was up with git on that last commit, but it's
all properly committed now.
This commit is contained in:
eth-p
2018-05-12 13:44:10 -07:00
parent cd26d403a3
commit d4b438b9d3
3 changed files with 43 additions and 4 deletions

View File

@@ -94,7 +94,7 @@ impl<'a> Printer<'a> {
regions: &[(highlighting::Style, &str)],
) -> Result<()> {
let mut cursor: usize = 0;
let mut cursor_max: usize = self.config.term_width - 2;
let mut cursor_max: usize = self.config.term_width;
// Line decoration.
let decorations = self.gen_decorations(line_number);
@@ -116,6 +116,27 @@ impl<'a> Printer<'a> {
// Grid border.
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.
if self.config.output_wrap == OutputWrap::None {
let true_color = self.config.true_color;
let colored_output = self.config.colored_output;
write!(self.handle, "{}",
regions.iter()
.map(|&(style, text)| as_terminal_escaped(style, text, true_color, colored_output))
.collect::<Vec<_>>()
.join(" ")
)?;
} else {
for &(style, text) in regions.iter() {
let mut chars = text.chars().filter(|c| *c != '\n');
@@ -136,7 +157,7 @@ impl<'a> Printer<'a> {
style,
&*text,
self.config.true_color,
self.config.colored_output
self.config.colored_output,
)
)?;
break;
@@ -155,7 +176,7 @@ impl<'a> Printer<'a> {
style,
&*text,
self.config.true_color,
self.config.colored_output
self.config.colored_output,
),
" ".repeat(gutter_width),
border.text.to_owned()