5555function calculate_eta_text (current:: Int , max:: Int , start_time:: Float64 , is_complete:: Bool , show_eta:: Bool ):: Tuple{String, String}
5656 # Early return if ETA is disabled or no progress yet
5757 if ! show_eta || current == 0 || start_time == 0
58- return @sprintf (" %d %%" , round (Int, calculate_percentage (current, max))), " "
58+ return @sprintf (" %4d %%" , round (Int, calculate_percentage (current, max))), " "
5959 end
6060
6161 elapsed = time () - start_time
6262
6363 if is_complete
64- # Completed: only show total time, no progress percentage
65- return " " , " Time: $(format_time (elapsed)) "
64+ # Completed: show 100% and total time
65+ return " 100% " , " Time: $(format_time (elapsed)) "
6666 elseif elapsed > 0
67- # In progress: show progress percentage and ETA
68- perc_text = @sprintf (" %d %%" , round (Int, calculate_percentage (current, max)))
67+ # In progress: show progress percentage and ETA (right-aligned to match "100%")
68+ perc_text = @sprintf (" %4d %%" , round (Int, calculate_percentage (current, max)))
6969 rate = current / elapsed
7070 remaining = max - current
7171 eta_seconds = remaining / rate
7272 return perc_text, " ETA: $(format_time (eta_seconds)) "
7373 else
7474 # Edge case: no time elapsed yet
75- return @sprintf (" %d %%" , round (Int, calculate_percentage (current, max))), " "
75+ return @sprintf (" %4d %%" , round (Int, calculate_percentage (current, max))), " "
7676 end
7777end
7878
7979# Render the progress bar string
8080function render_progress_bar (io:: IO , p:: MiniProgressBar , perc:: Float64 ,
8181 progress_text:: String , eta_text:: String , termwidth:: Int ):: Nothing
8282 # Calculate available width for progress bar
83+ # Use fixed width for progress text (4 chars for "100%" + 2 spaces = 6 total)
84+ progress_width = isempty (progress_text) ? 0 : 6
8385 max_progress_width = max (0 , min (termwidth - textwidth (p. header) -
84- textwidth (progress_text) - textwidth (eta_text) - PROGRESS_BAR_PADDING, p. width))
86+ progress_width - textwidth (eta_text) - PROGRESS_BAR_PADDING, p. width))
8587
8688 # Calculate filled and empty portions
8789 filled_width = max_progress_width * perc / 100
@@ -94,7 +96,13 @@ function render_progress_bar(io::IO, p::MiniProgressBar, perc::Float64,
9496 print (io, ANSI_CLEAR_LINE)
9597 printstyled (io, " [ Info:" ; color = :cyan , bold = true )
9698 print (io, " " )
97- print (io, p. header, " " )
99+ print (io, p. header)
100+
101+ # Print progress text before the bar (right-aligned percentage with 1 space before and after)
102+ if ! isempty (progress_text)
103+ # Print 1 space, then right-align the percentage in 4 characters
104+ print (io, " " , lpad (strip (progress_text), 4 ), " " )
105+ end
98106
99107 # Draw filled portion
100108 printstyled (io, " ━" ^ n_filled; color = p. color)
@@ -110,9 +118,7 @@ function render_progress_bar(io::IO, p::MiniProgressBar, perc::Float64,
110118 printstyled (io, empty_char^ (n_left - 1 + ! hascolor); color = :light_black )
111119 end
112120
113- # Print progress text and ETA
114- printstyled (io, " " ; color = :light_black )
115- print (io, progress_text)
121+ # Print ETA after the bar
116122 ! isempty (eta_text) && print (io, eta_text)
117123
118124 return nothing
0 commit comments