atomicgo/cursor

Area is buggy when the content height is > terminal height

Closed this issue · 3 comments

	area := cursor.NewArea()
	area.Update(strings.Repeat("aaaaaaaaaaaa\n", 25))
	area.Update(strings.Repeat("bbbbbbbbbbbb\n", 25))

After investigating the issue, I found that we had actually looked into this behavior about a year ago, but it had slipped my mind. Unfortunately, the content area cannot exceed the size of the terminal, and updating lines that aren't visible is not possible since the cursor cannot move outside the current viewing area. This is a limitation of how terminals work. However, if contentHeight < terminalHeight, then everything should function as expected.

We could potentially implement a View in PTerm that functions similarly to a textbox and responds to user scrolls, but this would require some time to develop. Alternatively, if the content doesn't need to be updated dynamically, it can be printed without the area. Another approach would be to create an alternative screen (virtual temporary terminal) using fmt.Print("\x1b[?1049h"). You could then print the content, clear the screen, and print the content again, to update it. However, it's important to keep in mind that alternative screens don't work with every terminal.

Once you're finished with the alternative screen, you can close it by using fmt.Print("\x1b[?1049l"). This will clear everything on the screen and return to the original terminal.