1package tui
2
3import (
4 "smoothie/tui/bubbles/commits"
5 "smoothie/tui/bubbles/selection"
6
7 tea "github.com/charmbracelet/bubbletea"
8)
9
10type stateMsg struct{ state sessionState }
11type infoMsg struct{ text string }
12type windowMsg struct{}
13type errMsg struct{ err error }
14
15func (e errMsg) Error() string {
16 return e.err.Error()
17}
18
19func (m *Model) windowChangesCmd() tea.Msg {
20 w := <-m.windowChanges
21 m.width = w.Width
22 m.height = w.Height
23 return windowMsg{}
24}
25
26func (m *Model) loadGitCmd() tea.Msg {
27 rs := make([]string, 0)
28 for _, r := range m.repoSource.AllRepos() {
29 rs = append(rs, r.Name)
30 }
31 m.bubbles[0] = selection.NewBubble(rs)
32 m.bubbles[1] = commits.NewBubble(m.height, 7, 80, m.repoSource.GetCommits(200))
33 m.activeBubble = 0
34 m.state = loadedState
35 return nil
36}