Open MilesCranmer opened 1 year ago
Currently, ANSI escape codes will already work, e.g.
iter = ProgressBar(1:100)
for i in iter
# ...
set_multiline_postfix(iter, "\u001b[31mred: \u001b[32mgreen\u001b[37m")
end
However, this is not a great API to program around and might not work on windows platforms either. I guess the best way to go about this is for ProgressBars.jl to also accept a Crayon
instead of a string for methods like set_postfix
, set_multiline_postfix
, etc.
Just realized that Crayons.jl is by the same author as OhMyREPL.jl, so it's likely what they are using there as well.
Awesome. Thanks! I didn't realize it would be that simple. I'm happy with that as-is, it seems like this works well and isn't much work at all to interface:
for i in iter
set_multiline_postfix(iter, "$(Crayon(foreground=:red))In red: $i$(Crayon(reset=true))")
sleep(0.01)
end
It will be cool to have different colors for each column of the output and also for nested expressions!
Okay that's convenient, I guess we won't need a new API from the ProgressBars.jl side for that then.
The ANSI escapes will currently mess up the character-counting for the multiline_postfix:
for i in iter
set_multiline_postfix(iter, "$(Crayon(foreground=:red))In red: $i$(Crayon(reset=true))\nsecond line")
sleep(0.01)
end
Currently working on fixing that with some regex-magic :smiley:
Just released v1.5.0 that fixes colorful multiline postfixes
That was fast 🤯 nice work!!
It could be nice to have colorful printouts of equations, with colored parentheses indicating level of nestedness, similar to OhMyREPL.jl.
@khdlr do you know if ProgressBars.jl
set_multiline_postfix
would support colors?