37 lines
752 B
Go
37 lines
752 B
Go
package handlers
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"github.com/StevanFreeborn/term-tier/internal/state"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
type updateItemHandler struct {
|
|
keys []string
|
|
description string
|
|
}
|
|
|
|
func NewUpdateItemHandler() KeyMsgHandler {
|
|
return updateItemHandler{
|
|
keys: []string{"r"},
|
|
description: "Update item",
|
|
}
|
|
}
|
|
|
|
func (h updateItemHandler) KeysHandled() []string {
|
|
return h.keys
|
|
}
|
|
|
|
func (h updateItemHandler) Description() string {
|
|
return h.description
|
|
}
|
|
|
|
func (h updateItemHandler) Match(s state.State, msg tea.KeyMsg) bool {
|
|
return s.Mode() == state.NavigationMode && slices.Contains(h.keys, msg.String())
|
|
}
|
|
|
|
func (h updateItemHandler) Handle(s state.State, msg tea.KeyMsg) tea.Cmd {
|
|
return s.UpdateItem()
|
|
}
|