Open k0ral opened 10 months ago
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 :thinking:
Took another look at this. It seems like Ratatui just doesn't have a great solution for this right now. Relevant Ratatui RFCs: https://github.com/ratatui-org/ratatui/issues/293 https://github.com/ratatui-org/ratatui/issues/174
To fix this in the near future, we may need to handle text wrapping ourselves along these lines: https://github.com/ratatui-org/ratatui/issues/293#issuecomment-1617166104
It seems like the Ratatui folks want to use textwrap so that's worth a try.
How to reproduce
Here's what![image](https://github.com/rgwood/systemctl-tui/assets/524268/0326fadb-7068-490b-b71c-a2aa6db69231)
systemctl-tui
shows when first displaying the logs of, for example, theacpid
service:Upon pressing![image](https://github.com/rgwood/systemctl-tui/assets/524268/3cd982e8-9c61-4043-9d74-1aa8ddecb160)
<End>
to scroll to bottom, here's what I get:It actually scrolled past the last log, and I have to scroll back up using![image](https://github.com/rgwood/systemctl-tui/assets/524268/8e431d2a-83a7-4f5f-90a8-5eb73c5fab09)
<PageUp>
to see the actual last (== oldest) log messages: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](https://github.com/rgwood/systemctl-tui/assets/524268/34d047d7-76aa-454b-a8cc-f9cd5f3a63ea)
Incidentally, pressing
<PageDown>
should also be a no-op if the last line is already displayed.