tcell icon indicating copy to clipboard operation
tcell copied to clipboard

Option to not clear the terminal when finishing the screen

Open udhos opened this issue 6 years ago • 4 comments

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?

t.TPuts(ti.Clear)

Thanks, Everton

udhos avatar Feb 22 '19 21:02 udhos

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.

gdamore avatar Mar 10 '19 07:03 gdamore

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.

gdamore avatar Mar 04 '24 03:03 gdamore

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

igo-git avatar Apr 22 '24 12:04 igo-git

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

3052 avatar Apr 25 '24 12:04 3052