mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-12-22 21:52:15 +01:00
Made terminal.output_progress(...) aware of the terminal width.
Instead of clearing the row using the "\b" character on each iteration, the function now passes a carriage return ("\r") instead. Furthermore, the row is now always completely cleared before printing the progress.
This commit is contained in:
parent
d5106a7302
commit
7dda8d34b5
1 changed files with 7 additions and 2 deletions
|
@ -148,6 +148,11 @@ def rjust(string, pad):
|
|||
|
||||
def output_progress(text, pos, length):
|
||||
if sys.stdout.isatty():
|
||||
clear_row()
|
||||
print(text.format(100 * pos / length), end="")
|
||||
(width, _unused) = get_size()
|
||||
progress_text = text.format(100 * pos / length)
|
||||
|
||||
if len(progress_text) > width:
|
||||
progress_text = "...%s" % progress_text[-width+3:]
|
||||
|
||||
print("\r{0}\r{1}".format(" " * width, progress_text), end="")
|
||||
sys.stdout.flush()
|
||||
|
|
Loading…
Reference in a new issue