mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
Add ErrorToast function
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/status"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
@ -23,7 +24,7 @@ func NewAppStatusHelper(c *HelperCommon, statusMgr func() *status.StatusManager,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AppStatusHelper) Toast(message string) {
|
||||
func (self *AppStatusHelper) Toast(message string, kind types.ToastKind) {
|
||||
if self.c.RunningIntegrationTest() {
|
||||
// Don't bother showing toasts in integration tests. You can't check for
|
||||
// them anyway, and they would only slow down the test unnecessarily by
|
||||
@ -31,7 +32,7 @@ func (self *AppStatusHelper) Toast(message string) {
|
||||
return
|
||||
}
|
||||
|
||||
self.statusMgr().AddToastStatus(message)
|
||||
self.statusMgr().AddToastStatus(message, kind)
|
||||
|
||||
self.renderAppStatus()
|
||||
}
|
||||
@ -87,7 +88,8 @@ func (self *AppStatusHelper) HasStatus() bool {
|
||||
}
|
||||
|
||||
func (self *AppStatusHelper) GetStatusString() string {
|
||||
return self.statusMgr().GetStatusString()
|
||||
appStatus, _ := self.statusMgr().GetStatusString()
|
||||
return appStatus
|
||||
}
|
||||
|
||||
func (self *AppStatusHelper) renderAppStatus() {
|
||||
@ -95,7 +97,8 @@ func (self *AppStatusHelper) renderAppStatus() {
|
||||
ticker := time.NewTicker(time.Millisecond * utils.LoaderAnimationInterval)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
appStatus := self.statusMgr().GetStatusString()
|
||||
appStatus, color := self.statusMgr().GetStatusString()
|
||||
self.c.Views().AppStatus.FgColor = color
|
||||
self.c.OnUIThread(func() error {
|
||||
self.c.SetViewContent(self.c.Views().AppStatus, appStatus)
|
||||
return nil
|
||||
@ -127,7 +130,8 @@ func (self *AppStatusHelper) renderAppStatusSync(stop chan struct{}) {
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
appStatus := self.statusMgr().GetStatusString()
|
||||
appStatus, color := self.statusMgr().GetStatusString()
|
||||
self.c.Views().AppStatus.FgColor = color
|
||||
self.c.SetViewContent(self.c.Views().AppStatus, appStatus)
|
||||
// Redraw all views of the bottom line:
|
||||
bottomLineViews := []*gocui.View{
|
||||
|
Reference in New Issue
Block a user