erm/internal/app/darktile/gui/update.go

52 lines
1.2 KiB
Go

package gui
import (
"time"
"github.com/hajimehoshi/ebiten/v2"
)
func (g *GUI) getModifierStr() string {
switch true {
case g.keyState.RepeatPressed(ebiten.KeyShift) && g.keyState.RepeatPressed(ebiten.KeyControl) && g.keyState.RepeatPressed(ebiten.KeyAlt):
return ";8"
case g.keyState.RepeatPressed(ebiten.KeyAlt) && g.keyState.RepeatPressed(ebiten.KeyControl):
return ";7"
case g.keyState.RepeatPressed(ebiten.KeyShift) && g.keyState.RepeatPressed(ebiten.KeyControl):
return ";6"
case g.keyState.RepeatPressed(ebiten.KeyControl):
return ";5"
case g.keyState.RepeatPressed(ebiten.KeyShift) && g.keyState.RepeatPressed(ebiten.KeyAlt):
return ";4"
case g.keyState.RepeatPressed(ebiten.KeyAlt):
return ";3"
case g.keyState.RepeatPressed(ebiten.KeyShift):
return ";2"
}
return ""
}
// Update changes the terminal GUI state - all user-initiated modification should happen here.
func (g *GUI) Update() error {
if err := g.handleInput(); err != nil {
return err
}
g.filterPopupMessages()
return nil
}
func (g *GUI) filterPopupMessages() {
var filtered []PopupMessage
for _, msg := range g.popupMessages {
if time.Since(msg.Expiry) >= 0 {
continue
}
filtered = append(filtered, msg)
}
g.popupMessages = filtered
}