mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-26 20:16:31 +00:00
Consider color when printing squeeze indicator
When color option has been set to never, the squeeze indicator character asterisk '*' should not be printed in color. Fixes #63
This commit is contained in:
1 parent
def066ff92
commit
c4028bb213
1 file changed
+7
-2
+7
-2
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user