Skip to content

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

MasonProtter
Copy link
Contributor

This is a continuation of #341 after it was reverted because it errored when encountering an AnnotatedString.

Seems to be working with AnnotatedString.

julia> let n = 20
           xs = Float64[]
           p = Progress(n)
           for iter = 1:n
               append!(xs, rand())
               sleep(0.5)
               plt = lineplot(xs)
               str = Base.AnnotatedString(" julia", [(2:6, :face, rand((:magenta, :red, :blue, :green)))])
               ProgressMeter.next!(p; showvalues = [(:UnicodePlot, plt), ("An annoted string", str2)])
           end
       end
Screencast_20250405_002203.webm

The downside is that styled strings will get a " wrapped around them as you can see in the video, so if anyone has any better suggestions for how to deal with this generically, I'd be open to input. cc @MilesCranmer

Copy link

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.45%. Comparing base (807496a) to head (f452210).
Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #345      +/-   ##
==========================================
+ Coverage   93.48%   96.45%   +2.97%     
==========================================
  Files           1        1              
  Lines         399      564     +165     
==========================================
+ Hits          373      544     +171     
+ Misses         26       20       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MilesCranmer
Copy link

Probably worth adding some tests; also see the code coverage

Comment on lines 595 to 596
# I don't understand why the minus 1 is necessary here, but empircally
# it is needed.

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

@MasonProtter MasonProtter Apr 4, 2025

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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

string_value = "\e[0m" * if value isa Union{String, SubString{String}}
value
else
repr("text/plain", value; context=IOContext(PipeBuffer(), :color => true))

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?

Copy link
Contributor Author

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 as AnnotatedString(" julia", ...)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MasonProtter
Copy link
Contributor Author

Yeah I'll throw some tests together soon, I just wanted to put the PR up for now to see if people have suggestions for how to deal with these annotated strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants