ratatui-org / ratatui

Rust library that's all about cooking up terminal user interfaces (TUIs) 👨‍🍳🐀

Home Page:https://ratatui.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a well-documented way to prevent scrolling down when all lines are already within view

DeflateAwning opened this issue · comments

Problem

I don't want users to be able to scroll down when there are fewer lines showed on the screen than can fit on the screen.

For example:
image

In the example, there are only 9 lines of text in the middle block. About 20 lines will fit in the middle block. As such, the scrollbar should occupy the whole height of the entire Window, with the requested feature enabled.

Solution

I want a way to make the scrollbar basically full-height if all lines fit on the screen (i.e., there's nowhere to scroll). I'm not sure if this belongs within the ScrollbarState type or in the rest of the scrollbar styling/setup.

Alternatives

Maybe something exists? Haven't been able to find it or come up with it though.

Additional context

#965 is an attempt of me to configure something like this but no one seemed to be interested enough to look into it so far (so I haven’t continued working on it).

my approach was to hide the scrollbar in that situation instead of showing it full height.

I'm definitely interested in having this as a feature (apologies of not getting to that review yet)
I'd like to see it designed out a bit so it makes sense to everyone that wants to use it.

Would we want this to be the intended behaviour going forward, or should this be an option? My vote is for intended behaviour, as scrolling past the extents seems "cheap".

Both behaviors are valid. I thought the current over-scroll behavior was a bug when I first started to experiment with it, but it was an intentional approach (there also happened to be some extra complex code that made it difficult to see, which we fixed with a rewrite).

It's worth taking a quick (who am I kidding, long) read of the recent scrollbar PRs for context on this. I can't really summarize them - there's too much back and forth to do so.
https://github.com/ratatui-org/ratatui/pulls?q=is%3Apr+scrollbar+is%3Aclosed