diff --git a/ui/components/footer/footer.go b/ui/components/footer/footer.go index 5a8e10aa5a275f193c33801baa71a4cb2795bac0..43015a88fba7e73b157e9ede6f357da5e21d3b3f 100644 --- a/ui/components/footer/footer.go +++ b/ui/components/footer/footer.go @@ -41,6 +41,13 @@ func (f *Footer) Init() tea.Cmd { // Update implements tea.Model. func (f *Footer) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.KeyMsg: + switch msg.String() { + case "?": + f.help.ShowAll = !f.help.ShowAll + } + } return f, nil } diff --git a/ui/pages/repo/files.go b/ui/pages/repo/files.go index 2c9d153206a96bf5988ddb12fde75271cff2f405..b5222848ef6c1ad85c51fabe6ba2ae174aeb153e 100644 --- a/ui/pages/repo/files.go +++ b/ui/pages/repo/files.go @@ -139,15 +139,19 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } case tea.WindowSizeMsg: - if f.currentContent.content != "" { - m, cmd := f.code.Update(msg) - f.code = m.(*code.Code) - if cmd != nil { - cmds = append(cmds, cmd) + switch f.activeView { + case filesViewFiles: + if f.repo != nil { + cmds = append(cmds, f.updateFilesCmd) + } + case filesViewContent: + if f.currentContent.content != "" { + m, cmd := f.code.Update(msg) + f.code = m.(*code.Code) + if cmd != nil { + cmds = append(cmds, cmd) + } } - } - if f.repo != nil { - cmds = append(cmds, f.updateFilesCmd) } } switch f.activeView { diff --git a/ui/pages/repo/refs.go b/ui/pages/repo/refs.go index 1a1f49207abf96910b8218bb041961447edaa568..df5b000f39c727313c57188fe88402c2c125efc0 100644 --- a/ui/pages/repo/refs.go +++ b/ui/pages/repo/refs.go @@ -22,6 +22,7 @@ type Refs struct { selector *selector.Selector repo git.GitRepo ref *ggit.Reference + activeRef *ggit.Reference refPrefix string } @@ -63,6 +64,13 @@ func (r *Refs) Update(msg tea.Msg) (tea.Model, tea.Cmd) { cmds = append(cmds, r.Init()) case RefItemsMsg: cmds = append(cmds, r.selector.SetItems(msg.items)) + r.activeRef = r.selector.SelectedItem().(RefItem).Reference + case selector.ActiveMsg: + switch sel := msg.IdentifiableItem.(type) { + case RefItem: + r.activeRef = sel.Reference + } + cmds = append(cmds, updateStatusBarCmd) case selector.SelectMsg: switch i := msg.IdentifiableItem.(type) { case RefItem: @@ -90,7 +98,10 @@ func (r *Refs) View() string { } func (r *Refs) StatusBarValue() string { - return "" + if r.activeRef == nil { + return "" + } + return r.activeRef.Name().String() } func (r *Refs) StatusBarInfo() string { diff --git a/ui/pages/selection/item.go b/ui/pages/selection/item.go index 1b9495c4aeeffe97ee03a41f850409c15afc7fa1..db54f5f9eed026c1b0d9d1231bb456daf55040c2 100644 --- a/ui/pages/selection/item.go +++ b/ui/pages/selection/item.go @@ -61,7 +61,7 @@ func (d ItemDelegate) Height() int { } // Spacing returns the spacing between items. Implements list.ItemDelegate. -func (d ItemDelegate) Spacing() int { return 1 } +func (d ItemDelegate) Spacing() int { return 0 } // Update implements list.ItemDelegate. func (d ItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go index 170628f022178b2ec14f2cddd24dd00b28a259db..0cb4986918b4502aad8402f159d11ca44e95ebf7 100644 --- a/ui/pages/selection/selection.go +++ b/ui/pages/selection/selection.go @@ -62,7 +62,7 @@ func (s *Selection) SetSize(width, height int) { // +1 to get wrapping to work. // This is needed because the readme box width has to be -1 from the // readme style in order for wrapping to not break. - 1 + 2 hm := s.common.Styles.ReadmeBox.GetVerticalFrameSize() s.readme.SetSize(width-wm, height-hm) s.selector.SetSize(sw, height) diff --git a/ui/ui.go b/ui/ui.go index ea4e75562e8c1b2eef9e1feafe3640d282b03ab0..b84eeb223b22da136ea6150790011db28e13f32f 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -114,23 +114,13 @@ func (ui *UI) Init() tea.Cmd { } // Update implements tea.Model. -// TODO show full help +// TODO show full help. func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { log.Printf("msg: %T", msg) cmds := make([]tea.Cmd, 0) switch msg := msg.(type) { case tea.WindowSizeMsg: ui.SetSize(msg.Width, msg.Height) - h, cmd := ui.header.Update(msg) - ui.header = h.(*header.Header) - if cmd != nil { - cmds = append(cmds, cmd) - } - f, cmd := ui.footer.Update(msg) - ui.footer = f.(*footer.Footer) - if cmd != nil { - cmds = append(cmds, cmd) - } for i, p := range ui.pages { m, cmd := p.Update(msg) ui.pages[i] = m.(common.Page) @@ -161,6 +151,16 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } } + h, cmd := ui.header.Update(msg) + ui.header = h.(*header.Header) + if cmd != nil { + cmds = append(cmds, cmd) + } + f, cmd := ui.footer.Update(msg) + ui.footer = f.(*footer.Footer) + if cmd != nil { + cmds = append(cmds, cmd) + } if ui.state == loadedState { m, cmd := ui.pages[ui.activePage].Update(msg) ui.pages[ui.activePage] = m.(common.Page)