gdamore/tcell

Cursor style is not reset when closing

delthas opened this issue · 6 comments

Running screen.SetCursorStyle(tcell.CursorStyleSteadyBar) then closing (properly) tcell still leaves the cursor style to the bar.

It should probably be reset to the previous/default value on exit.

I worked around the issue with:

	screen.SetCursorStyle(tcell.CursorStyleDefault)
	screen.Sync()
	screen.Fini()

in the meantime.

I can confirm that this problem still occurs in the Windows cmd/commander on Amazon Workspaces.

One thing I don't like about that is that we don't know if we started with the default cursor style. I don't think this is something we can inquire about. But maybe we can do it and just tell users they need to change their terminal preferences if the Default is not really an appropriate choice.

On Windows Console it is actually possible to get the cursor style: https://learn.microsoft.com/en-us/windows/console/getconsolecursorinfo It could be fetched once at startup and then reinstated with https://learn.microsoft.com/en-us/windows/console/setconsolecursorinfo

On linux and other VT-ish terminals it seems you have to use the "cnorm" to set it back to the "normal" value, however, there doesn't seem to be a universal or easy way to actually get the original cursor style. https://unix.stackexchange.com/questions/55423/how-to-change-cursor-shape-color-and-blinkrate-of-linux-console

On Windows Console it is actually possible to get the cursor style: https://learn.microsoft.com/en-us/windows/console/getconsolecursorinfo It could be fetched once at startup and then reinstated with https://learn.microsoft.com/en-us/windows/console/setconsolecursorinfo

On linux and other VT-ish terminals it seems you have to use the "cnorm" to set it back to the "normal" value, however, there doesn't seem to be a universal or easy way to actually get the original cursor style. https://unix.stackexchange.com/questions/55423/how-to-change-cursor-shape-color-and-blinkrate-of-linux-console

Figured I should put this for reference... The different OSC escapes and such that are used for cursor and selection style, color palettes, dynamic styles(bold,ital,etc)

rivo/tview#859 (comment)

This comment I made contains some code for querying those OSC/xterm escape values to retrieve palette, selection/bg/cursor style so they can be utilized/pulled thru the term. I dunno if it will help on windows, but it does help me when I want to query all the specific styles/colors for a user's terminal, instead of the generic named/indexed color values, and get the real RGB/CSS hex values

I am going to just reset the cursor to the default. If that's not what the user wants, then they should configure their terminal preferences. It makes no sense for us to try to detect what the previous default was any more than we should do so for colors or text attributes.