Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal cursor style is changed when running tcell #559

Closed
moson-mo opened this issue Sep 12, 2022 · 2 comments
Closed

terminal cursor style is changed when running tcell #559

moson-mo opened this issue Sep 12, 2022 · 2 comments

Comments

@moson-mo
Copy link
Contributor

When changing the cursor style in the terminal (f.e.: echo -e -n "\x1b[3 q" for blinking-underline)
and running tcell, it is changed back to the (default) blinking block.

Steps to reproduce:

  1. execute echo -e -n "\x1b[3 q" to change the cursor style in terminal
  2. run the following go program
package main

import (
	"fmt"
	"os"

	"github.com/gdamore/tcell/v2"
)

func main() {
	tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
	s, e := tcell.NewScreen()
	if e != nil {
		fmt.Fprintf(os.Stderr, "%v\n", e)
		os.Exit(1)
	}
	if e = s.Init(); e != nil {
		fmt.Fprintf(os.Stderr, "%v\n", e)
		os.Exit(1)
	}
	s.ShowCursor(0, 0)
	s.Show()
	s.Fini()
}
  1. back in the terminal you'll noticed that the style is changed back to the default one.

This happens since commit 761abf6
It's probably because of the default value of 0 for cursorStyle in tScreen.
I guess to fix this it would be needed to get the current setting when tcell is starting and assigning it to cursorStyle. No clue if/how that is possible though.

ref: moson-mo/pacseek#19

@gdamore
Copy link
Owner

gdamore commented Sep 12, 2022

There is no way (that I am aware of) to query the existing cursor style. So we can't save and restore it.

One thing we could do is conditionalize the "restoring" of the cursor style upon whether an application changes it or not.

If this bothers you greatly, you might see if your terminal emulator can support changing the "default". The value 0 is the "default" -- so terminals should restore the cursor to whatever the user preference for the default is.

@moson-mo
Copy link
Contributor Author

moson-mo commented Sep 12, 2022

Hi @gdamore
thanks for your quick reply. I guess setting the default style is the terminal itself is the way to go indeed.
Just tried it with xfce4-terminal and it works fine that way.

Closing this.

btw. thank you for this awesome project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants