TheMathemagicians/sevenkeys/tui/home/update.go

29 lines
482 B
Go

package home
import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"sevenkeys/tui"
)
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, tui.KeyMap.Quit):
return m, tea.Quit
}
break
}
return m, cmd
}