bluenote10 / yachalk

🖍️ Terminal string styling done right
MIT License
161 stars 3 forks source link

Background colors leak through to end of line on multilined text #12

Open daxxycodes opened 2 years ago

daxxycodes commented 2 years ago

In Python on Mac OS 12 (zsh), while doing

print(chalk.bg_blue("some long line of text"))

if "some long line of text" wraps to the next line in the terminal (say because the text hits the right edge of the terminal after "of"), then in the second line, the blank space after "text" will also be background-colored through to the right edge of the terminal window.

bluenote10 commented 2 years ago

I'm not sure if there can be done something on the library level. Isn't this behavior entirely depending on how the terminal is implemented. Gnome terminal behaves like this for instance

image

which is basically what one would expect right?

daxxycodes commented 2 years ago

I'm glad it works in at least some cases. :) In mine, I started adding "\033[0m\033[K", but I don't know if that's a great fix for all situations.