Alternate screen doesn't clear the terminal when running in GNU Screen
Steps to reproduce
- Run GNU Screen (I'm running it in an OSX Terminal)
- In the bubbletea repo,
go run examples/fullscreen/main.go
Expected result: Screen is cleared and you only see the countdown message
Actual result: Your terminal prompt, history, and whatever else is still visible alongside the output of the program.
However, once the program exits, the contents of the terminal are cleared.
This bug does not happen in tmux or in a bare Terminal.
Screenshot
(I ran ls just before running the program, to illustrate how it writes over top of the existing terminal contents)
Thanks for this! I can replicate the behavior, though it's a bit of an interesting case here:
The alternate screen buffer is disabled by default in GNU Screen. To enable it you can press screen’s escape key (ctrl+a by default) and enter :altscreen on. After that the altscreen in Bubble Tea will behave as expected.
That said, we shouldn't be printing over existing text in the terminal like in the screenshot above. To fix this, Bubble Tea should clear the screen after the altscreen initializes, even if it doesn't initialize. For comparison, Vim, which also usually operates in an altscreen, does this.
Aha! Adding altscreen on to my .screenrc seems like a fine workaround -- I'm surprised it's off by default.
(I'm also surprised I've been using screen for ~20 years with this fairly standard terminal feature turned off 😮 )