Sebastian Mark
8a0ef32c91
- implement TUI in bubbletea - split components into separate files - remove now unused functions - restructure files
44 lines
854 B
Go
44 lines
854 B
Go
package client
|
|
|
|
import "github.com/charmbracelet/bubbles/key"
|
|
|
|
// keyMap defines a set of keybindings. To work for help it must satisfy
|
|
// key.Map. It could also very easily be a map[string]key.Binding.
|
|
type keyMap struct {
|
|
Start key.Binding
|
|
Stop key.Binding
|
|
Reset key.Binding
|
|
Quit key.Binding
|
|
}
|
|
|
|
var keys = keyMap{
|
|
Start: key.NewBinding(
|
|
key.WithKeys(" "),
|
|
key.WithHelp("space", "start/pause/resume"),
|
|
),
|
|
Stop: key.NewBinding(
|
|
key.WithKeys("s"),
|
|
key.WithHelp("s", "stop"),
|
|
),
|
|
Reset: key.NewBinding(
|
|
key.WithKeys("r"),
|
|
key.WithHelp("r", "reset"),
|
|
),
|
|
Quit: key.NewBinding(
|
|
key.WithKeys("q"),
|
|
key.WithHelp("q", "quit"),
|
|
),
|
|
}
|
|
|
|
func (k keyMap) ShortHelp() []key.Binding {
|
|
return []key.Binding{
|
|
keys.Start,
|
|
keys.Stop,
|
|
keys.Reset,
|
|
keys.Quit,
|
|
}
|
|
}
|
|
|
|
func (k keyMap) FullHelp() [][]key.Binding {
|
|
return [][]key.Binding{}
|
|
}
|