Skip to content

Commit

Permalink
Consider color when printing squeeze indicator
Browse files Browse the repository at this point in the history
When color option has been set to never, the squeeze indicator
character asterisk '*' should not be printed in color.

Fixes #63
  • Loading branch information
awidegreen authored and sharkdp committed May 30, 2019
1 parent def066f commit c4028bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use clap::{App, AppSettings, Arg};
use ansi_term::Color;
use ansi_term::Color::Fixed;

use atty::Stream;
use crate::squeezer::{SqueezeAction, Squeezer};
use atty::Stream;

const BUFFER_SIZE: usize = 256;

Expand Down Expand Up @@ -369,10 +369,15 @@ impl<'a> Printer<'a> {
SqueezeAction::Print => {
self.buffer_line.clear();
let style = COLOR_OFFSET.normal();
let asterisk = if self.show_color {
format!("{}", style.paint("*"))
} else {
String::from("*")
};
let _ = writeln!(
&mut self.buffer_line,
"{5}{0}{1:2$}{5}{1:3$}{6}{1:3$}{5}{1:4$}{6}{1:4$}{5}",
style.paint("*"),
asterisk,
"",
7,
25,
Expand Down

0 comments on commit c4028bb

Please sign in to comment.