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

Option to not clear the terminal when finishing the screen #262

Open
udhos opened this issue Feb 22, 2019 · 4 comments
Open

Option to not clear the terminal when finishing the screen #262

udhos opened this issue Feb 22, 2019 · 4 comments
Labels

Comments

@udhos
Copy link

udhos commented Feb 22, 2019

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

@gdamore
Copy link
Owner

gdamore commented Mar 10, 2019

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
Copy link
Owner

gdamore commented Mar 4, 2024

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.

@igo-git
Copy link

igo-git commented Apr 22, 2024

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

@3052
Copy link

3052 commented Apr 25, 2024

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

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

No branches or pull requests

4 participants