rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang
MIT License
10.33k stars 545 forks source link

Feature request: generalize list items #979

Open voodookiidoo opened 2 months ago

voodookiidoo commented 2 months ago

Currently, tview.List is based around text and secondary text. But if you need to store a list of items and keep their representation valid - you have to keep a list of some items somewhere else, and keep track of their order. What about adding a CustomList (call it how you want), where instead of using plain text for items, use an interface like

type interface ListItem {
GetText() string
GetSecondaryText() string
GetRune() rune
GetSelectionFunction() func()
}

That would make maintaining both data and it's view much easier! (I implemented it in my fork of your lib, can show you if you'd like to)