-
Notifications
You must be signed in to change notification settings - Fork 91
Retry Fix printing of multiline values, and allow colors in showed values #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2472db6
29d27a4
4b5745c
16a2279
84fa6ea
dbd0e3c
e816612
f452210
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -580,11 +580,21 @@ function printvalues!(p::AbstractProgress, showvalues; color = :normal, truncate | |
p.numprintedvalues = 0 | ||
|
||
for (name, value) in showvalues | ||
msg = "\n " * lpad(string(name) * ": ", maxwidth+2+1) * string(value) | ||
string_value = "\e[0m" * if value isa Union{String, SubString{String}} | ||
value | ||
else | ||
repr("text/plain", value; context=IOContext(PipeBuffer(), :color => true)) | ||
end | ||
if countlines(IOBuffer(string_value)) > 1 | ||
# Multiline objects should go on their own line so their | ||
# alignment doesn't get messed up | ||
string_value = "\n" * string_value | ||
end | ||
msg = "\n " * lpad(string(name) * ": ", maxwidth+2+1) * string_value | ||
max_len = (displaysize(p.output)::Tuple{Int,Int})[2] | ||
# I don't understand why the minus 1 is necessary here, but empircally | ||
# it is needed. | ||
Comment on lines
595
to
596
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this "empirically it is needed" change at all with this modified calculation? Is there a test for this that verifies it is/is not needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's an old comment from before my PR. I did try some tests to change that value, and it causes the number of printed lines to shrink or expand each iteration if you change it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I assumed it was old, I was just wondering if it was no longer relevant since it’s now a different method for counting lines |
||
msg_lines = ceil(Int, (length(msg)-1) / max_len) | ||
msg_lines = countlines(IOBuffer(msg))-1 | ||
if truncate && msg_lines >= 2 | ||
# For multibyte characters, need to index with nextind. | ||
printover(p.output, msg[1:nextind(msg, 1, max_len-1)] * "…", color) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this repr the cause of the explicit quotes showing up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Trying to
show
it like in the previous commit causes it to show up asAnnotatedString(" julia", ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe with
sprint
? https://docs.julialang.org/en/v1/stdlib/StyledStrings/#Applying-faces-to-a-AnnotatedString