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

Prevent from scrolling past the bottom line in the logs #10

Open
k0ral opened this issue Nov 1, 2023 · 2 comments
Open

Prevent from scrolling past the bottom line in the logs #10

k0ral opened this issue Nov 1, 2023 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@k0ral
Copy link

k0ral commented Nov 1, 2023

How to reproduce

Here's what systemctl-tui shows when first displaying the logs of, for example, the acpid service:
image

Upon pressing <End> to scroll to bottom, here's what I get:
image

It actually scrolled past the last log, and I have to scroll back up using <PageUp> to see the actual last (== oldest) log messages:
image

Expected behavior

Scrolling to bottom should end-up with the last/oldest log message displayed at the bottom of the screen/widget, like this:
image

Incidentally, pressing <PageDown> should also be a no-op if the last line is already displayed.

@rgwood rgwood added bug Something isn't working good first issue Good for newcomers labels Nov 1, 2023
@rgwood
Copy link
Owner

rgwood commented Dec 25, 2023

I spent a little time trying to solve this, and... it's a bit tricky.

The crux of the problem is that because individual log messages can wrap onto multiple lines, I don't know how tall the rendered list is going to be ahead of time. And without that information, I don't know what the maximum scroll offset should be.

Can probably hack something together but I'm not sure what a robust solution in Ratatui would look like 🤔

@rgwood rgwood added help wanted Extra attention is needed and removed good first issue Good for newcomers labels Jan 15, 2024
@rgwood
Copy link
Owner

rgwood commented Jan 27, 2024

Took another look at this. It seems like Ratatui just doesn't have a great solution for this right now. Relevant Ratatui RFCs:
ratatui/ratatui#293
ratatui/ratatui#174

To fix this in the near future, we may need to handle text wrapping ourselves along these lines: ratatui/ratatui#293 (comment)

It seems like the Ratatui folks want to use textwrap so that's worth a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants