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

Scroll bars for tables and textviews #950

Open
darkhz opened this issue Feb 22, 2024 · 2 comments
Open

Scroll bars for tables and textviews #950

darkhz opened this issue Feb 22, 2024 · 2 comments

Comments

@darkhz
Copy link

darkhz commented Feb 22, 2024

It would be good if scroll bars were shown for tables and textviews, so that the user can be notified about the position of the content and if there is any remaining content to be scrolled to.

@rivo
Copy link
Owner

rivo commented Mar 7, 2024

I don't think this will be added any time soon. Most widgets, especially text views and text areas, don't know their entire content, much less a laid out version of it. They gradually parse and layout text as the user navigates to it. Tables can also be "infinitely" large, see https://github.com/rivo/tview/blob/master/demos/table/virtualtable/main.go for an example. If we wanted to show scrollbars for a text view, for example, we'd have to parse its entire text first, including any style/region tags and word wrapping. This would be a huge performance hit on large texts. (Actually, it was like this in beginning and lots of people complained about bad performance.)

I have plans to add functionality that might make it easier for you to add something like this yourself, however. Can't say right now, though, when this will be available.

@digitallyserviced
Copy link
Contributor

digitallyserviced commented Apr 28, 2024

@darkhz @rivo
My fork has the ability to handle the scrollbars on any item you wish. While i do not haave a decent PR/patch to allow for easy integration into what your use case/code you should beable to trrack down the needed bits to make it work for integrating with your tview

Here is a few links of where you can see my fork implementing the DrawOverflow function which handles the scrollbars.

for tables

https://github.com/digitallyserviced/tview/blob/0660e902605bb2f4dac9833579044ad133a34386/table.go#L1183-L1185

for textview

https://github.com/digitallyserviced/tview/blob/0660e902605bb2f4dac9833579044ad133a34386/textview.go#L1247-L1249

for treeview

https://github.com/digitallyserviced/tview/blob/0660e902605bb2f4dac9833579044ad133a34386/treeview.go#L725

you can see look into how they handle those calls, to generate scrollbars based on their current location and the total listings/etc.

the actual call that is made to create/draw a scrollbar (will work on my ANY primitive based on box

https://github.com/digitallyserviced/tview/blob/611a26b9bad195005135a6ce0215280c68d57903/box.go#L833

Here is a gif where you can see the scrollbar being used in many different widgets... Lists, treeviews, tables, the pop-up animated context menus (a custom List element).

forgive the speed of it, but you can see how my fork implements up and down arrows and also handling the size of the bar based on the ratio of the content.

265284960-f36d2cc4-6e58-45e4-ab00-d4602495d66a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants