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