piotrmurach / tty-progressbar

Display a single or multiple progress bars in the terminal.
https://ttytoolkit.org
MIT License
424 stars 24 forks source link

Pad formatted output when it gets shorter #29

Closed drbrain closed 6 years ago

drbrain commented 6 years ago

When using the CurrentByte formatter the rendered progress bar may get shorter. When the current values advances from under 1MB to over 1MB the bar should show "1024.00KB" then "1.00MB".

The output was not padded so the end result on the screen would look like "1.00MB0KB" which was not easy to read and does not look nice.

Now the output is padded so the characters left over from the last render are replaced by spaces so the result on the screen will look like "1.00MB".

To accomplish this the existing ProgressBar#padout method is called from ProgressBar#render and #padout is updated to use ProgressBar#display_columns so the next render width is correctly calculated.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.8%) to 95.325% when pulling 7e3cbe60054b8458ad2f6798789ef5bc9c51f252 on drbrain:drbrain/padout into e29cd5ff18f4d8d4b2326d0ae54d55710dab1964 on piotrmurach:master.

piotrmurach commented 6 years ago

There are a couple of issues that I would like to fix before release, can you wait?

drbrain commented 6 years ago

Yes, I can wait

piotrmurach commented 6 years ago

Thank you for another great contribution ❤️

piotrmurach commented 6 years ago

Released v0.15.0 with your patches and few other fixes to multi bar rendering. Please see changelog for more info. The most notable change is the addition of Unicode support which helps with multi bar rendering when top level bar is present.