List scrolls automatically.

If the selected item is off the screen, the list will scroll up/down so that the item is visable.
This commit is contained in:
hmmmmmmmm 2019-01-31 10:15:31 +00:00 committed by GitHub
parent a01016fd0d
commit 52d428bd5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,12 @@ func (self *List) Draw(buf *Buffer) {
point := self.Inner.Min
if self.SelectedRow >= uint(self.Inner.Max.Y)+self.topRow-2 {
self.topRow = self.SelectedRow-uint(self.Inner.Max.Y)+2
} else if self.SelectedRow < self.topRow {
self.topRow = self.SelectedRow
}
for row := self.topRow; row < uint(len(self.Rows)) && point.Y < self.Inner.Max.Y; row++ {
cells := ParseText(self.Rows[row], self.TextStyle)
if self.WrapText {