colorama icon indicating copy to clipboard operation
colorama copied to clipboard

Auto reset doesn't function in uncommon situations

Open Rongronggg9 opened this issue 6 years ago • 1 comments

Py 2.7.13

init(autoreset=True)

I'd like to use different colors in a single line, so what I did was:

out = eval("co.p%d('%s') + co.white(' : ')" % (self.p, self.s))
print out

But if I make co.p%d('%s') return like Fore.LIGHTWHITE_EX + Back.CYAN + s and co.white(' : ') return like Fore.LIGHTWHITE_EX + s , Back.CYAN will take effect on :.

Finally I had to add + Fore.RESET + Back.RESET to each return.

It may be nicer if auto reset can function not only after stdout...

But after thinking it over, I doubted if auto reset was just expected to be used in common situations...

Rongronggg9 avatar Jul 10 '17 18:07 Rongronggg9

I'd like to use different colors in a single line

autoreset is meant to take effect only after a line is printed. It doesn't have an effect inside a single line. So if you print something like:

`Fore.LIGHTWHITE_EX + Back.CYAN + s + Fore.LIGHTWHITE_EX + ' : '`

there is nothing that resets Back.CYAN and the ':' will get a cyan background. You will have to add Back.RESET in between. This is the expected behavior.

wiggin15 avatar Sep 03 '17 09:09 wiggin15