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

Area is buggy when the content height is > terminal height #15

Closed
MarvinJWendt opened this issue May 10, 2023 · 3 comments · Fixed by #16
Closed

Area is buggy when the content height is > terminal height #15

MarvinJWendt opened this issue May 10, 2023 · 3 comments · Fixed by #16
Assignees
Labels
bug Something isn't working

Comments

@MarvinJWendt
Copy link
Member

More infos in:

@MarvinJWendt MarvinJWendt added the bug Something isn't working label May 10, 2023
@MarvinJWendt MarvinJWendt self-assigned this May 10, 2023
@create-issue-branch
Copy link

@MarvinJWendt
Copy link
Member Author

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

@MarvinJWendt
Copy link
Member Author

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.

@MarvinJWendt MarvinJWendt linked a pull request Jun 7, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant