Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed May 23, 2023
1 parent 6151dda commit 48a7ada
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions bubbletea/adapter_bubbletea.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ type teaKey struct {
rune []rune
}

func repeatingKeyPressed(key ebiten.Key) bool {
const (
delay = 30
interval = 3
)
d := inpututil.KeyPressDuration(key)
if d == 1 {
return true
}
if d >= delay && (d-delay)%interval == 0 {
return true
}
return false
}

var ebitenToTeaKeys = map[ebiten.Key]teaKey{
ebiten.KeyEnter: {tea.KeyEnter, []rune{'\n'}},
ebiten.KeyTab: {tea.KeyTab, []rune{}},
Expand Down Expand Up @@ -152,21 +167,6 @@ func (b *Adapter) HandleMouseWheel(wheel crt.MouseWheel) {
}
}

func repeatingKeyPressed(key ebiten.Key) bool {
const (
delay = 30
interval = 3
)
d := inpututil.KeyPressDuration(key)
if d == 1 {
return true
}
if d >= delay && (d-delay)%interval == 0 {
return true
}
return false
}

func (b *Adapter) HandleKeyPress() {
newInputs := ebiten.AppendInputChars([]rune{})
for _, v := range newInputs {
Expand Down

0 comments on commit 48a7ada

Please sign in to comment.