tcell
tcell copied to clipboard
Option to not clear the terminal when finishing the screen
Hi,
My application would benefit from keeping some terminal contents after exiting.
Is it reasonable to have an option to not clear the Screen on Fini() ?
Would it be enough to make the code portion below optional?
Thanks, Everton
This is going to have mixed results. The issue is that on some terminals, we wind up using an alternate screen, so when the program exits the default screen is restored. This is typical for xterm for example. This is more or less baked into the terminal initialization sequences, and we don't really know about it.
If you're on Windows or on a terminal that doesn't suffer this problem, then yes, you might be able to use this approach.
So this is unofficial for now, but on master (or 2.7.4) if you put TCELL_ALTSCREEN=disable in your environment, it should do what you want. Please let me know if this helps. I have not yet decided to make this more official in another manner.
So this is unofficial for now, but on master (or 2.7.4) if you put TCELL_ALTSCREEN=disable in your environment, it should do what you want. Please let me know if this helps. I have not yet decided to make this more official in another manner.
Hi!
This feature is exactly what we've been missing. I really hope that you will not remove it in future releases
I found a couple of workarounds. Instead of using Fini(), you can use something like this:
w, h := s.Size()
s.ShowCursor(0, h - 1)
for x := 0; x < w; x++ {
s.SetContent(x, h - 1, ' ', nil, tcell.StyleDefault)
}
s.Show()
Or, I found another package that calls Fini(), but save the buffer so you can print it after if you want:
https://pkg.go.dev/github.com/noborus/ov/oviewer#Root.WriteOriginal