70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
package home
|
|
|
|
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"),
|
|
),
|
|
}
|
|
|
|
type Model struct {
|
|
WindowHeight int
|
|
WindowWidth int
|
|
|
|
Help help.Model
|
|
}
|
|
|
|
func NewModel() Model {
|
|
help := help.New()
|
|
help.ShortSeparator = help.FullSeparator
|
|
|
|
return Model{
|
|
Help: help,
|
|
}
|
|
}
|