42 lines
811 B
Go
42 lines
811 B
Go
package handlers
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"github.com/StevanFreeborn/term-tier/internal/state"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
type downNavigationHandler struct {
|
|
keys []string
|
|
description string
|
|
}
|
|
|
|
func NewDownNavigationHandler() KeyMsgHandler {
|
|
return downNavigationHandler{
|
|
keys: []string{"down", "j"},
|
|
description: "Move down",
|
|
}
|
|
}
|
|
|
|
func (h downNavigationHandler) KeysHandled() []string {
|
|
return h.keys
|
|
}
|
|
|
|
func (h downNavigationHandler) Description() string {
|
|
return h.description
|
|
}
|
|
|
|
func (h downNavigationHandler) Match(s state.State, msg tea.KeyMsg) bool {
|
|
if s.Mode() != state.NavigationMode {
|
|
return false
|
|
}
|
|
|
|
return slices.Contains(h.keys, msg.String())
|
|
}
|
|
|
|
func (h downNavigationHandler) Handle(s state.State, msg tea.KeyMsg) tea.Cmd {
|
|
s.MoveDown()
|
|
return nil
|
|
}
|