1package footer23import (4 "charm.land/bubbles/v2/help"5 "charm.land/bubbles/v2/key"6 tea "charm.land/bubbletea/v2"7 "charm.land/lipgloss/v2"8 "github.com/charmbracelet/soft-serve/pkg/ui/common"9)1011// ToggleFooterMsg is a message sent to show/hide the footer.12type ToggleFooterMsg struct{}1314// Footer is a Bubble Tea model that displays help and other info.15type Footer struct {16 common common.Common17 help help.Model18 keymap help.KeyMap19}2021// New creates a new Footer.22func New(c common.Common, keymap help.KeyMap) *Footer {23 h := help.New()24 h.Styles.ShortKey = c.Styles.HelpKey25 h.Styles.ShortDesc = c.Styles.HelpValue26 h.Styles.FullKey = c.Styles.HelpKey27 h.Styles.FullDesc = c.Styles.HelpValue28 f := &Footer{29 common: c,30 help: h,31 keymap: keymap,32 }33 f.SetSize(c.Width, c.Height)34 return f35}3637// SetSize implements common.Component.38func (f *Footer) SetSize(width, height int) {39 f.common.SetSize(width, height)40 f.help.SetWidth(width -41 f.common.Styles.Footer.GetHorizontalFrameSize())42}4344// Init implements tea.Model.45func (f *Footer) Init() tea.Cmd {46 return nil47}4849// Update implements tea.Model.50func (f *Footer) Update(_ tea.Msg) (common.Model, tea.Cmd) {51 return f, nil52}5354// View implements tea.Model.55func (f *Footer) View() string {56 if f.keymap == nil {57 return ""58 }59 s := f.common.Styles.Footer.60 Width(f.common.Width)61 helpView := f.help.View(f.keymap)62 return f.common.Zone.Mark(63 "footer",64 s.Render(helpView),65 )66}6768// ShortHelp returns the short help key bindings.69func (f *Footer) ShortHelp() []key.Binding {70 return f.keymap.ShortHelp()71}7273// FullHelp returns the full help key bindings.74func (f *Footer) FullHelp() [][]key.Binding {75 return f.keymap.FullHelp()76}7778// ShowAll returns whether the full help is shown.79func (f *Footer) ShowAll() bool {80 return f.help.ShowAll81}8283// SetShowAll sets whether the full help is shown.84func (f *Footer) SetShowAll(show bool) {85 f.help.ShowAll = show86}8788// Height returns the height of the footer.89func (f *Footer) Height() int {90 return lipgloss.Height(f.View())91}9293// ToggleFooterCmd sends a ToggleFooterMsg to show/hide the help footer.94func ToggleFooterCmd() tea.Msg {95 return ToggleFooterMsg{}96}