feat(table): add function to set cursor position (#219)

This commit is contained in:
Nicolas Karolak 2022-08-31 02:54:25 +02:00 committed by GitHub
parent d44e242f37
commit afd6f58c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -291,6 +291,12 @@ func (m Model) Cursor() int {
return m.cursor return m.cursor
} }
// SetCursor sets the cursor position in the table.
func (m *Model) SetCursor(n int) {
m.cursor = clamp(n, 0, len(m.rows)-1)
m.UpdateViewport()
}
// MoveUp moves the selection up by any number of row. // MoveUp moves the selection up by any number of row.
// It can not go above the first row. // It can not go above the first row.
func (m *Model) MoveUp(n int) { func (m *Model) MoveUp(n int) {