rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.45k stars 205 forks source link

Output problem when printing/logging multiple lines in `dual_line` mode #208

Closed dlesbre closed 1 year ago

dlesbre commented 1 year ago

The bar.text doesn't clear cleanly in dual_line mode when I'm printing or logging multiple lines at once.

Minimal example:

from alive_progress import alive_bar
from time import sleep

total = 5

with alive_bar(total, dual_line=True) as bar:
    bar.text = "Some fairly long line that stretches on and on and on..."
    for x in range(total):
        print("Any multiline\ntext")
        bar()
        sleep(2)

Output (python 3.10.7, alive_progress 2.4.1 on kubuntu 22.10) :

on 0: Any multiline
      texty long line that stretches on and on and on...
on 1: Any multiline
      texty long line that stretches on and on and on...
on 2: Any multiline
      texty long line that stretches on and on and on...
on 3: Any multiline
      texty long line that stretches on and on and on...
on 4: Any multiline
      texty long line that stretches on and on and on...
|████████████████████████████████████████| 5/5 [100%] in 10.1s (0.50/s) 

Expected output:

on 0: Any multiline
      text
on 1: Any multiline
      text
on 2: Any multiline
      text
on 3: Any multiline
      text
on 4: Any multiline
      text
|████████████████████████████████████████| 5/5 [100%] in 10.1s (0.50/s) 
rsalmei commented 1 year ago

Hi @dlesbre, I've just confirmed this does happen on the new upcoming version, thanks!