KristofferC / Crayons.jl

Colored and styled strings for terminals.
Other
150 stars 14 forks source link

Only print escape sequences if IO supports #25

Closed ronisbr closed 5 years ago

ronisbr commented 5 years ago

Hi @KristofferC ,

If I try to save an output of print with Crayons to a file, then I get a lot of escape sequences. Hence, I am proposing this PR in which the print of a Crayon will check if the IO has support for colors. It it has, then the escape sequences will be printed, otherwise they will be omitted. This behavior can be changed by the ENV key FORCE_COLOR.

codecov-io commented 5 years ago

Codecov Report

Merging #25 into master will decrease coverage by 0.26%. The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #25      +/-   ##
=========================================
- Coverage   85.66%   85.4%   -0.27%     
=========================================
  Files           7       7              
  Lines         272     274       +2     
=========================================
+ Hits          233     234       +1     
- Misses         39      40       +1
Impacted Files Coverage Δ
src/crayon.jl 83.19% <50%> (-0.57%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dc8fa9a...24df3ee. Read the comment docs.

ronisbr commented 5 years ago

Well, it turns out that the way I code my package makes it very easy to do this check inside it. Then, this is not required anymore, sorry :)

However, I think this is a good modification to match the behavior of printstyled.

ronisbr commented 5 years ago

Bump!

Hi @KristofferC any new ideas on this one?

KristofferC commented 5 years ago

Sorry, thanks for bumping.