Skip to content

Commit

Permalink
Ignore negative Cursor() values
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea committed Mar 21, 2024
1 parent 61b3878 commit 3427b53
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
22 changes: 12 additions & 10 deletions examples/starwars/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,18 @@ func (m model) updateImage() tea.Msg {

// updateViewport updates the viewport with the selected character's details.
func (m model) updateViewport() {
character := m.characters[m.table.Cursor()]
md, _ := m.renderer.Render(
fmt.Sprintf(
characterTpl,
character.ID,
sanitize(character.Name),
sanitize(character.Description),
),
)
m.viewport.SetContent(md)
if m.table.Cursor() > 0 {
character := m.characters[m.table.Cursor()]
md, _ := m.renderer.Render(
fmt.Sprintf(
characterTpl,
character.ID,
sanitize(character.Name),
sanitize(character.Description),
),
)
m.viewport.SetContent(md)
}
}

// setTableRows sets the table rows with the provided character data.
Expand Down
Binary file modified examples/starwars/starwars.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 11 additions & 10 deletions examples/starwars/starwars.tape
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ Output starwars.gif
Require echo

Set Shell "bash"
Set FontSize 12
Set FontSize 13
Set Width 1200
Set Height 600

Type "./starwars"
Enter
Sleep 5000ms
Down
Sleep 500ms
Down
Down
Sleep 500ms
Down
Enter@5
Down@1
Down@1
Down@1
Down@1
Down@1
Down@1
Down@1
Down@1
Down@1

Sleep 5s

0 comments on commit 3427b53

Please sign in to comment.