bubbletea icon indicating copy to clipboard operation
bubbletea copied to clipboard

Alternate screen doesn't clear the terminal when running in GNU Screen

Open mackstann opened this issue 4 years ago • 2 comments

Steps to reproduce

  1. Run GNU Screen (I'm running it in an OSX Terminal)
  2. 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)

Screen Shot 2021-07-13 at 9 38 44 PM

mackstann avatar Jul 14 '21 04:07 mackstann

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.

meowgorithm avatar Jul 14 '21 14:07 meowgorithm

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 😮 )

mackstann avatar Jul 14 '21 17:07 mackstann