@@ -7,8 +7,17 @@ import (
77 "charm.land/lipgloss/v2"
88)
99
10- // StatusModel manages the status bar and the executing spinner.
10+ // MessageUpdateMsg is used to update the message in the status bar
11+ type MessageUpdateMsg struct {
12+ Message string
13+ }
14+
15+ // MessageResetMsg is used to reset the message in the status bar
16+ type MessageResetMsg struct {}
17+
18+ // StatusModel manages the status bar and the executing spinner
1119type StatusModel struct {
20+ Message string
1221 Version string
1322 Width int
1423 IssueLink string
@@ -32,6 +41,10 @@ func (m StatusModel) Update(msg tea.Msg) (StatusModel, tea.Cmd) {
3241 switch msg := msg .(type ) {
3342 case tea.WindowSizeMsg :
3443 m .Width = msg .Width
44+ case MessageUpdateMsg :
45+ m .Message = msg .Message
46+ case MessageResetMsg :
47+ m .Message = ""
3548 }
3649 return m , cmd
3750}
@@ -63,7 +76,14 @@ func (m StatusModel) View() string {
6376 }
6477 padding := strings .Repeat (" " , paddingWidth )
6578
66- statusBar := m .StatusBarStyle .Width (m .Width ).Render (name + padding + link )
79+ firstLine := m .StatusBarStyle .Faint (true ).Render (m .Message )
80+ secondLine := m .StatusBarStyle .Render (lipgloss .Sprintf ("%s%s%s" , name , padding , link ))
81+
82+ statusBar := lipgloss .JoinVertical (
83+ lipgloss .Top ,
84+ firstLine ,
85+ secondLine ,
86+ )
6787
6888 return lipgloss .JoinVertical (
6989 lipgloss .Top ,
@@ -75,8 +95,7 @@ func (m StatusModel) View() string {
7595// StaticHeight returns the height of the footer.
7696func (m StatusModel ) StaticHeight () int {
7797 separator := m .SeparatorStyle .Render (strings .Repeat ("─" , m .Width ))
78- statusBar := m .StatusBarStyle .Width (m .Width ).Render ("pgxcli " + m .Version )
7998
80- // Top separator + Bottom separator + Status bar
81- return lipgloss .Height (separator )* 2 + lipgloss . Height ( statusBar )
99+ // Top separator + Bottom separator + message line + version line
100+ return lipgloss .Height (separator )* 2 + 2
82101}
0 commit comments