rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scroll bars for tables and textviews

darkhz opened this issue · comments

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.

commented

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.

@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