diff --git a/tui/bubble.go b/tui/bubble.go index 8c8c810c7..8d1080a35 100644 --- a/tui/bubble.go +++ b/tui/bubble.go @@ -105,6 +105,9 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { b.width = msg.Width b.height = msg.Height case selection.SelectedMsg: + b.activeBox = 1 + cmds = append(cmds, b.getRepoCmd(b.repoMenu[msg.Index].Repo)) + case selection.ActiveMsg: cmds = append(cmds, b.getRepoCmd(b.repoMenu[msg.Index].Repo)) } if b.state == loadedState { diff --git a/tui/bubbles/selection/bubble.go b/tui/bubbles/selection/bubble.go index ab4f0c6bd..f148acb1e 100644 --- a/tui/bubbles/selection/bubble.go +++ b/tui/bubbles/selection/bubble.go @@ -10,6 +10,11 @@ type SelectedMsg struct { Index int } +type ActiveMsg struct { + Name string + Index int +} + type Bubble struct { NormalStyle lipgloss.Style SelectedStyle lipgloss.Style @@ -49,19 +54,31 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "k", "up": if b.selectedItem > 0 { b.selectedItem-- + cmds = append(cmds, b.sendActiveMessage) } case "j", "down": if b.selectedItem < len(b.Items)-1 { b.selectedItem++ + cmds = append(cmds, b.sendActiveMessage) } case "enter": - cmds = append(cmds, b.sendMessage) + cmds = append(cmds, b.sendSelectedMessage) } } return b, tea.Batch(cmds...) } -func (b *Bubble) sendMessage() tea.Msg { +func (b *Bubble) sendActiveMessage() tea.Msg { + if b.selectedItem >= 0 && b.selectedItem < len(b.Items) { + return ActiveMsg{ + Name: b.Items[b.selectedItem], + Index: b.selectedItem, + } + } + return nil +} + +func (b *Bubble) sendSelectedMessage() tea.Msg { if b.selectedItem >= 0 && b.selectedItem < len(b.Items) { return SelectedMsg{ Name: b.Items[b.selectedItem], diff --git a/tui/bubbles/selection/style.go b/tui/bubbles/selection/style.go index 8aeeb002b..120fc75a7 100644 --- a/tui/bubbles/selection/style.go +++ b/tui/bubbles/selection/style.go @@ -5,7 +5,7 @@ import ( ) var normalStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#FFFFFF")) + Foreground(lipgloss.Color("#707070")) var selectedStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#714C7B")) + Foreground(lipgloss.Color("#FFFFFF")) diff --git a/tui/commands.go b/tui/commands.go index a32ad7d4c..0018e2b49 100644 --- a/tui/commands.go +++ b/tui/commands.go @@ -50,8 +50,10 @@ func (b *Bubble) loadGitCmd() tea.Msg { boxRightWidth-horizontalPadding-2, b.repoSource.GetCommits(200), ) + msg := b.getRepoCmd("config")() + b.activeBox = 0 b.state = loadedState - return b.getRepoCmd("config")() + return msg } func (b *Bubble) getRepoCmd(name string) tea.Cmd { @@ -65,7 +67,6 @@ func (b *Bubble) getRepoCmd(name string) tea.Cmd { b.readmeViewport.Viewport.Width = boxLeftWidth - 2 b.readmeViewport.Viewport.SetContent(r.Readme) b.boxes[1] = b.readmeViewport - b.activeBox = 1 return nil } } diff --git a/tui/defaults.go b/tui/defaults.go index 6724b8101..b69c4bb99 100644 --- a/tui/defaults.go +++ b/tui/defaults.go @@ -17,8 +17,7 @@ const defaultConfig = `{ "menu": [ { "name": "Home", - "repo": "config", - "note": "" + "repo": "config" } ] }`