@@ -13,10 +13,9 @@ import (
1313)
1414
1515type statusCmp struct {
16- err error
17- info string
18- width int
19- messageTTL time.Duration
16+ info * util.InfoMsg
17+ width int
18+ messageTTL time.Duration
2019}
2120
2221// 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) {
3433 switch msg := msg .(type ) {
3534 case tea.WindowSizeMsg :
3635 m .width = msg .Width
37- case util.ErrorMsg :
38- m .err = msg
39- m .info = ""
4036 return m , m .clearMessageCmd ()
4137 case util.InfoMsg :
42- m .info = string (msg )
43- m .err = nil
38+ m .info = & msg
4439 return m , m .clearMessageCmd ()
4540 case util.ClearStatusMsg :
46- m .info = ""
47- m .err = nil
41+ m .info = nil
4842 }
4943 return m , nil
5044}
@@ -56,25 +50,25 @@ var (
5650
5751func (m statusCmp ) View () string {
5852 status := styles .Padded .Background (styles .Grey ).Foreground (styles .Text ).Render ("? help" )
59-
60- if m .err != nil {
61- status += styles .Regular .Padding (0 , 1 ).
62- Background (styles .Red ).
63- Foreground (styles .Text ).
64- Width (m .availableFooterMsgWidth ()).
65- Render (m .err .Error ())
66- } else if m .info != "" {
67- status += styles .Padded .
53+ if m .info != nil {
54+ infoStyle := styles .Padded .
6855 Foreground (styles .Base ).
69- Background (styles .Green ).
70- Width (m .availableFooterMsgWidth ()).
71- Render (m .info )
56+ Width (m .availableFooterMsgWidth ())
57+ switch m .info .Type {
58+ case util .InfoTypeInfo :
59+ infoStyle = infoStyle .Background (styles .Blue )
60+ case util .InfoTypeWarn :
61+ infoStyle = infoStyle .Background (styles .Peach )
62+ case util .InfoTypeError :
63+ infoStyle = infoStyle .Background (styles .Red )
64+ }
65+ status += infoStyle .Render (m .info .Msg )
7266 } else {
7367 status += styles .Padded .
7468 Foreground (styles .Base ).
7569 Background (styles .LightGrey ).
7670 Width (m .availableFooterMsgWidth ()).
77- Render (m . info )
71+ Render ("" )
7872 }
7973 status += m .model ()
8074 status += versionWidget
0 commit comments