> Is there any way to check how far along a viewport is scrolled? I
> both want to display a scrollbar to the side, and change <space> from
> scroll down to next entry when at the bottom of an "entry".
The short answer is: yes, but with a caveat.
The long answer:
You can get the data for a viewport in EventM with lookupViewport:
https://hackage.haskell.org/package/brick-0.62/docs/Brick-Main.html#v:lookupViewport
The issue is that the viewport data you get will be current *as of the
last rendering*. That means it'll be possibly stale by the time you use
it the next time you draw the UI, because the viewport state is
determined at rendering time. If the viewport data said the scroll
position was at 50%, that might be horribly wrong if the next redraw of
the UI happens because of a resize that radically alters the viewport
width and thus the scroll percentage, say.
I don't have a great way to deal with this problem which is why I've
avoided trying to display viewport info in my own Brick programs.
Instead I sometimes use my knowledge of the viewport content to indicate
a scroll position, like "X of Y total items", such as when I have a list
of elements. That way I avoid measuring things in terms of screen space
so I avoid this problem. I hope that is helpful.
--
Jonathan Daugherty