lib/downloader: Fix progress bar length on older CrOS terminals (#7482)

* Fix progress bar on older CrOS terminals

* Make rubocop happy

* Use new color code functions

* Make rubocop happy

* Align variables

* Fix typo

* Remove extra space
This commit is contained in:
supechicken
2022-10-15 00:43:44 +08:00
committed by GitHub
parent f20e2b6d1e
commit 43381ba173

View File

@@ -13,8 +13,8 @@ class ProgressBar
# color scheme of progress bar, can be changed
# see color.rb for more available colors
@bar_front_color = :lightcyan
@bar_bg_color = :gray
@bar_front_color = %i[lightcyan no_bold]
@bar_bg_color = %i[gray no_bold]
# all info blocks with space taken
@info_before_bar = { downloaded_size_in_str: 20 }
@@ -94,8 +94,8 @@ class ProgressBar
end
# print progress bar with color code
print ( @bar_char * completed_length).send(@bar_front_color),
(@bar_char * uncompleted_length).send(@bar_bg_color)
print (@bar_char * completed_length).send(*@bar_front_color),
(@bar_char * uncompleted_length).send(*@bar_bg_color)
@info_after_bar.each_pair do |varName, width|
printf ' %*.*s', width, width, instance_variable_get("@#{varName}")