Detailed changes
@@ -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
}
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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)
@@ -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)