Skip to content

Commit 7241673

Browse files
Port progress bar improvements from Pkg (#56125)
Includes changes from JuliaLang/Pkg.jl#4038 and JuliaLang/Pkg.jl#4044. Co-authored-by: Kristoffer Carlsson <[email protected]>
1 parent 67c93b9 commit 7241673

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

base/precompilation.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ function show_progress(io::IO, p::MiniProgressBar; termwidth=nothing, carriagere
297297
end
298298
termwidth = @something termwidth displaysize(io)[2]
299299
max_progress_width = max(0, min(termwidth - textwidth(p.header) - textwidth(progress_text) - 10 , p.width))
300-
n_filled = ceil(Int, max_progress_width * perc / 100)
300+
n_filled = floor(Int, max_progress_width * perc / 100)
301+
partial_filled = (max_progress_width * perc / 100) - n_filled
301302
n_left = max_progress_width - n_filled
302303
headers = split(p.header, ' ')
303304
to_print = sprint(; context=io) do io
@@ -306,8 +307,15 @@ function show_progress(io::IO, p::MiniProgressBar; termwidth=nothing, carriagere
306307
printstyled(io, join(headers[2:end], ' '))
307308
print(io, " ")
308309
printstyled(io, ""^n_filled; color=p.color)
309-
printstyled(io, perc >= 95 ? "" : ""; color=p.color)
310-
printstyled(io, ""^n_left, " "; color=:light_black)
310+
if n_left > 0
311+
if partial_filled > 0.5
312+
printstyled(io, ""; color=p.color) # More filled, use ╸
313+
else
314+
printstyled(io, ""; color=:light_black) # Less filled, use ╺
315+
end
316+
printstyled(io, ""^(n_left-1); color=:light_black)
317+
end
318+
printstyled(io, " "; color=:light_black)
311319
print(io, progress_text)
312320
carriagereturn && print(io, "\r")
313321
end

0 commit comments

Comments
 (0)