TheMathemagicians/sevenkeys/tui/home/model.go

70 lines
1.4 KiB
Go
Raw Normal View History

2024-06-08 15:32:19 +00:00
package home
2024-06-05 12:06:24 +00:00
2024-06-05 13:13:29 +00:00
import (
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
)
type KeyMap struct {
Update key.Binding
SearchCriteria key.Binding
Search key.Binding
StorageOptions key.Binding
Find key.Binding
Quit key.Binding
}
func (k KeyMap) ShortHelp() []key.Binding {
return []key.Binding{k.Update, k.SearchCriteria, k.Search, k.StorageOptions, k.Find, k.Quit}
}
func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.Update, k.SearchCriteria, k.Search},
{k.StorageOptions, k.Find, k.Quit},
}
}
var DefaultKeyMap = KeyMap{
Update: key.NewBinding(
key.WithKeys("u"),
key.WithHelp("u", "update database"),
),
SearchCriteria: key.NewBinding(
key.WithKeys("c"),
key.WithHelp("c", "card printing search criteria"),
),
Search: key.NewBinding(
key.WithKeys("s"),
key.WithHelp("s", "card printing search"),
),
StorageOptions: key.NewBinding(
key.WithKeys("o"),
key.WithHelp("o", "card storage options"),
),
Find: key.NewBinding(
key.WithKeys("f"),
key.WithHelp("f", "find in storage"),
),
Quit: key.NewBinding(
key.WithKeys("ctrl+c", "q"),
key.WithHelp("q", "quit program"),
),
}
2024-06-05 12:06:24 +00:00
type Model struct {
WindowHeight int
WindowWidth int
2024-06-05 13:13:29 +00:00
Help help.Model
2024-06-05 12:06:24 +00:00
}
func NewModel() Model {
2024-06-05 13:13:29 +00:00
help := help.New()
help.ShortSeparator = help.FullSeparator
return Model{
Help: help,
}
2024-06-05 12:06:24 +00:00
}