diff options
Diffstat (limited to 'internal/tui/components/core')
| -rw-r--r-- | internal/tui/components/core/status.go | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/internal/tui/components/core/status.go b/internal/tui/components/core/status.go index bd3629319..eb1aca2eb 100644 --- a/internal/tui/components/core/status.go +++ b/internal/tui/components/core/status.go @@ -13,10 +13,9 @@ import ( ) type statusCmp struct { - err error - info string - width int - messageTTL time.Duration + info *util.InfoMsg + width int + messageTTL time.Duration } // clearMessageCmd is a command that clears status messages after a timeout @@ -34,17 +33,12 @@ func (m statusCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: m.width = msg.Width - case util.ErrorMsg: - m.err = msg - m.info = "" return m, m.clearMessageCmd() case util.InfoMsg: - m.info = string(msg) - m.err = nil + m.info = &msg return m, m.clearMessageCmd() case util.ClearStatusMsg: - m.info = "" - m.err = nil + m.info = nil } return m, nil } @@ -56,25 +50,25 @@ var ( func (m statusCmp) View() string { status := styles.Padded.Background(styles.Grey).Foreground(styles.Text).Render("? help") - - if m.err != nil { - status += styles.Regular.Padding(0, 1). - Background(styles.Red). - Foreground(styles.Text). - Width(m.availableFooterMsgWidth()). - Render(m.err.Error()) - } else if m.info != "" { - status += styles.Padded. + if m.info != nil { + infoStyle := styles.Padded. Foreground(styles.Base). - Background(styles.Green). - Width(m.availableFooterMsgWidth()). - Render(m.info) + Width(m.availableFooterMsgWidth()) + switch m.info.Type { + case util.InfoTypeInfo: + infoStyle = infoStyle.Background(styles.Blue) + case util.InfoTypeWarn: + infoStyle = infoStyle.Background(styles.Peach) + case util.InfoTypeError: + infoStyle = infoStyle.Background(styles.Red) + } + status += infoStyle.Render(m.info.Msg) } else { status += styles.Padded. Foreground(styles.Base). Background(styles.LightGrey). Width(m.availableFooterMsgWidth()). - Render(m.info) + Render("") } status += m.model() status += versionWidget |
