MCPcopy
hub / github.com/jesseduffield/lazygit / MainLoop

Method MainLoop

pkg/gocui/gui.go:714–746  ·  view source on GitHub ↗

MainLoop runs the main loop until an error is returned. A successful finish should return ErrQuit.

()

Source from the content-addressed store, hash-verified

712// MainLoop runs the main loop until an error is returned. A successful
713// finish should return ErrQuit.
714func (g *Gui) MainLoop() error {
715 go func() {
716 for {
717 select {
718 case <-g.stop:
719 return
720 default:
721 g.gEvents <- g.pollEvent()
722 }
723 }
724 }()
725
726 Screen.EnableFocus()
727 Screen.EnablePaste()
728
729 previousEnableMouse := false
730 for {
731 if g.Mouse != previousEnableMouse {
732 if g.Mouse {
733 Screen.EnableMouse()
734 } else {
735 Screen.DisableMouse()
736 }
737
738 previousEnableMouse = g.Mouse
739 }
740
741 err := g.processEvent()
742 if err != nil {
743 return err
744 }
745 }
746}
747
748func (g *Gui) handleError(err error) error {
749 if err != nil && !standardErrors.Is(err, ErrQuit) && g.ErrorHandler != nil {

Callers 2

RunTUIFunction · 0.95
RunMethod · 0.80

Calls 2

pollEventMethod · 0.95
processEventMethod · 0.95

Tested by

no test coverage detected