Skip to content

Commit

Permalink
feat(table): add function to set cursor position (charmbracelet#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikaro committed Aug 31, 2022
1 parent d44e242 commit afd6f58
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions table/table.go
Expand Up @@ -291,6 +291,12 @@ func (m Model) Cursor() int {
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.
// It can not go above the first row.
func (m *Model) MoveUp(n int) {
Expand Down

0 comments on commit afd6f58

Please sign in to comment.