Merge pull request #403 from tslocum/scrolltable

Fix scrolling table with PageDown and PageUp
This commit is contained in:
rivo 2020-04-14 13:51:03 +02:00 committed by GitHub
commit 7e599fe9aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -1155,27 +1155,37 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi
}
pageDown = func() {
offsetAmount := t.visibleRows - t.fixedRows
if offsetAmount < 0 {
offsetAmount = 0
}
if t.rowsSelectable {
t.selectedRow += t.visibleRows
t.selectedRow += offsetAmount
if t.selectedRow >= len(t.cells) {
t.selectedRow = len(t.cells) - 1
}
next()
} else {
t.rowOffset += t.visibleRows
t.rowOffset += offsetAmount
}
}
pageUp = func() {
offsetAmount := t.visibleRows - t.fixedRows
if offsetAmount < 0 {
offsetAmount = 0
}
if t.rowsSelectable {
t.selectedRow -= t.visibleRows
t.selectedRow -= offsetAmount
if t.selectedRow < 0 {
t.selectedRow = 0
}
previous()
} else {
t.trackEnd = false
t.rowOffset -= t.visibleRows
t.rowOffset -= offsetAmount
}
}
)