busyloop / lolcat

Rainbows and unicorns!
BSD 3-Clause "New" or "Revised" License
6.11k stars 219 forks source link

Lolcat Forces Cursor to be Visible #122

Closed applesud closed 3 years ago

applesud commented 3 years ago

Expected Behaviour: Lolcat doesn't affect cursor visibility.

Actual Behaviour: Lolcat makes cursor visible.

Example:

$ tput  civis  # makes cursor invisible
$ echo "hello" | lolcat  # makes cursor visible (it shouldn't)

Causes: This seems to be the relevant line of code: https://github.com/busyloop/lolcat/blob/b7ce4bd8882d22ee3db4b7d4d0df43eab6851cf5/lib/lolcat/lol.rb#L64

m-o-e commented 3 years ago

There is unfortunately no good way to fix this because there's (afaik) no portable way to detect the status of cursor visibility.

Lolcat hides the cursor to avoid flickering and then enables it again, because that's the desired behavior most of the time and it can't know what the original state was.

If you wish to hide the cursor after invoking lolcat you can follow it up with: echo -e '\e[?25l' or tput civis