Open aamrun opened 4 months ago
Actually, when you pring a newline( '\n'), on the console with specific styling set, the stylings or in this case background should apply on the rest of the line. I have already tested and resolved that issue when working using C and win32 system calls. Actually appending the reset resets the styling before the newline is printed.
That should not be a bug with colorama.
I came across your project while browsing the packages installed on my system ( Ubuntu 22.04 running as WSL on Windows 11). I ran the demo code below which is mentioned both on your PyPi and Github homepages :
from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')
Doing so, I got the output below :
As can be seen, not only the line with the text containing 'green background' but the two following lines also have a green background. It's interesting that the 'green background' line is green only for the sentence but the two subsequent lines are green for the entire screen width.
I don't know if this is the intended effect but it looked like a bug to me and I came up with this 'fix' :
from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background' + Back.RESET)
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')
Now the output looks like this :
Also, because a Fore.RESET hasn't been applied on the first line, the 'green background' text is in red and the 'dim text' is really dim, especially on a black background. With this line :
print(Fore.RED + 'some red text' + Fore.RESET)
The output looks more 'proper'
Again, not sure if the current code is intended to work "as it is" or if this 'issue' has been reported in the past. I came across it and thought of letting you know.
Thanks !