rsalmei / alive-progress

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

CSI ANSI Escape Codes are not printed #239

Closed ItsABlackScreen closed 1 year ago

ItsABlackScreen commented 1 year ago

With the recent update to 3.1.1 has introduced a bug relating to ansi codes.

Code

with alive_bar(25) as bar:
    for i in range(25):
        print(f"\033[93mNOT FOUND : ")
        bar()

Result

on 0:
on 1:
on 2:
on 3:
on 4:
on 5:
on 6:
on 7:
on 8:
on 9:
on 10:
on 11:
on 12:
on 13:
on 14:
on 15:
on 16:
on 17:
on 18:
on 19:
on 20:
on 21:
on 22:
on 23:
on 24:
|████████████████████████████████████████| 25/25 [100%] in 0.0s (10102.12/s)

The issue also happens when using colorama and is not present on 3.1.0

Tested on Python version : [3.11.3 , 3.9.7]

rsalmei commented 1 year ago

I see. I did some tricks to avoid printing anything when the text was only an escape code. Try closing your color code, it is missing the 0 at the end.

rsalmei commented 1 year ago

Humm, you're right, even including the finalizer you forgot, it still doesn't print anything...

In [3]: with alive_bar(25) as bar:
   ...:     for i in range(25):
   ...:         print(f"\033[93mNOT FOUND : \033[0m")
   ...:         bar()
   ...:
on 0:
on 1:
on 2:
on 3:
...
rsalmei commented 1 year ago

It is released @ItsABlackScreen! 👍