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