From 48a7adaf9ec0c284442a8b86e2c81adeb6297642 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Tue, 23 May 2023 23:30:56 +0200 Subject: [PATCH] Refactor. --- bubbletea/adapter_bubbletea.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bubbletea/adapter_bubbletea.go b/bubbletea/adapter_bubbletea.go index f8ef62f..1879b23 100644 --- a/bubbletea/adapter_bubbletea.go +++ b/bubbletea/adapter_bubbletea.go @@ -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{}}, @@ -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 {