TheMathemagicians/sevenkeys/tui/home/update.go

29 lines
482 B
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/key"
tea "github.com/charmbracelet/bubbletea"
2024-06-08 15:41:09 +00:00
"sevenkeys/tui"
2024-06-05 13:13:29 +00:00
)
2024-06-05 12:06:24 +00:00
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
2024-06-05 13:13:29 +00:00
m.Help.Width = msg.Width
2024-06-05 12:06:24 +00:00
return m, nil
case tea.KeyMsg:
2024-06-05 13:13:29 +00:00
switch {
2024-06-08 15:41:09 +00:00
case key.Matches(msg, tui.KeyMap.Quit):
2024-06-05 12:06:24 +00:00
return m, tea.Quit
}
break
}
return m, cmd
}