diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-03 15:21:33 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-03 15:21:33 +1100 |
commit | 4bb577ab7d6546d92c75d7840e509caf470403c6 (patch) | |
tree | d7ac8c87c6835d4093d4799fc2242e86b75c0c6b /pkg/gui/app_status_manager.go | |
parent | 8305d8e72f5f941da0b1404376057052054db307 (diff) |
show loading status for rebasing events
Diffstat (limited to 'pkg/gui/app_status_manager.go')
-rw-r--r-- | pkg/gui/app_status_manager.go | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/pkg/gui/app_status_manager.go b/pkg/gui/app_status_manager.go index 2d479e42f..9aee3fa11 100644 --- a/pkg/gui/app_status_manager.go +++ b/pkg/gui/app_status_manager.go @@ -1,6 +1,9 @@ package gui -import "github.com/jesseduffield/lazygit/pkg/utils" +import ( + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/utils" +) type appStatus struct { name string @@ -42,3 +45,26 @@ func (m *statusManager) getStatusString() string { } return topStatus.name } + +// WithWaitingStatus wraps a function and shows a waiting status while the function is still executing +func (gui *Gui) WithWaitingStatus(name string, f func() error) error { + go func() { + gui.g.Update(func(g *gocui.Gui) error { + gui.statusManager.addWaitingStatus(name) + return nil + }) + + defer gui.g.Update(func(g *gocui.Gui) error { + gui.statusManager.removeStatus(name) + return nil + }) + + if err := f(); err != nil { + gui.g.Update(func(g *gocui.Gui) error { + return gui.createErrorPanel(gui.g, err.Error()) + }) + } + }() + + return nil +} |