TheMathemagicians/sevenkeys/ui/update.go

27 lines
465 B
Go

package ui
import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
)
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
switch msg := msg.(type) {
case tea.WindowSizeMsg:
m.WindowHeight = msg.Height
m.WindowWidth = msg.Width
m.Help.Width = msg.Width
return m, nil
case tea.KeyMsg:
switch {
case key.Matches(msg, DefaultKeyMap.Quit):
return m, tea.Quit
}
break
}
return m, cmd
}